[Bugfix][SpecDecode] Scope MTP completeness checks outside bucketed updates (#49178)

Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com>
Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com>
This commit is contained in:
aoshen02
2026-07-21 18:56:39 -07:00
committed by GitHub
co-authored by aoshen02
parent 0500ca6a58
commit ba18929079
14 changed files with 131 additions and 37 deletions
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Scoped controls for MTP checkpoint completeness validation."""
from collections.abc import Iterator
from contextlib import contextmanager
from contextvars import ContextVar
_mtp_completeness_check_enabled: ContextVar[bool] = ContextVar(
"mtp_completeness_check_enabled", default=True
)
def is_mtp_completeness_check_enabled() -> bool:
"""Return whether MTP completeness validation is enabled in this scope."""
return _mtp_completeness_check_enabled.get()
@contextmanager
def disable_mtp_completeness_check() -> Iterator[None]:
"""Temporarily disable MTP completeness validation for one weight load."""
token = _mtp_completeness_check_enabled.set(False)
try:
yield
finally:
_mtp_completeness_check_enabled.reset(token)
@@ -20,6 +20,9 @@ from vllm.model_executor.layers.vocab_parallel_embedding import (
ParallelLMHead,
VocabParallelEmbedding,
)
from vllm.model_executor.model_loader.mtp_validation import (
is_mtp_completeness_check_enabled,
)
from vllm.model_executor.model_loader.weight_utils import (
default_weight_loader,
maybe_remap_kv_scale_name,
@@ -370,7 +373,10 @@ class BailingMoeV25MTPModel(nn.Module):
self.model.mtp_start_layer_idx,
self.model.mtp_start_layer_idx + self.model.num_mtp_layers,
):
if layer_idx not in loaded_mtp_layers:
if (
layer_idx not in loaded_mtp_layers
and is_mtp_completeness_check_enabled()
):
raise ValueError(
f"Bailing MTP speculative decoding layer {layer_idx} "
"weights are missing from checkpoint. Use a checkpoint "
+4 -1
View File
@@ -21,6 +21,9 @@ from vllm.model_executor.layers.vocab_parallel_embedding import (
ParallelLMHead,
VocabParallelEmbedding,
)
from vllm.model_executor.model_loader.mtp_validation import (
is_mtp_completeness_check_enabled,
)
from vllm.model_executor.model_loader.weight_utils import (
default_weight_loader,
maybe_remap_kv_scale_name,
@@ -516,7 +519,7 @@ class DeepSeekMTP(nn.Module, DeepseekV2MixtureOfExperts):
self.model.mtp_start_layer_idx,
self.model.mtp_start_layer_idx + self.model.num_mtp_layers,
):
if layer_idx not in loaded_layers:
if layer_idx not in loaded_layers and is_mtp_completeness_check_enabled():
raise ValueError(
f"MTP speculative decoding layer {layer_idx} weights "
f"missing from checkpoint. The checkpoint may have "
+4 -1
View File
@@ -15,6 +15,9 @@ from vllm.model_executor.layers.vocab_parallel_embedding import (
ParallelLMHead,
VocabParallelEmbedding,
)
from vllm.model_executor.model_loader.mtp_validation import (
is_mtp_completeness_check_enabled,
)
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
from vllm.sequence import IntermediateTensors
@@ -283,7 +286,7 @@ class Step3p5MTP(nn.Module):
and getattr(param, "requires_grad", False) is False
}
params_need_to_load -= optional_params
if params_need_to_load != loaded_params:
if params_need_to_load != loaded_params and is_mtp_completeness_check_enabled():
missing_params = list(params_need_to_load - loaded_params)
param_name_example = missing_params[0]
raise RuntimeError(