From d9c72bdd2b8bae9a0e2af2b87d9a100dcc6f596c Mon Sep 17 00:00:00 2001 From: Cheng Wan <54331508+ch-wan@users.noreply.github.com> Date: Thu, 23 Apr 2026 17:30:19 -0700 Subject: [PATCH] Skip unselected experts in flashinfer_trtllm (#23493) --- python/sglang/srt/layers/moe/moe_runner/flashinfer_trtllm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/sglang/srt/layers/moe/moe_runner/flashinfer_trtllm.py b/python/sglang/srt/layers/moe/moe_runner/flashinfer_trtllm.py index 6a637805f..b28a8e61e 100644 --- a/python/sglang/srt/layers/moe/moe_runner/flashinfer_trtllm.py +++ b/python/sglang/srt/layers/moe/moe_runner/flashinfer_trtllm.py @@ -333,8 +333,7 @@ def _pack_topk_for_flashinfer_routed( packed_ids = topk_ids.to(torch.int32) packed_weights = topk_weights.to(torch.bfloat16) packed = (packed_ids << 16) | packed_weights.view(torch.int16).to(torch.int32) - # SGLang can mark padded tokens with -1 expert ids. - return packed.masked_fill_(packed_ids < 0, 0) + return packed def fused_experts_none_to_flashinfer_trtllm_fp8(