[Fix] eplb: Fix Qwen3 MoE output corruption after EPLB rebalance (#39580)
Signed-off-by: Spycsh <sihan.chen@intel.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user