[Bugfix][MiniMax M3] Share target embeddings with MTP under PP (#58648)

Signed-off-by: Peiyuan Zhou <peiyuanzhou1994@gmail.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Woosuk Kwon <woosuk@inferact.ai>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
xiaozhoupy
2026-09-29 20:04:10 -07:00
committed by GitHub
co-authored by Codex Woosuk Kwon Jee Jee Li
parent 2798f66860
commit a8e069f81b
6 changed files with 229 additions and 6 deletions
+4 -1
View File
@@ -85,6 +85,7 @@ from vllm.model_executor.models.utils import (
make_empty_intermediate_tensors_factory,
make_layers,
maybe_prefix,
spec_decode_needs_target_embed,
)
from vllm.model_executor.models.vision import run_dp_sharded_mrope_vision_model
from vllm.models.minimax_m3.amd.indexer_aiter import (
@@ -1370,7 +1371,9 @@ class MiniMaxM3Model(nn.Module, EagleModelMixin):
self.vocab_size = config.vocab_size
if get_pp_group().is_first_rank:
if get_pp_group().is_first_rank or spec_decode_needs_target_embed(
vllm_config, include_mtp=vllm_config.use_v2_model_runner
):
self.embed_tokens = VocabParallelEmbedding(
config.vocab_size,
config.hidden_size,
+11
View File
@@ -24,6 +24,7 @@ import torch
import torch.nn as nn
from vllm.config import VllmConfig
from vllm.distributed import get_pp_group
from vllm.model_executor.layers.fused_moe import (
fused_moe_make_expert_params_mapping,
)
@@ -164,6 +165,10 @@ class MiniMaxM3MTP(nn.Module):
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
super().__init__()
if vllm_config.use_v2_model_runner and get_pp_group().world_size > 1:
# Preserve embeddings from loaders that bypass load_weights.
self.has_own_embed_tokens = vllm_config.load_config.load_format != "dummy"
assert vllm_config.speculative_config is not None
self.config = vllm_config.speculative_config.draft_model_config.hf_config
self.quant_config = vllm_config.quant_config
@@ -333,4 +338,10 @@ class MiniMaxM3MTP(nn.Module):
f"Failed to load MTP layer {layer_idx} weights from checkpoint."
)
if hasattr(self, "has_own_embed_tokens"):
if "model.embed_tokens.weight" in loaded_params:
self.has_own_embed_tokens = True
elif is_mtp_completeness_check_enabled():
# A complete checkpoint without embeddings borrows the target's.
self.has_own_embed_tokens = False
return loaded_params
+4 -1
View File
@@ -68,6 +68,7 @@ from vllm.model_executor.models.utils import (
make_empty_intermediate_tensors_factory,
make_layers,
maybe_prefix,
spec_decode_needs_target_embed,
)
from vllm.model_executor.models.vision import run_dp_sharded_mrope_vision_model
from vllm.models.minimax_m3.common.encoder_cudagraph import (
@@ -803,7 +804,9 @@ class MiniMaxM3Model(nn.Module, EagleModelMixin):
self.vocab_size = config.vocab_size
if get_pp_group().is_first_rank:
if get_pp_group().is_first_rank or spec_decode_needs_target_embed(
vllm_config, include_mtp=vllm_config.use_v2_model_runner
):
self.embed_tokens = VocabParallelEmbedding(
config.vocab_size,
config.hidden_size,
+11
View File
@@ -8,6 +8,7 @@ import torch
import torch.nn as nn
from vllm.config import VllmConfig
from vllm.distributed import get_pp_group
from vllm.model_executor.layers.fused_moe import (
fused_moe_make_expert_params_mapping,
)
@@ -146,6 +147,10 @@ class MiniMaxM3MTP(nn.Module):
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
super().__init__()
if vllm_config.use_v2_model_runner and get_pp_group().world_size > 1:
# Preserve embeddings from loaders that bypass load_weights.
self.has_own_embed_tokens = vllm_config.load_config.load_format != "dummy"
assert vllm_config.speculative_config is not None
self.config = vllm_config.speculative_config.draft_model_config.hf_config
self.quant_config = vllm_config.quant_config
@@ -315,4 +320,10 @@ class MiniMaxM3MTP(nn.Module):
f"Failed to load MTP layer {layer_idx} weights from checkpoint."
)
if hasattr(self, "has_own_embed_tokens"):
if "model.embed_tokens.weight" in loaded_params:
self.has_own_embed_tokens = True
elif is_mtp_completeness_check_enabled():
# A complete checkpoint without embeddings borrows the target's.
self.has_own_embed_tokens = False
return loaded_params