Skip redundant moe_sum_reduce for single-expert routing on XPU (#22660)

Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
This commit is contained in:
Rahul Vijayaraghavan
2026-07-07 09:03:16 +08:00
committed by GitHub
co-authored by Ma Mingfei
parent 7047afafec
commit 4b5c612257
2 changed files with 45 additions and 9 deletions
@@ -790,11 +790,14 @@ def _fused_moe_kernel_sequence(
routed_scaling_factor,
)
elif _is_xpu:
moe_sum_reduce(
intermediate_cache3.view(*intermediate_cache3.shape),
out_hidden_states,
routed_scaling_factor,
)
if topk == 1 and routed_scaling_factor == 1.0 and not _use_intermediate:
pass # we wrote directly into out_hidden_states
else:
moe_sum_reduce(
intermediate_cache3.view(*intermediate_cache3.shape),
out_hidden_states,
routed_scaling_factor,
)
else:
if _has_vllm_ops:
vllm_ops.moe_sum(