Skip to content

[HIP] [Perf] gfx1250 ar2s: MXFP8 output and sequence-parallel residual ops - #8428

Draft
XiaobingSuper wants to merge 3 commits into
ROCm:mainfrom
XiaobingSuper:xiaobingsuper/gfx1250-ar2s-seq-parallel
Draft

XiaobingSuper wants to merge 3 commits into
ROCm:mainfrom
XiaobingSuper:xiaobingsuper/gfx1250-ar2s-seq-parallel

Conversation

@XiaobingSuper

@XiaobingSuper XiaobingSuper commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Extends the gfx1250 pushed two-shot AR + RMSNorm (ar2s_rms_gfx1250, #8427) with ar2s_rms_ex and three modes. They are exposed as sequence-parallel ops for prefill: tensor_model_parallel_sp_fused_allreduce_rmsnorm{,_mxfp8_quant} and tensor_model_parallel_sp_allreduce_add_residual (mutates_args=[]).

  • FP8: the epilogue writes MXFP8 (E4M3 + row-major E8M0 per 32), the bytes per_1x32_mx_quant_hip gives for the bf16 output. The group max is floored at kAmaxFloor, so an all-zero group gets scale 85.
  • SP: each rank keeps the residual of its own row chunk only. The owner normalizes (and quantizes) its rows and pushes the result, so the all-gather moves MXFP8 and phase 3 is a copy. The normed output is whole on every rank and bit-identical to the replicated path.
  • AUX (with SP): no norm; the whole all_reduce(x) + residual on every rank.

The SP ops take the SP path at the ar2s sizes and run the replicated ops below them, so every call of a forward takes the same branch.

Why

In MiniMax-M3.1 TP4 prefill, the two AR + RMSNorm (+ MXFP8) calls of a layer were about 31% of a 14K-token prefill forward on a 100K-token cached prefix. With a sequence-parallel residual, each rank needs only its own rows, and the all-gather can carry the 8-bit activations the next GEMM consumes.

Evidence

TP4, hidden 6144, Gemma norm, 4x MI455X:

The times were measured on an earlier aiter base (576d3f0); this rebase was checked for correctness on GPU (below), not re-timed.

Gated on

PR Self-Review

Reviewed revision

93c6e8d

Behavior and intent

New SP / FP8 / AUX modes of ar2s behind explicit SP ops; the replicated path is unchanged.

Validation and unverified scope

Stacking. Rebased onto #8427's review head 0c78341fb (#8310 is on main now). The top commit is this PR. Adaptations:

On 4x MI455X at f000c5e33, which differs from this head only in the import order of the two new test files (aiter JIT module rebuilt from that tree):

  • tests/test_ar_rmsnorm_routing.py: 87 passed (CPU).
  • op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py ([HIP] [JIT] [Perf] gfx1250 custom AR: pushed two-shot AR + RMSNorm for 32-288 MiB #8427's replicated-route test, here with the 192 MiB cap): all passed. At the default cap and at 48 MiB, 24 routed calls each matched the fp32 rank-order reference; at 0, none.
  • test_ar2s_rms_ex_gfx1250.py --check at 4 / 2752 / 6144 / 12288 / 14336 / 16384 rows: every check is True — fp8, sp, sp_fp8, aux, the public SP ops (api), and rank agreement. 16384 rows run in one launch.
  • test_ar2s_mxfp8_zero_group.py: pass, replicated and SP. The E4M3 / E8M0 bytes equal per_1x32_mx_quant_hip's, and the all-zero row's scale is 85.

Lint. black and ruff 0.16.0 (main's pyproject.toml) are clean on every changed Python file.

Unverified. Re-timing on this base, TP2, and an in-model run on this base.

PR-specific question

Stacked on #8427 (the bottom two commits); please review only the top commit.

Changed op tests

  • op_tests/multigpu_tests/test_ar2s_rms_ex_gfx1250.py (new) checks every mode and the public SP ops, bit for bit, against ar2s + per_1x32_mx_quant_hip, at 4-32768 rows:
    • non-owned residual rows are poisoned with NaN;
    • ranks must agree;
    • it also times each mode.
  • op_tests/multigpu_tests/test_ar2s_mxfp8_zero_group.py (new) checks an all-zero row's E4M3 / E8M0 bytes (scale 85), replicated and SP.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8428 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@XiaobingSuper

Copy link
Copy Markdown
Contributor Author

Update: pushed 63b9540, ar2s kernel 2, on top of this branch. It is the base for the MoE-front mode PR that stacks on this one.

  • What. A second ar2s kernel with kernel 1's data layout, flags and arithmetic, so outputs are bit-identical. Kernel 1's serializations are removed:

    • row-local barriers are LDS-only;
    • straight-line loads;
    • bounded flag polls (AITER_AR2S_MAXIT); a poll that gives up is counted, not hung;
    • at most 64 VGPRs, so two 768-thread blocks fit a CU.
  • PF. Phase 2 reads its rows through a double-buffered LDS slot, loaded one row ahead with global_load_async_to_lds_b128. PF is on by default; AITER_AR2S_PF=0 turns it off.

  • Default. Kernel 2 is the default up to TP4; it spills at 6 / 8 ranks. AITER_AR2S_KERNEL=1/2 overrides.

  • PF on vs off. 4x MI455X, TP4, bit-exact, us:

    mode 14336 rows 32768 rows
    sp_fp8 213.1 -> 189.0 453.5 -> 401.2
    sp 248.6 -> 224.1 538.7 -> 485.4
    aux 229.3 -> 222.0 506.1 -> 483.2
  • Validation. Validated in our MiniMax-M3.1 integration stack: serving gate and GSM8K. It applied cleanly onto this branch. Not re-run on GPUs after the rebase.

@XiaobingSuper
XiaobingSuper force-pushed the xiaobingsuper/gfx1250-ar2s-seq-parallel branch from 63b9540 to 4d96b11 Compare November 23, 2026 08:43
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…duce + RMSNorm

At prefill sizes on gfx1250 TP > 1 (one PP stage, no TBO, every layer on the
bf16 or native-MXFP8 AR + norm), the decoder's all-reduce + Gemma RMSNorm run
aiter's sequence-parallel residual ops (ROCm/aiter#8428): reduce-scatter, norm
of this rank's owner rows only, all-gather of the (MXFP8) normed output. The
normed outputs are bit-identical; the residual stream stays valid on the owner
rows only and is gathered by the final add. aiter falls back to the
replicated ops for sizes or configurations its kernel does not take.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XiaobingSuper
XiaobingSuper force-pushed the xiaobingsuper/gfx1250-ar2s-seq-parallel branch from 4d96b11 to 7c7986e Compare November 23, 2026 09:50
XiaobingSuper and others added 2 commits December 2, 2026 15:57
fused_allreduce_rmsnorm on gfx1250 fell back to RCCL + a separate add +
RMSNorm above the Lamport kernels' range. Add a pushed two-shot all-reduce +
residual add + (Gemma) RMSNorm kernel (ar2s_rms_gfx1250) and route bf16
inputs of 32-288 MiB to it at TP4:

- phase 1 pushes each row chunk to its owner's RS inbox, phase 2 sums the own
  chunk in fp32 in rank order, rounds once to bf16, pushes it to every peer's
  AG inbox and normalizes it, phase 3 normalizes the peers' rows;
- block b only waits for block b of its peers (a flag per phase, sender and
  block, epoch counters), so no barrier is needed, eager or in a CUDA graph;
- row-local barriers are LDS-only and only a flag waits for the store drain;
  the three phases are pipelined per step; phase 2 prefetches the next row's
  summands into LDS asynchronously; flag polls are bounded (no hang);
- out / residual_out follow the Lamport fused kernel step by step;
- the kernel body is compiled only for gfx1250 (as mega_mhc_gfx1250.cu), so
  the gfx942 / gfx950 wheel builds do not see the gfx1250 async builtins.

The inbox is set up on the IPC transport only; the route is traced as "ar2s"
under AITER_AR_ROUTE_TRACE like the other fused AR + RMSNorm routes.

TP4, hidden 6144 bf16, Gemma norm, 4x MI455X, eager, us per call, measured
with the first, unpipelined version of this kernel (same layout, flags and
arithmetic, so the same outputs):
  tokens   2752  4096  6144  8192  12288  24576
  before  108.1 147.9 258.2 299.7  368.1  537.4
  after    85.3 104.9 145.5 182.7  256.1  502.4

residual_out matches an fp32 reference bit for bit, out is within 1 bf16 ulp
for < 1e-5 of the values (4 ranks, eager and graph, 13 row counts including
non-multiples of 4 and a split launch). Gated on gfx1250, TP4 (the measured
world size), bf16, hidden a multiple of 256 up to 8192, 32-288 MiB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gate, op test

Review follow-ups for the pushed two-shot AR + RMSNorm:

- A flag poll that runs out of kMaxPolls now traps instead of reading an
  inbox the peer never filled: the call's output would be wrong on every
  rank and the next call's inbox reuse would no longer hold.
- AITER_CUSTOM_AR_AR2S_RMS_MAX_SIZE overrides the per-launch cap (default
  160 MiB at TP4, rounded down to whole MiB); 0 turns the route off and
  allocates no inbox.
- The route takes hidden 4096-7168 only. Measured at TP4 against main's
  route, 32-288 MiB: 4096, 6144 and 7168 are 1.06-1.60x faster; 2048 is
  even above 64 MiB and 0.92x at 288 MiB; 8192 is 0.94-1.13x, as its
  160 KiB of dynamic LDS a block leaves one block a CU.
- op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py (moved here from
  ROCm#8428): route window and hidden gate, values against an fp32 rank-order
  reference, ranks agree, CUDA-graph replay, with the default cap, 48 MiB
  and 0.
- Stale comments updated to the re-measured numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XiaobingSuper
XiaobingSuper force-pushed the xiaobingsuper/gfx1250-ar2s-seq-parallel branch from 7c7986e to f000c5e Compare December 3, 2026 14:14
Extend the pushed two-shot AR + RMSNorm (ar2s_rms_gfx1250) with ar2s_rms_ex
and three modes, exposed as sequence-parallel tensor_model_parallel_sp_* ops
for prefill:

- FP8: the norm output is written as MXFP8 (E4M3 + row-major E8M0 per 32),
  the bytes per_1x32_mx_quant_hip gives for the bf16 out (the group max is
  floored at kAmaxFloor as there, so an all-zero group gets scale 85).
- SP: each rank keeps the residual of its own row chunk only; the owner
  normalizes (and quantizes) its rows and pushes the result, so the
  all-gather moves MXFP8 and phase 3 is a copy. The normed output is whole
  on every rank and bit-identical to the replicated path.
- AUX (with SP): no norm, the whole all_reduce(x) + residual on every rank.

tensor_model_parallel_sp_fused_allreduce_rmsnorm{,_mxfp8_quant} and
tensor_model_parallel_sp_allreduce_add_residual take the SP path at the ar2s
sizes and are the replicated ops below it, so every call of a forward takes
the same branch (mutates_args=[]).

The TP4 per-launch cap is 192 MiB, one launch for a 14336-token chunk of
hidden 6144.

TP4, hidden 6144, Gemma norm, 4x MI455X: AR + RMSNorm + MXFP8 at 14336 rows
347 -> 226 us a call (SP + MXFP8 all-gather vs ar2s + separate quant);
sp_fp8 at 14336 / 32768 rows 189.0 / 401.2 us, bit-exact.

On top of ROCm#8427 at 0c78341 (the review round there), adapted as follows:

- The SP gate (ar2s_sp_eligible) takes the replicated route's measured
  hidden range (_AR2S_RMS_HIDDEN, 4096-7168) in whole 512-element groups,
  which the MXFP8 output needs.
- The replicated MXFP8 fallback calls main's
  fused_allreduce_rmsnorm_group_quant(..., "mxfp8") (ROCm#8310 renamed it).
- The 192 MiB cap keeps ROCm#8427's AITER_CUSTOM_AR_AR2S_RMS_MAX_SIZE
  override; the routing test's default is 192 MiB.
- ROCm#8427 now carries op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py (the
  replicated route); this PR's test and benchmark of the ex modes moves to
  test_ar2s_rms_ex_gfx1250.py, on main's public MXFP8 op
  (tensor_model_parallel_fused_allreduce_rmsnorm_quant with
  quant_type="per_1x32", quant_dtype=fp8), ruff-clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XiaobingSuper
XiaobingSuper force-pushed the xiaobingsuper/gfx1250-ar2s-seq-parallel branch from f000c5e to 93c6e8d Compare December 4, 2026 02:38
XiaobingSuper pushed a commit to XiaobingSuper/aiter that referenced this pull request Dec 4, 2026
No behavior change.
- op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py and
  test_ar2s_mxfp8_zero_group.py (from ROCm#8428's earlier head): no shebang on
  a non-executable file (EXE001), the timed lambdas bind their loop
  variables through functools.partial (B023), unused unpacked values are
  _-prefixed (RUF059), one combined `with` (SIM117), imports sorted with
  aiter first-party (I001).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper pushed a commit to XiaobingSuper/aiter that referenced this pull request Dec 4, 2026
No behavior change.
- op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py and
  test_ar2s_mxfp8_zero_group.py (from ROCm#8428's earlier head): no shebang on
  a non-executable file (EXE001), the timed lambdas bind their loop
  variables through functools.partial (B023), unused unpacked values are
  _-prefixed (RUF059), one combined `with` (SIM117), imports sorted with
  aiter first-party (I001).
- aiter/tuned_gemm.py: the unused row count of A is _m (RUF059).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper pushed a commit to XiaobingSuper/aiter that referenced this pull request Dec 4, 2026
No behavior change.
- op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py and
  test_ar2s_mxfp8_zero_group.py (from ROCm#8428's earlier head): no shebang on
  a non-executable file (EXE001), the timed lambdas bind their loop
  variables through functools.partial (B023), unused unpacked values are
  _-prefixed (RUF059), one combined `with` (SIM117), imports sorted with
  aiter first-party (I001).
- moe_deferred_tail.py: __all__ and __slots__ sorted (RUF022, RUF023; nothing
  reads the slots' order), and materialize's imports sorted (I001).
- communicator_cuda.py: the deferred-tail imports one aliased name a
  statement (I001), and the three `# noqa: E731` dropped (RUF100: E731 is
  not enabled).
- custom_all_reduce.py: the k5 tail entry's imports sorted (I001).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant