Skip to content

[Triton/Gluon] [HIP] [Perf] Fuse gfx1250 AR RMSNorm native MXFP8 - #8310

Merged
TennyWang1223 merged 8 commits into
ROCm:mainfrom
XiaobingSuper:perf/gfx1250-ar-rmsnorm-mxfp8
Dec 2, 2026
Merged

TennyWang1223 merged 8 commits into
ROCm:mainfrom
XiaobingSuper:perf/gfx1250-ar-rmsnorm-mxfp8

Conversation

@XiaobingSuper

@XiaobingSuper XiaobingSuper commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

tensor_model_parallel_fused_allreduce_rmsnorm_quant(quant_type=QuantType.per_1x32, quant_dtype=dtypes.fp8) (or quant_type="mxfp8"): all-reduce + residual add + (Gemma) RMSNorm with native group-32 MXFP8 output, E4M3 values and row-major E8M0 scales of shape (tokens, hidden // 32). The bytes are those of the AR + RMSNorm kernel the route runs followed by per_1x32_mx_quant_hip(quant_dtype=fp8, scale_type=fp8_e8m0).

API. quant_type names the quant block and the new keyword quant_dtype the element type, as aiter's quant ops take them: per_1x32 with fp8 is MXFP8, with fp4x2 MXFP4. quant_dtype=None keeps what each quant_type meant before (per_1x32 is MXFP4, the others FP8), so existing callers are unchanged; a format name gives both ("mxfp4", "mxfp8"); any other pair raises ValueError with the supported ones. The epilogues are defined in one module, aiter/dist/ar_rms_quant.py: the table of supported pairs and the route each takes (QUANTS), the names and defaults, the canonicalization, and the group-quant specs (GROUP_QUANTS: group size, element type, scale type). MXFP8 is the first group quant: one torch.compile op (fused_allreduce_rmsnorm_group_quant_, its fake shaped by the spec), one route (CudaCommunicator.fused_allreduce_rmsnorm_group_quant) and and the Lamport wrapper (lamport_fused_ar_rms_quant, which takes the spec as quant; without it, the per-token quant as before), all keyed by it. Another group size (e.g. FP8 1x128) is then entries in that module and the kernel epilogues that have it, not a new set of entry points.

On gfx1250 it is one launch wherever a one-shot fused kernel takes the call:

  • Lamport (HIP), first wherever it runs: lamport_ar_rmsnorm_gfx1250 ([HIP] fea: gfx1250 Lamport AR + RMSNorm: split sends, preloaded arguments, faster reductions #8559's kernel) gets an MXFP8 epilogue (as [Triton/Gluon] [HIP] gfx1250 all-reduce + RMSNorm + per-token FP8 in one kernel #8022 added per-token FP8), taken wherever should_lamport_ar_rms holds (TP2 / TP4, hidden a multiple of 256 up to 8192, up to the Lamport cap, 8 MiB at TP4). A group of 32 is pack k of four neighbouring lanes; the amax starts at kAmaxFloor and uses main's lamport_xor_lane, the scale is fp_f32_to_e8m0_scale<RoundUp> capped at 2^127 and v_cvt_scalef32_pk8_fp8_{bf16,f16} converts: the steps and helpers of per_1x32_mx_quant_hip. The epilogue is the kernel's LamportRmsQuant template parameter (kPerToken, kMxfp8; another one is an enumerator and its branch), and the C++ entry fused_allreduce_rmsnorm_quant_lamport reads it from the scale's layout (lamport_rms_quant_of: one FP32 a row, or one E8M0 a group of 32): no new pybind or compile_ops symbol.
  • Gluon (TP4 with the Gluon all-reduce), where Lamport cannot run: the Gluon AR + RMSNorm kernel gets a third output mode (QUANT=2), taken where _use_gluon_ar_norm holds (main's gate, unchanged), e.g. hidden 2880.
  • Elsewhere: fused_allreduce_rmsnorm and then the quant. QuantType.per_1x32 keeps meaning MXFP4; existing quant types and archs keep their routes.

Why

MXFP8 GEMM consumers (native-MXFP8 QKV and dense linears) paid a separate quant launch after every AR + RMSNorm. In one launch the route takes 0.21-0.90x the time of fused_allreduce_rmsnorm + per_1x32_mx_quant_hip (97 shapes, never slower).

Evidence

Setup: 4x MI455X (gfx1250), TP4, bf16 in, Gemma RMSNorm, the Gluon all-reduce on, on this head's code. Each arm is a CUDA graph of 10 calls on distinct inputs inside aiter's graph_capture; 21 ABAB rounds after 2 warm-up rounds, median, max over ranks; us per call. All arms of a hidden size run in one process; an A/A arm (a second graph of the route) gates each shape, which is re-measured when it differs by more than 5% (the tray is shared).

hidden rows main: AR + RMSNorm, then quant Lamport, then quant Lamport MXFP8 Gluon MXFP8
1024 1 7.15 6.87 5.61 6.35
1024 64 9.47 9.44 7.52 8.37
1024 256 14.96 12.35 9.60 13.38
1024 2048 24.29 23.13 20.52 28.26
1024 4096 (8 MiB) 40.00 38.71 36.14 -
2048 1 7.80 7.07 5.64 6.71
2048 64 10.98 9.01 7.86 8.36
2048 256 13.60 11.78 10.29 12.65
4096 1 11.41 7.50 5.87 7.14
4096 64 13.78 9.49 7.47 9.29
4096 256 18.27 14.41 11.43 16.70
6144 1 7.83 7.59 6.13 6.73
6144 16 9.63 9.08 7.96 8.82
6144 64 13.73 13.10 10.92 12.35
6144 128 16.58 15.22 13.00 14.71
6144 256 18.30 18.42 15.62 18.96
7168 1 8.71 8.42 6.47 8.20
7168 64 12.06 11.19 9.36 11.05
7168 256 18.64 18.76 15.91 23.36
8192 1 32.09 8.70 6.81 8.75
8192 64 42.74 12.89 11.37 13.44
8192 256 47.48 20.83 18.25 25.47
2880 1 8.10 - - 6.72
2880 16 9.80 - - 8.19
2880 64 10.51 - - 9.47

Measured: hidden 1024 / 2048 / 2560 / 3072 / 3584 / 4096 / 5120 / 6144 / 7168 / 8192 x rows 1 / 8 / 16 / 32 / 64 / 128 / 129 / 192 / 256, plus 1024 x 1024 / 2048 / 3072 / 4096 and 2048 x 1024 / 1536 / 2048 (up to the 8 MiB cap), and 2880 x 1 / 16 / 64; the table shows a subset. ("main" at 8192 takes the Gluon power-of-2 kernel, as main's bf16 route does with the Gluon all-reduce on; with it off, main's route is the next column, Lamport then the quant.)

  • Lamport MXFP8 vs Lamport then the quant: 0.75-0.94x (97 shapes).
  • Gluon MXFP8 vs Lamport MXFP8, where both run: 1.04-1.62x (93 shapes): the Lamport kernel is the faster at every shape, so the route takes it first. Gluon MXFP8 vs Gluon then the quant: 0.80-1.08x; at 2880 it takes 0.83-0.90x the time of main's route.
  • Up to the cap at power-of-2 hidden: at 1024 x 3072 / 4096 rows (6 / 8 MiB) Lamport MXFP8 takes 0.89-0.90x the time of main's route, so the route needs no size bound below the Lamport cap.

Bytes: Lamport MXFP8 vs Lamport + per_1x32_mx_quant_hip, and Gluon MXFP8 vs the Gluon per-token kernel (bf16 out) + per_1x32_mx_quant_hip: every byte of out, scale and residual of the last call of each graph above, 190 comparisons, 0 bytes differ. The MXFP8 instantiation keeps the squares of the RMSNorm sum unfused, as the bf16 / per-token instantiations compile them; left to the compiler it fused them into FMAs and fp16 rows differed in rare last bits.

Notes

  • Only the MXFP8 route changes. The bf16 and per-token FP8 routes and _use_gluon_ar_norm stay as on main: with the Gluon all-reduce on (AITER_GLUON_FUSED_AR=1, which ATOM sets by default through ATOM_ENABLE_GLUON_FUSED_AR), they keep main's choice between the Gluon kernels and the Lamport one-shot. A deployment that wants the Lamport one-shot on those routes wherever it runs turns the Gluon all-reduce off (in ATOM, ATOM_ENABLE_GLUON_FUSED_AR=0). The MXFP8 route takes Lamport first either way.
  • The route checks Lamport before Gluon, so at every shape both kernels can take the MXFP8 bytes are Lamport's; where fused_allreduce_rmsnorm takes another kernel than the MXFP8 route (the Gluon kernels at power-of-2 hidden on main), the MXFP8 bytes are not those of fused_allreduce_rmsnorm + quant there, as for the per-token route.
  • ISA (author's check at 78c98fc21, the parent of the routing commit; that commit changes Python only): the module builds for gfx942, gfx950 and gfx1250; main's 563 gfx1250 kernels keep byte-identical ISA and metadata, and the 40 new MXFP8 kernels use no scratch.

Tests

  • tests/test_ar_rmsnorm_routing.py (CPU), pytest tests/test_ar_rmsnorm_routing.py: 70 passed at 89a7e15ef.
    • test_mxfp8_route: Lamport at 6144 x 1 / 128 / 129 rows, 7168 x 1, 4096 x 513 and power-of-2 1024 x 2048 / 4096 rows (4 / 8 MiB); the split path past the Lamport cap (1024 x 4097, 6144 x 683); the Gluon MXFP8 kernel at a non-Lamport hidden (2880), the split path there without the Gluon all-reduce; the Lamport wrapper gets the MXFP8 spec, the split quant E4M3 / E8M0.
    • test_quant_type_and_dtype_pick_one_route: every spelling of each supported pair (string, QuantType, its int value, format name, with and without quant_dtype) takes the same route; a format name with another element type, an unsupported pair and an unknown name raise.
    • test_each_group_quant_route_is_its_pair, test_the_group_quant_fake_follows_its_spec: the pair table and the group-quant specs agree; the torch.compile fake has the spec's shapes and dtypes.
  • op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py (4 GPUs), the whole file: 3 passed at 537cb958a and again at 89a7e15ef (4x MI455X). In test_fused_allreduce_rmsnorm_dispatch, through the public API, the MXFP8 call takes the expected kernel (wrapped) and its bytes equal that kernel's AR + RMSNorm followed by per_1x32_mx_quant_hip: Lamport at 6144 x 1 / 128, 7168 x 64 (split sends), 6144 x 192 / 512 (four / eight packs a thread) and 1024 x 4096 (8 MiB); Gluon at 2880 x 1. Since 1cb5eb802 it calls the API as quant_type=QuantType.per_1x32, quant_dtype=dtypes.fp8 and wraps lamport_fused_ar_rms_quant.

PR Self-Review

Reviewed revision

89a7e15

Behavior and intent

The fused AR + RMSNorm entry points take the epilogue as (quant_type, quant_dtype); quant_dtype=None keeps every existing call's meaning. They gain MXFP8 (per_1x32 with FP8, or "mxfp8"), run on gfx1250 in one launch wherever a one-shot fused kernel takes the call, instead of AR + RMSNorm and a separate per_1x32_mx_quant_hip: the Lamport one-shot (HIP, new MXFP8 epilogue) first, wherever should_lamport_ar_rms holds, because measured it is the faster MXFP8 kernel at every shape where both run; else the Gluon AR + RMSNorm kernel (QUANT=2) where main's _use_gluon_ar_norm takes the call; else the split path. Other quant types, archs and the bf16 / per-token routes are unchanged.

Validation and unverified scope

At 537cb958a (4x MI455X, TP4, bf16, the Gluon all-reduce on):

  • the timing sweep and byte comparisons above (190 comparisons, 0 bytes differ);
  • python3 -m pytest op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py tests/test_ar_rmsnorm_routing.py: 46 passed (3 on 4 GPUs, 43 on CPU).

At 1cb5eb802 and 31ee61f71 (the API commits, Python only): tests/test_ar_rmsnorm_routing.py 67 passed (CPU); black and ruff clean on the changed files.

At 00ef84687 (C++ refactor: bool MX / bool mx become LamportRmsQuant): the module compiled for gfx1250 before and after with its JIT flags; all 603 kernels, the 120 lamport_ar_rmsnorm_gfx1250 instances among them, have identical instructions and kernel descriptors (607,376 instruction lines and 603 descriptors compared, names differing only in the epilogue's template argument); the host + device compile succeeds with the same warnings as before.

At 89a7e15ef (Python only: one Lamport quant wrapper): tests/test_ar_rmsnorm_routing.py 70 passed (CPU), with the wrapper's per-token and MXFP8 output layouts and its emit_bf16 refusal; black and ruff clean.

At 89a7e15ef on 4x MI455X (TP4, AITER_GLUON_FUSED_AR=1): pytest op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py tests/test_ar_rmsnorm_routing.py 73 passed (3 on 4 GPUs, the MXFP8 calls taking the expected kernel with the bytes of its AR + RMSNorm and per_1x32_mx_quant_hip; 70 on CPU). The timing sweep is from 537cb958a; the commits since change no kernel code (00ef84687 keeps every kernel's ISA).

Not run: TP2 and fp16 (the Lamport MXFP8 kernel is instantiated for both; the Gluon route is TP4 / bf16-only), TP6 / TP8, hidden sizes outside 1024-8192 other than 2880, gfx950 and older archs (route unchanged there).

PR-specific question

The Lamport MXFP8 kernel is selected only where should_lamport_ar_rms holds: gfx1250 (the Lamport inbox exists only there), bf16 / fp16 in, hidden a multiple of 256 up to 8192, contiguous operands, input within the Lamport cap; the C++ entry checks the E8M0 scale's element count (rows x hidden / 32), contiguity and device, and rejects a bf16 output pointer. The LamportRmsQuant template parameter defaults to kPerToken, so other instantiations cannot reach the MXFP8 epilogue; an enumerator without its kernel branch fails to compile (static_assert), and the dispatch switch warns on a missing case. The Gluon mode is selected only where Lamport cannot run and _use_gluon_ar_norm holds (TP4, bf16, contiguous, up to 4 MiB).

Changed op tests

op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py, test_fused_allreduce_rmsnorm_dispatch: about 50 lines. It checks that the MXFP8 call takes the Lamport kernel wherever Lamport runs (including a power-of-2 hidden at the 8 MiB cap) and the Gluon kernel where it cannot (2880), and that its bytes equal that kernel's AR + RMSNorm followed by per_1x32_mx_quant_hip. It fails before this PR (quant_type="mxfp8" raised, and no Lamport MXFP8 route existed). No other test covers MXFP8 out of the fused op. It calls the API as quant_type=QuantType.per_1x32, quant_dtype=dtypes.fp8.

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

lirui927 pushed a commit that referenced this pull request Nov 20, 2026
Port of #8310 (925d22b) onto the m3-mi455 perf stack. The stack
still has the single _all_reduce_kernel (NORM constexpr, y0..y5 planes), so
the NORM 3 branch and _mxfp8_quant_store are added to that kernel and the
host wrapper launches it with (n, programs) instead of main's split
_all_reduce_rmsnorm_kernel / norm_fits.

Co-authored-by: Cursor <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
@XiaobingSuper
XiaobingSuper force-pushed the perf/gfx1250-ar-rmsnorm-mxfp8 branch from a581921 to 7ab8944 Compare November 23, 2026 08:43
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…rm + MXFP8 quant

On gfx1250 with an aiter that has
tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant (ROCm/aiter#8310),
the decoder's input and post-attention all-reduce + Gemma RMSNorm hand the
native group-32 FP8 QKV and dense-MLP linears E4M3 values with row-major E8M0
scales, so the standalone quantize_fp8 launch before those GEMMs goes away.
The bytes equal the separate norm and quantize_fp8. Other linears, archs and
aiter builds keep the existing path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…rm + MXFP8 quant

On gfx1250 with an aiter that has
tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant (ROCm/aiter#8310),
the decoder's input and post-attention all-reduce + Gemma RMSNorm hand the
native group-32 FP8 QKV and dense-MLP linears E4M3 values with row-major E8M0
scales, so the standalone quantize_fp8 launch before those GEMMs goes away.
The bytes equal the separate norm and quantize_fp8. Other linears, archs and
aiter builds keep the existing path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 23, 2026
…rm + MXFP8 quant

On gfx1250 with an aiter that has
tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant (ROCm/aiter#8310),
the decoder's input and post-attention all-reduce + Gemma RMSNorm hand the
native group-32 FP8 QKV and dense-MLP linears E4M3 values with row-major E8M0
scales, so the standalone quantize_fp8 launch before those GEMMs goes away.
The bytes equal the separate norm and quantize_fp8. Other linears, archs and
aiter builds keep the existing path.

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

Copy link
Copy Markdown
Contributor Author

GPU check of 4a0f73e on 4x MI455X (gfx1250), TP4: this PR's tree (main bf59948 + the two commits), every module JIT-built from it, flydsl 0.5.3.

  • python3 -m pytest op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_mxfp8_quant.py: 1 passed (21 s). M = 0-256: payload, scale and residual bytes equal the split path, eager and through the public API, ranks agree, no poll timeout. The public path takes the Gluon kernel up to 128 rows and the Lamport one-shot + MXFP8 quant at 240 / 256 rows.
  • python3 -m pytest tests/test_ar_rmsnorm_mxfp8.py: 11 passed.

The previous head (7ab8944, same kernel code) gave the same bytes. It failed only the old dispatch expectation at M = 240 / 256 and the mock comparison of tensor[0] views, which this commit fixes.

@XiaobingSuper
XiaobingSuper marked this pull request as ready for review November 24, 2026 06:05
@XiaobingSuper
XiaobingSuper requested review from a team and a balanced review from Copilot November 24, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@aiter-bot

aiter-bot commented Nov 24, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 89a7e15ef6ea · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

The fused AR + RMSNorm entry points take the epilogue as (`quant_type`, `quant_dtype`); `quant_dtype=None` keeps every existing call's meaning. They gain MXFP8 (`per_1x32` with FP8, or `"mxfp8"`), run on gfx1250 in one launch wherever a one-shot fused kernel takes the call, instead of AR + RMSNorm and a separate `per_1x32_mx_quant_hip`: the Lamport one-shot (HIP, new MXFP8 epilogue) first, wherever `should_lamport_ar_rms` holds, because measured it is the faster MXFP8 kernel at every shape where both run; else the Gluon AR + RMSNorm kernel (`QUANT=2`) where main's `_use_gluon_ar_norm` takes the call; else the split path. Other quant types, archs and the bf16 / per-token routes are unchanged.

Validation and unverified scope

At `537cb958a` (4x MI455X, TP4, bf16, the Gluon all-reduce on):
- the timing sweep and byte comparisons above (190 comparisons, 0 bytes differ);
- `python3 -m pytest op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py tests/test_ar_rmsnorm_routing.py`: 46 passed (3 on 4 GPUs, 43 on CPU).

At `1cb5eb802` and `31ee61f71` (the API commits, Python only): `tests/test_ar_rmsnorm_routing.py` 67 passed (CPU); black and ruff clean on the changed files.

At `00ef84687` (C++ refactor: `bool MX` / `bool mx` become `LamportRmsQuant`): the module compiled for gfx1250 before and after with its JIT flags; all 603 kernels, the 120 `lamport_ar_rmsnorm_gfx1250` instances among them, have identical instructions and kernel descriptors (607,376 instruction lines and 603 descriptors compared, names differing only in the epilogue's template argument); the host + device compile succeeds with the same warnings as before.

At `89a7e15ef` (Python only: one Lamport quant wrapper): `tests/test_ar_rmsnorm_routing.py` 70 passed (CPU), with the wrapper's per-token and MXFP8 output layouts and its emit_bf16 refusal; black and ruff clean.

At `89a7e15ef` on 4x MI455X (TP4, `AITER_GLUON_FUSED_AR=1`): `pytest op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py tests/test_ar_rmsnorm_routing.py` 73 passed (3 on 4 GPUs, the MXFP8 calls taking the expected kernel with the bytes of its AR + RMSNorm and `per_1x32_mx_quant_hip`; 70 on CPU). The timing sweep is from `537cb958a`; the commits since change no kernel code (`00ef84687` keeps every kernel's ISA).

Not run: TP2 and fp16 (the Lamport MXFP8 kernel is instantiated for both; the Gluon route is TP4 / bf16-only), TP6 / TP8, hidden sizes outside 1024-8192 other than 2880, gfx950 and older archs (route unchanged there).

PR-specific question

The Lamport MXFP8 kernel is selected only where `should_lamport_ar_rms` holds: gfx1250 (the Lamport inbox exists only there), bf16 / fp16 in, hidden a multiple of 256 up to 8192, contiguous operands, input within the Lamport cap; the C++ entry checks the E8M0 scale's element count (rows x hidden / 32), contiguity and device, and rejects a bf16 output pointer. The `LamportRmsQuant` template parameter defaults to `kPerToken`, so other instantiations cannot reach the MXFP8 epilogue; an enumerator without its kernel branch fails to compile (`static_assert`), and the dispatch `switch` warns on a missing case. The Gluon mode is selected only where Lamport cannot run and `_use_gluon_ar_norm` holds (TP4, bf16, contiguous, up to 4 MiB).

Changed op tests

`op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py`, `test_fused_allreduce_rmsnorm_dispatch`: about 50 lines. It checks that the MXFP8 call takes the Lamport kernel wherever Lamport runs (including a power-of-2 hidden at the 8 MiB cap) and the Gluon kernel where it cannot (2880), and that its bytes equal that kernel's AR + RMSNorm followed by `per_1x32_mx_quant_hip`. It fails before this PR (`quant_type="mxfp8"` raised, and no Lamport MXFP8 route existed). No other test covers MXFP8 out of the fused op. It calls the API as `quant_type=QuantType.per_1x32, quant_dtype=dtypes.fp8`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • ADVISORY — Copilot could not review the current head (for example, quota or service failure)

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@XiaobingSuper
XiaobingSuper force-pushed the perf/gfx1250-ar-rmsnorm-mxfp8 branch from 4a0f73e to e3eaf80 Compare November 24, 2026 06:52
Copilot AI balanced review requested due to automatic review settings November 24, 2026 06:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@zufayu
zufayu requested review from a team and Dewei-Wang-sh November 25, 2026 01:11
Copilot AI balanced review requested due to automatic review settings November 26, 2026 03:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 05:14
@XiaobingSuper

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (6f8df0a08) as three commits: the Gluon MXFP8 route (08e47d75d), the Lamport MXFP8 epilogue (6cc188864), and the hidden-1024 bound (78c98fc21).

Main's #8559 rewrote lamport_ar_rmsnorm_gfx1250 into split-send and multi-pack layouts, so the MXFP8 epilogue was ported. It now loops over a thread's packs, where a group of 32 is pack k of four neighbouring lanes (tid[k] = row * row_packs + threadIdx.x + k * block, and both terms are multiples of 4). It reuses main's lamport_xor_lane for the amax. The MXFP8-only contract(off) block is gone, because main's kernel is uncontracted throughout.

Checked after the rebase:

  • The module builds for gfx942, gfx950 and gfx1250.
  • Main's 563 gfx1250 kernels keep their ISA and metadata byte for byte.
  • tests/test_ar_rmsnorm_routing.py passes (41).

Not rerun on the new kernel: the 4-GPU byte comparison and dispatch test (python3 -m pytest op_tests/multigpu_tests/triton_test/test_all_reduce_rmsnorm_quant.py -k dispatch), and the timings behind the Gluon-vs-Lamport rule and the 4 MiB bound. Those need a rerun before this merges; the description says so. The earlier CI failures were not from this PR: the 1-GPU shards lost their runner, and Triton shard 4 is the test_gemm_a16wfp4 flake that #8768 fixes.

…t runs

Re-measured on ROCm#8559's Lamport kernel (this branch's base), the Lamport
MXFP8 kernel is as fast as the Gluon MXFP8 kernel or faster at every shape
where both run: 4x MI455X, TP4, bf16, CUDA graphs, arms interleaved in one
process, hidden 1024-8192 (10 sizes) x 1-256 rows, the Gluon kernel never
more than 3% faster. The rule that gave Gluon up to 128 rows while no wave
of its program idles (norm_waves_busy) lost up to 21% (1.9 us) against the
faster of the two; Lamport first loses nothing.

The 4 MiB bound over the Gluon power-of-2 route at hidden up to 1024
(_GLUON_POW2_LAMPORT_MXFP8_MAX_BYTES) also goes: at 1024 x 3072 / 4096 rows
(6 / 8 MiB) the Lamport MXFP8 kernel takes 0.89-0.90x the time of
fused_allreduce_rmsnorm + per_1x32_mx_quant_hip (it was 1.03-1.04x on the
previous kernel).

fused_allreduce_rmsnorm_mxfp8_quant now takes Lamport wherever
should_lamport_ar_rms holds, else the Gluon MXFP8 kernel where
_use_gluon_ar_norm takes the call (now main's gate unchanged), else
fused_allreduce_rmsnorm and the quant. norm_waves_busy goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@XiaobingSuper

Copy link
Copy Markdown
Contributor Author

Pushed 537cb958a: the Lamport one-shot first wherever it runs. Re-measured on this head (#8559's kernel): the Lamport MXFP8 kernel is the faster of the two at every shape where both run (Gluon MXFP8 took 1.04-1.62x its time, 93 shapes), and up to the 8 MiB cap at power-of-2 hidden (1024 x 6 / 8 MiB: 0.89-0.90x of main's route), so the Gluon-up-to-128-rows rule (norm_waves_busy) and the 4 MiB bound go. The route takes 0.21-0.90x the time of fused_allreduce_rmsnorm + per_1x32_mx_quant_hip; bytes equal the kernel's AR + RMSNorm + quant (190 comparisons, 0 differ). The dispatch test and byte checks, previously run only on the pre-rebase head, now pass on this head (46 passed). The description is rewritten with the new numbers only.

XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Nov 30, 2026
…rm + MXFP8 quant

On gfx1250 with an aiter that has
tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant (ROCm/aiter#8310),
the decoder's input and post-attention all-reduce + Gemma RMSNorm hand the
native group-32 FP8 QKV and dense-MLP linears E4M3 values with row-major E8M0
scales, so the standalone quantize_fp8 launch before those GEMMs goes away.
The bytes equal the separate norm and quantize_fp8. Other linears, archs and
aiter builds keep the existing path.

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

quant_type names the quant block (per_Token / per_1x128 / per_1x32) and the new
quant_dtype the element type: per_1x32 with fp8 is MXFP8, with fp4x2 (the default, as
before) MXFP4. MXFP8 is the first group quant routed through
fused_allreduce_rmsnorm_group_quant, with its spec in aiter/dist/ar_rms_group_quant.py:
one torch.compile op, one route (Lamport, then Gluon, then the split path) and one
Lamport wrapper, all keyed by the group quant, so another group size (1x128) is a table
entry and the kernels that have its epilogue. The "mxfp8" name stays an alias;
tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant goes. Kernels and bytes
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 03:04
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Dec 1, 2026
… per_1x32, quant_dtype E4M3

ROCm/aiter#8310 now takes the epilogue as (quant_type, quant_dtype) and drops the
tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant helper. The MXFP8 call goes
through tensor_model_parallel_fused_allreduce_rmsnorm_quant(quant_type=per_1x32,
quant_dtype=float8_e4m3fn), and the gate asks whether that function takes quant_dtype.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The collective lacks effect registration, so compilation can remove an unused call on one rank and leave peer ranks waiting indefinitely.

1 open issue

Review effort: Balanced

…r_rms_quant.py

The (quant_type, quant_dtype) pair table, the name aliases, the default element types,
the canonicalization and the group-quant specs move into one module, so an epilogue is
defined in one place: communication_op keeps the public API and imports it; the
torch.compile op, the route and the Lamport wrapper read the specs from it.
ar_rms_group_quant.py goes. No behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 03:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Quantization emits 0xFF instead of HIP’s 0xFE scale cap for infinite normalized values, and padded inputs produce fake output and scale shapes that disagree with real execution.

1 open issue

Review effort: Balanced

…ilogue enum, not bool mx

The FP8 epilogue of lamport_ar_rmsnorm_gfx1250 was a bool template parameter (MX:
per-token or MXFP8) and a bool argument of the entry: a third epilogue (FP8 1x128)
would take another flag and conditions like QUANT && !MX && !G128. LamportRmsQuant
names the epilogue instead (kPerToken, kMxfp8): one template parameter, a switch in
the dispatch (-Wswitch flags a missing case), a static_assert in the kernel for an
enumerator without its branch, and lamport_rms_quant_of reads it from the scale's
layout in one place. Same kernels: every instantiation's ISA and kernel descriptor
are identical to before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 05:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…nd group quants

lamport_fused_ar_rms_group_quant folds into lamport_fused_ar_rms_quant: quant=None is the
per-token FP8 quant as before (same call, same outputs, emit_bf16), a group quant spec
lays out its outputs from the spec. Both call the same C++ entry, which picks the
epilogue by the scale's layout (LamportRmsQuant); emit_bf16 stays per-token only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 05:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@TennyWang1223
TennyWang1223 merged commit 9a92230 into ROCm:main Dec 2, 2026
91 of 94 checks passed
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Dec 2, 2026
…s quant_dtype

ATOM runs on aiter main, whose fused AR + RMSNorm takes `quant_dtype` since
ROCm/aiter#8310. The helper passes it for every quant, and the MXFP8 gate no
longer asks whether aiter has it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/ATOM that referenced this pull request Dec 2, 2026
…rm + MXFP8 quant

On gfx1250, MiniMax-M3's decoder hands its native group-32 E4M3FN QKV and
dense-MLP linears E4M3 values and row-major E8M0 scales straight from aiter's
fused all-reduce + Gemma RMSNorm + quant (ROCm/aiter#8310), so the standalone
quantize_fp8 launch before those GEMMs goes away.

- fused_allreduce_gemma_rms_norm_quant takes (quant_type, quant_dtype) as
  aiter's op does: "per_token" FP8 by default, or "per_1x32" with
  float8_e4m3fn for MXFP8; any other pair raises. It passes quant_dtype to
  aiter on every call. At TP 1 it runs the norm and then the same quant
  (quantize_fp8 for MXFP8).
- fused_allreduce_gemma_rms_norm_mxfp8_supported(linear) gates MXFP8: gfx1250,
  and a linear that reads native E4M3FN with group-32 E8M0 scales and does not
  run in BF16. Each decoder layer decides it once at construction, and
  _fused_ar_rms_quant picks the quant of each fused norm.
- tests/test_minimax_m3_mxfp8_fused_ar.py loads atom.model_ops.layernorm
  through aiter_stub.atom_without_aiter, so it runs in the CPU job: the gate
  (1x32 and 32x32 weight scales), the helper's per-token and MXFP8 calls and
  their scale shapes, TP 1 MXFP8 (the norm, then quantize_fp8), and the pairs
  it refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/aiter that referenced this pull request Dec 3, 2026
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 added a commit to XiaobingSuper/ATOM that referenced this pull request Dec 4, 2026
…rm + MXFP8 quant

On gfx1250, MiniMax-M3's decoder hands its native group-32 E4M3FN QKV and
dense-MLP linears E4M3 values and row-major E8M0 scales straight from aiter's
fused all-reduce + Gemma RMSNorm + quant (ROCm/aiter#8310), so the standalone
quantize_fp8 launch before those GEMMs goes away.

- fused_allreduce_gemma_rms_norm_quant takes (quant_type, quant_dtype) as
  aiter's op does: "per_token" FP8 by default, or "per_1x32" with
  float8_e4m3fn for MXFP8; any other pair raises. It passes quant_dtype to
  aiter on every call. At TP 1 it runs the norm and then the same quant
  (quantize_fp8 for MXFP8).
- fused_allreduce_gemma_rms_norm_mxfp8_supported(linear) gates MXFP8: gfx1250,
  and a linear that reads native E4M3FN with group-32 E8M0 scales and does not
  run in BF16. Each decoder layer decides it once at construction, and
  _fused_ar_rms_quant picks the quant of each fused norm.
- tests/test_minimax_m3_mxfp8_fused_ar.py loads atom.model_ops.layernorm
  through aiter_stub.atom_without_aiter, so it runs in the CPU job: the gate
  (1x32 and 32x32 weight scales), the helper's per-token and MXFP8 calls and
  their scale shapes, TP 1 MXFP8 (the norm, then quantize_fp8), and the pairs
  it refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/aiter that referenced this pull request Dec 4, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants