[Feature] Migrate moe sp support to non-torch compiled path for GLM5.2 (#47881)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Wentao Ye
2026-07-15 23:33:15 +00:00
committed by GitHub
co-authored by mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent eb33ff34dd
commit 4238b011a7
4 changed files with 92 additions and 16 deletions
+3 -1
View File
@@ -45,9 +45,10 @@ def _restore_full_token_layout_if_needed(
hidden_states: torch.Tensor,
residual: torch.Tensor,
num_tokens: int,
is_sequence_parallel: bool = False,
) -> tuple[torch.Tensor, torch.Tensor]:
"""Restore full token rows for the MTP proposer after SP MoE layers."""
if hidden_states.shape[0] == num_tokens:
if not is_sequence_parallel and hidden_states.shape[0] == num_tokens:
return hidden_states, residual
combined_states = torch.cat([hidden_states, residual], dim=-1)
@@ -142,6 +143,7 @@ class DeepSeekMultiTokenPredictorLayer(nn.Module):
hidden_states,
residual,
positions.shape[0],
is_sequence_parallel=self.mtp_block.use_sequence_parallel_moe,
)
hidden_states = residual + hidden_states # pre-final-norm (logits hidden)
# Recycle the post-final-norm hidden into the next draft step.