[Fix] eplb: Fix Qwen3 MoE output corruption after EPLB rebalance (#39580)

Signed-off-by: Spycsh <sihan.chen@intel.com>
This commit is contained in:
Sihan Chen
2026-10-20 03:00:39 -07:00
committed by GitHub
parent a70b1b73d3
commit 9db58ab547
+11 -1
View File
@@ -338,10 +338,20 @@ class Qwen3MoeSparseMoeBlock(nn.Module):
num_tokens, hidden_dim = hidden_states.shape
hidden_states = hidden_states.view(-1, hidden_dim)
dispatch_info = (
ExpertLocationDispatchInfo.init_new(layer_id=self.layer_id)
if get_exec().moe.enable_eplb
else None
)
if hidden_states.shape[0] > 0:
# router_logits: (num_tokens, n_experts)
router_logits, _ = self.gate(hidden_states)
topk_output = self.topk(hidden_states, router_logits)
topk_output = self.topk(
hidden_states,
router_logits,
expert_location_dispatch_info=dispatch_info,
)
else:
topk_output = self.topk.empty_topk_output(hidden_states.device)
final_hidden_states = self.experts(hidden_states, topk_output)