[Bugfix] Fix DeepSeek-V4 DSpark draft shared-expert padding for TP > 8 (#49415)

Signed-off-by: Mike G <180722391+mikekg@users.noreply.github.com>
This commit is contained in:
Mike G
2026-07-23 05:06:21 +00:00
committed by GitHub
parent 9a698f3255
commit 76bf55240c
3 changed files with 31 additions and 11 deletions
+12 -4
View File
@@ -43,6 +43,7 @@ from vllm.model_executor.models.utils import maybe_prefix
from .model import (
DeepseekV4DecoderLayer,
DeepseekV4Model,
make_deepseek_v4_expert_params_mapping,
)
@@ -277,6 +278,11 @@ class DSparkDeepseekV4ForCausalLM(nn.Module):
assert vllm_config.speculative_config is not None
self.draft_model_config = vllm_config.speculative_config.draft_model_config
self.config = self.draft_model_config.hf_config
self.quant_config = vllm_config.quant_config
self.pad_shared_expert = (
getattr(self.quant_config, "weight_block_size", None) is not None
and not vllm_config.parallel_config.use_sequence_parallel_moe
)
self.model = DSparkDeepseekV4Model(
vllm_config=vllm_config, prefix=maybe_prefix(prefix, "model")
)
@@ -396,6 +402,12 @@ class DSparkDeepseekV4ForCausalLM(nn.Module):
else ".weight_scale_inv"
)
name = name.removesuffix(".scale") + suffix
if ".shared_experts.w2" in name:
name = name.replace(".shared_experts.w2", ".shared_experts.down_proj")
if self.pad_shared_expert and ".shared_experts." in name:
loaded_weight = DeepseekV4Model._pad_shared_expert_weight(
self.quant_config, name, loaded_weight
)
# E8M0 expert scales: keep raw exponent bytes.
if ".experts." in name:
@@ -440,10 +452,6 @@ class DSparkDeepseekV4ForCausalLM(nn.Module):
params_dict[name][: narrow.shape[0]].copy_(narrow)
loaded_params.add(name)
continue
if ".shared_experts.w2" in name:
name = name.replace(
".shared_experts.w2", ".shared_experts.down_proj"
)
if name.endswith(".ffn.gate.bias"):
name = name.replace(
".ffn.gate.bias", ".ffn.gate.e_score_correction_bias"