Skip to content

[HIP] Fuse gfx1250 LL all-reduce RMSNorm FP8 epilogue - #7082

Open
xytpai wants to merge 1 commit into
mainfrom
xyt/ll-ar-rmsnorm-fp8
Open

xytpai wants to merge 1 commit into
mainfrom
xyt/ll-ar-rmsnorm-fp8

Conversation

@xytpai

@xytpai xytpai commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fuse the residual + RMSNorm + per-token FP8 epilogue after the gfx1250
low-latency custom all-reduce, replacing two local kernel launches with one.
The LL all-reduce itself is unchanged.

The existing fused quantizer normally quantizes FP32 normalized values.
The split path first rounds the norm to the input BF16/FP16 dtype.
Add an opt-in round_before_quant=False parameter to add_rmsnorm_quant
to preserve that intermediate rounding and the standalone quantizer's
zero-row scale policy. The default behavior remains unchanged.

A separate template instantiation isolates the new path from legacy
quantization kernels. The rounded instantiation keeps its conversion
runtime-selected to prevent -ffast-math from folding the narrow/widen
conversion and changing split-path rounding (including signed zero).

Dispatch is limited to the existing gfx1250 CA LL fallback:

  • Matching contiguous 2-D FP16/BF16 input/residual/weight.
  • 32-aligned hidden size within the existing HIP kernel's <=8192 limit.
  • CA enabled, QuickReduce disabled, no BF16/FP16 mirror requested.
  • Existing CA capability and size checks remain authoritative.
  • Unsupported alignment, mirror requests, strided inputs, old architectures,
    and large-message fused AR retain their existing paths.

No new environment variables, MiniMax-specific shape dispatch or ATOM changes.

Related: https://github.com/wuhuikx/LLM-Booster/issues/188

This is independent of #7080, which optimizes the large-message second-stage
FP8 amax reduction; this PR targets the LL/small-message fallback.

Validated candidate commit: 8f7115b697e984ef12ffcda4b69919ec7e62bed4.

Final-revision performance

4 x gfx1250, 256 CU/device, TP4; BF16 inputs, Gemma norm, hidden 6144.
Baseline: bbef5a6f2d3733b293c80d2cee6a8d464e88bc01.
Image: rocm/fw-bringup-mlperf:gfx1250-atom-20261023.
PyTorch 2.11.0+rocm10.1.0a20260811-bkc.20260820, reported HIP 7.16.26315.

Separate checkouts, containers and JIT caches; GPUs checked for unrelated
processes before runs. Three runs per side, interleaved base/opt, opt/base,
base/opt. Each graph contains 16 calls, with three traced replays per rank.
For each run, sum local epilogue kernel durations / 48 calls per rank,
then take the median across four ranks; table is the median of three runs.

Rows x hidden Base norm + quant (us) Fused epilogue (us) Speedup
1 x 6144 3.490 2.005 1.740x
12 x 6144 3.790 2.212 1.713x
64 x 6144 3.981 2.375 1.676x
128 x 6144 4.190 2.375 1.765x
341 x 6144 5.119 3.163 1.618x

Trace confirms two -> one epilogue kernels per call (96 -> 48 events
over 48 traced calls). LL communication remains the same kernel. For
6144-wide BF16 rows, M341 is below the 4 MiB threshold; M342 keeps the
existing large-message path. No-quant BF16 remains a control.

These numbers are epilogue-only kernel timings, not end-to-end collective
latency or model throughput. Whole-graph event measurements were noisy and
are not used to claim end-to-end speedup. No GSM8K/model accuracy result
or whole-model throughput improvement is claimed.

Correctness and regression tests

All evidence below was rerun on the final production revision:

  • 1280 stress combinations: 768 supported numerical cases plus
    512 explicit unsupported-width rejection cases, no failures.
    BF16/FP16, ordinary/Gemma norm, multiple seeds, random/zero/exact-cancellation/
    small inputs. Includes 32/64/96/128/160 columns to distinguish the
    standalone quantizer's floored/non-floored zero-row behavior.
  • Added single-GPU correctness/performance regression and invalid-argument
    regression: 2 pytest tests passed. Uses existing op-test file,
    @benchmark, run_perftest, checkAllclose, and markdown tables with
    latency, logical TFLOPS/TB/s and errors.
  • Added TP2/TP4 public-API regression: 2 pytest tests passed. Checks
    intermediate dtype semantics, exact residual/FP8/scales, exact cross-rank
    and eager/graph agreement, mirror fallback, alignment fallback and the
    4 MiB boundary. Replays captured graphs after changing inputs to zero.
  • CPU dispatch policy: 11 cases passed, including disabled CA,
    QuickReduce, old-arch capability, strided input/residual, FP32, empty,
    mirror, unaligned and large-message controls. This is policy coverage,
    not hardware validation on gfx950.
  • 144 legacy/default cases matched base bit-for-bit: FP16/BF16,
    ordinary/Gemma norm, norm/FP8/INT8 outputs and per-token/per-group modes.
  • 36 saved base/candidate output pairs from the three final TP4
    performance runs matched bit-for-bit, including residual and scales.
    Cross-rank agreement was independently checked in each run.
  • Black, Ruff and git diff --check passed.

The unchanged scale convention is intentional: standalone per-token
quantization uses a floor for widths 32/64/128 but zero for all-zero wider
rows. The new mode reproduces this; it does not silently change that API.

Reproduction

In the described gfx1250 environment:

HIP_VISIBLE_DEVICES=0 python3 -m pytest -q       op_tests/test_rmsnorm2dFusedAddQuant.py::test_round_before_quant       op_tests/test_rmsnorm2dFusedAddQuant.py::test_round_before_quant_rejects_unsupported

OMP_NUM_THREADS=1 NCCL_IB_DISABLE=1 RCCL_IB_DISABLE=1     python3 -m pytest -q       op_tests/multigpu_tests/test_fused_ar_rms.py::test_ll_quant_epilogue       op_tests/multigpu_tests/test_fused_ar_rms.py::test_ll_quant_dispatch_guards

Raw traces, repeated timing samples and additional stress/default-comparison
drivers remain outside the repository. No docs/benchmark artifacts are added.

@xytpai
xytpai requested a review from a team October 28, 2026 08:14
@github-actions github-actions Bot added the HIP label Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 7082 --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.

@XiaobingSuper

Copy link
Copy Markdown
Contributor

Needs owner ruling: should a one-launch LL all-reduce + RMSNorm + FP8 kernel build on this PR, or replace its epilogue? @xytpai

xiaobing/gfx1250-fused-ar-rms-one-launch adds ar_ll_rmsnorm_gfx1250: up to 4 MiB, the LL all-reduce, residual add, RMSNorm and per-token FP8 quant run in one kernel. This PR keeps the LL all-reduce as its own launch.

Evidence

4 x MI455X, TP4, hidden 6144, bf16, Gemma norm, FP8 per-token quant, graph replay, us a call (measured 10-30 against that day's main):

rows call split path one launch
12 after attention 10.10 9.42
12 after MoE 12.49 9.49
128 after attention 19.32 15.73
128 after MoE 21.51 15.90

Residual and FP8 outputs match the split path bit for bit; the bf16 output is within 1 ulp. A MiniMax-M3 layer's AR + norm + quant kernels go from 5 to 2. The branch also lets the two-stage fused path take messages up to 128 MiB instead of 64 MiB.

XiaobingSuper added a commit that referenced this pull request Nov 2, 2026
Squash of #7082 at 8f7115b, by @xytpai.

Conflict: op_tests/multigpu_tests/test_fused_ar_rms.py, where #7080 and #7082 each add a test helper at the same spot; both kept.
@TennyWang1223

Copy link
Copy Markdown
Contributor

Rebase needed: new elif takes over the Gluon fused AR+RMSNorm path on current main.
This PR is based on bbef5a6f. Since then, #6974 added the AITER_GLUON_FUSED_AR path inside fused_allreduce_rmsnorm(). On the merged tree, the new elif in fused_allreduce_rmsnorm_quant runs before the else that calls it, and it does not check gluon_ar. With AITER_GLUON_FUSED_AR=1, TP4, bf16, hidden 2048/4096 and messages ≤4 MiB, per-token calls switch from Gluon fused AR+RMSNorm + quant to Gluon plain AR + add_rmsnorm_quant. Nobody has measured this switch; the PR's perf numbers predate the Gluon path. MiniMax (hidden 6144) is not affected.
→ Add a self.gluon_ar is None guard, or benchmark both paths and justify the order.

lirui927 pushed a commit that referenced this pull request Nov 10, 2026
Squash of #7082 at 8f7115b, by @xytpai.

Conflict: op_tests/multigpu_tests/test_fused_ar_rms.py, where #7080 and #7082 each add a test helper at the same spot; both kept.
(cherry picked from commit 22961df)
lirui927 pushed a commit that referenced this pull request Nov 16, 2026
…launch

The all_reduce_rmsnorm epilogue of #7396, on main and without #7082. The
plain Gluon all-reduce (_all_reduce_kernel, set up on TP4 with
AITER_GLUON_FUSED_AR=1) gains an optional epilogue: residual add, RMSNorm
and optionally the per-token FP8 quant, so the call is one launch. Any
hidden that is a multiple of 8 up to 24576 works (norm_waves). At hidden
6144 the outputs are bit for bit those of the same all-reduce followed by
add_rmsnorm (and the per-token quant of its bf16 out); other sizes are
within 1 bf16 ulp or 1 FP8 code of an fp32 reference. Without the
epilogue the kernel is unchanged.

CudaCommunicator, TP4, bf16 in: all_reduce_rmsnorm takes calls up to the
4 MiB of the plain all-reduce, but only up to _GLUON_AR_NORM_MAX_TOKENS
(128) rows where the Lamport one-shot could take them, as Lamport is
faster past that. The #6923 Gluon AR + RMSNorm keeps its bf16 sizes
(power-of-2 hidden), and emit_bf16 stays on Lamport.
AITER_GLUON_AR_NORM=0 turns the new path off.

TP4 MI455X, HIP graph replay, slowest rank, hidden 6144, per call
(M1 / M16 / M64 / M128), against the Lamport kernels:
FP8 7.58 / 8.70 / 10.01 / 13.29 -> 5.74 / 6.68 / 8.09 / 11.42 us,
bf16 6.74 / 7.54 / 8.85 / 11.94 -> 5.54 / 6.24 / 7.72 / 11.10 us.
Part of wuhuikx/LLM-Booster#393.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e0fe5ee)

Conflict: aiter/dist/device_communicators/communicator_cuda.py, the same
qr_comm line as in the previous commit; kept.

@zufayu zufayu 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.

AITER SOP code review on current head 8f7115b:

Verified blocker: the new LL CA branch is evaluated before the existing Gluon fused RMSNorm fallback. With AITER_GLUON_FUSED_AR=1 on gfx1250 BF16 (for example hidden size 4096), the new branch can steal traffic from the fused Gluon route and replace it with plain all-reduce plus a separate epilogue, changing backend selection and risking a performance regression.

Primary reviewer: @TennyWang1223 (communication dispatch owner); @zufayu can co-review the norm/quant integration.

Author action: preserve the Gluon route priority, or explicitly exclude Gluon-enabled cases, and add a dispatch regression test with Gluon enabled. Required CI is green, but Multi-GPU Tests were skipped, so fresh gfx1250 TP2/TP4 coverage is still required.

@TennyWang1223 TennyWang1223 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.

Requesting changes. The PR head hasn't changed since the last review, and it now conflicts with main.

  1. Please rebase onto current main and resolve the conflict in op_tests/multigpu_tests/test_fused_ar_rms.py.

  2. Main now has #8022, which runs all-reduce + RMSNorm + per-token FP8 in one Lamport kernel on gfx1250 (TP2 up to 16 MiB, TP4 up to 8 MiB, hidden a multiple of 256 up to 8192). In the merged tree, the new elif comes after that path and after _use_gluon_ar_norm. So it only gets hidden sizes that are a multiple of 32 but not of 256, hidden > 8192, and TP6/TP8. Please list which shapes and TP sizes this PR still covers, and post gfx1250 perf numbers for them against current main. If what's left isn't worth it, please close this
    PR.

  3. Add a self.gluon_ar is None guard to the new branch. If you think the current order is right, benchmark both paths with AITER_GLUON_FUSED_AR=1 and post the numbers.

  4. Update both tests for the new dispatch order:

    • test_ll_quant_dispatch_guards: the mocks have no should_lamport_ar_rms or gluon_ar_plain, so it will raise AttributeError on main.
    • _ll_quant_worker: it expects add_rmsnorm_quant for (12, 6144) and (341, 6144), but Lamport takes those shapes on main.

    Also add a dispatch test with Gluon enabled, and add the ci:multi-gpu label so TP2/TP4 runs on gfx1250. That job was skipped on this PR

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants