diff --git a/python/sglang/srt/models/qwen3_moe.py b/python/sglang/srt/models/qwen3_moe.py index 5cb3b37161..7d35ab6fc5 100644 --- a/python/sglang/srt/models/qwen3_moe.py +++ b/python/sglang/srt/models/qwen3_moe.py @@ -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)