From 79246b5ea6e0ede64a7fe18f4538d59d33dd4792 Mon Sep 17 00:00:00 2001 From: Lanze Liu <86434077+liulanze@users.noreply.github.com> Date: Tue, 5 May 2026 14:56:06 -0700 Subject: [PATCH] [Spec Decode] Fix max_model_len logging in speculative config for draft model (#41571) Signed-off-by: Lanze Liu --- tests/v1/spec_decode/test_max_len.py | 21 +++++++++++++++++++++ vllm/config/speculative.py | 10 +++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/v1/spec_decode/test_max_len.py b/tests/v1/spec_decode/test_max_len.py index 1e1c6745191..77c041d84a9 100644 --- a/tests/v1/spec_decode/test_max_len.py +++ b/tests/v1/spec_decode/test_max_len.py @@ -6,6 +6,7 @@ import pytest from tests.utils import get_attn_backend_list_based_on_platform from vllm import LLM, SamplingParams +from vllm.config import ModelConfig, ParallelConfig, SpeculativeConfig from vllm.platforms import current_platform from vllm.sampling_params import StructuredOutputsParams @@ -77,3 +78,23 @@ def test_eagle_max_len( "is longer than the eagle max length" ) assert o.outputs[0].text == "a b c d e " * 15 + + +@pytest.mark.parametrize("spec_max_model_len", [80, 150]) +def test_mtp_speculative_config_max_model_len(spec_max_model_len: int): + """Regression test for #41456: max_model_len in speculative config + should be respected for the draft model.""" + model_config = ModelConfig( + model="XiaomiMiMo/MiMo-7B-Base", + runner="generate", + max_model_len=200, + trust_remote_code=True, + ) + spec_config = SpeculativeConfig( + target_model_config=model_config, + target_parallel_config=ParallelConfig(), + method="mtp", + num_speculative_tokens=1, + max_model_len=spec_max_model_len, + ) + assert spec_config.draft_model_config.max_model_len == spec_max_model_len diff --git a/vllm/config/speculative.py b/vllm/config/speculative.py index 8763e6a0525..0d52f396751 100644 --- a/vllm/config/speculative.py +++ b/vllm/config/speculative.py @@ -626,6 +626,7 @@ class SpeculativeConfig: revision=self.revision, code_revision=self.code_revision, tokenizer_revision=self.target_model_config.tokenizer_revision, + max_model_len=self.max_model_len, # type: ignore[arg-type] spec_target_max_model_len=self.target_model_config.max_model_len, quantization=self.quantization, enforce_eager=self.target_model_config.enforce_eager, @@ -837,10 +838,17 @@ class SpeculativeConfig: return speculative_max_model_len - return min( + result = min( draft_max_model_len, target_max_model_len, ) + if result != draft_max_model_len: + logger.info( + "Overriding draft model max model len from %d to %d", + draft_max_model_len, + result, + ) + return result @staticmethod def _verify_and_get_draft_tp(