[Fix] Avoid duplicate residual in LongCat MoE shortcut (#40799)

This commit is contained in:
Cheng Wan
2026-09-23 14:37:39 -07:00
committed by GitHub
parent 954458567e
commit 0e80c73c92
2 changed files with 86 additions and 1 deletions
+2 -1
View File
@@ -501,7 +501,8 @@ class LongcatFlashDecoderLayer(nn.Module):
hidden_states, residual, forward_batch
)
moe_hidden_states = hidden_states.clone()
moe_residual = residual.clone()
# The final gather adds its residual; the dense branch already carries it.
moe_residual = torch.zeros_like(residual)
moe_hidden_states = self.mlp(moe_hidden_states)
moe_hidden_states, moe_residual = self.moe_layer_communicator.postprocess_layer(
moe_hidden_states, moe_residual, forward_batch