Skip to content

[HIP] fea: gfx1250 Lamport AR + RMSNorm: split sends, preloaded arguments, faster reductions - #8559

Merged
zufayu merged 3 commits into
mainfrom
gfx1250_lamport_rms_opt
Nov 27, 2026
Merged

zufayu merged 3 commits into
mainfrom
gfx1250_lamport_rms_opt

Conversation

@TennyWang1223

@TennyWang1223 TennyWang1223 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Speed up lamport_ar_rmsnorm_gfx1250, the gfx1250 Lamport one-shot all-reduce + residual add + RMSNorm (bf16/fp16 out, and per-token FP8 out in the same kernel). It is the default route of fused_allreduce_rmsnorm(_quant) at TP2/TP4 up to the Lamport cap. The output keeps the same bits (those of ar_rmsnorm_gfx1250).

On 4x gfx1250, against main (median over 6 hidden sizes x 11 row counts): TP4 1.25x faster with bf16 out and 1.33x with FP8 out, TP2 1.30x and 1.39x. No measured shape is slower.

The fused AR + RMSNorm + per-token FP8 quant gains the most. Its cost over the bf16 out of the same shape drops by about 70%: at TP4 from a median 0.89 us (1.09x the bf16 time) to 0.25 us (1.03x). The default path is now also faster than the opt-in Gluon all_reduce_rmsnorm_per_token_quant (#8022) at every measured TP4 shape, bf16 and FP8 out (median 0.84x of its time). On main it was slower than the Gluon kernel at 40 of 57 shapes with bf16 out and 46 of 57 with FP8 out.

Only csrc/include/custom_all_reduce_gfx1250.cuh changes. The Python routing is unchanged, the Gluon paths included.

Motivation

On main, the kernel has one block a row, or one workgroup cluster a row while the rows leave CUs idle. Measured costs:

  • Small M, large hidden: one CU sends a whole row (2304 remote stores at hidden 6144) and then polls it. The cluster path spreads the row, but its partial sums go through memory behind a cluster barrier.
  • The row reduction: __syncthreads() also waits for the acks of the wave's remote stores, about one more fabric trip.
  • FP8 out (per-token quant): the row amax is a second cross-wave reduction after the RMSNorm (on the cluster path, through memory behind a second cluster barrier), and the epilogue reads scale_out and bf16_output as non-preloaded kernel arguments after the poll. At TP4 the FP8 out costs a median 0.89 us more than the bf16 out.
  • Kernel arguments: the module preloads the first 30 dwords of the arguments into SGPRs. On main the inbox pointers are an aggregate (LamportPeers), so the arguments after it are scalar loads; the epilogue (gemma_norm, scale_out, bf16_output) waits for them after the poll.

Changes

csrc/include/custom_all_reduce_gfx1250.cuh:

  • Split mode: sender blocks (256 packs each) send the packs and re-arm the inbox, ahead of the row blocks in the grid; a row block only polls and reduces. The row blocks have one pack a thread. Senders and row blocks count rounds apart, so the round counters are now [2][slot / 32] (tx, rx). The one-shot, two-shot and all-gather kernels write both, so all Lamport ops still interleave.
  • Row mode: a thread owns PACKS packs (1, 2, 4 or 8). After its sends, a row block waits for one non-preloaded kernel argument before it polls. Measured: the peers' data arrives sooner (TP4 6144x1 in row mode 10.4 -> 7.6 us). A s_sleep of any length does not give this gain, and the mechanism is not proven (the load seems to return after the sends left).
  • Row sum: an LDS-only block barrier (no wait for remote store acks). DPP / permlanex16 wave sums with bound_ctrl, folded into v_add_f32_dpp; the adds keep the order of block_allreduce_f32. One barrier: every wave adds the partials itself.
  • FP8 out (per-token quant): the amax is never negative nor NaN (it starts at 0 and fmaxf drops NaNs), so its bits order as unsigned integers. Each thread takes the max of its packs, then an integer DPP max over the wave (v_max_u32_dpp), then one ds_max_u32 a wave into an LDS word zeroed before the sum barrier. After the second barrier every thread reads that one word: no second wave reduction and no memory round trip. scale_out and bf16_output are preloaded arguments. The scale, rcp, clamp and cvt_pk_fp8 steps are those of ar_rmsnorm_gfx1250, so the FP8 out and its scale keep their bits.
  • Arguments: up to 4 GPUs, every argument the sends and the epilogue read is in the 30 preloaded dwords: p0..p3 (one pointer a peer), scale_out, bf16_output, eps, send_packs; gemma_norm is bit 8 of rank; p4..p7 come last. No gridDim / blockDim reads (they are hidden kernel arguments).
  • Memory ops: remote stores, polls and re-arms are buffer instructions with th:TH_*_BYPASS scope:SCOPE_SYS, as the Gluon all-reduce. Offsets are from the inbox slot, so they fit 32 bits at any cap.
  • Dispatch (LamportArRms::run): split for rows of more than 1024 values while TP4 has at most 64 rows (TP2: at most 32K packs, rows x hidden / 8). Row mode otherwise, with the fewest packs a thread that keep the block at most 256 threads (128 from 257 rows, 64 from 513). Over TP2/TP4, hidden 1024-8192, M 1-2048, bf16 and FP8 out, this choice is 0.1% (TP4) / 1.4% (TP2) slower on average than the best of six fixed configurations at each shape.
  • Removed: the cluster path (slower than split at every measured shape), cluster_partials and its allocation.

Performance (if applicable)

Setup: 4x gfx1250 (256 CU), ROCm 10.1, IPC transport, bf16 input. CustomAllreduce.lamport_fused_ar_rms(_quant) in a CUDA graph of 10 calls, median of 20 replays, slowest rank, median of 3 rounds. Before (main 3845cd6) and after (this PR) ran 3 times each, alternately; the tables give the median of the 3 runs (run-to-run spread of a shape: median 2%, at most 8%). Gluon: all_reduce_rmsnorm_per_token_quant (#8022, AITER_GLUON_FUSED_AR=1) in the same process, where it takes the shape.

Over 6 hidden sizes (2048-8192) x 11 row counts (1-1024):

TP Out Speedup vs main, median (range) This PR / Gluon, median (worst) Main slower than Gluon
4 bf16 1.25x (1.01-1.38x) 0.84 (0.98 at 6144x1) 40 of 57 shapes
4 FP8 1.33x (1.06-1.48x) 0.84 (0.99 at 6144x1) 46 of 57 shapes
2 bf16 1.30x (1.05-1.48x) - -
2 FP8 1.39x (1.08-1.58x) - -

FP8 out against bf16 out of the same shape (the cost of the fused per-token quant), median (range):

TP main this PR
4 +0.89 us, 1.09x (0.98-1.13x) +0.25 us, 1.03x (1.01-1.07x)
2 +0.94 us, 1.10x (1.03-1.15x) +0.21 us, 1.02x (0.99-1.07x)

Selected shapes (us):

Hardware Workload/configuration Before After Change Gluon
gfx1250 TP4 bf16, 2048 x 1 6.82 5.27 1.29x 6.19
gfx1250 TP4 bf16, 4096 x 1 7.64 5.52 1.38x 6.63
gfx1250 TP4 bf16, 6144 x 1 8.19 6.05 1.35x 6.15
gfx1250 TP4 bf16, 6144 x 64 10.41 8.38 1.24x 9.37
gfx1250 TP4 bf16, 7168 x 128 15.44 12.46 1.24x 17.62
gfx1250 TP4 bf16, 8192 x 1 8.45 6.21 1.36x 7.73
gfx1250 TP4 bf16, 8192 x 256 22.11 18.75 1.18x 25.67
gfx1250 TP4 FP8, 2048 x 1 7.41 5.46 1.36x 6.44
gfx1250 TP4 FP8, 4096 x 1 8.44 5.76 1.47x 6.92
gfx1250 TP4 FP8, 6144 x 1 9.13 6.35 1.44x 6.40
gfx1250 TP4 FP8, 6144 x 64 11.31 8.78 1.29x 9.58
gfx1250 TP4 FP8, 7168 x 128 16.56 12.72 1.30x 16.15
gfx1250 TP4 FP8, 8192 x 1 9.42 6.66 1.41x 8.28
gfx1250 TP4 FP8, 8192 x 256 22.72 18.88 1.20x 26.18
gfx1250 TP2 bf16, 6144 x 1 7.95 5.43 1.46x -
gfx1250 TP2 bf16, 8192 x 256 14.33 10.70 1.34x -
gfx1250 TP2 FP8, 7168 x 1 9.02 5.74 1.57x -
gfx1250 TP2 FP8, 4096 x 1024 18.74 15.65 1.20x -

Full results

Every measured shape, from the same runs. "-": the shape is above the Lamport cap (8 MiB at TP4), or Gluon does not take it.

TP4, bf16 out: main us → this PR us (speedup); median 1.25x, 1.01-1.38x over 62 shapes
hidden \ M 1 2 4 8 16 32 64 128 256 512 1024
2048 6.8→5.3 (1.29x) 6.9→5.5 (1.27x) 7.2→5.8 (1.24x) 7.5→5.9 (1.28x) 7.5→6.0 (1.25x) 7.8→6.2 (1.27x) 8.2→6.8 (1.21x) 9.4→8.2 (1.14x) 10.3→9.3 (1.11x) 15.3→12.3 (1.25x) 21.8→19.5 (1.12x)
4096 7.6→5.5 (1.38x) 7.8→5.8 (1.34x) 7.9→5.9 (1.34x) 8.0→6.2 (1.30x) 8.2→6.4 (1.28x) 8.5→6.9 (1.24x) 9.7→8.1 (1.20x) 10.6→9.0 (1.18x) 14.9→11.9 (1.26x) 21.4→18.0 (1.19x) 35.8→32.0 (1.12x)
5120 7.9→5.8 (1.36x) 7.9→5.9 (1.33x) 8.1→6.1 (1.32x) 8.3→6.4 (1.29x) 8.5→6.8 (1.25x) 9.1→7.5 (1.22x) 10.1→9.1 (1.11x) 12.9→10.7 (1.21x) 17.0→14.6 (1.17x) 25.0→23.5 (1.07x) -
6144 8.2→6.0 (1.35x) 8.1→6.1 (1.33x) 8.4→6.3 (1.34x) 8.6→6.4 (1.33x) 8.8→6.8 (1.29x) 9.3→7.6 (1.22x) 10.4→8.4 (1.24x) 14.8→11.9 (1.25x) 18.6→15.5 (1.20x) 28.4→26.3 (1.08x) -
7168 8.2→6.2 (1.33x) 8.3→6.2 (1.34x) 8.4→6.5 (1.30x) 8.6→6.7 (1.28x) 9.0→7.2 (1.26x) 10.1→8.0 (1.25x) 10.9→10.6 (1.03x) 15.4→12.5 (1.24x) 20.4→17.3 (1.17x) 31.9→29.0 (1.10x) -
8192 8.4→6.2 (1.36x) 8.3→6.4 (1.31x) 8.5→6.5 (1.30x) 8.7→6.8 (1.27x) 9.1→7.2 (1.25x) 10.0→8.3 (1.21x) 11.2→11.1 (1.01x) 16.6→13.1 (1.27x) 22.1→18.8 (1.18x) 37.2→31.6 (1.18x) -
TP4, per-token FP8 out: main us → this PR us (speedup); median 1.33x, 1.06-1.48x over 62 shapes
hidden \ M 1 2 4 8 16 32 64 128 256 512 1024
2048 7.4→5.5 (1.36x) 7.5→5.6 (1.34x) 7.8→6.0 (1.30x) 8.0→6.0 (1.33x) 8.1→6.2 (1.31x) 8.4→6.5 (1.29x) 8.7→7.0 (1.24x) 10.0→8.3 (1.20x) 10.8→9.4 (1.15x) 15.6→12.4 (1.26x) 22.6→19.7 (1.15x)
4096 8.4→5.8 (1.47x) 8.6→6.1 (1.42x) 8.8→6.1 (1.43x) 8.8→6.4 (1.37x) 8.9→6.6 (1.35x) 9.5→7.0 (1.35x) 10.7→8.1 (1.32x) 11.7→9.4 (1.24x) 15.4→12.3 (1.26x) 22.1→18.4 (1.20x) 35.6→32.3 (1.10x)
5120 8.9→6.0 (1.48x) 8.8→6.1 (1.45x) 9.1→6.4 (1.42x) 9.2→6.6 (1.39x) 9.5→7.0 (1.36x) 10.1→7.5 (1.34x) 11.2→9.3 (1.20x) 13.7→11.1 (1.23x) 17.5→14.8 (1.19x) 25.5→23.6 (1.08x) -
6144 9.1→6.3 (1.44x) 9.1→6.4 (1.43x) 9.2→6.6 (1.39x) 9.6→6.7 (1.43x) 9.7→7.0 (1.38x) 10.4→7.8 (1.33x) 11.3→8.8 (1.29x) 15.7→12.1 (1.30x) 19.1→15.8 (1.21x) 28.9→26.7 (1.08x) -
7168 9.3→6.5 (1.44x) 9.4→6.5 (1.44x) 9.5→6.7 (1.41x) 9.6→7.0 (1.37x) 10.0→7.4 (1.35x) 11.1→8.3 (1.35x) 11.9→10.9 (1.10x) 16.6→12.7 (1.30x) 21.0→17.6 (1.20x) 32.4→29.3 (1.11x) -
8192 9.4→6.7 (1.41x) 9.1→6.7 (1.36x) 9.4→7.0 (1.35x) 9.6→7.2 (1.32x) 10.1→7.6 (1.33x) 11.3→8.7 (1.31x) 12.1→11.5 (1.06x) 17.5→13.4 (1.31x) 22.7→18.9 (1.20x) 36.6→32.0 (1.14x) -
TP4, bf16 out: this PR us / Gluon us (ratio, below 1 is faster); median 0.84, worst 0.984; main was slower than Gluon at 40 of 57
hidden \ M 1 2 4 8 16 32 64 128 256 512 1024
2048 5.3 / 6.2 (0.85) 5.5 / 6.3 (0.86) 5.8 / 6.4 (0.90) 5.9 / 6.7 (0.88) 6.0 / 6.9 (0.88) 6.2 / 7.3 (0.85) 6.8 / 8.1 (0.84) 8.2 / 9.0 (0.92) 9.3 / 12.5 (0.74) 12.3 / 17.0 (0.72) 19.5 / 27.2 (0.72)
4096 5.5 / 6.6 (0.83) 5.8 / 6.8 (0.85) 5.9 / 7.0 (0.84) 6.2 / 7.3 (0.85) 6.4 / 7.5 (0.85) 6.9 / 8.2 (0.83) 8.1 / 9.2 (0.88) 9.0 / 12.1 (0.74) 11.9 / 16.6 (0.72) 18.0 / 24.7 (0.73) -
5120 5.8 / 6.7 (0.86) 5.9 / 7.0 (0.84) 6.1 / 7.2 (0.85) 6.4 / 7.5 (0.86) 6.8 / 7.8 (0.87) 7.5 / 8.8 (0.85) 9.1 / 9.6 (0.94) 10.7 / 13.2 (0.81) 14.6 / 18.6 (0.78) - -
6144 6.0 / 6.2 (0.98) 6.1 / 6.5 (0.94) 6.3 / 6.7 (0.94) 6.4 / 7.0 (0.93) 6.8 / 7.4 (0.92) 7.6 / 8.5 (0.90) 8.4 / 9.4 (0.89) 11.9 / 13.2 (0.90) 15.5 / 18.6 (0.83) - -
7168 6.2 / 7.3 (0.84) 6.2 / 7.7 (0.81) 6.5 / 7.9 (0.82) 6.7 / 8.1 (0.82) 7.2 / 8.8 (0.82) 8.0 / 9.8 (0.82) 10.6 / 11.2 (0.94) 12.5 / 17.6 (0.71) 17.3 / 23.8 (0.73) - -
8192 6.2 / 7.7 (0.80) 6.4 / 8.0 (0.80) 6.5 / 8.2 (0.80) 6.8 / 8.5 (0.80) 7.2 / 9.3 (0.78) 8.3 / 10.2 (0.82) 11.1 / 12.1 (0.91) 13.1 / 19.0 (0.69) 18.8 / 25.7 (0.73) - -
TP4, per-token FP8 out: this PR us / Gluon us (ratio, below 1 is faster); median 0.84, worst 0.992; main was slower than Gluon at 46 of 57
hidden \ M 1 2 4 8 16 32 64 128 256 512 1024
2048 5.5 / 6.4 (0.85) 5.6 / 6.6 (0.84) 6.0 / 6.7 (0.90) 6.0 / 7.0 (0.86) 6.2 / 7.1 (0.87) 6.5 / 7.5 (0.86) 7.0 / 8.3 (0.85) 8.3 / 9.2 (0.91) 9.4 / 13.0 (0.72) 12.4 / 17.5 (0.71) 19.7 / 28.8 (0.68)
4096 5.8 / 6.9 (0.83) 6.1 / 7.2 (0.84) 6.1 / 7.3 (0.83) 6.4 / 7.6 (0.85) 6.6 / 7.8 (0.85) 7.0 / 8.6 (0.82) 8.1 / 9.5 (0.86) 9.4 / 12.5 (0.76) 12.3 / 16.4 (0.75) 18.4 / 25.6 (0.72) -
5120 6.0 / 7.1 (0.85) 6.1 / 7.3 (0.84) 6.4 / 7.5 (0.85) 6.6 / 7.7 (0.87) 7.0 / 8.1 (0.86) 7.5 / 9.0 (0.84) 9.3 / 9.9 (0.94) 11.1 / 13.6 (0.82) 14.8 / 19.0 (0.78) - -
6144 6.3 / 6.4 (0.99) 6.4 / 6.6 (0.96) 6.6 / 6.9 (0.96) 6.7 / 7.1 (0.94) 7.0 / 7.6 (0.93) 7.8 / 8.8 (0.89) 8.8 / 9.6 (0.92) 12.1 / 13.4 (0.90) 15.8 / 18.9 (0.84) - -
7168 6.5 / 7.9 (0.82) 6.5 / 8.3 (0.79) 6.7 / 8.3 (0.81) 7.0 / 8.6 (0.82) 7.4 / 9.2 (0.81) 8.3 / 10.3 (0.80) 10.9 / 11.6 (0.94) 12.7 / 16.1 (0.79) 17.6 / 24.1 (0.73) - -
8192 6.7 / 8.3 (0.80) 6.7 / 8.5 (0.79) 7.0 / 8.7 (0.80) 7.2 / 9.1 (0.80) 7.6 / 9.8 (0.78) 8.7 / 10.7 (0.81) 11.5 / 12.7 (0.91) 13.4 / 17.6 (0.76) 18.9 / 26.2 (0.72) - -
TP2, bf16 out: main us → this PR us (speedup); median 1.30x, 1.05-1.48x over 66 shapes
hidden \ M 1 2 4 8 16 32 64 128 256 512 1024
2048 6.6→5.1 (1.30x) 6.6→5.2 (1.27x) 7.0→5.4 (1.29x) 7.0→5.6 (1.26x) 7.1→5.6 (1.26x) 7.4→5.9 (1.26x) 7.4→6.1 (1.20x) 7.8→6.3 (1.25x) 8.3→7.0 (1.18x) 10.2→8.0 (1.27x) 13.3→10.5 (1.26x)
4096 7.3→5.3 (1.38x) 7.5→5.4 (1.39x) 7.5→5.6 (1.35x) 7.6→5.8 (1.32x) 7.8→5.8 (1.33x) 7.9→5.9 (1.34x) 8.1→6.7 (1.22x) 8.6→6.6 (1.30x) 10.2→7.9 (1.30x) 13.3→10.4 (1.28x) 17.9→15.2 (1.18x)
5120 7.7→5.3 (1.44x) 7.6→5.5 (1.37x) 7.9→5.7 (1.37x) 8.0→6.0 (1.33x) 8.0→6.3 (1.27x) 8.3→6.6 (1.26x) 8.5→7.0 (1.21x) 9.9→7.8 (1.28x) 10.9→9.1 (1.19x) 15.2→12.8 (1.18x) 28.6→19.7 (1.45x)
6144 8.0→5.4 (1.46x) 8.1→5.5 (1.47x) 8.1→5.8 (1.41x) 8.1→5.8 (1.40x) 8.2→6.0 (1.38x) 8.3→6.4 (1.29x) 8.7→7.1 (1.24x) 10.7→8.2 (1.30x) 11.8→9.6 (1.22x) 16.2→13.4 (1.21x) 28.7→21.6 (1.33x)
7168 8.1→5.5 (1.48x) 8.1→5.7 (1.44x) 8.4→5.8 (1.44x) 8.4→6.0 (1.40x) 8.5→6.4 (1.34x) 8.8→6.7 (1.32x) 9.3→7.5 (1.26x) 11.1→8.4 (1.32x) 13.2→10.2 (1.29x) 17.0→16.2 (1.05x) 30.9→25.0 (1.23x)
8192 8.1→5.7 (1.43x) 8.0→5.8 (1.38x) 8.2→5.9 (1.39x) 8.2→6.0 (1.37x) 8.4→6.3 (1.33x) 8.8→6.6 (1.33x) 9.1→7.5 (1.21x) 11.2→8.7 (1.29x) 14.3→10.7 (1.34x) 18.4→15.4 (1.19x) 33.5→26.2 (1.28x)
TP2, per-token FP8 out: main us → this PR us (speedup); median 1.39x, 1.08-1.58x over 66 shapes
hidden \ M 1 2 4 8 16 32 64 128 256 512 1024
2048 7.2→5.1 (1.40x) 7.2→5.3 (1.37x) 7.6→5.5 (1.38x) 7.7→5.5 (1.38x) 7.7→5.7 (1.34x) 7.9→5.9 (1.35x) 8.1→6.2 (1.30x) 8.4→6.7 (1.25x) 9.0→7.1 (1.26x) 10.8→8.2 (1.32x) 13.8→10.7 (1.29x)
4096 8.2→5.3 (1.53x) 8.4→5.5 (1.52x) 8.5→5.7 (1.50x) 8.6→5.8 (1.48x) 8.7→5.9 (1.47x) 8.9→6.2 (1.44x) 9.1→6.6 (1.38x) 9.6→7.0 (1.36x) 10.8→8.2 (1.32x) 13.8→10.6 (1.30x) 18.7→15.7 (1.20x)
5120 8.6→5.5 (1.58x) 8.7→5.6 (1.55x) 8.9→5.8 (1.54x) 8.9→6.0 (1.48x) 9.0→6.3 (1.44x) 9.5→6.6 (1.43x) 9.6→7.3 (1.31x) 11.0→8.0 (1.37x) 11.4→9.2 (1.23x) 15.7→13.1 (1.20x) 30.0→19.9 (1.51x)
6144 8.8→5.8 (1.52x) 8.9→5.8 (1.54x) 9.1→5.9 (1.54x) 9.1→6.1 (1.50x) 9.2→6.2 (1.48x) 9.4→6.5 (1.45x) 9.7→7.4 (1.31x) 11.7→8.4 (1.39x) 12.3→9.9 (1.24x) 16.9→14.0 (1.21x) 30.0→22.3 (1.35x)
7168 9.0→5.7 (1.57x) 9.1→6.0 (1.53x) 9.3→6.0 (1.54x) 9.3→6.2 (1.51x) 9.5→6.5 (1.46x) 9.9→6.8 (1.44x) 10.1→7.7 (1.32x) 12.0→8.6 (1.40x) 13.7→10.3 (1.32x) 17.7→16.4 (1.08x) 32.2→25.1 (1.29x)
8192 9.1→6.0 (1.52x) 8.7→6.1 (1.42x) 9.2→6.2 (1.48x) 9.2→6.4 (1.42x) 9.4→6.6 (1.43x) 9.8→6.9 (1.42x) 10.2→7.8 (1.31x) 12.2→8.9 (1.36x) 14.7→10.9 (1.35x) 19.7→16.0 (1.23x) 35.6→26.7 (1.33x)

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Tested on 4x gfx1250 (see "Validation and unverified scope").

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

The change is internal to the kernel and its launcher; the comments in the code describe the modes.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. Same outputs and bits, same API, same routing. Device memory: the round counter allocation doubles (the rx counters, 4 bytes a group of 32 packs, 64 KiB at the TP4 cap) and the cluster_partials allocation (8 bytes a group) is gone; the inbox is unchanged.

PR Self-Review

Reviewed revision

5cded34

Behavior and intent

Only speed changes. The kernel keeps the arithmetic of ar_rmsnorm_gfx1250 step by step (rank-order fp32 sum rounded to T, fp32 residual add, the same square-sum order, the same per-token FP8 steps), so out, residual_out, the FP8 out and its scale keep their bits. The Python routing is unchanged: the default path takes this kernel where it did before, and AITER_GLUON_FUSED_AR=1 keeps its Gluon routes (their numerics differ from this kernel's).

Validation and unverified scope

4x gfx1250, ROCm 10.1, bf16 unless stated:

  • op_tests/multigpu_tests/test_fused_ar_rms_lamport.py, TP2/TP4, bf16 and fp16, bf16 and FP8 out: hidden 1024-8192 and M around every mode switch (64/65, 256/300, 512/600), and the default set: 0 bit differences against ar_rmsnorm_gfx1250; the mixed sequence (shapes, bf16/FP8, NaN, unaligned operands, graph) 0 bit differences. gemma_norm=True checked separately against custom_fused_ar_rms(_quant): 0.
  • Interleaving with the other Lamport ops (they now write the rx counters): gfx1250_poc/test_gfx1250_lamport_allreduce.py (route by size and by M, mixed sequence of one-shot, two-shot, AR + add, AR + RMSNorm, all-gather), test_ar_add_lamport.py, test_ag_lamport.py, gfx1250_poc/test_gfx1250_allgather.py, test_custom_ar_fused_interleave.py --tp 4: pass, 0 bit differences.
  • test_custom_allreduce.py --regression TP4 and TP2, test_custom_allreduce_rank_order.py, test_custom_allreduce_size_env.py, test_fused_ar_rms.py -t 4 and -t 2, tests/test_ar_rmsnorm_routing.py, triton_test/test_all_reduce_rmsnorm_quant.py (the Gluon paths with AITER_GLUON_FUSED_AR=1): pass.
  • Stress: 3 TP4 runs and 1 TP2 run of 13 row counts x 6 hidden sizes x bf16/FP8, 200 graph replays a shape, with the Gluon kernel in between: no hang, 0 bit differences.

What remains unverified: TP6/TP8 (this machine has 4 GPUs; the Lamport cap is 0 there by default, so these sizes do not take the kernel unless AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE sets a cap), fp16 performance (fp16 correctness is tested), and other gfx1250 SKUs.

PR-specific question

Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?

The changed path is lamport_ar_rmsnorm_gfx1250 and its launcher LamportArRms::run (plus the rx counter write at the end of the other Lamport kernels). The kernel is reached only through CustomAllreduce.lamport_fused_ar_rms(_quant), which the routing calls only when should_lamport_ar_rms holds. This PR does not change that gate:

  • Architecture: gfx1250 with the IPC transport. Only there does _init_lamport_ar_rms set up the inbox and the size cap; elsewhere _lamport_max_bytes stays 0 and the gate is false.
  • World size: a nonzero cap, by default TP2 16 MiB and TP4 8 MiB. TP6/TP8 have no default cap.
  • Dtype: input, residual and weight are all fp16 or all bf16. The FP8 out comes only from the per-token quant entry.
  • Shape: contiguous operands, hidden a multiple of 256 and at most 8192, and 0 < input bytes <= cap.

Inside, run() checks hidden and the cap again and throws if they fail, so no unsupported input launches the kernel. The mode (split or row) and the packs a thread depend only on rows, hidden and world size, so every rank launches the same grid. Both modes compute the same bits, checked bit for bit against ar_rmsnorm_gfx1250 on both sides of every mode switch.

Changed op tests

None.

🤖 Generated with Claude Code

…ents, faster reductions

Speed up lamport_ar_rmsnorm_gfx1250 (bf16/fp16 and per-token FP8 out).
Same bits as before, the bits of ar_rmsnorm_gfx1250.

Kernel:
- A row block now owns PACKS packs a thread (1, 2, 4 or 8), and a split
  mode sends the packs from sender blocks ahead of the row blocks (one
  pack a thread of a row block); the senders also re-arm. Senders and
  row blocks count rounds apart: the round counters are now [2][slot/32]
  (tx, rx), and the one-shot, two-shot and all-gather kernels write both.
- LDS-only block barrier for the row reduction (__syncthreads also waits
  for the remote stores' acks), DPP / permlanex16 wave sums folded into
  v_add_f32_dpp, one barrier for the row sum.
- FP8 amax as unsigned bits (never negative nor NaN): integer DPP max and
  one ds_max_u32 a wave; the second barrier hands one LDS word around.
- Kernel arguments ordered so that up to 4 GPUs every argument the sends
  and the epilogue read sits in the 30 preloaded dwords; gemma_norm in bit
  8 of rank; no gridDim / blockDim reads.
- Row mode waits for one non-preloaded kernel argument after its sends:
  the peers' data arrives sooner (TP4 6144x1 10.4 -> 7.6 us).
- Remote stores, polls and re-arms as buffer ops with
  th:TH_*_BYPASS scope:SCOPE_SYS, as the Gluon all-reduce.
- The cluster path is gone (slower than split at every shape).

Host: LamportArRms::run picks split for rows of more than 1024 values
while TP4 has at most 64 rows (TP2 at most 32K packs), row mode otherwise,
with the fewest packs a thread that keep the block at most 256 threads
(128 from 257 rows, 64 from 513).

Signed-off-by: TennyWang1223 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TennyWang1223
TennyWang1223 requested a review from a team November 24, 2026 09:27
@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 8559 --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.

@github-actions github-actions Bot added the HIP label Nov 24, 2026
@aiter-bot

aiter-bot commented Nov 24, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 5cded348e5e2 · 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

Only speed changes. The kernel keeps the arithmetic of `ar_rmsnorm_gfx1250` step by step (rank-order fp32 sum rounded to T, fp32 residual add, the same square-sum order, the same per-token FP8 steps), so out, residual_out, the FP8 out and its scale keep their bits. The Python routing is unchanged: the default path takes this kernel where it did before, and `AITER_GLUON_FUSED_AR=1` keeps its Gluon routes (their numerics differ from this kernel's).

Validation and unverified scope

4x gfx1250, ROCm 10.1, bf16 unless stated:

- `op_tests/multigpu_tests/test_fused_ar_rms_lamport.py`, TP2/TP4, bf16 and fp16, bf16 and FP8 out: hidden 1024-8192 and M around every mode switch (64/65, 256/300, 512/600), and the default set: 0 bit differences against `ar_rmsnorm_gfx1250`; the mixed sequence (shapes, bf16/FP8, NaN, unaligned operands, graph) 0 bit differences. `gemma_norm=True` checked separately against `custom_fused_ar_rms(_quant)`: 0.
- Interleaving with the other Lamport ops (they now write the rx counters): `gfx1250_poc/test_gfx1250_lamport_allreduce.py` (route by size and by M, mixed sequence of one-shot, two-shot, AR + add, AR + RMSNorm, all-gather), `test_ar_add_lamport.py`, `test_ag_lamport.py`, `gfx1250_poc/test_gfx1250_allgather.py`, `test_custom_ar_fused_interleave.py --tp 4`: pass, 0 bit differences.
- `test_custom_allreduce.py --regression` TP4 and TP2, `test_custom_allreduce_rank_order.py`, `test_custom_allreduce_size_env.py`, `test_fused_ar_rms.py -t 4` and `-t 2`, `tests/test_ar_rmsnorm_routing.py`, `triton_test/test_all_reduce_rmsnorm_quant.py` (the Gluon paths with `AITER_GLUON_FUSED_AR=1`): pass.
- Stress: 3 TP4 runs and 1 TP2 run of 13 row counts x 6 hidden sizes x bf16/FP8, 200 graph replays a shape, with the Gluon kernel in between: no hang, 0 bit differences.

What remains unverified: TP6/TP8 (this machine has 4 GPUs; the Lamport cap is 0 there by default, so these sizes do not take the kernel unless `AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE` sets a cap), fp16 performance (fp16 correctness is tested), and other gfx1250 SKUs.

PR-specific question

**Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?**

The changed path is `lamport_ar_rmsnorm_gfx1250` and its launcher `LamportArRms::run` (plus the rx counter write at the end of the other Lamport kernels). The kernel is reached only through `CustomAllreduce.lamport_fused_ar_rms(_quant)`, which the routing calls only when `should_lamport_ar_rms` holds. This PR does not change that gate:

- Architecture: gfx1250 with the IPC transport. Only there does `_init_lamport_ar_rms` set up the inbox and the size cap; elsewhere `_lamport_max_bytes` stays 0 and the gate is false.
- World size: a nonzero cap, by default TP2 16 MiB and TP4 8 MiB. TP6/TP8 have no default cap.
- Dtype: input, residual and weight are all fp16 or all bf16. The FP8 out comes only from the per-token quant entry.
- Shape: contiguous operands, hidden a multiple of 256 and at most 8192, and 0 < input bytes <= cap.

Inside, `run()` checks hidden and the cap again and throws if they fail, so no unsupported input launches the kernel. The mode (split or row) and the packs a thread depend only on rows, hidden and world size, so every rank launches the same grid. Both modes compute the same bits, checked bit for bit against `ar_rmsnorm_gfx1250` on both sides of every mode switch.

Changed op tests

None.

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

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

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.

@junhaha666

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 3 review(s); expect to start in about 66 min. The box reviews one PR at a time.

@TennyWang1223

Copy link
Copy Markdown
Contributor Author

Full results: every measured shape

Setup: 4x gfx1250 (256 CU), ROCm 10.1, IPC transport, bf16 input. Each time is one call, in us: a CUDA graph of 10 calls, median of 20 replays, slowest rank, median of 3 rounds. Before (main 3845cd6) and after (this PR 3b15a63) ran 3 times each, alternately; a cell is the median of the 3 runs (run-to-run spread of a shape: median 2%, at most 8%). FP8 out is the fused AR + RMSNorm + per-token FP8 quant. Gluon: all_reduce_rmsnorm_per_token_quant (#8022, AITER_GLUON_FUSED_AR=1), measured in the same runs as this PR.

Speedup = baseline time / this PR time - 1 (main or Gluon as the baseline). Positive: this PR is faster; +25% means the baseline takes 1.25x the time of this PR.

"-" in the Gluon columns: Gluon does not take the shape (above its 4 MiB limit). At TP4 the Lamport cap is 8 MiB, so the larger shapes (e.g. hidden above 4096 at M = 1024) are not measured; at TP2 (16 MiB cap) all are.

TP4, bf16 out

Speedup vs main: median +25%, range +1% to +38% over 62 shapes. Speedup vs Gluon: median +19%, range +2% to +45% over 57 shapes.

hidden M main (us) this PR (us) speedup vs main Gluon (us) speedup vs Gluon
2048 1 6.82 5.27 +29% 6.19 +17%
2048 2 6.94 5.45 +27% 6.33 +16%
2048 4 7.18 5.77 +24% 6.42 +11%
2048 8 7.49 5.86 +28% 6.68 +14%
2048 16 7.55 6.02 +25% 6.88 +14%
2048 32 7.84 6.18 +27% 7.27 +18%
2048 64 8.22 6.82 +21% 8.11 +19%
2048 128 9.41 8.25 +14% 8.97 +9%
2048 256 10.27 9.28 +11% 12.53 +35%
2048 512 15.30 12.28 +25% 17.04 +39%
2048 1024 21.81 19.48 +12% 27.22 +40%
4096 1 7.64 5.52 +38% 6.63 +20%
4096 2 7.75 5.80 +34% 6.84 +18%
4096 4 7.92 5.89 +34% 7.05 +20%
4096 8 8.03 6.18 +30% 7.26 +17%
4096 16 8.22 6.40 +28% 7.54 +18%
4096 32 8.51 6.86 +24% 8.25 +20%
4096 64 9.70 8.07 +20% 9.19 +14%
4096 128 10.58 9.00 +18% 12.13 +35%
4096 256 14.94 11.89 +26% 16.62 +40%
4096 512 21.36 18.00 +19% 24.66 +37%
4096 1024 35.78 31.98 +12% - -
5120 1 7.87 5.77 +36% 6.71 +16%
5120 2 7.90 5.92 +33% 7.01 +18%
5120 4 8.08 6.11 +32% 7.19 +18%
5120 8 8.26 6.41 +29% 7.49 +17%
5120 16 8.51 6.80 +25% 7.78 +14%
5120 32 9.13 7.47 +22% 8.79 +18%
5120 64 10.11 9.08 +11% 9.63 +6%
5120 128 12.92 10.69 +21% 13.18 +23%
5120 256 17.02 14.55 +17% 18.61 +28%
5120 512 25.00 23.47 +7% - -
6144 1 8.19 6.05 +35% 6.15 +2%
6144 2 8.12 6.12 +33% 6.48 +6%
6144 4 8.44 6.28 +34% 6.67 +6%
6144 8 8.58 6.44 +33% 6.95 +8%
6144 16 8.75 6.80 +29% 7.41 +9%
6144 32 9.32 7.64 +22% 8.48 +11%
6144 64 10.41 8.38 +24% 9.37 +12%
6144 128 14.78 11.86 +25% 13.24 +12%
6144 256 18.59 15.51 +20% 18.64 +20%
6144 512 28.42 26.34 +8% - -
7168 1 8.22 6.18 +33% 7.33 +19%
7168 2 8.35 6.21 +34% 7.68 +24%
7168 4 8.41 6.47 +30% 7.92 +22%
7168 8 8.55 6.68 +28% 8.11 +21%
7168 16 8.99 7.15 +26% 8.75 +22%
7168 32 10.09 8.04 +25% 9.82 +22%
7168 64 10.89 10.55 +3% 11.20 +6%
7168 128 15.44 12.46 +24% 17.62 +41%
7168 256 20.36 17.34 +17% 23.79 +37%
7168 512 31.94 29.02 +10% - -
8192 1 8.45 6.21 +36% 7.73 +24%
8192 2 8.34 6.37 +31% 8.01 +26%
8192 4 8.53 6.54 +30% 8.22 +26%
8192 8 8.70 6.83 +27% 8.52 +25%
8192 16 9.09 7.25 +25% 9.27 +28%
8192 32 10.04 8.29 +21% 10.16 +23%
8192 64 11.17 11.07 +1% 12.12 +9%
8192 128 16.55 13.08 +27% 19.02 +45%
8192 256 22.11 18.75 +18% 25.67 +37%
8192 512 37.22 31.56 +18% - -

TP4, FP8 out

Speedup vs main: median +33%, range +6% to +48% over 62 shapes. Speedup vs Gluon: median +19%, range +1% to +46% over 57 shapes.

hidden M main (us) this PR (us) speedup vs main Gluon (us) speedup vs Gluon
2048 1 7.41 5.46 +36% 6.44 +18%
2048 2 7.48 5.58 +34% 6.62 +19%
2048 4 7.79 5.98 +30% 6.68 +12%
2048 8 8.04 6.03 +33% 6.99 +16%
2048 16 8.13 6.22 +31% 7.14 +15%
2048 32 8.38 6.51 +29% 7.53 +16%
2048 64 8.71 7.02 +24% 8.30 +18%
2048 128 9.97 8.30 +20% 9.15 +10%
2048 256 10.80 9.39 +15% 13.02 +39%
2048 512 15.60 12.39 +26% 17.52 +41%
2048 1024 22.57 19.71 +15% 28.83 +46%
4096 1 8.44 5.76 +47% 6.92 +20%
4096 2 8.63 6.07 +42% 7.19 +18%
4096 4 8.77 6.12 +43% 7.35 +20%
4096 8 8.78 6.41 +37% 7.58 +18%
4096 16 8.93 6.62 +35% 7.82 +18%
4096 32 9.52 7.04 +35% 8.62 +22%
4096 64 10.72 8.13 +32% 9.50 +17%
4096 128 11.71 9.44 +24% 12.49 +32%
4096 256 15.44 12.29 +26% 16.44 +34%
4096 512 22.07 18.37 +20% 25.59 +39%
4096 1024 35.64 32.30 +10% - -
5120 1 8.92 6.01 +48% 7.07 +18%
5120 2 8.85 6.09 +45% 7.28 +20%
5120 4 9.09 6.39 +42% 7.49 +17%
5120 8 9.21 6.62 +39% 7.65 +16%
5120 16 9.49 6.96 +36% 8.05 +16%
5120 32 10.09 7.55 +34% 9.02 +19%
5120 64 11.16 9.32 +20% 9.88 +6%
5120 128 13.70 11.10 +23% 13.59 +22%
5120 256 17.54 14.80 +19% 19.02 +29%
5120 512 25.48 23.63 +8% - -
6144 1 9.13 6.35 +44% 6.40 +1%
6144 2 9.11 6.38 +43% 6.62 +4%
6144 4 9.21 6.62 +39% 6.88 +4%
6144 8 9.61 6.74 +43% 7.14 +6%
6144 16 9.70 7.05 +38% 7.59 +8%
6144 32 10.43 7.82 +33% 8.75 +12%
6144 64 11.31 8.78 +29% 9.58 +9%
6144 128 15.74 12.11 +30% 13.42 +11%
6144 256 19.13 15.81 +21% 18.88 +19%
6144 512 28.88 26.68 +8% - -
7168 1 9.31 6.47 +44% 7.92 +22%
7168 2 9.39 6.51 +44% 8.26 +27%
7168 4 9.48 6.73 +41% 8.35 +24%
7168 8 9.63 7.02 +37% 8.58 +22%
7168 16 10.02 7.44 +35% 9.21 +24%
7168 32 11.14 8.27 +35% 10.28 +24%
7168 64 11.91 10.87 +10% 11.59 +7%
7168 128 16.56 12.72 +30% 16.15 +27%
7168 256 21.01 17.58 +20% 24.14 +37%
7168 512 32.42 29.27 +11% - -
8192 1 9.42 6.66 +41% 8.28 +24%
8192 2 9.14 6.74 +36% 8.48 +26%
8192 4 9.41 6.95 +35% 8.71 +25%
8192 8 9.60 7.25 +32% 9.09 +25%
8192 16 10.14 7.63 +33% 9.82 +29%
8192 32 11.32 8.67 +31% 10.71 +24%
8192 64 12.13 11.48 +6% 12.65 +10%
8192 128 17.52 13.41 +31% 17.55 +31%
8192 256 22.72 18.88 +20% 26.18 +39%
8192 512 36.64 32.03 +14% - -

TP2, bf16 out

Speedup vs main: median +30%, range +5% to +48% over 66 shapes.

hidden M main (us) this PR (us) speedup vs main
2048 1 6.58 5.08 +30%
2048 2 6.64 5.21 +27%
2048 4 6.98 5.39 +29%
2048 8 7.03 5.60 +26%
2048 16 7.12 5.64 +26%
2048 32 7.39 5.86 +26%
2048 64 7.39 6.14 +20%
2048 128 7.80 6.26 +25%
2048 256 8.34 7.05 +18%
2048 512 10.21 8.01 +27%
2048 1024 13.29 10.53 +26%
4096 1 7.29 5.30 +38%
4096 2 7.47 5.37 +39%
4096 4 7.54 5.57 +35%
4096 8 7.57 5.75 +32%
4096 16 7.78 5.84 +33%
4096 32 7.91 5.92 +34%
4096 64 8.14 6.67 +22%
4096 128 8.58 6.58 +30%
4096 256 10.20 7.86 +30%
4096 512 13.33 10.40 +28%
4096 1024 17.90 15.21 +18%
5120 1 7.73 5.35 +44%
5120 2 7.57 5.51 +37%
5120 4 7.86 5.74 +37%
5120 8 7.95 5.96 +33%
5120 16 8.01 6.30 +27%
5120 32 8.26 6.57 +26%
5120 64 8.54 7.03 +21%
5120 128 9.95 7.77 +28%
5120 256 10.86 9.14 +19%
5120 512 15.15 12.85 +18%
5120 1024 28.62 19.71 +45%
6144 1 7.95 5.43 +46%
6144 2 8.13 5.53 +47%
6144 4 8.09 5.75 +41%
6144 8 8.11 5.81 +40%
6144 16 8.25 5.98 +38%
6144 32 8.33 6.44 +29%
6144 64 8.74 7.06 +24%
6144 128 10.66 8.19 +30%
6144 256 11.76 9.61 +22%
6144 512 16.21 13.40 +21%
6144 1024 28.73 21.65 +33%
7168 1 8.13 5.50 +48%
7168 2 8.14 5.67 +44%
7168 4 8.38 5.83 +44%
7168 8 8.38 6.00 +40%
7168 16 8.51 6.36 +34%
7168 32 8.85 6.72 +32%
7168 64 9.35 7.45 +26%
7168 128 11.10 8.42 +32%
7168 256 13.15 10.21 +29%
7168 512 16.99 16.20 +5%
7168 1024 30.86 25.00 +23%
8192 1 8.13 5.68 +43%
8192 2 7.96 5.75 +38%
8192 4 8.18 5.89 +39%
8192 8 8.25 6.03 +37%
8192 16 8.36 6.27 +33%
8192 32 8.76 6.57 +33%
8192 64 9.09 7.49 +21%
8192 128 11.21 8.67 +29%
8192 256 14.33 10.70 +34%
8192 512 18.38 15.43 +19%
8192 1024 33.55 26.16 +28%

TP2, FP8 out

Speedup vs main: median +39%, range +8% to +58% over 66 shapes.

hidden M main (us) this PR (us) speedup vs main
2048 1 7.17 5.11 +40%
2048 2 7.20 5.26 +37%
2048 4 7.58 5.50 +38%
2048 8 7.66 5.55 +38%
2048 16 7.69 5.74 +34%
2048 32 7.94 5.90 +35%
2048 64 8.11 6.22 +30%
2048 128 8.38 6.69 +25%
2048 256 8.96 7.12 +26%
2048 512 10.83 8.21 +32%
2048 1024 13.83 10.74 +29%
4096 1 8.19 5.35 +53%
4096 2 8.38 5.50 +52%
4096 4 8.54 5.68 +50%
4096 8 8.55 5.78 +48%
4096 16 8.71 5.91 +47%
4096 32 8.91 6.18 +44%
4096 64 9.09 6.61 +38%
4096 128 9.62 7.05 +36%
4096 256 10.84 8.22 +32%
4096 512 13.85 10.63 +30%
4096 1024 18.74 15.65 +20%
5120 1 8.64 5.46 +58%
5120 2 8.70 5.60 +55%
5120 4 8.86 5.75 +54%
5120 8 8.91 6.02 +48%
5120 16 9.02 6.26 +44%
5120 32 9.46 6.63 +43%
5120 64 9.55 7.27 +31%
5120 128 11.01 8.03 +37%
5120 256 11.38 9.25 +23%
5120 512 15.72 13.13 +20%
5120 1024 29.97 19.89 +51%
6144 1 8.77 5.78 +52%
6144 2 8.86 5.77 +54%
6144 4 9.12 5.93 +54%
6144 8 9.09 6.08 +50%
6144 16 9.22 6.22 +48%
6144 32 9.36 6.45 +45%
6144 64 9.72 7.41 +31%
6144 128 11.67 8.42 +39%
6144 256 12.27 9.86 +24%
6144 512 16.90 14.01 +21%
6144 1024 29.97 22.28 +35%
7168 1 9.02 5.74 +57%
7168 2 9.12 5.97 +53%
7168 4 9.33 6.05 +54%
7168 8 9.31 6.16 +51%
7168 16 9.48 6.49 +46%
7168 32 9.86 6.84 +44%
7168 64 10.14 7.68 +32%
7168 128 12.03 8.61 +40%
7168 256 13.67 10.35 +32%
7168 512 17.71 16.36 +8%
7168 1024 32.22 25.07 +29%
8192 1 9.09 5.98 +52%
8192 2 8.66 6.10 +42%
8192 4 9.22 6.25 +48%
8192 8 9.16 6.43 +42%
8192 16 9.40 6.58 +43%
8192 32 9.85 6.92 +42%
8192 64 10.22 7.83 +31%
8192 128 12.17 8.94 +36%
8192 256 14.72 10.88 +35%
8192 512 19.74 16.01 +23%
8192 1024 35.61 26.70 +33%

@aiter-bot aiter-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ROCm/aiter PR #8559 — [HIP] fea: gfx1250 Lamport AR + RMSNorm: split sends, preloaded arguments, faster reductions

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — required, but the PR ships no test target (the changed path is run-time code: the default fused_allreduce_rmsnorm route at TP2/TP4 on gfx1250); auto-validation was also disabled
Perf (advisory): NOT RUN — no perf target: the PR and the repo ship no benchmark entry point for this path, so the author's own before/after tables (a custom harness) are the only timing
Size: 749 lines / 1 files
Design (advisory): split-mode sends with separate tx/rx round counters (sender blocks send and re-arm, row blocks only poll and reduce) replacing the one-counter block-a-row protocol; workgroup-cluster path removed
Human: recommend lirui review the split-mode protocol change in this PR (tx/rx counters, sender-side re-arm, interleaving with the one-shot/two-shot/all-gather kernels) — it must stay bit-exact with the ar_rmsnorm_gfx1250 kernel he authored in #8022

⚠️ [verified] The rewrite of csrc/include/custom_all_reduce_gfx1250.cuh ships no target anyone but the author can run: the PR's triage record (validation_requirement.json) shows no test target and no perf command, every Standard Tests CI job is 1-GPU MI35X while the Lamport path needs ≥2 gfx1250 GPUs, and the repo's own op_tests/multigpu_tests/test_fused_ar_rms_lamport.py runs on no PR job — a protocol or bit-exactness regression in the tx/rx counter change would ship green, with only the author's local runs as evidence. Author must get the multigpu Lamport tests (test_fused_ar_rms_lamport.py plus the one-shot/two-shot/all-gather interleaving tests) run in CI or attach the exact commands and logs so a reviewer can reproduce them.

📝 [verified] The red required checks are baseline, not this PR: C++ Interface Tests (MI300X and MI350X-DPX) fail PagedAttentionTest.BasicTest / .MatchesCpuReference identically on the unrelated PR kaiyang-1/mqa_topk_bf16 in the same window, Standard Tests shard 1 fails mla_decode-absorb on MI35X where this kernel is not in the path (plus CK-submodule and wheel-artifact infra noise), and main's own Aiter Test run in the same window fails its wheel build. Reviewer should ask for a re-run only if these persist on an unrelated clean PR.

📝 [verified] At TP6/TP8 the rewritten kernel runs a configuration the author lists as unverified: the split dispatch in csrc/include/custom_all_reduce_gfx1250.cuh takes its world_size >= 4 arm there, p4..p7 sit past the 30 preloaded SGPR dwords (scalar loads on the send path, per the kernel's own comment) and scratch grows to 7 peer packs a thread; the default Lamport cap is 0 at TP6/TP8, so the path is opt-in via AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE. Reviewer should ask whether run() should throw at world_size > 4 until TP6/TP8 are measured.

1 finding(s) posted inline, on the lines they are about:

  • csrc/include/custom_all_reduce_gfx1250.cuh:1509 — The row-mode speedup trick lamport_kernarg_wait (csrc/include/custom_all_reduce_gfx1250.cuh:1509) reads a…

@junhaha666

Copy link
Copy Markdown
Contributor

@TennyWang1223 Please take a look at the aiter-bot review. It has been over 12 hours without a follow-up commit or explanation. Please address the feedback or leave a brief update on how you plan to proceed.

TennyWang1223 and others added 2 commits November 26, 2026 10:19
lamport_kernarg_wait reads offset 128 of the kernel arguments, which must
stay past the 30 preloaded dwords and inside the argument list. Comment
only: mark it ATTENTION/TODO so a later argument change that silently
loses the gain is easy to trace. No code change.

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

Copy link
Copy Markdown
Contributor Author

Replies to the aiter-bot review:

  1. No CI target for the Lamport path. CI has no multi-GPU gfx1250 runner. ci:multi-gpu runs on linux-aiter-do-mi350x-8 (gfx950), CI builds only gfx950 (and gfx942 with ci:mi300x), and the only gfx1250 job is the single-GPU, label-triggered FFM bring-up. On those GPUs test_fused_ar_rms_lamport.py logs "unsupported" and skips. The tests for this path are already in the repo (test_fused_ar_rms_lamport.py, test_ar_add_lamport.py, test_ag_lamport.py, test_custom_ar_fused_interleave.py) and will run once CI has a gfx1250 multi-GPU runner. This PR does not change them. The local runs on 4x gfx1250 are listed under Validation in the description.
  2. Red checks: agreed, they fail the same way on unrelated PRs and on main. Not from this PR.
  3. TP6/TP8: a gfx1250 node has 4 GPUs, so TP6/TP8 places ranks on more than one node. This path does not support that by default, and the default Lamport cap there is 0. Multi-node support is a later extension.
  4. Kernarg offset: answered in the inline thread; 5cded34 adds an ATTENTION/TODO comment at lamport_kernarg_wait (comment only, no code change).

@zufayu
zufayu merged commit 73ecded into main Nov 27, 2026
69 of 70 checks passed
@zufayu
zufayu deleted the gfx1250_lamport_rms_opt branch November 27, 2026 02:35
zejunchen-zejun added a commit that referenced this pull request Nov 27, 2026
Conflicts with #8559 (gfx1250 Lamport AR + RMSNorm split sends):
- lamport_ar_2shot_gfx1250 keeps this branch's kernel. #8559 made the
  round counters [2][slot / 32] (tx, rx) and has every Lamport kernel
  advance both, as a split lamport_ar_rmsnorm_gfx1250 reads the rx
  counters; both branches of this kernel now do (advance_round).
- LamportArRms keeps num_cus, which #8559 dropped with the cluster
  path: run_2shot's split layout (a block a CU) reads it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit that referenced this pull request Nov 30, 2026
…t first where it runs

Since #8559 the Lamport one-shot AR + RMSNorm is the fastest of the three
gfx1250 TP4 kernels wherever it can take the call: 4x MI455X, CUDA graphs,
arms interleaved in one process, hidden 1024 / 2048 / 4096 / 8192, 1 row to
the 8 MiB cap. The Gluon power-of-2 kernel took 1.01-4.6x its time (also at
1024 / 2048, which the first commit kept on it) and the Gluon per-token
kernel 0.96-1.27x up to 128 rows, bf16 and per-token FP8 out alike.

fused_allreduce_rmsnorm now takes Lamport before both Gluon kernels, and
_use_gluon_ar_norm declines what Lamport can take, so the per-token FP8
route (fused_allreduce_rmsnorm_quant) takes Lamport first too. The Gluon
kernels keep the calls Lamport cannot take: hidden outside its range (not a
multiple of 256, or past 8192, e.g. 16384 for the power-of-2 kernel) or
past its size cap. _GLUON_AR_MAX_HIDDEN_WITH_LAMPORT and
_GLUON_AR_NORM_MAX_TOKENS go.

Bits: at the calls that move to Lamport the output has Lamport's bits
(another reduction order than either Gluon kernel). The dispatch op test
now checks the route of each call (Lamport at power-of-2 hidden 2048 from 1
row to 8 MiB and at 7168 / 4096 per-token, the power-of-2 kernel at 16384,
the Gluon per-token kernel at 6152) and its values against the reference
of the kernel that took it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to XiaobingSuper/aiter that referenced this pull request Nov 30, 2026
…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]>
TennyWang1223 pushed a commit that referenced this pull request Dec 2, 2026
* [Triton/Gluon] [Perf] Fuse gfx1250 AR RMSNorm native MXFP8

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, where the per-token
Gluon AR + RMSNorm kernel takes the call (up to 128 rows where the Lamport
one-shot applies), it runs that kernel with an MXFP8 epilogue (QUANT=2);
otherwise fused_allreduce_rmsnorm followed by per_1x32_mx_quant_hip, the same
bytes. The op is registered with mutates_args=[] (it writes no argument;
Inductor cannot remove an auto_functionalized_v2 that returns E8M0).

- the Gluon kernel keeps its QUANT parameter (2 = MXFP8), so the per-token
  path is untouched;
- one quant_type alias ("mxfp8"); group_size is not required, as for mxfp4;
  the option check (no emit_bf16) is in GroupCoordinator only;
- the calls are traced under AITER_AR_ROUTE_TRACE as the other fused routes;
- test_fused_allreduce_rmsnorm_dispatch checks the bytes against
  fused_allreduce_rmsnorm + per_1x32_mx_quant_hip at hidden 2880 / 7168 /
  6144, on the Gluon kernel and past it.

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

* [HIP] [Perf] gfx1250 AR + RMSNorm: MXFP8 out of the Lamport one-shot in one kernel

fused_allreduce_rmsnorm_mxfp8_quant ran the Lamport one-shot AR + RMSNorm and
then per_1x32_mx_quant_hip wherever the Gluon kernel did not take the call.
lamport_ar_rmsnorm_gfx1250 now also has an MXFP8 epilogue (template flag MX,
off by default), the steps and helpers of per_1x32_mx_quant_hip on gfx1250: a
group of 32 is pack k of 4 neighbouring lanes (two lamport_xor_lane steps),
the amax starts at kAmaxFloor, the scale is fp_f32_to_e8m0_scale<RoundUp>
capped at 2^127 and v_cvt_scalef32_pk8_fp8_{bf16,f16} converts; one row-major
E8M0 byte a group. It runs in every launch layout of the kernel (split sends,
1-8 packs a thread) and shares the sum of squares of the bf16 / fp16
instantiation (the kernel is uncontracted), so the bytes are those of
lamport_fused_ar_rms and the quant.

fused_allreduce_rmsnorm_quant_lamport takes it when scale_out is E8M0 (no new
pybind symbol); CustomAllreduce.lamport_fused_ar_rms_mxfp8 wraps it, and the
MXFP8 route takes it wherever should_lamport_ar_rms holds and the Gluon kernel
does not. Where both can run, the Gluon kernel keeps up to 128 rows only while
no wave of its program idles (norm_waves_busy: cdiv(hidden, 768) a power of
two); elsewhere the Lamport kernel was as fast or faster (TP4, 10 hidden sizes
from 1024 to 8192, 1-256 rows: mean 0.8% from the faster of the two). Where
fused_allreduce_rmsnorm takes the Gluon power-of-2 kernel (the Gluon all-reduce
on), the Lamport MXFP8 kernel takes the call up to 4 MiB
(_GLUON_POW2_LAMPORT_MXFP8_MAX_BYTES): at hidden 1024 from 6 MiB that kernel and
the quant were faster.

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

* [Perf] gfx1250 MXFP8 AR + RMSNorm: the 4 MiB bound over the Gluon power-of-2 route only up to hidden 1024

At hidden 2048 / 4096 / 8192 the Lamport MXFP8 kernel is faster than the
Gluon power-of-2 AR + RMSNorm and the quant up to the 8 MiB cap (0.64-0.94x
at 6 and 8 MiB); only hidden 1024 was slower from 6 MiB. Keep main's route
above 4 MiB for power-of-2 hidden up to 1024 only.

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

* [Perf] gfx1250 MXFP8 AR + RMSNorm: the Lamport one-shot first where it runs

Re-measured on #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]>

* [API] gfx1250 fused AR + RMSNorm quant: quant_type + quant_dtype pick 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]>

* [Refactor] fused AR + RMSNorm quant epilogues defined in aiter/dist/ar_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]>

* [HIP] [Refactor] gfx1250 Lamport AR + RMSNorm: one LamportRmsQuant epilogue 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]>

* [Refactor] one Lamport AR + RMSNorm quant wrapper for per-token FP8 and 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]>

---------

Co-authored-by: Cursor <[email protected]>
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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants