From 7e3a8dc90670fd312ce1e0d4eba9bf11c571e3ad Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Thu, 7 Aug 2025 18:13:04 +0100 Subject: [PATCH] Remove `from_dict` from `SpeculativeConfig` (#22451) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- tests/v1/spec_decode/test_ngram.py | 13 ++++++------- vllm/config.py | 5 ----- vllm/engine/arg_utils.py | 19 +++---------------- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/tests/v1/spec_decode/test_ngram.py b/tests/v1/spec_decode/test_ngram.py index c844925e6caed..b7303e0443d32 100644 --- a/tests/v1/spec_decode/test_ngram.py +++ b/tests/v1/spec_decode/test_ngram.py @@ -47,13 +47,12 @@ def test_ngram_proposer(): model_config = ModelConfig(model="facebook/opt-125m") return NgramProposer( vllm_config=VllmConfig(model_config=model_config, - speculative_config=SpeculativeConfig. - from_dict({ - "prompt_lookup_min": min_n, - "prompt_lookup_max": max_n, - "num_speculative_tokens": k, - "method": "ngram", - }))) + speculative_config=SpeculativeConfig( + prompt_lookup_min=min_n, + prompt_lookup_max=max_n, + num_speculative_tokens=k, + method="ngram", + ))) # No match. result = ngram_proposer( diff --git a/vllm/config.py b/vllm/config.py index 8dcd429a6b335..7147702eddde2 100644 --- a/vllm/config.py +++ b/vllm/config.py @@ -2895,11 +2895,6 @@ class SpeculativeConfig: usedforsecurity=False).hexdigest() return hash_str - @classmethod - def from_dict(cls, dict_value: dict) -> "SpeculativeConfig": - """Parse the CLI value for the speculative config.""" - return cls(**dict_value) - @staticmethod def hf_config_override(hf_config: PretrainedConfig) -> PretrainedConfig: if hf_config.model_type == "deepseek_v3": diff --git a/vllm/engine/arg_utils.py b/vllm/engine/arg_utils.py index d2153dfae3414..c0ac3ff6317fe 100644 --- a/vllm/engine/arg_utils.py +++ b/vllm/engine/arg_utils.py @@ -757,18 +757,6 @@ class EngineArgs: lora_group.add_argument("--default-mm-loras", **lora_kwargs["default_mm_loras"]) - # Speculative arguments - speculative_group = parser.add_argument_group( - title="SpeculativeConfig", - description=SpeculativeConfig.__doc__, - ) - speculative_group.add_argument( - "--speculative-config", - type=json.loads, - default=None, - help="The configurations for speculative decoding. Should be a " - "JSON string.") - # Observability arguments observability_kwargs = get_kwargs(ObservabilityConfig) observability_group = parser.add_argument_group( @@ -848,6 +836,8 @@ class EngineArgs: title="VllmConfig", description=VllmConfig.__doc__, ) + vllm_group.add_argument("--speculative-config", + **vllm_kwargs["speculative_config"]) vllm_group.add_argument("--kv-transfer-config", **vllm_kwargs["kv_transfer_config"]) vllm_group.add_argument('--kv-events-config', @@ -1033,10 +1023,7 @@ class EngineArgs: "enable_chunked_prefill": enable_chunked_prefill, "disable_log_stats": disable_log_stats, }) - speculative_config = SpeculativeConfig.from_dict( - self.speculative_config) - - return speculative_config + return SpeculativeConfig(**self.speculative_config) def create_engine_config( self,