Repository navigation
[FlyDSL] dist: public SP APIs: PCP graph_capture, head exchange, all_to_all, MegaMoE setup errors - #7346
[FlyDSL] dist: public SP APIs: PCP graph_capture, head exchange, all_to_all, MegaMoE setup errors#7346whx-sjtu wants to merge 3 commits into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
- Drop the FP4 pre-gather wire and its fused_moe dispatch predictor; the PCP/SP split pass packs routed_rows_wire again, so plain PCP matches main. - Dispatch SP MegaMoE from FusedMoE.forward_impl behind the existing moe_forward op. Remove the comm-fused op, supports(), the sp_mega_moe_enabled config field and its compile-hash factor; M3 marks its MoE with allow_sp_mega_moe instead of enable_comm_fused. - Import fused_qk_rmsnorm_per_token_quant directly and raise on shapes the FP32-norm quant path cannot take. - Use ROCm/aiter#7346: graph_capture() enters PCP, CustomAllreduce exposes registered_input_view/head_exchange, and dim-0 reduce_scatter writes in place. Delete sp_graph_capture, sp_registered_buffer, the private CustomAllreduce reads and reduce_scatter_tokens. - One custom all-gather check (token_transport.custom_gather_ok) shared by indexer_cp and the V4.1 mono runner. - Delete sp_pad_len, the SP group aliases and kv_head_shards; use the PCP helpers and attn_head_shard_size(). - Graphs and eager read the SP token shard as a view of forward_vars["input_ids"]; refuse max_num_batched_tokens not divisible by the SP size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Use AITER's public SP APIs (ROCm/aiter#7346): device_communicator all_gatherv / all_to_all, QuickAllReduce's reduce-scatter admission, MegaMoeSetupError and MegaMoeTP.prepare_all. Drop gather_tokens, all_to_all_into, quick_reduce_scatter.py, the MORI probe and the setup-failure string matching. - SPModelWrapper shards, runs and gathers the model like UBatchWrapper, so eager, TR_HYBRID, capture and full_forward share one call. - Move the SP attention op and its FP8 output path to model_ops/sp_attention.py; distributed keeps the exchange. - gather_heads pads inside its send buffer instead of torch.cat. - pcp_is_enabled -> pcp_stripes_tokens, pcp_stripe_count(), local_num_kv_heads(), group_min. - Revert the topK.py non-EP fast path and the graph_capture re-wrap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Drop the FP4 pre-gather wire and its fused_moe dispatch predictor; the PCP/SP split pass packs routed_rows_wire again, so plain PCP matches main. - Dispatch SP MegaMoE from FusedMoE.forward_impl behind the existing moe_forward op. Remove the comm-fused op, supports(), the sp_mega_moe_enabled config field and its compile-hash factor; M3 marks its MoE with allow_sp_mega_moe instead of enable_comm_fused. - Import fused_qk_rmsnorm_per_token_quant directly and raise on shapes the FP32-norm quant path cannot take. - Use ROCm/aiter#7346: graph_capture() enters PCP, CustomAllreduce exposes registered_input_view/head_exchange, and dim-0 reduce_scatter writes in place. Delete sp_graph_capture, sp_registered_buffer, the private CustomAllreduce reads and reduce_scatter_tokens. - One custom all-gather check (token_transport.custom_gather_ok) shared by indexer_cp and the V4.1 mono runner. - Delete sp_pad_len, the SP group aliases and kv_head_shards; use the PCP helpers and attn_head_shard_size(). - Graphs and eager read the SP token shard as a view of forward_vars["input_ids"]; refuse max_num_batched_tokens not divisible by the SP size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Use AITER's public SP APIs (ROCm/aiter#7346): device_communicator all_gatherv / all_to_all, QuickAllReduce's reduce-scatter admission, MegaMoeSetupError and MegaMoeTP.prepare_all. Drop gather_tokens, all_to_all_into, quick_reduce_scatter.py, the MORI probe and the setup-failure string matching. - SPModelWrapper shards, runs and gathers the model like UBatchWrapper, so eager, TR_HYBRID, capture and full_forward share one call. - Move the SP attention op and its FP8 output path to model_ops/sp_attention.py; distributed keeps the exchange. - gather_heads pads inside its send buffer instead of torch.cat. - pcp_is_enabled -> pcp_stripes_tokens, pcp_stripe_count(), local_num_kv_heads(), group_min. - Revert the topK.py non-EP fast path and the graph_capture re-wrap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Drop the FP4 pre-gather wire and its fused_moe dispatch predictor; the PCP/SP split pass packs routed_rows_wire again, so plain PCP matches main. - Dispatch SP MegaMoE from FusedMoE.forward_impl behind the existing moe_forward op. Remove the comm-fused op, supports(), the sp_mega_moe_enabled config field and its compile-hash factor; M3 marks its MoE with allow_sp_mega_moe instead of enable_comm_fused. - Import fused_qk_rmsnorm_per_token_quant directly and raise on shapes the FP32-norm quant path cannot take. - Use ROCm/aiter#7346: graph_capture() enters PCP, CustomAllreduce exposes registered_input_view/head_exchange, and dim-0 reduce_scatter writes in place. Delete sp_graph_capture, sp_registered_buffer, the private CustomAllreduce reads and reduce_scatter_tokens. - One custom all-gather check (token_transport.custom_gather_ok) shared by indexer_cp and the V4.1 mono runner. - Delete sp_pad_len, the SP group aliases and kv_head_shards; use the PCP helpers and attn_head_shard_size(). - Graphs and eager read the SP token shard as a view of forward_vars["input_ids"]; refuse max_num_batched_tokens not divisible by the SP size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Use AITER's public SP APIs (ROCm/aiter#7346): device_communicator all_gatherv / all_to_all, QuickAllReduce's reduce-scatter admission, MegaMoeSetupError and MegaMoeTP.prepare_all. Drop gather_tokens, all_to_all_into, quick_reduce_scatter.py, the MORI probe and the setup-failure string matching. - SPModelWrapper shards, runs and gathers the model like UBatchWrapper, so eager, TR_HYBRID, capture and full_forward share one call. - Move the SP attention op and its FP8 output path to model_ops/sp_attention.py; distributed keeps the exchange. - gather_heads pads inside its send buffer instead of torch.cat. - pcp_is_enabled -> pcp_stripes_tokens, pcp_stripe_count(), local_num_kv_heads(), group_min. - Revert the topK.py non-EP fast path and the graph_capture re-wrap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Drop the FP4 pre-gather wire and its fused_moe dispatch predictor; the PCP/SP split pass packs routed_rows_wire again, so plain PCP matches main. - Dispatch SP MegaMoE from FusedMoE.forward_impl behind the existing moe_forward op. Remove the comm-fused op, supports(), the sp_mega_moe_enabled config field and its compile-hash factor; M3 marks its MoE with allow_sp_mega_moe instead of enable_comm_fused. - Import fused_qk_rmsnorm_per_token_quant directly and raise on shapes the FP32-norm quant path cannot take. - Use ROCm/aiter#7346: graph_capture() enters PCP, CustomAllreduce exposes registered_input_view/head_exchange, and dim-0 reduce_scatter writes in place. Delete sp_graph_capture, sp_registered_buffer, the private CustomAllreduce reads and reduce_scatter_tokens. - One custom all-gather check (token_transport.custom_gather_ok) shared by indexer_cp and the V4.1 mono runner. - Delete sp_pad_len, the SP group aliases and kv_head_shards; use the PCP helpers and attn_head_shard_size(). - Graphs and eager read the SP token shard as a view of forward_vars["input_ids"]; refuse max_num_batched_tokens not divisible by the SP size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Use AITER's public SP APIs (ROCm/aiter#7346): device_communicator all_gatherv / all_to_all, QuickAllReduce's reduce-scatter admission, MegaMoeSetupError and MegaMoeTP.prepare_all. Drop gather_tokens, all_to_all_into, quick_reduce_scatter.py, the MORI probe and the setup-failure string matching. - SPModelWrapper shards, runs and gathers the model like UBatchWrapper, so eager, TR_HYBRID, capture and full_forward share one call. - Move the SP attention op and its FP8 output path to model_ops/sp_attention.py; distributed keeps the exchange. - gather_heads pads inside its send buffer instead of torch.cat. - pcp_is_enabled -> pcp_stripes_tokens, pcp_stripe_count(), local_num_kv_heads(), group_min. - Revert the topK.py non-EP fast path and the graph_capture re-wrap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Drop the FP4 pre-gather wire and its fused_moe dispatch predictor; the PCP/SP split pass packs routed_rows_wire again, so plain PCP matches main. - Dispatch SP MegaMoE from FusedMoE.forward_impl behind the existing moe_forward op. Remove the comm-fused op, supports(), the sp_mega_moe_enabled config field and its compile-hash factor; M3 marks its MoE with allow_sp_mega_moe instead of enable_comm_fused. - Import fused_qk_rmsnorm_per_token_quant directly and raise on shapes the FP32-norm quant path cannot take. - Use ROCm/aiter#7346: graph_capture() enters PCP, CustomAllreduce exposes registered_input_view/head_exchange, and dim-0 reduce_scatter writes in place. Delete sp_graph_capture, sp_registered_buffer, the private CustomAllreduce reads and reduce_scatter_tokens. - One custom all-gather check (token_transport.custom_gather_ok) shared by indexer_cp and the V4.1 mono runner. - Delete sp_pad_len, the SP group aliases and kv_head_shards; use the PCP helpers and attn_head_shard_size(). - Graphs and eager read the SP token shard as a view of forward_vars["input_ids"]; refuse max_num_batched_tokens not divisible by the SP size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Use AITER's public SP APIs (ROCm/aiter#7346): device_communicator all_gatherv / all_to_all, QuickAllReduce's reduce-scatter admission, MegaMoeSetupError and MegaMoeTP.prepare_all. Drop gather_tokens, all_to_all_into, quick_reduce_scatter.py, the MORI probe and the setup-failure string matching. - SPModelWrapper shards, runs and gathers the model like UBatchWrapper, so eager, TR_HYBRID, capture and full_forward share one call. - Move the SP attention op and its FP8 output path to model_ops/sp_attention.py; distributed keeps the exchange. - gather_heads pads inside its send buffer instead of torch.cat. - pcp_is_enabled -> pcp_stripes_tokens, pcp_stripe_count(), local_num_kv_heads(), group_min. - Revert the topK.py non-EP fast path and the graph_capture re-wrap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review: #7346 — Public SP APIs (PCP graph_capture, head exchange, all_to_all, quick RS, MegaMoE errors)Verdict: What it does
Must fix
Should fix
Note
Checked, no issues
Validation and perf were not run locally: running the tests needs a JIT build inside the checkout. If you want it as a shareable page instead, I can publish it as an artifact |
…mmunication (#2364) * feat(sp): add Ulysses sequence parallelism with MegaMoE prefill MoE Add `--sequence-parallel-size`, riding the PCP process group as an axis independent of TP: non-attention layers run on T/W tokens, and an exchange around attention trades the sequence for a head slice (GQA KV heads and an indexer tail are replicated to the ranks whose queries use them). MoE gathers the SP shards, runs this rank's expert slice and reduce-scatters the partial sums; large MXFP4 batches route and quantize before the gather. ATOM_SP_MOE_MEGA (default on) runs eligible SP MXFP4 prefill MoE blocks through AITER's MegaMoeTP, with the native norm, gate and top-k in front of it. Ineligible configs, layers or a failed runtime setup keep the native MoE. ATOM_TP_REPLICATED_O_PROJ (experimental, default off) keeps o_proj replicated under TP and exchanges heads instead of all-reducing. Both are generic and opted into per model; MiniMax-M3 is the first user. Ported onto the request/token graph runner (#2688) and the route-before-gather MoE (#2725): SP graphs capture this rank's token shard at a fixed address, gathered SP rows place their experts after the gather and skip the per-rank row count, and SP keeps its own reduce-scatter instead of the PCP-merge all-reduce. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(sp): replay TR_HYBRID token graphs under sequence parallelism Under SP a decode token graph is keyed by this rank's shard of the batch, while the capture skip and the step's replay check compared the global row count, so SP decode never found its graph and ran eagerly. Compare the local shard (sp_local_len) on both sides, and keep the TR_HYBRID ladder on multiples of the SP width so each local bucket maps to one batch size. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: skip the quick reduce-scatter dispatch test without AITER The SP4 dispatch's arch gate imports AITER's chip_info lazily, so the test cannot patch it on the CPU CI runner, where the module import failed collection and interrupted the whole non-GPU suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Fold SP head exchange into ulysses_sp and fix MegaMoE transport to FP8 The four-rank head exchange is Ulysses transport, so it moves next to _swap_heads; the AITER op is resolved lazily to keep the module importable without AITER. Drop ATOM_SP_MOE_MEGA_COMM_DTYPE: MegaMoeTP always moves tokens as FP8. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: MegaMoE timeout and fallback, SP refusals, LM-head gather - sp_mega_moe: raise when the MegaMoE timeout flag is set (read one step late, no host sync), and agree the native fallback across SP ranks. - SP: refuse attention layers that apply RoPE outside the attention impl or use sinks or ALiBi, indexer heads SP can neither shard nor replicate, and KV-transfer connectors. - ModelRunner: clamp the SP token-graph capture ladder to max_bs instead of dropping rounded-up sizes; set sp_mega_moe after any runner's model build, so RapidServe's decode runner has it too. - LM head: under SP, prefill gathers only each prompt's last row instead of all-gathering every token's hidden state. - Compiler: flatten nested inputs for every cache-backed artifact, not only torch >= 2.10. - SP Triton kernels: int64 row offsets. - Name the QuickRS and head-exchange thresholds. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: one routed-row MoE gather, token transport, MegaMoE hook - MoE under SP and the replicated o_proj token group: route the local rows on their owner, then gather hidden states, top-k weights and ids (and MXFP4 scales when fused_moe would prequantize) in one all_gatherv, the pack_routed_rows/gather_rows path DP and PCP already use. Drops the separate route-then-gather branch, its M3-shaped gates and the 32768-row threshold. - Prequant prediction resolves the 2-stage config as fused_moe does for MXFP4 input with scales: Opus-sorted a4w4 override, EP mask, no inline sort; FP8 activations never prequantize. - reassign_gathered_shared_ids returns early without EP, where every row carries the same prefilled shared ids. - atom/distributed/token_transport.py holds the token and head transport shared by Ulysses SP, the replicated o_proj and the MoE gathers. - MegaMoE finds a model's MoE layers through the registry (sp_mega_moe_layers); FusedMoE.sp_mega_moe holds the backend, and MiniMax-M3 runs one decoder loop with or without it. - TP1: Gemma RMSNorm + per-token FP8 quant takes the fused kernel when no all-reduce is pending. - Decode-padding test: SP prefill passes the local shard to compute_logits. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: non-SP norm numerics, MegaMoE setup, replicated o_proj - MiniMax-M3: the one-kernel Gemma RMSNorm + per-token FP8 quant runs only under SP and the replicated o_proj (gemma_rms_norm_quant's `fused`). Plain TP and TP1 quantize the BF16-rounded norm again, as on main, so mono's stages match. - sp_mega_moe: the epoch-reset budget counts the launches forward_block runs for the uncapped local shard. Setup refuses without the fused Gemma RMSNorm FP8 kernel, and only the imports and a MORI probe fall back on ImportError, before any collective. - Replicated o_proj: with an unfused shared expert, gather the local rows once before the gate for the routed and shared experts. The capture ladder rounds to batch sizes whose rows split evenly over TP (split_rows_graph_ladder, speculative q lengths included), so decode graphs do not pad. The BF16 scale is new_empty, padding uses pcp_pad_dense, and a padded residual is not cloned. - SP no longer counts as PCP striping: the runner reads Config.pcp_striping_size and pcp_is_enabled() is False under SP. ModelRunner.world_size is the TP width again; the KV-head math divides by kv_head_shards = tp * sp. - The graph-bucket memory guard MIN-reduces free memory over the DP, TP and PCP groups. - MoE: the MXFP4 prequant wire is chosen for the rows after the simulated DP repeat. - token_transport: the PyNccl reduce-scatter calls reduce_scatterv, which checks the split. - GemmaRMSNorm's BF16 path and MegaMoE's _norm_input share gemma_rms_norm_unquantized. - Docs: ATOM_TP_REPLICATED_O_PROJ, ATOM_SP_MOE_MEGA and --sequence-parallel-size / -sp. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: refuse SP with pipeline parallelism - Ulysses SP refuses --pipeline-parallel-size > 1 at configuration time; the combination is not validated. The guides list -pp 1 next to -tp 1. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Resolve the MXFP4 gather wire on first use - Mxfp4MoEMethod resolved `_fp4_rows_wire` in `__init__`, which reads `moe.in_dtype`/`hidden_dim`; main's MXFP4 method tests build the method from a stub config without them and failed. It is a cached property now, read only when a gather is prequantized. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: refuse SP with expert parallelism - SP + EP has never run on GPU, so `_init_sequence_parallel` now raises for `--enable-expert-parallel`, and the guides list it next to `-tp 1` and `-pp 1`. The SP-only EP pieces go with it: SP token shards in the MoE EP/all2all selection, the local-shard all2all capacity, and the shared-expert fusion fallback for non-MXFP4 SP + EP. They return with the follow-up that adapts SP to EP. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: state SP's only validated model in the guides - The configuration and distributed guides now say SP has been validated only on MiniMax-M3 MXFP4; no other model or quantization has run under SP on GPU. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: pass the post-attention eps into SP MegaMoE - sp_mega_moe_block takes the post-attention norm's own eps instead of assuming the fused tail's eps; the tail still runs fused only when the next norm's eps matches it. - The configuration and distributed guides say SP has run only at SP4 and that KV replication (fewer KV heads than SP ranks) has not run end to end. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: SP MegaMoE agreement, vocab-sharded SP LM head, drop riders - SP MegaMoE: route through tgemm.mm; read the error bits group-wide before resetting them; agree the all-or-nothing fallback with tp_agree and warn on it; launch the fallback as one untailed tile without a BF16 scale. - Ulysses SP decode projects each rank's vocab slice and gathers the slices instead of running the full LM head on every rank. - Drop the EP routed-scale and EP compile-hash changes; the SP hash factor only appears when SP is on. - Refuse SP with --enable-dp-attention, in DP-isolated RLHF workers and for MiniMax-M3 image input; say so in the docs and -sp help. - Log the first INT4 quick reduce-scatter; explain the 2 MiB all-gather threshold and reuse custom_gather_ok for the head exchange. - Restore main's running_tokens_across_dp and fix the stale sparse-decode comment. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Test the MXFP4 gathered-rows wire against AITER fused_moe On MiniMax-M3's SP MoE shape, rows the method gathers in MXFP4 must come out of apply as their BF16 originals do. Skips without AITER or gfx950. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: move the TP replicated o_proj to its own PR - Remove the experimental TP replicated o_proj (ATOM_TP_REPLICATED_O_PROJ, its config field, validation and hash factor, the custom ops module, the MoE token_group gather, the capture-ladder and capacity branches, docs and tests); the SP code paths are unchanged. - Keep the FP8 head-exchange flag on the owning M3 attention module, so _minimax_m3_attend_and_project takes that module and reads one flag. - The final norm now has one exit besides the SP MegaMoE tail. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: one routed-rows gather for SP and PCP SP's MoE gather and PCP_MOE_MERGE's gather in _run_experts now share gather_routed_rows: one grouped all_gatherv of the packed rows, then the shared-expert id reassignment. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: SP refusals, MegaMoE warmup and step accounting - Refuse what bypasses the SP token split: RLHF hidden-state export, ATOM_FWD_DUMP_DIR forward hooks under SP MegaMoE, and RapidServe with -pcp or -sp; LLMEngine rechecks DP after the legacy DP kwargs land. - Fall back to the native MoE when a MegaMoeTP big-M warmup wait timed out on any rank, instead of failing the second step. - Count launches and copy MegaMoE error bits only on steps whose rows take MegaMoE; supports() asks fused_moe's own activation dtype resolver at the gathered M, shared with the MXFP4 prequant predictor, whose cache is keyed on the padded M. - Move the CPU-group agreement to atom/distributed/group_agreement.py; mono re-exports it as tp_agree. - Share the vocab-slice GEMM between the SP and DP sharded LM heads; SP gathers the slices with all_gather(dim=-1). - Remove dead code: the unreachable SP prefill token graph refusal, the lcm over q buckets (SP refuses speculative decoding), and MiniMaxM3MoE's x_scale argument. - Test the rows wire at the SP4 intermediate (768); restore device="cpu" in the memory guard; docs for the SP index and the PCP dimension. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: run MegaMoE as a comm-fused MoE backend; drop the side paths Review 5731266938: - SP MegaMoE is a CommFusedMoeBackend reached through forward_maybe_comm_fused. The per-model custom op, the registry table, the FusedMoE attributes, M3's second forward branch, _router_logits and the fused next-norm tail are gone; small batches fall back to the layer's native forward. - One PCP split branch in _run_experts serves PCP merge and SP: the wire comes from gathered_rows_wire and pcp_reduce_scatter tries the quick reduce-scatter first. sp_moe_reduce_scatter is removed. - sp_mega_buffers.py and its test are removed (copy_ covers them); gemma_norm_fp8.py is folded into layernorm.gemma_rms_norm_quant, renamed quantize_fp32_norm and dropped from the TP all-reduce helper. - MORI is probed only when the local tile reaches the big-M kernel, and the runtime is closed when an agreed setup failure aborts prepare(). - The refusal lists keep only what Config cannot see (EPLB, dtype, gfx950, ATOM_FWD_DUMP_DIR); the multimodal refusal in llm_engine goes. - The SP decode graph records the token gather and the LM head, as TP1 does. ModelRunner asserts no token-graph builder runs under SP, the precondition sp_attention_fp8 now states. - fp8_head_exchange passes STRIDE and RANK at run time: one build. - MiniMax-M3's FlyDSL row limit counts KV heads per attn_head_shard_size(). Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review: keep PCP merge on the exact reduce-scatter; zero-row norm guard - pcp_reduce_scatter takes the INT4 QuickReduce reduce-scatter only under SP; PCP merge alone keeps main's exact BF16 reduce-scatter. - GemmaRMSNorm.forward_cuda skips the launch on zero rows again, as gemma_rms_norm_quant does (lost when gemma_rms_norm_unquantized was inlined). Co-Authored-By: Claude Opus 5.5 <[email protected]> * Skip the PCP reduce-scatter dispatch test where aiter is absent pcp_utils imports aiter at load, so the non-GPU CI cannot import it; skip through import_guard as the other aiter-backed tests do. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Return empty outputs from gemma_rms_norm_quant before any zero-row launch AITER's per-token HIP quant has no rows==0 guard either, so the unfused path left the same invalid-configuration error for the next kernel as the fused one did. Guard once at entry so both paths skip every launch. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: address review round 13, use aiter public comm APIs - Drop the FP4 pre-gather wire and its fused_moe dispatch predictor; the PCP/SP split pass packs routed_rows_wire again, so plain PCP matches main. - Dispatch SP MegaMoE from FusedMoE.forward_impl behind the existing moe_forward op. Remove the comm-fused op, supports(), the sp_mega_moe_enabled config field and its compile-hash factor; M3 marks its MoE with allow_sp_mega_moe instead of enable_comm_fused. - Import fused_qk_rmsnorm_per_token_quant directly and raise on shapes the FP32-norm quant path cannot take. - Use ROCm/aiter#7346: graph_capture() enters PCP, CustomAllreduce exposes registered_input_view/head_exchange, and dim-0 reduce_scatter writes in place. Delete sp_graph_capture, sp_registered_buffer, the private CustomAllreduce reads and reduce_scatter_tokens. - One custom all-gather check (token_transport.custom_gather_ok) shared by indexer_cp and the V4.1 mono runner. - Delete sp_pad_len, the SP group aliases and kv_head_shards; use the PCP helpers and attn_head_shard_size(). - Graphs and eager read the SP token shard as a view of forward_vars["input_ids"]; refuse max_num_batched_tokens not divisible by the SP size. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: address review round 14 - Use AITER's public SP APIs (ROCm/aiter#7346): device_communicator all_gatherv / all_to_all, QuickAllReduce's reduce-scatter admission, MegaMoeSetupError and MegaMoeTP.prepare_all. Drop gather_tokens, all_to_all_into, quick_reduce_scatter.py, the MORI probe and the setup-failure string matching. - SPModelWrapper shards, runs and gathers the model like UBatchWrapper, so eager, TR_HYBRID, capture and full_forward share one call. - Move the SP attention op and its FP8 output path to model_ops/sp_attention.py; distributed keeps the exchange. - gather_heads pads inside its send buffer instead of torch.cat. - pcp_is_enabled -> pcp_stripes_tokens, pcp_stripe_count(), local_num_kv_heads(), group_min. - Revert the topK.py non-EP fast path and the graph_capture re-wrap. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: sort the pcp_utils imports after the pcp_stripes_tokens rename Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: address review round 15 - run_model: SP takes model_output[:scheduled_tokens] like every other path. - Config refuses -pcp > 1 with -sp > 1; ulysses_sp reads the SP width from the current config. - Attention impls declare their fused-qkv fields (qkv_fields); one column table drives the head exchange and the pack kernel. - sp_head_shards() for head sharding; the legacy DP kwargs build ParallelConfig before Config. - do_not_specialize the runtime sizes of the SP Triton kernels; the head exchange communicator is chosen at layer build. - check_aiter_sp_api() names the missing AITER APIs at startup. - SPModelWrapper hands the model this rank's rows of inputs_embeds, so a multimodal prefill runs under SP. - SP tests load ATOM through tests/aiter_stubs.py where AITER is absent; so does the top-k routing rows test. - Move sp_mega_moe.py to model_ops/fused_moe/; drop the unused index_q_size kwarg M3 passed to Attention. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: read the SP width through an explicit optional config get_current_atom_config_or_none() returns None where no config is set; get_current_atom_config() keeps its assertion on top of it. ulysses_sp reads the SP width through it instead of catching the AssertionError. Co-Authored-By: Claude Opus 5.5 <[email protected]> * tests: keep scaled_table's values and scales on separate pages The 1 MiB scale buffer comes off the heap once malloc's mmap threshold has grown, so the small values tensor could share its first page; both were then registered as one run and the scripted second refusal never came (test_a_refused_shared_registration_falls_back_to_a_copy, Pre Checkin). Both now sit in one buffer, two pages apart. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Address review round 16 - Keep decode logits out of graphs when the SP head would gather over RCCL (ATOM_USE_CUSTOM_ALL_GATHER=0). - Skip-top-k sparse layers exchange only q/k/v under Ulysses SP. - Note that SP and plain -tp 1 quantize the M3 norm at different points. - Pass device="cpu" to the group agreement tensor. - Tests: patch attn_head_shard_size in the DCP builder test, pin the AOT artifact's unflattened inputs, and check the real AITER resolver's MegaMoE threshold. Co-Authored-By: Claude Opus 5.5 <[email protected]> * vLLM plugin: derive the MiniMax-M3 index_q_size like the native impl The M3 layer no longer passes index_q_size to Attention, and the vLLM sparse layer refused to build without it. It now takes num_kv_heads * index_head_dim, as the native impl does when indexer CP is off, which plugin mode always is. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP MegaMoE: close the runtime at exit; rename count_step to before_step ModelRunner.exit() closes the shared MegaMoeTP runtime next to close_mega_transports(): its close is collective over the SP group, which destroy_dist_env() destroys. count_step did more than count, so it is before_step, and its docstring says what it does: the async timeout check, the launch count, and every RESET_LAUNCHES the agreed host sync and collective reset; capture warmups go uncounted. The exit test now sets structured_compile_executor, without which exit() raised before any close on an AITER host. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP MegaMoE: ask AITER whether the GPU has the kernel mega_moe_tp_supported() is the MegaMoeTP constructor's own check, which raises ValueError rather than MegaMoeSetupError, so it stays a pre-check; it ships in the same module as MegaMoeTP, so the import's ImportError fallback covers both. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SPModelWrapper: drop the inputs_embeds branch Nothing passes inputs_embeds under SP: SP takes MHA models only, the one MHA VL model (MiniMax-M3) refuses images under SP, and SP refuses PP. A future MHA VL model gets a TypeError instead of a silent path. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: mark every pass pcp_split in SPModelWrapper; FusedMoE reads only that FusedMoE no longer asks sp_is_enabled() per layer. Plain PCP is unchanged: its setters never mark a dummy pass split. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ModelRunner: drop TP from the capture memory guard; restore main's capture loop The guard min-reduces free memory over DP and PCP, as before SP; the capture loop slices input_ids inline again, as main does. Co-Authored-By: Claude Opus 5.5 <[email protected]> * MiniMax-M3: mono matches TP4, not -tp 1; fix the quantization comment Co-Authored-By: Claude Opus 5.5 <[email protected]> * Move the custom all-gather admission out of the SP head transport custom_gather_ok and the communicator lookup it needs now live in atom/distributed/custom_gather.py, so indexer CP and the DeepSeek-V4.1 mono runner no longer import an SP module to ask whether AITER's registered-buffer all-gather takes a payload. Behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Shard the SP LM head only where the custom all-gather takes it The vocab-sharded SP head now runs only when AITER's custom all-gather admits the per-rank logit slice (env on, a usable ca_comm, an even split and 16-byte rows). Otherwise every SP rank runs the whole replicated head, which needs no collective, so decode logits stay capturable and logits_in_graph is back to `self.world_size == 1`. Co-Authored-By: Claude Opus 5.5 <[email protected]> * compile: keep a split op's getitems in its own piece split_graph put the getitems that unpack a tuple-returning split op (sp_attention_fp8's (output, scale)) into the next compiled piece, so that piece took the tuple as one input. A reloaded standalone artifact cannot unpack it, which the loader worked around by flattening the call arguments. Port vLLM's fix (vllm-project/vllm#28533): a getitem joins its producer's piece, so the split op's piece returns the tensors and no compiled piece takes a tuple. The loader goes back to calling the artifact as is. Graphs whose split ops return one tensor partition as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: drop the INT4 QuickReduce reduce-scatter With MegaMoE running, the native expert reduce-scatter only sees decode batches under 256 global rows (under 3 MiB at M3's hidden size), far below AITER's 24 MiB QuickReduce threshold, so the branch never ran in the deployment SP is validated on. Go back to the exact reduce_scatter and stop requiring QuickAllReduce.quick_reduce_scatter from AITER. Co-Authored-By: Claude Opus 5.5 <[email protected]> * norm: drop the zero-row guards Every SP rank runs ceil(N / SP) >= 1 rows, padding included, and no forward runs with zero tokens, so the GemmaRMSNorm and gemma_rms_norm_quant guards never fired. GemmaRMSNorm.forward_cuda is back to main's form. Co-Authored-By: Claude Opus 5.5 <[email protected]> * tests: one AITER stub module, shared MoE fixtures in a conftest Fold tests/aiter_stubs.py into tests/aiter_stub.py, whose docstring now says which helper to use when; the two cleanup rules stay as they are. Move the atom_modules and sp_modules fixtures into tests/model_ops/conftest.py, so the SP MoE tests no longer import fixtures across files or call a fixture's __wrapped__. The directory gets an __init__.py, as tests/attentions/deepseek_v41 has: a conftest outside a package is imported as `conftest` and would shadow tests/conftest.py for every `from conftest import ...` collected after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: keep -pcp's value under SP; size the PCP group by max(pcp, sp) SP no longer rewrites prefill_context_parallel_size. Config.pcp_group_size (max of the two) sizes AITER's PCP process group, which SP runs over, and every rank count derived from it: the runner's device span and both init_dist_env calls, EngineCore's worker count, CoreManager's RPC ranks and EngineCapabilities.workers_per_engine. With -pcp at 1 under SP, generic PCP code needs no SP special case, so pcp_stripes_tokens / pcp_stripe_count go back to base's pcp_is_enabled and config reads. The RapidServe refusal moves into SP's validation, so plain -pcp with RapidServe is accepted again as on main. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: refuse RLHF weight updates under Ulysses SP SPModelWrapper holds the model as a child, so every name a trainer sent missed and the sync was a warned no-op that kept the old weights. All three update entry points resolve their target through _sync_target_model before writing anything; it now raises on the SP wrapper instead of peeling it, since reloading SP's MegaMoE experts in place is unverified. The worker capability report stops advertising fp8_weight_update under SP. Co-Authored-By: Claude Opus 5.5 <[email protected]> * tests: back out the engram scaled_table fixture change It fixes a flake in main's test and does not belong in the SP PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> * moe: keep the dummy-pass guard for plain PCP Only SP splits its dummy and captured passes; plain PCP with ATOM_PCP_MOE_MERGE again runs no PCP collective on a dummy pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> * config: refuse --level 1 under Ulysses SP fullgraph cannot trace the SP decode token gather (AITER's custom_all_gatherv), so the server would fail at the first decode warmup. Co-Authored-By: Claude Opus 5.5 <[email protected]> * model_runner: size the TR_HYBRID memory guard on SP-local rows The token graph records the inner model on a rank's local rows, so the capture memory guard takes the same local count as the dedup key. Co-Authored-By: Claude Opus 5.5 <[email protected]> * SP: size the PCP process group through one helper Config, the capabilities report and the RPC fan-out all take the group size from pcp_group_size_of(), and the sampled-id broadcast comment now says why SP needs it too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * llm_engine: keep main's legacy DP kwargs, recheck SP after them Restore main's post-construction assignment of the loose DP kwargs and refuse Ulysses SP against the final DP size there instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> * attention: route to Ulysses on the layer's SP columns The layer builds sp_columns only under SP, so the per-step split op checks that attribute instead of looking the SP size up in the config. Co-Authored-By: Claude Opus 5.5 <[email protected]> * mono, engram: call group_agree directly Drop the tp_agree alias and route engram's UVA vote through group_agree. Co-Authored-By: Claude Opus 5.5 <[email protected]> * moe: gate sp megamoe on --moe-backend mega, raise when unsupported Drop ATOM_SP_MOE_MEGA and the per-model opt-in. Under -sp, mega needs no EP and keeps the standard MXFP4 method; SP without it runs the native MoE. Co-Authored-By: Claude Opus 5.5 <[email protected]> * moe: skip the collective sp megamoe close after a timeout A rank that raised on a timed-out wait exits through ModelRunner.exit; its peers are still in the step, so the close() barrier would hold it ~30 min. Co-Authored-By: Claude Opus 5.5 <[email protected]> * moe: count only the real rows of a gathered sp moe pass SP shards are contiguous, so the gather keeps the step's real rows first and the sort can skip the trailing pads, as on padded pure-TP graphs. Co-Authored-By: Claude Opus 5.5 <[email protected]> * minimax_m3: keep main's bf16-rounded norm quant under sp Drop the fused FP32-norm quantization SP used and its layernorm helper; SP now quantizes the same BF16-rounded norm output as TP 1. Co-Authored-By: Claude Opus 5.5 <[email protected]> * token_transport: match the all-gather threshold comment to its value Co-Authored-By: Claude Opus 5.5 <[email protected]> * ulysses_sp: say trailing ranks may hold only pad rows Co-Authored-By: Claude Opus 5.5 <[email protected]> * token_transport: pad with pcp_pad_dense Co-Authored-By: Claude Opus 5.5 <[email protected]> * sp_attention: one gather_heads ladder for bf16 and fp8 outputs The FP8 output now takes the same alignment check, size cap, rows and head-exchange communicator as BF16; only the long-row wire format differs. ulysses_attention returns the padded length instead of taking a transform, and the head all-to-all reuses ulysses_sp's. Co-Authored-By: Claude Opus 5.5 <[email protected]> * attention: hand an fp8 o_proj per-token fp8 under sp Attention takes `per_token_fp8_out` and returns `(out, scale)` from `sp_attention_fp8`, which now writes the scale into a caller buffer and returns one tensor, so the backend needs no getitem rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pcp: keep pcp_is_enabled() false under Ulysses SP SP still runs over AITER's PCP group; its sampled-id broadcast is gated explicitly, and mono / comm-fused MoE refuse on the group size. Co-Authored-By: Claude Opus 5.5 <[email protected]> * model_runner: drop the unreachable SP prefill-token-graph guard No MHA backend SP accepts records prefill token graphs. Co-Authored-By: Claude Opus 5.5 <[email protected]> * region_graph: list SP token graphs under the step's rows The SP recording unit runs one rank's shard, so its key is local; the wrapper names the step's rows and captured_sizes reports those. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ulysses_sp: read the SP size from the required atom config Every entry point sets the config before a layer is built, so a missing one is a bug, not SP=1. Drops get_current_atom_config_or_none(). Co-Authored-By: Claude Opus 5.5 <[email protected]> * rollout: refuse Ulysses SP once, in the RLHF runner constructor Replaces the capability, weight-update, hidden-state export and DP-isolation guards, so an RLHF engine fails at startup instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> * config: refuse multimodal checkpoints under Ulysses SP SPModelWrapper does not shard inputs_embeds. MiniMax-M3 is not refused: it builds no vision tower under SP and serves text. Co-Authored-By: Claude Opus 5.5 <[email protected]> * sp: let AITER choose the all-gather path Drop atom/distributed/custom_gather.py. The SP all-gathers call device_communicator.all_gather, which takes the custom all-gather when AITER can and otherwise falls back to pynccl. indexer_cp.py and the DeepSeek V4.1 mono runner go back to main. Co-Authored-By: Claude Opus 5.5 <[email protected]> * moe: read pcp_split only on PCP-merge or SP passes vLLM plugin passes have no ATOM forward context, so _run_experts must not touch it unless PCP merge or SP is on, as on main. Co-Authored-By: Claude Opus 5.5 <[email protected]> * sp: drop admission checks AITER already makes MegaMoeTP refuses a non-gfx950 GPU, non-contiguous weights and non-BF16 activations itself, on every rank alike, so the startup plan no longer repeats those checks or votes across the SP group. The head exchange leaves the GPU, dtype and size admission to AITER's should_head_exchange; ATOM_USE_CUSTOM_ALL_GATHER remains the opt-out. Co-Authored-By: Claude Opus 5.5 <[email protected]> * moe: decide the split pass from pcp_merge first A layer without PCP merge never splits, so check it before asking whether SP is enabled; that query needs the atom config, which a bare layer (and its unit test) does not have. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Fold token_transport.py into its users What remained were two constants and two head-exchange helpers, each with one user: the all-gather cap moves to ulysses_sp.py, the head-exchange row floor and the communicator / staging-view helpers to sp_attention.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…reduce_scatter graph_capture() entered TP/PP/DP/EP/DCP and the custom groups but not PCP, so a PCP group's custom all-reduce was never armed for capture and callers had to wrap the context and read ca_comm._IS_CAPTURING themselves. Enter _PCP next to _DCP (the DCP entry also moves out of the PP/DP/EP loop, where it was entered once per group). CustomAllreduce gains the public surface sequence-parallel callers need instead of reading _pool / _ptr / _IS_CAPTURING: - registered_input_view(shape, dtype): a view of the registered input pool a producer can write before a collective called with registered=True. - should_head_exchange(inp) / head_exchange(inp, registered=...): the four-rank [S, H] -> [S/4, 4H] exchange over sp_head_exchange, binding a captured input in place like the other collectives. CudaCommunicator.reduce_scatter with dim=0 and a contiguous output now scatters straight into output_ instead of through a temporary and a copy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eSetupError, prepare_all - PyNcclCommunicator.all_to_all and CudaCommunicator.all_to_all (falls back to all_to_all_single without PyNccl). - QuickAllReduce.should_quick_reduce_scatter / quick_reduce_scatter. - MegaMoeSetupError, raised alike on every rank for SDMA setup, arena mapping, warmup timeout and MORI import failures; SdmaComm all-gathers the import error so no rank proceeds alone. - MegaMoeTP.prepare_all() prepares every launch variant once. - sdma_available() for callers that only need the MORI check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Drop QuickAllReduce.should_quick_reduce_scatter / quick_reduce_scatter and sdma_available(): their only caller (ATOM's SP path) no longer uses them. - CustomAllreduce.head_exchange raises when the communicator is disabled or on the gfx1250 kernel, instead of passing the op a handle it would cast to the wrong type. - test_sp_head_exchange: write new values into the input after capture and check the replay against them; the pool still holds the staged copy, so a capture bound to the wrong buffer now fails. Check that a disabled communicator's head_exchange raises. - test_parallel_groups: with pcp > 1, require PCP's custom all-reduce to exist and be armed by graph_capture(). - aiter_test.sh: run test_sp_head_exchange.py through pytest (it has no script entry point), and run test_parallel_groups.py again with --tp 2 --pcp 2 --dp 1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1992233 to
d1df819
Compare
|
Thanks for the review. Addressed in d1df819, rebased onto main f705d6b:
4x MI355X (gfx950), d1df819 on main f705d6b |
zufayu
left a comment
There was a problem hiding this comment.
AITER SOP code review on current head d1df819:
Verified blocker: CustomAllreduce.head_exchange() is a public API, but it only checks disabled/gfx1250 and does not enforce the constraints already encoded by should_head_exchange(): world_size == 4, 2-D contiguous input, rows divisible by 4, and 16-byte alignment. A direct TP2 or invalid-shape call can still launch a four-rank-semantics kernel and produce wrong output or a device fault.
Primary reviewer: @TennyWang1223 (communication/all-reduce owner); @coderfeli can co-review the FlyDSL MegaMoE portion.
Author action: enforce the complete contract inside head_exchange(), add TP2/non-divisible/non-aligned rejection tests, and rebase current main. The current red FlyDSL test does not have a demonstrated causal link to this patch, but the stale conflict must still be resolved before merge.
|
Re-review of d1df819 Thanks @whx-sjtu. I checked all five points from my earlier review against d1df819, and they are all fixed:
On @zufayu's blocker (full contract in head_exchange): the C++ op already rejects these inputs before launch. csrc/kernels/sp_head_exchange.cu:44-69 checks world_size_ == 4, 2-D contiguous input and output, size(0) % 4, row_bytes % 16, 16-byte alignment of input, output and the staged buffer, and the pool size. Each check is an AITER_CHECK, which throws std::runtime_error. So a TP2 call or a bad shape raises an error; it does not produce wrong output or a device fault. I still agree with the ask as hardening, because it's cheap and makes the error clear on the Python side:
Still blocking merge:
Once the rebase is in, the guard and tests above are added, and CI (including Multi-GPU) is green, I'll approve. |
|
No activity for 15 days, so this is now labelled |
Summary
Small
aiter.distand MegaMoE-TP changes so sequence-parallel callers (ROCm/ATOM#2364) stop patching around aiter and reading its privates:parallel_state.graph_capture()also enters the PCP group, as it already does DCP.CustomAllreducegets a public registered-input view and a public four-rank head exchange (should_head_exchange/head_exchange) over the existingsp_head_exchangeop.CudaCommunicator.reduce_scatter(dim=0)writes straight into its output instead of through a temporary and a copy.PyNcclCommunicator.all_to_all/CudaCommunicator.all_to_all: an equal-split dim-0 all-to-all on the current stream.MegaMoeSetupErrorfor setup failures raised alike on every rank, andMegaMoeTP.prepare_all().Motivation
graph_capture()enters TP/PP/DP/EP/DCP and the custom groups but not PCP, so a PCP group's custom all-reduce is never armed and its captured collectives take the eager path. ATOM worked around this by wrappinggraph_capture()and readingca_comm._IS_CAPTURING. Plain PCP with custom all-reduce has the same gap.sp_head_exchangeitself, fromca._ptr,ca._pool["input"]andpool._buffer, and had its own copy of the capture-time registration check.ncclSend/ncclRecvloop againstpynccl.nccl,pynccl.commandbuffer_typefor its all-to-all.RuntimeErrortext, and calledlaunch_config(rows)for every row count to enumerate the small-engine variants before capture. Rewording one message here would have turned its fallback into a raise on every rank.The ATOM reviewer asked for these to land in aiter and for #2364 to use them. ATOM #2364 is merged and uses all of them.
Changes
parallel_state.graph_capture: enter_DCPand_PCPwhen their world size is above 1. The DCP entry also moves out of the PP/DP/EP loop, where it was entered once per iteration (ExitStackmade that harmless).CustomAllreduce.registered_input_view(shape, dtype): a view of the registered input pool, orNonewhen the communicator is disabled, the size is not a whole number of 16-byte packs, the pool is too small, or the pool has no tensor (VMM). A producer writes there and calls the collective withregistered=Trueto skip staging.CustomAllreduce.should_head_exchange(inp)/head_exchange(inp, *, registered=False):[S, H]to[S/4, 4H]on four ranks, pre-gfx1250 kernel. Undercapture()a captured input is bound in place through_capture_registered, the same as the other collectives.head_exchangeraisesRuntimeErroron a disabled communicator or on gfx1250, where the op would cast the wrong handle.CudaCommunicator.reduce_scatter: whendim == 0andoutput_is contiguous, callpynccl_comm.reduce_scatter(output_, input_tensor)directly.PyNcclCommunicator.all_to_all(output, input): one groupedncclSend/ncclRecvper peer over same-shape contiguous tensors, dim 0 divisible by the world size.CudaCommunicator.all_to_alluses it, elseall_to_all_single.MegaMoeSetupError(RuntimeError)inaiter.ops.communication, re-exported byaiter.ops.flydsl.mega_moe_tp. Raised on every rank for: MORI failing to import on any rank (SdmaCommnow gathers the import result before raising), MORI SDMA setup, the symmetric arena's IPC mapping, and warmup timeouts. The last three already raisedRuntimeErroron every rank and keep their messages, soexcept RuntimeErrorstill catches them.MegaMoeTP.prepare_all(tail=False, tail_bf16=False, warmup=True):prepare()one token count per launch variant of 1 ..max_local_tokens, so no batch in range compiles while serving or inside graph capture..github/scripts/aiter_test.sh):test_sp_head_exchange.pyruns through pytest, andtest_parallel_groups.pyruns again with--tp 2 --pcp 2 --dp 1after its default layout, which has no PCP group.Existing calls keep their behaviour, except that a MORI import failure now raises on every rank (see Behavior and intent). The reduce-scatter result is the same values in the same layout.
Testing
On 4x MI355X (gfx950), at d1df819 (this head, on main f705d6b):
pytest op_tests/multigpu_tests/test_sp_head_exchange.py: 4 passed.registered_input_viewthenhead_exchange(registered=True); a staged input; and a captured input bound in place, rewritten after capture and replayed. It also checks thathead_exchangeraises on a disabled communicator.all_to_allexactly, eagerly and as a captured graph replayed on three fresh inputs.python op_tests/multigpu_tests/test_parallel_groups.pyand... --tp 2 --pcp 2 --dp 1: ALL PASS, including the new assert thatgraph_capture()arms the PCP group's custom all-reduce. The same test file run against main without this change fails it:AssertionError: Rank 0: graph_capture() missed PCP.test_mega_moe_tp.py --models m3 --modes ag_rs -t 256 -r random --seeds 0: 15/15 passed. This file stays skipped in CI, as on main (Skip MegaMoE TP multigpu test #6933).head_exchangetemporarily binding the registered pool instead of the captured input, the capture case fails (512/512 elements off by one), while the previous version of the case still passed. With_is_gfx1250forced on an enabled communicator,head_exchangeraises on all four ranks.MegaMoeSetupErrorand fell back to the native MoE alike.Documentation
Dependencies
Breaking Changes
None in aiter.
SdmaComm()without MORI now raisesMegaMoeSetupErroron every rank, instead ofImportErroron the ranks that lack it. Nothing in aiter catches theImportError.PR Self-Review
Reviewed revision
d1df819
Behavior and intent
graph_capture()now arms PCP's custom all-reduce, so PCP collectives inside a captured graph take the custom path (registered or staged), as the TP/DCP ones already do.RuntimeErrors. A MORI import failure on some ranks now raisesMegaMoeSetupErroron all of them, where before only the failing ranks raisedImportErrorand the rest went on into the arena's collectives.Validation and unverified scope
See Testing. Not verified on hardware: the gfx1250 and symm_mem transports.
should_head_exchangerefuses gfx1250 andhead_exchangeraises there (checked by forcing the flag on gfx950), andregistered_input_viewreturnsNonewhen the pool has no tensor. Not run on MI300X.PR-specific question
The only CI change is in
.github/scripts/aiter_test.sh, which the existingAiter Testjobs already run from the PR checkout inside the test container. No workflow, trigger, permission, secret or token changes. The new lines addtest_sp_head_exchange.pyto the pytest list and runtest_parallel_groups.pya second time with fixed arguments. The file path comes from the same repository file list as every other case and reachesbash -cas a positional argument, not as script text, and no PR title, body, branch name or other PR text is read. So fork PR code reaches nothing it could not reach before: it already runs in thesepull_requestjobs, and the Tests step passes onlyMULTIGPU=TRUEinto the container.Changed op tests
op_tests/multigpu_tests/test_sp_head_exchange.py: covers the communicator wrappers: the head exchange's three entry paths and its guard, andall_to_alleager and replayed. Before this PR both new cases fail withAttributeError. The existing cases drive the raw op with their own buffers, so they cannot catch a wrong pool pointer, stage flag or capture binding in the wrapper, nor a wrong peer offset in the all-to-all. The file has no__main__, so CI now runs it through pytest.op_tests/multigpu_tests/test_parallel_groups.py: one assert thatgraph_capture()arms PCP's custom all-reduce; on main it fails withgraph_capture() missed PCP. Nothing else covers which groupsgraph_capture()enters. CI ran this file only at its default layout, which has no PCP group, so it now also runs with--tp 2 --pcp 2 --dp 1.🤖 Generated with Claude Code