Fix FlashInfer A2A top-k ID dtype (#29929)

This commit is contained in:
Po-Han Huang (NVIDIA)
2026-07-15 17:56:11 -07:00
committed by GitHub
parent 34f5691ea1
commit 5d004a20c5
2 changed files with 76 additions and 2 deletions
@@ -21,7 +21,11 @@ from sglang.srt.layers.moe.token_dispatcher import (
from sglang.srt.layers.moe.token_dispatcher.flashinfer_utils import (
TorchDistributedCommBackend,
)
from sglang.srt.layers.moe.topk import StandardTopKOutput, TopKOutput
from sglang.srt.layers.moe.topk import (
StandardTopKOutput,
TopKOutput,
TopKOutputChecker,
)
from sglang.srt.layers.moe.utils import get_moe_runner_backend
from sglang.srt.runtime_context import get_server_args
from sglang.srt.speculative.spec_info import SpeculativeAlgorithm
@@ -176,7 +180,12 @@ class FlashinferDispatcher(BaseDispatcher):
output_dtype = hidden_states.dtype
x = hidden_states
x_sf = None
topk_ids = topk_output.topk_ids
# FlashInfer dispatch requires materialized top-k IDs and weights.
if TopKOutputChecker.format_is_bypassed(topk_output):
topk_output = topk_output.to_standard()
# FlashInfer MoeAlltoAll's expert-ID ABI is int32. This dispatcher is
# only selected for moe_a2a_backend="flashinfer".
topk_ids = topk_output.topk_ids.to(torch.int32)
topk_weights = topk_output.topk_weights
global_scale = self.quant_config.get("input_global_scale", None)