[ROCm] fixed aiter master flag and expert parallelism compatibility on minimax-m3-mxfp8 (#47158)

Signed-off-by: Hongxia Yang <hongxia.yang@amd.com>
This commit is contained in:
Hongxia Yang
2026-07-08 15:26:17 +08:00
committed by GitHub
parent d35eba302f
commit 2c64b4c1cc
2 changed files with 107 additions and 12 deletions
@@ -78,9 +78,6 @@ class AiterMxfp8Experts(Mxfp8TritonExpertsBase):
@staticmethod
def _supports_parallel_config(moe_parallel_config) -> bool:
# Both TP (expert_map=None) and EP are supported: apply() forwards the
# expert_map as aiter's ``expert_mask`` (the per-rank local-expert
# selection), mirroring the native rocm_aiter_moe path.
return True
@staticmethod
@@ -129,17 +126,21 @@ class AiterMxfp8Experts(Mxfp8TritonExpertsBase):
limit = self.quant_config.gemm1_clamp_limit
swiglu_limit = 0.0 if limit is None else float(limit)
# Under EP, aiter expects ``expert_mask`` as a 0/1 *local-expert* mask
# over global ids with a trailing fake-expert sentinel slot
# (shape ``[global_num_experts + 1]``), NOT vLLM's expert_map (a
# global->local index map with -1 for non-local). Convert it; aiter
# derives the global->local compaction from the mask itself. ``None``
# under pure TP.
if expert_map is not None:
# Under EP, aiter expects ``expert_mask``: a 0/1 *local-expert* mask over
# global ids with a trailing fake-expert sentinel slot (shape
# ``[global_num_experts + 1]``), from which it derives the global->local
# compaction. What ``RoutedExperts.expert_map`` hands us depends on the
# aiter master switch (``rocm_aiter_fmoe_enabled``).
# Branching on the (static) master flag — not the tensor contents —
# keeps this HIP-graph/torch.compile safe (no data-dependent sync).
# ``None`` under pure TP.
if expert_map is None:
expert_mask = None
elif self.moe_config.rocm_aiter_fmoe_enabled:
expert_mask = expert_map
else:
local_mask = (expert_map >= 0).to(torch.int32)
expert_mask = torch.cat([local_mask, local_mask.new_zeros(1)])
else:
expert_mask = None
# Route through the graph-safe ``rocm_aiter_fused_moe`` custom op so the
# call is captured under HIP graphs / torch.compile (a direct