From 239b5ff30cf46f9196149c888a20be2096fdff03 Mon Sep 17 00:00:00 2001 From: Michael Goin Date: Mon, 18 May 2026 20:22:27 -0400 Subject: [PATCH] [Frontend] Add --spec-method/--spec-model/--spec-tokens CLI aliases (#42476) Signed-off-by: mgoin Co-authored-by: Claude --- vllm/engine/arg_utils.py | 24 ++++++++++++++++++++++++ vllm/entrypoints/llm.py | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/vllm/engine/arg_utils.py b/vllm/engine/arg_utils.py index 3f8889c5bc1..49189862eb7 100644 --- a/vllm/engine/arg_utils.py +++ b/vllm/engine/arg_utils.py @@ -607,6 +607,9 @@ class EngineArgs: reasoning_parser_plugin: str | None = None speculative_config: dict[str, Any] | None = None + spec_method: str | None = None + spec_model: str | None = None + spec_tokens: int | None = None show_hidden_metrics_for_version: str | None = ( ObservabilityConfig.show_hidden_metrics_for_version @@ -1435,6 +1438,12 @@ class EngineArgs: vllm_group.add_argument( "--speculative-config", "-sc", **vllm_kwargs["speculative_config"] ) + speculative_kwargs = get_kwargs(SpeculativeConfig) + vllm_group.add_argument("--spec-method", **speculative_kwargs["method"]) + vllm_group.add_argument("--spec-model", **speculative_kwargs["model"]) + vllm_group.add_argument( + "--spec-tokens", **speculative_kwargs["num_speculative_tokens"] + ) vllm_group.add_argument( "--kv-transfer-config", **vllm_kwargs["kv_transfer_config"] ) @@ -1634,6 +1643,21 @@ class EngineArgs: """Initializes and returns a SpeculativeConfig object based on `speculative_config`. """ + for flag, key, value in ( + ("--spec-method", "method", self.spec_method), + ("--spec-model", "model", self.spec_model), + ("--spec-tokens", "num_speculative_tokens", self.spec_tokens), + ): + if value is None: + continue + if self.speculative_config is None: + self.speculative_config = {} + if key in self.speculative_config: + raise ValueError( + f"{flag} and --speculative-config['{key}'] are mutually exclusive" + ) + self.speculative_config[key] = value + if self.speculative_config is None: return None diff --git a/vllm/entrypoints/llm.py b/vllm/entrypoints/llm.py index ce28ddafcc9..9c342fc4808 100644 --- a/vllm/entrypoints/llm.py +++ b/vllm/entrypoints/llm.py @@ -188,6 +188,10 @@ class LLM(PoolingOfflineMixin): dictionary or an AttentionConfig instance. If a dictionary, it will be converted to an AttentionConfig. Allows specifying the attention backend and other attention-related settings. + spec_method: Top-level alias for `speculative_config["method"]`. + spec_model: Top-level alias for `speculative_config["model"]`. + spec_tokens: Top-level alias for + `speculative_config["num_speculative_tokens"]`. **kwargs: Arguments for [`EngineArgs`][vllm.EngineArgs]. Note: @@ -236,6 +240,9 @@ class LLM(PoolingOfflineMixin): compilation_config: int | dict[str, Any] | CompilationConfig | None = None, quantization_config: dict[str, Any] | QuantizationConfigArgs | None = None, logits_processors: list[str | type[LogitsProcessor]] | None = None, + spec_method: str | None = None, + spec_model: str | None = None, + spec_tokens: int | None = None, **kwargs: Any, ) -> None: """LLM constructor.""" @@ -357,6 +364,9 @@ class LLM(PoolingOfflineMixin): compilation_config=compilation_config_instance, quantization_config=quantization_config, logits_processors=logits_processors, + spec_method=spec_method, + spec_model=spec_model, + spec_tokens=spec_tokens, **kwargs, )