[XPU]Fix the accuracy issue when meet topk_ids=-1 on DP+EP scenarios (#57787)

Signed-off-by: yisheng <yi.sheng@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
YiSheng5
2026-10-09 20:01:54 +08:00
committed by GitHub
co-authored by Kunshang Ji
parent 196483e25b
commit 0cc0460870
@@ -175,6 +175,11 @@ class XPUExperts(mk.FusedMoEExpertsModular):
gemm1_clamp_limit=self.gemm1_clamp_limit,
)
assert self.fused_moe_impl is not None
if self.moe_config.ep_size > 1:
# Avoid topk_ids = -1, remap them to an
# expert not owned by this rank so they are skipped.
sentinel = global_num_experts - 1 if self.moe_config.ep_rank == 0 else 0
topk_ids = torch.where(topk_ids < 0, sentinel, topk_ids)
self.fused_moe_impl.apply(
output=output,
hidden_states=hidden_states,