Skip to content

[HIP] [Perf] gfx1250 TP4 one-shot decode AR + RMSNorm (+ MXFP8) for 1-256 rows - #8456

Draft
XiaobingSuper wants to merge 6 commits into
ROCm:mainfrom
XiaobingSuper:xiaobingsuper/gfx1250-k5-decode-ar-rmsnorm
Draft

XiaobingSuper wants to merge 6 commits into
ROCm:mainfrom
XiaobingSuper:xiaobingsuper/gfx1250-k5-decode-ar-rmsnorm

Conversation

@XiaobingSuper

@XiaobingSuper XiaobingSuper commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

A one-shot all-reduce + residual add + RMSNorm kernel for gfx1250 TP4 decode sizes (csrc/kernels/ar_k5_gfx1250.cu, CustomAllreduce.k5_fused_ar_rms) with an MXFP8 epilogue (E4M3 + row-major E8M0 per 32), hidden 6144, up to 256 rows. It takes the calls of tensor_model_parallel_fused_allreduce_rmsnorm{,_mxfp8_quant} that the Gluon one-shot (<= 128 rows) or the Lamport fused kernel (above) would take, with their bits: lamport_order picks the summation order of the path it replaces, and for MXFP8 above 128 rows its Lamport-order epilogue replaces the Lamport kernel + per_1x32_mx_quant_hip pair in one launch (group max floored at kAmaxFloor as the quant does).

  • Its inbox (3 x 4 x rows x hidden, 37.7 MB a rank at 256 rows) and counters follow the Lamport AR + RMSNorm inbox in the same IPC allocation: no IPC buffer of its own.
  • Flag polls are bounded; a timeout is counted (k5_ar_errors) instead of hanging.

Why

MiniMax-M3.1 decode runs two AR + RMSNorm (+ MXFP8) calls per layer at 1-256 rows; above 128 rows the production path changes kernel and its cost steps up.

Evidence

4x MI455X, TP4, hidden 6144, CUDA graph of 10 calls, max over ranks of the median, us per call (production -> k5):

rows 16 64 80 128 192 256
bf16 6.16 -> 6.10 7.72 -> 7.04 8.29 -> 7.46 9.83 -> 8.64 15.75 -> 11.61 16.58 -> 12.99
MXFP8 6.84 -> 6.52 8.32 -> 7.54 8.94 -> 8.16 11.28 -> 9.07 18.14 -> 12.09 19.22 -> 13.41

bf16 bit-identical at every row count 1-256; MXFP8 payloads bit-identical. In the model (MiniMax-M3.1 TP4) the serving gate passes, GSM8K (1319, 5-shot) 0.9545 (k5) and 0.9553 (k5 + fused MXFP8).

Gated on

gfx1250, TP4 (the inbox is set up for world size 4 only), bf16 [rows, 6144], 0 < rows <= 256, and only where the Gluon one-shot or the Lamport fused kernel would have taken the call. No environment variable (the former AITER_K5_AR, _MAX_ROWS, _MAXIT and _FUSED_MXFP8 are now the default / constants).

Needs GPU check before ready, especially the fused MXFP8 epilogue above 128 rows: the kAmaxFloor scale-floor change has not been re-run on GPU (test_ar_k5_gfx1250.py --check --diag: scale bytes vs Lamport + per_1x32_mx_quant_hip, including all-zero groups).

PR Self-Review

Reviewed revision

b44a706

Behavior and intent

At gfx1250 TP4 hidden 6144, decode-size fused AR + RMSNorm (+ MXFP8) calls take the k5 kernel by default with the bits of the path they replace.

Validation and unverified scope

Measured on an earlier aiter base (576d3f0), the fused MXFP8 epilogue before the scale floor. This revision: hipcc --offload-arch=gfx1250 -fsyntax-only on both kernel files, ruff 0.16.0 clean. Not run on GPU.

PR-specific question

Stacked on #8428 (which carries #8427 and #8310); please review only the top commit.

Changed op tests

op_tests/multigpu_tests/test_ar_k5_gfx1250.py (new): out / residual_out / scale against the production path (k5 off) on every rank, eager and CUDA graph, --diag for the fused-MXFP8 scale bytes, plus timing.

🤖 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 8456 --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.

tensor_model_parallel_fused_allreduce_rmsnorm_quant(quant_type="mxfp8")
(and tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant) returns E4M3
values with row-major group-32 E8M0 scales. On gfx1250 up to 128 rows where
the Lamport one-shot applies it runs the Gluon AR + RMSNorm + MXFP8 one-shot;
otherwise the Lamport / existing fused AR + RMSNorm followed by
per_1x32_mx_quant_hip. The op is registered with mutates_args=[] (it writes
no argument; Inductor cannot remove an auto_functionalized_v2 that returns
E8M0).

Hidden 6144 bf16, TP4, Gemma norm, CUDA graphs, 4x MI455X, us per call
(cap at 128 rows vs. one-shot everywhere up to 4 MiB):
  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

Co-authored-by: Cursor <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XiaobingSuper
XiaobingSuper force-pushed the xiaobingsuper/gfx1250-k5-decode-ar-rmsnorm branch from aed372b to 127fa32 Compare November 23, 2026 08:43
XiaobingSuper added a commit to XiaobingSuper/aiter that referenced this pull request Nov 23, 2026
ROCm#8456 (k5 decode AR)

# Conflicts:
#	aiter/ops/flydsl/grouped_moe_gfx1250.py
#	aiter/ops/flydsl/moe_kernels.py
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…irst, tail in the AR

With aiter's moe_defer_tail (ROCm/aiter#8457) and the k5 decode all-reduce
(ROCm/aiter#8456), MiniMax-M3's decode MoE (glue epilogue or shared fold, TP >
1, one PP stage, up to 256 rows, nothing but the next all-reduce reading the
layer's output) leaves its gather-reduce (+ routed scale + shared add) to the
all-reduce + RMSNorm that reads it. With the glue epilogue and the fused router
on the dual-stream path, the router launches before the shared MLP's kernels,
so the routed chain is not queued behind them. Same kernels and bytes; other
configurations keep the existing order and the separate gather-reduce.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…irst, tail in the AR

With aiter's moe_defer_tail (ROCm/aiter#8457) and the k5 decode all-reduce
(ROCm/aiter#8456), MiniMax-M3's decode MoE (glue epilogue or shared fold, TP >
1, one PP stage, up to 256 rows, nothing but the next all-reduce reading the
layer's output) leaves its gather-reduce (+ routed scale + shared add) to the
all-reduce + RMSNorm that reads it. With the glue epilogue and the fused router
on the dual-stream path, the router launches before the shared MLP's kernels,
so the routed chain is not queued behind them. Same kernels and bytes; other
configurations keep the existing order and the separate gather-reduce.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper and others added 3 commits November 23, 2026 09:49
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.

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]>
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.

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

A one-shot all-reduce + residual add + Gemma/RMS norm kernel for decode
sizes (hidden 6144, up to 256 rows) with an MXFP8 epilogue (E4M3 +
row-major E8M0 per 32). On gfx1250 TP4 it takes the calls the Gluon one-shot
(<= 128 rows) or the Lamport fused kernel (above) would take, with their
bits: lamport_order picks the summation order of the path it replaces, and
the MXFP8 epilogue floors the group max at kAmaxFloor as
per_1x32_mx_quant_hip does, so it replaces the Lamport kernel + quant pair
in one launch.

- Its inbox (3 x 4 x rows x hidden) and counters follow the Lamport AR +
  RMSNorm inbox in the same IPC allocation: no IPC buffer of its own.
- Flag polls are bounded; a timeout is counted (k5_ar_errors) instead of
  hanging.

4x MI455X, TP4, CUDA graph of 10 calls, us per call (production path ->
k5): bf16 80 rows 8.29 -> 7.46, 128 rows 9.83 -> 8.64, 192 rows 15.75 ->
11.61; MXFP8 80 rows 8.94 -> 8.16, 128 rows 11.28 -> 9.07, 192 rows 18.14 ->
12.09.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XiaobingSuper
XiaobingSuper force-pushed the xiaobingsuper/gfx1250-k5-decode-ar-rmsnorm branch from 127fa32 to b44a706 Compare November 23, 2026 09:50
XiaobingSuper added a commit to XiaobingSuper/aiter that referenced this pull request Nov 23, 2026
ROCm#8456 (k5 decode AR)

# Conflicts:
#	aiter/ops/flydsl/grouped_moe_gfx1250.py
#	aiter/ops/flydsl/moe_kernels.py
With a bf16 output the one-shot k5 is slower than the path it replaces above
128 rows (4x MI455X, graphs: 15.06 vs 14.18 us at 160, 18.05 vs 17.06 at
256); with the MXFP8 output it is faster at every size up to 256 rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 30, 2026
…irst, tail in the AR

With aiter's moe_defer_tail (ROCm/aiter#8457) and the one-shot decode
all-reduce (ROCm/aiter#8456), MiniMax-M3's decode MoE with the glue
epilogue (TP > 1, one PP stage, up to 256 rows, nothing but the next
all-reduce reading the layer's output) leaves its gather-reduce (+ routed
scale + shared add) to the all-reduce + RMSNorm that reads it. A forward
hook on the layer or a forward pre-hook on the next one (DSpark / Eagle3
taps) keeps the gather-reduce in the MoE.

With the glue epilogue and the fused router on the dual-stream path, the
shared MLP still forks at the MoE input but launches right after the
router (FusedMoE runs moe_after_router_hook there), so the routed chain
is not queued behind the shared MLP's kernels.

Same kernels and bytes; other configurations keep the existing order and
the separate gather-reduce.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>

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