Skip to content

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

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

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

Conversation

@XiaobingSuper

@XiaobingSuper XiaobingSuper commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What

This PR extends the gfx1250 pushed two-shot AR + RMSNorm (ar2s_rms_gfx1250, #8427) with an ar2s_rms_ex entry point that has three modes. It also exposes them as sequence-parallel all-reduce ops for prefill.

  • FP8. The kernel's epilogue writes the norm output as MXFP8: E4M3 values plus a row-major E8M0 scale per 32 values. These are the bytes per_1x32_mx_quant_hip(fp8, e8m0) gives for the bf16 output. The bf16 output itself is not written.
  • SP (sequence-parallel residual). Each rank keeps the residual stream only for the rows it owns: chunk rank of each launch, given by CustomAllreduce.ar2s_sp_own_rows. The owner normalizes (and quantizes) its rows and pushes the result instead of the bf16 sum. The all-gather therefore moves MXFP8 instead of bf16, and phase 3 becomes a copy. The normed output is whole on every rank and bit-identical to the replicated path's.
  • AUX (with SP, bf16). No norm. Every rank gets the whole all_reduce(x) + residual, computed from a sequence-parallel residual. This is how the taps of a speculative drafter gather the residual stream.

New public ops in aiter.dist.communication_op:

  • tensor_model_parallel_sp_fused_allreduce_rmsnorm
  • tensor_model_parallel_sp_fused_allreduce_rmsnorm_mxfp8_quant
  • tensor_model_parallel_sp_allreduce_add_residual

They are registered through torch_compile_guard with mutates_args=[]. At ar2s sizes (32 MiB and up) they take the SP path. Below that they call the replicated ops, so every call in one forward takes the same branch. A residual returned at prefill size is only valid on the rows this rank owns, so it must only be passed back into these ops.

Other knobs:

  • AITER_AR2S_MXFP8=1 lets the replicated fused_allreduce_rmsnorm_mxfp8_quant use the FP8 mode as well. It is off by default: at 14336 rows it measured level with ar2s + a separate quant (318.7 vs 317.7 us).
  • ar2s_rms_ex takes an optional grid cap. The default, 0, leaves the grid unchanged.

Why

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

Performance

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

That measurement used AITER_AR2S_RMS_MAX_SIZE=201326592, so a 14K-token all-reduce is one launch.

Correctness

op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py (4 GPUs) compares every mode bit for bit against ar2s + per_1x32_mx_quant_hip. It runs at 4, 100, 2752, 6144, 14336, 16384, 24576 and 32768 rows.

  • fp8: q, scale and residual_out.
  • sp: out on all rows, residual_out on owned rows. Residual rows a rank does not own are poisoned with NaN, to show they are never read.
  • sp_fp8, aux: both checked the same way.
  • Public ops: the SP path at prefill sizes, and equality with the replicated ops below 32 MiB.
  • Rank consistency: every rank holds the same output.

All checks pass on the validation stack. In the model, our serving gate passes with real speculative acceptance, and greedy outputs are identical on 16K-token prompts.

All-zero groups (fixed). The first version wrote E8M0 scale byte 0 for an all-zero 32-element group, where per_1x32_mx_quant_hip writes 85 (2^-42, from its 1e-10 floor on the group max); the E4M3 values were already identical. Commit 43918cb (the top commit) seeds the group max at aiter::kAmaxFloor, as the HIP quantizer does. The replicated and SP FP8 outputs now equal per_1x32_mx_quant_hip byte for byte, including scale 85 on all-zero rows. op_tests/multigpu_tests/test_ar2s_mxfp8_zero_group.py checks this and passes on 4x MI455X.

End-to-end (combined stack, not this PR alone)

MiniMax-M3.1 on 4x MI455X, TP4: agentic multi-turn trace replay (AgentX) at concurrency 64, 900 s per run, same node, same afternoon.

The stack is our 1120 integration image plus all the changes in this series, with every flag on. That covers ROCm/aiter PRs 8273, 8310 and 8427-8432 and ROCm/ATOM PRs 3680-3683. It also includes pieces not yet in a PR: the ATOM wiring for the fused QKV chain, the fast o_proj and the FlyDSL indexer CP scorer, and the paged-attention split-KV fused reduce. Speculative acceptance length was forced to 4.04 for this A/B; the same configuration passed our serving gate with real acceptance.

tok/s/GPU P90 interactivity (tok/s/user) median interactivity ITL p50 / p90 TTFT p50 / p90
baseline 99,473 164.6 249.7 4.0 / 6.1 ms 0.52 / 1.16 s
combined stack 103,140 192.8 289.5 3.5 / 5.2 ms 0.46 / 1.05 s

Baseline P90 interactivity varied from 164.6 to 181.8 across three baseline runs that day (mean 173.4; mean median 253.7). Our best estimate is therefore about +11% P90 and +14% median interactivity against the mean baseline. That is for the whole stack; this PR's own share is not separated out.

Dependencies

Depends on #8310 (fused native MXFP8 AR RMSNorm, with its two follow-up commits: the one-shot cap and mutates_args=[]) and #8427 (the base ar2s kernel); please review only the top 2 commits (the SP modes and the all-zero-group scale fix).

The four commits below the top two are those PRs, unmodified, rebased onto main. The SP MXFP8 op falls back to #8310's fused_allreduce_rmsnorm_mxfp8_quant below the ar2s range. Once both land, this rebases to the top two commits.

Limitations

  • The SP ops are meant for a model that keeps the whole forward on them, with no PP stage boundary and no TBO-style micro-batch interleaving inside the forward. ATOM's opt-in flag checks for that.
  • Only TP4 at hidden 6144 has been measured. The kernel requires hidden % 512 == 0 and hidden <= 8192 for the SP modes.
  • The SP ops need the ar2s context, which [HIP] [Perf] gfx1250 custom AR: pushed two-shot AR + RMSNorm for 32-288 MiB #8427 sets up by default at TP4 only; other TP sizes opt in with AITER_AR2S_RMS_MAX_SIZE. Without it the ops are the replicated ones.

Validation status: validated on the 1120 integration stack (aiter 576d3f0 / ATOM 6c20f00); not yet re-validated on main after rebase. The rebase needed no code changes.

🤖 Generated with Claude Code

XiaobingSuper and others added 5 commits November 21, 2026 14:15
Co-authored-by: Cursor <cursoragent@cursor.com>
…t one-shot takes over

fused_allreduce_rmsnorm_mxfp8_quant sent every input up to the plain Gluon
all-reduce's 4 MiB to the Gluon AR + RMSNorm + MXFP8 one-shot. Where the
Lamport one-shot AR + RMSNorm can take the call, that one-shot only wins up
to _GLUON_AR_NORM_MAX_TOKENS (128) rows: above, the Lamport fused AR +
RMSNorm followed by the separate MXFP8 quant is faster. Use the same
eligibility rule as the bf16 / per-token paths (lamport=...).

Hidden 6144 bf16, TP4, Gemma norm, CUDA graphs (10 calls a graph), 4x
MI455X, us per call:
  rows    128   192   256   320   384   512
  before 14.6  25.8  26.1  28.5  26.7  29.1
  after  14.7  18.3  19.5  25.9  26.3  29.3
Unchanged where the Lamport one-shot does not apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fused_allreduce_rmsnorm_mxfp8_quant_ was registered with the default
mutates_args="unknown", so torch.compile wrapped it in auto_functionalized_v2.
Inductor does not decompose one that returns E8M0, and a MiniMax-M3.1 server
with ATOM_MINIMAX_M3_GLUON_AR_MXFP8=1 failed its warmup compile with
"auto_functionalized_v2 was not removed". The op returns new tensors only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…8 MiB

fused_allreduce_rmsnorm on gfx1250 used to fall back to RCCL + a separate
add + RMSNorm above the Lamport kernels' range. Add a pushed two-shot
all-reduce + residual add + (Gemma) RMSNorm kernel (ar_2shot_rms_gfx1250) and
route bf16 inputs of 32-288 MiB to it:

- phase 1 pushes each row chunk to its owner's RS inbox (remote stores, the
  faster direction on MI455X), 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 from the AG inbox;
- block b only waits for block b of its peers (a flag per phase, sender and
  block, epoch counters), so no barrier is needed at either end, eager or in
  a CUDA graph;
- out / residual_out follow the Lamport fused kernel step by step.

TP4, hidden 6144 bf16, Gemma norm, 4x MI455X, eager, us per call:
  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).

On by default for TP4 only, the measured configuration; TP2 / TP6 / TP8
opt in by setting AITER_AR2S_RMS_MAX_SIZE (bytes a launch; TP4 default
160 MiB, 0 = off). AITER_AR2S_RMS_MIN_SIZE and AITER_AR2S_RMS_MAX_TOTAL
tune the range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l residual modes

Extend the pushed two-shot AR + RMSNorm (ar2s_rms_gfx1250) with
ar2s_rms_ex and three modes, and expose them 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(fp8, e8m0) gives for the bf16 out, from
  the kernel's epilogue; the bf16 out is not written.
- SP: each rank keeps the residual stream of its own row chunk only (reads
  res_inp and writes residual_out on those rows); the owner normalizes (and
  quantizes) its rows and pushes the result instead of the bf16 sum, so the
  all-gather moves MXFP8 rather than bf16 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, returns the whole all_reduce(x) + residual on every
  rank from a sequence-parallel residual (e.g. for taps of a drafter).

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 (>= 32 MiB) and are the replicated ops below it, so every call of a
forward takes the same branch. They are registered with mutates_args=[].
AITER_AR2S_MXFP8=1 also lets the replicated
fused_allreduce_rmsnorm_mxfp8_quant use the FP8 mode (off by default: level
with ar2s + a separate quant, 318.7 vs 317.7 us at 14336 rows). ar2s_rms_ex
takes an optional grid cap (0 = unchanged).

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).
op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py checks fp8 / sp / sp_fp8 /
aux and the public ops bit for bit against ar2s + per_1x32_mx_quant_hip at
4-32768 rows (non-owned residual rows poisoned with NaN), and that every
rank holds the same output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 and others added 2 commits November 21, 2026 23:49
…mx_quant_hip

mxfp8_quant8 started the group max at 0, so an all-zero 32-element group
got E8M0 scale byte 0, where per_1x32_mx_quant_hip writes 85 (2^-42, from
its 1e-10 floor on the group max). Seed the max at aiter::kAmaxFloor, as
the HIP quantizer does. The E4M3 values were already identical; now the
scale bytes are too, for the replicated and the sequence-parallel FP8
modes.

op_tests/multigpu_tests/test_ar2s_mxfp8_zero_group.py (TP4, hidden 6144)
puts an all-zero row next to random rows and checks the E4M3 and E8M0
bytes against per_1x32_mx_quant_hip of the bf16 output, including scale
85 on the zero row, with and without sp_residual. Passes on 4x MI455X.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… LDS prefetch

A second ar2s kernel with kernel 1's data layout, flags and arithmetic
(bit-identical outputs) and its serializations removed:
- row-local barriers are LDS-only (__syncthreads() drained every row's
  remote all-gather stores before the next row); the only store drains are
  the ones before a flag;
- straight-line loads instead of a per-chunk `if` around each;
- optional pipelining of the reduce-scatter and the all-gather in steps
  (AITER_AR2S_STEP; default one step, the measured best);
- bounded flag polls (AITER_AR2S_MAXIT); a poll that gives up is counted
  (ar2s_rms_errors) instead of hanging;
- <= 64 VGPRs so two 768-thread blocks fit a CU;
- PF (default on, AITER_AR2S_PF=0 turns it off): phase 2 reads its rows
  through a double-buffered LDS slot loaded asynchronously one row ahead
  (global_load_async_to_lds_b128).

Kernel 2 is the default up to TP4 (it spills at 6 / 8 ranks);
AITER_AR2S_KERNEL=1 / 2 overrides. ar2s_rms_set_kernel / ar2s_rms_errors are
for tests and profiling.

4x MI455X, TP4, 14336 / 32768 rows, PF on vs off: sp_fp8 213.1 -> 189.0 /
453.5 -> 401.2 us, sp 248.6 -> 224.1 / 538.7 -> 485.4 us, aux 229.3 -> 222.0
/ 506.1 -> 483.2 us, bit-exact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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.

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.

2 participants