Support specific pass of bias_grouped_topk for xpu (#26349)

This commit is contained in:
gaopengff
2026-06-03 13:13:48 +08:00
committed by GitHub
parent f4e7a98fe5
commit aa510bda45
2 changed files with 133 additions and 0 deletions
+32
View File
@@ -1238,6 +1238,38 @@ def biased_grouped_topk_gpu(
renormalize,
scaling,
)
elif (
_is_xpu
and num_expert_group == 1
and topk_group == 1
and num_fused_shared_experts == 0
and num_experts <= 256
and topk <= 8
):
if not apply_routed_scaling_factor_on_output:
scaling = 1.0
num_tokens = gating_output.shape[0]
topk_values = torch.empty(
(num_tokens, topk), dtype=torch.float32, device=gating_output.device
)
topk_indices = torch.empty(
(num_tokens, topk), dtype=torch.int32, device=gating_output.device
)
if num_tokens == 0:
return topk_values, topk_indices
topk_sigmoid(
topk_values,
topk_indices,
gating_output,
renormalize,
correction_bias,
)
return topk_values * scaling, topk_indices
else:
return biased_grouped_topk_impl(
hidden_states,