Skip to content

[FlyDSL] [CI] Fused all-reduce + RMSNorm - #5670

Merged
TennyWang1223 merged 218 commits into
mainfrom
users/vpietila/flydsl-fused-comm-kernels
Nov 17, 2026
Merged

TennyWang1223 merged 218 commits into
mainfrom
users/vpietila/flydsl-fused-comm-kernels

Conversation

@vpietila-amd

@vpietila-amd vpietila-amd commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds FlyDSL fused all-reduce + residual add + RMSNorm kernels (exact one-shot, and INT4 mesh/ring) and integrates them into Aiter's communication dispatcher behind AITER_FLY_AR=1. The kernels extend the plain FlyDSL all-reduce from #5461 with an RMSNorm epilogue. The fused kernels are tuned for PCIe (MI350P) and xGMI (gfx942/gfx950) interconnects. The mesh/ring schedules of FlyQuickAllReduce are reworked into an epilogue-based design that the plain all-reduce and the new FlyQuickAllReduceRMSNorm share, and the features of #6369 and #6404 carry over to it. QuickAllReduceInt4, a plain alias of FlyQuickAllReduce on main, becomes a deprecated subclass that keeps vLLM's old call working.

Motivation

Current Aiter all-reduce + RMSNorm kernels are not optimal for PCIe interconnects. The new FlyDSL fused all-reduce + RMSNorm kernels offer the following speedups on MI350P/PCIe:

Regime Speedup TP=2 Speedup TP=4 Speedup TP=8
Decode: FlyDSL fused one-shot vs Aiter fused 1-stage (cdr_fused_1stage) 1.67x–2.16x (avg: 1.94x) 1.34x–2.00x (avg: 1.64x) 1.82x–2.57x (avg: 2.10x)¹
Decode: FlyDSL fused one-shot vs best exact Aiter/RCCL baseline 1.27x–1.53x (avg: 1.40x) 1.34x–2.00x (avg: 1.63x) 1.54x–2.47x (avg: 1.91x)¹
Prefill: FlyDSL fused QRInt4 mesh/ring vs best Aiter QR int4 (fused or + RMSNorm) 1.65x–1.87x (avg: 1.74x) 13.06x–23.06x (avg: 18.60x) 24.27x–37.55x (avg: 32.14x)
Prefill: FlyDSL fused QRInt4 mesh/ring vs best exact Aiter/RCCL baseline 2.94x–3.23x (avg: 3.06x) 1.92x–2.85x (avg: 2.37x) 2.68x–3.66x (avg: 3.01x)

¹ With AITER_FLY_AR_FUSED_SPLIT=1. With the default (split off), TP=8 decode is 1.68x–2.57x (avg: 1.99x) vs cdr_fused_1stage and 1.54x–2.32x (avg: 1.81x) vs the best exact baseline; see the TP=8 decode table.

The average is the geometric mean over the message sizes in each regime. Decode covers payloads of 8–168 KiB (M x K with M in {1..16} and K in {4096, 7168, 8192}). Prefill covers payloads of 8–128 MiB (M in {1024, 4096, 8192} and K in {4096, 7168, 8192}, plus 4681 x 7168).

  • The exact baseline is the fastest of fused cdr (1-/2-stage), separate cdr + RMSNorm and separate RCCL + RMSNorm, among those at or above 30 dB SQNR.
  • The quantized baseline is the faster of Aiter's fused QR int4 kernel (hip_fused) and Aiter's QR int4 all-reduce followed by a separate RMSNorm (hip+norm), among those at or above 14 dB SQNR. hip_fused only runs on rows that divide its 32 KiB tile, so it is not a candidate at K=7168.

On PCIe, Aiter's QR int4 is structurally slow at TP>2 because of its un-cached IPC memory.

Relation to PRs #6369 and #6404

This PR targets mainly PCIe interconnects, but it also improves the performance on xGMI interconnects that were the main target of PRs 6369 and 6404. Speedup of this PR over main (main time / this PR's time, > 1× means this PR's implementation is faster)

TP shapes Eager: fused Eager: fused+MXFP4 HIP graph: fused HIP graph: fused+MXFP4
8 4 1.22–1.28× (1.24×) 1.20–1.32× (1.26×) 1.24–1.30× (1.27×) 1.28–1.34× (1.31×)
4 9 0.98–1.17× (1.09×) 0.98–1.20× (1.10×) 1.02–1.19× (1.11×) 1.04–1.21× (1.13×)
2 4 1.04–1.12× (1.08×) 1.05–1.12× (1.09×) 1.09–1.13× (1.11×) 1.10–1.13× (1.12×)

Changes

  • New fused kernels (aiter/ops/flydsl/kernels/comm/): one_shot_allreduce_rmsnorm.py (exact 1-stage), quick_allreduce_rmsnorm.py, quick_allreduce_fusions.py and quick_allreduce_epilogue.py (shared epilogue, row geometry, padding for arbitrary hidden dims, row-split exchange word) for the INT4 mesh and ring schedules.
  • Host classes: OneShotAllReduceRMSNorm (aiter/ops/flydsl/one_shot_allreduce.py) and FlyQuickAllReduceRMSNorm (aiter/ops/flydsl/quick_allreduce.py). The mesh and ring kernels (quick_allreduce_mesh.py, quick_allreduce_ring.py) are reworked so that the plain and the fused forms share one epilogue interface. QuickAllReduceInt4 changes from a plain alias of FlyQuickAllReduce to a deprecated subclass (see Breaking Changes).
  • Shared helpers: kernels/comm/allreduce_shared.py is renamed to transport.py. allreduce_host_shared.py gains the split-row exchange state in the meta block and check_fused_aliasing() (only residual_out may alias residual_in, exactly), and takes the inbox-memory default from the policy (default_inbox_memory). quick_allreduce_codec.py accepts any block that is a multiple of BLOCK_ALIGN up to MAX_BLOCK, which the padded widths need.
  • Dispatch policy (allreduce_policy.py) with per-(arch, link, world_size) family windows, JSON tuning ladders (configs/comm/fused_allreduce_ladders.json, overridable with AITER_FLY_AR_FUSED_LADDERS), and env overrides AITER_FLY_AR_FUSED_<ALG>_{MIN,MAX}_BYTES, AITER_FLY_AR_FUSED_HIDDENS, AITER_FLY_AR_FUSED_SPLIT.
  • Communicator integration (flydsl_backends.py, communicator_cuda.py, custom_all_reduce.py, quick_all_reduce.py): FlyDSL fused path is tried first when AITER_FLY_AR=1, otherwise the existing fused kernels run. Initialization votes across ranks: a rank that declines alone cannot leave peers waiting in a collective.
  • Tests and CI: split_tests.sh adds three pytest suites to the standard shard (test_flydsl_allreduce_policy.py, test_flydsl_quick_allreduce_codec.py, test_flydsl_allreduce_rank_agreement.py), and aiter_test.sh runs them with pytest.
  • Empty payloads: the host entry points of the one-shot and the mesh/ring return before any launch when the payload is zero bytes. A launch has at least one workgroup, and the padded fused one-shot would read and write at address 0, which is the crash the review found. The plain one-shot and the mesh/ring bound their accesses by the payload size and did not fault, so the early return there is defensive, and their zero-byte tests are regression guards.
  • Impact on users: nothing changes unless AITER_FLY_AR=1 is set.

Performance

Hardware: 8x MI350P (gfx950, PCIe), HIP-graph replay timing (graph of 10 calls, 10 timed replays per sample, median of 12 rotated rounds, slowest rank). Representative rows, the full per-shape tables and geomeans are in the collapsible sections below.

TP Workload/configuration Stock Aiter This PR Change
2 Decode 1×4096 (8 KiB), vs cdr_fused_1stage 8.417 µs 4.217 µs 2.00x
4 Decode 1×4096 (8 KiB), vs cdr_fused_1stage 10.24 µs 5.432 µs 1.88x
8 Decode 1×4096 (8 KiB), vs cdr_fused_1stage 14.4 µs 7.426 µs 1.94x
2 Prefill 4096×8192 (64 MiB), vs best QR int4 (hip+norm) 728.9 µs 437.1 µs 1.67x
4 Prefill 4096×8192 (64 MiB), vs best QR int4 (hip_fused) 15420 µs 742.8 µs 20.76x
8 Prefill 4096×8192 (64 MiB), vs best QR int4 (hip_fused) 41690 µs 1220 µs 34.17x

Decode TP=8 rows marked ¹ use AITER_FLY_AR_FUSED_SPLIT=1 (opt-in, see Row splitting). Speedup of this PR over main on xGMI is in the "Relation to PRs #6369 and #6404" table above.

Testing

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

Documentation

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

Documentation is in aiter/ops/flydsl/kernels/comm/README.md (routes, windows, ladders, env vars, row splitting, hidden-size preparation). No user-guide or performance-guide page covers the FlyDSL all-reduce path.

Dependencies

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

Breaking Changes

  • QuickAllReduceInt4 changes from a plain alias of FlyQuickAllReduce to a deprecated subclass in aiter.ops.flydsl.quick_allreduce (still importable from aiter.ops.flydsl). It keeps the old call QuickAllReduceInt4(group=, device=, rank=, world_size=) working: algorithm defaults to "mesh", as before, min_bytes defaults to 0, since the old class had no payload floor and vLLM picks the payloads it sends, and compile() calls preload(). vLLM's create_flydsl_quick_all_reduce_int4 needs no change. Use FlyQuickAllReduce, which takes algorithm explicitly, in new code.
  • aiter/dist/device_communicators/flydsl_utils.py is removed, its content moved into flydsl_backends.py.
  • aiter/ops/flydsl/kernels/comm/allreduce_shared.py is renamed to transport.py. It is an internal kernel module, and every in-tree importer is updated.
  • op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py is removed, and its tests are folded into test_flydsl_quick_allreduce.py.
  • The FlyDSL paths stay off unless AITER_FLY_AR=1. Hence, Aiter's default dispatching behavior does not change.

Technical Details

This PR extends the plain all-reduce kernel from #5461 with an RMSNorm eplogue. RMSNorm is row-local, so every kernel maps one workgroup to one token row: the row is reduced across ranks, added to the residual, normalized, and written out (out and residual_out) from registers. There are three kernel families, each with its own heuristics to pick the best instance:

  • 1-stage (one-shot), exact: every rank pushes its row straight into all peers' inboxes (one fabric traversal, Lamport-style, the payload is its own flag), then reduces in fp32 and applies the epilogue. Lossless, aimed at small (decode) messages where latency dominates.
  • 2-stage mesh and ring, INT4 wire format: QuickReduce-style reduce-scatter + all-gather on an INT4 wire format, with the epilogue applied on the reduced chunk. As in the plain ring on main ([FlyDSL] QuickAllReduce INT5/INT6 and all-reduce cleanup #5555), the ring's reduce-scatter lap defaults to INT6 at TP ≥ 4 to hold the 18 dB SQNR floor; the mesh stays INT4 at every world size. Mesh pushes to all peers directly, ring forwards to one neighbour (bandwidth optimal, one destination per store, optimal for a PCIe host). Aimed at large (prefill) messages where bandwidth dominates.

A policy picks the family for each message size where it beats the current Aiter kernel, and is integrated into Aiter's communication dispatcher: with AITER_FLY_AR=1 the FlyDSL kernels are tried first and, if not applicable, the existing Aiter fused all-reduce kernels are used.

Padding for arbitrary hidden dims. A native build needs the hidden dim to split into whole waves/blocks of threads. Otherwise the build pads: the workgroup is widened to h_pad (the hidden dim rounded up to the next valid width) and the pad lanes are masked off with a per-row buffer descriptor bounded to hidden * 2 bytes, so out-of-bounds loads return 0 and stores are dropped by the hardware. Row strides and the RMS denominator use the true hidden dim, so results are unaffected. The only cost is extra wire volume for the pad columns on the quantized kernels. The only requirement is that the hidden dim is a whole number of 16 B atoms (a multiple of 8 bf16 elements), which makes every hidden dim up to the workgroup limit (1024 threads) addressable. The padding makes the FlyDSL kernels more flexible than the existing HIP qr_int4 kernel that is limited to power-of-two hidden dims for BF16/FP16.

Dispatch policy and JSON tuning ladders

The fused dispatch makes its decisions on two levels, both keyed by (arch, link, world_size) with link in pcie / xgmi (detected from the KFD topology):

  1. Which family (FUSED_FAMILY_POLICIES in aiter/ops/flydsl/allreduce_policy.py). Each family has a window of payload sizes. With AITER_QUICK_REDUCE_QUANTIZATION=INT4, the mesh and ring windows take their payloads first, then the one-shot. Without quantization, only the exact one-shot runs and everything else falls through to CustomAllreduce / RCCL. The windows can be overridden with AITER_FLY_AR_FUSED_<ALG>_{MIN,MAX}_BYTES.
arch / link TP one-shot mesh ring
gfx942 / xGMI 2 [0, 32 MiB) [2 MiB, ∞) –
gfx942 / xGMI 4 [0, 512 KiB) [1344 KiB, ∞) –
gfx942 / xGMI 8 [0, 128 KiB) [448 KiB, ∞) –
gfx950 / xGMI 2 [0, 2688 KiB) – [768 KiB, ∞)
gfx950 / xGMI 4 [0, 384 KiB) [1536 KiB, ∞) –
gfx950 / xGMI 8 [0, 168 KiB) [2 MiB, ∞) –
gfx950 / PCIe 2 [0, ∞) – [768 KiB, ∞)
gfx950 / PCIe 4 [0, ∞) [256 KiB, 16 MiB) [16 MiB, ∞)
gfx950 / PCIe 8 [0, ∞) [128 KiB, ∞) –
  1. Which configuration (the ladder file aiter/ops/flydsl/configs/comm/fused_allreduce_ladders.json). The kernel instances are tuned per platform and per hidden size. The ladders live in a JSON file rather than in Python, so a retune replaces one file, and a deployment can point AITER_FLY_AR_FUSED_LADDERS at its own file without code changes.
  • Ladder lookup. A ladder is a list of rungs in ascending min_bytes order, starting at 0. min_bytes is either an integer or a string such as "56 KiB" or "24 MiB". A payload runs on the last rung whose min_bytes is at most its size. A hidden size with no ladder of its own uses the default ladder of its family, so untuned widths still run.
  • One-shot rungs. Each rung sets atoms (16 B atoms per thread, which sets the block width), grid_cap, fanout (peer or atom), and split (the number of workgroups one token row is spread over). Split rungs only take effect with AITER_FLY_AR_FUSED_SPLIT=1, otherwise they run unsplit. The default ladder must not split, because it has to build at every width.
  • Mesh and ring rungs. A rung sets super_tile and grid_cap. The entry sets atoms_per_row (null means the engine default, otherwise it must divide a rank's reduce-scatter chunk of 8 / world_size atoms). Mesh rungs may also set low_latency parameter.
  • Coverage. The shipped file covers gfx942/xGMI (MI300X/MI325X), gfx950/xGMI (tuned on MI355X) and gfx950/PCIe (tuned on MI350P), each at TP 2/4/8.
  • Fitting. The ladders are fitted from bench sweeps of the two multi-GPU tests (--operation ar_rmsnorm --candidates ...). For each world size and width, the fit times every pinned configuration next to the shipping engine and the stock kernels.

Row splitting (opt-in)

For small decode batches, one workgroup per token row leaves most of the GPU idle. A split one-shot rung spreads each row over split workgroups. It is off by default (AITER_FLY_AR_FUSED_SPLIT=1 turns it on) because the split changes the numerics of the RMSNorm reduction.

The workgroups of a split row must combine their partial sums of squares, and every rank must decode exactly the same bits. They therefore join through an integer atomic in HBM, so the row's sum of squares is a fixed-point number instead of an fp32 one. This has three consequences:

  • Slightly different results. The resolution is 2^-22 per wave partial. Rows with a tiny RMS (about 1e-3, where eps dominates) can differ from the unsplit build by one bf16 ulp on a small share of lanes (under 1%). Ranks still agree bit for bit.
  • Bounded range. A wave partial that is not finite, or too large for the fixed point, makes the row's out NaN. The largest sum of squares one wave may contribute depends on the writer count: at 4096 wide and atoms=1 (8 writers), a single element of residual_out at or above 11585.2 (11648 in bf16) poisons its row, and at 8192 wide (16 writers) 8192 does. residual_out and the other rows are unaffected, and the unsplit build has no such limits. The limits for every writer count are in the README, and test_one_shot_allreduce_rmsnorm_split_poison sweeps consecutive bf16 values across each boundary and requires exactly the values at or above it to poison.
  • Width limit. A split row takes at most 31 writers (5-bit arrival and poison counts), so hidden is limited to about 15.9k at atoms=1 and 31.7k at atoms=2. Wider rows run unsplit.

The ladders keep their tuned split rungs either way. With the split off, a split rung runs unsplit with the same atoms, grid_cap and fanout, so by default the exact one-shot always reduces the sum of squares in fp32. The cost is the slower TP8 decode rows marked ¹ in the results.

Relation to PR #6369

PR #6369 (merged) added allreduce_rmsnorm() and allreduce_rmsnorm_mxfp4() to the previous QuickAllReduceInt4 design. This PR carries those features over to the epilogue-based mesh/ring design and functionality added in PR #6369 stays available on the new kernels.
Tests from PR #6369 are adapted to the new API and folded into op_tests/multigpu_tests/test_flydsl_quick_allreduce.py. They cover Gemma, in-place, MXFP4 (bit-exact against the unfused quantizer), and the low-latency mesh. The dispatcher (AITER_FLY_AR=1) does not route Gemma norm or MXFP4 output. Both are used through the FlyQuickAllReduceRMSNorm API directly.

Test Plan

Benchmark the new kernels against the existing Aiter kernels using the benchmarking script introduced in #5461, and add fused all-reduce + RMSNorm tests to the existing test suites:

  • op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py
  • op_tests/multigpu_tests/test_flydsl_quick_allreduce.py

Test Result

op_tests/multigpu_tests/test_flydsl_quick_allreduce.py passes on 8x MI350P (gfx950, PCIe) at TP 2/4/8.

Benchmarks were run on 8x MI350P (gfx950, PCIe) with HIP-graph replay timing: a graph of 10 calls, 10 timed replays per sample, and the median of 12 rotated rounds on the slowest rank. Commands:

python op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py --operation ar_rmsnorm --scenario bench
python op_tests/multigpu_tests/test_flydsl_quick_allreduce.py --operation ar_rmsnorm --scenario bench --tp 2 4
python op_tests/multigpu_tests/test_flydsl_quick_allreduce.py --operation ar_rmsnorm --scenario bench --tp 8

In the tables, fly_auto is the fused instance the heuristics select, and speedup is baseline us / fly_auto us.

For the decode regime, the first baseline is Aiter's fused 1-stage cross-device-reduce kernel (cdr_fused_1stage, the production choice for these sizes). The second is the fastest exact stock path, which at TP2 is the two-launch cdr + RMSNorm. The heuristics select the exact one-shot kernel for every decode size at all three world sizes, so every row is in the geomean.

For the prefill regime, the FlyDSL fused QRInt4 kernel (mesh or ring) is compared against the best quantized and the best exact Aiter/RCCL baselines (defined in Motivation). SQNR is reported next to latency because the QRInt4 kernels are lossy. The exact baselines are at 48 dB or above.

Decode shapes

TP=2 (decode)

message size aiter cdr_fused_1stage (us) best exact stock best stock (us) fly_auto (us) vs cdr_fused_1stage vs best stock
8 KiB (1×4096) 8.417 cdr+norm 5.81 4.217 2.00 1.38
14 KiB (1×7168) 10.35 cdr+norm 6.45 4.853 2.13 1.33
16 KiB (2×4096) 8.609 cdr+norm 5.969 4.377 1.97 1.36
16 KiB (1×8192) 10.69 cdr+norm 6.317 4.958 2.16 1.27
28 KiB (2×7168) 10.45 cdr+norm 6.774 4.956 2.11 1.37
32 KiB (4×4096) 9.112 cdr+norm 6.585 4.591 1.99 1.43
48 KiB (6×4096) 9.447 cdr+norm 7.164 4.903 1.93 1.46
56 KiB (4×7168) 10.72 cdr+norm 7.862 5.248 2.04 1.50
64 KiB (8×4096) 9.899 cdr+norm 7.753 5.196 1.91 1.49
64 KiB (4×8192) 11.41 cdr+norm 8.168 5.337 2.14 1.53
70 KiB (5×7168) 10.74 cdr+norm 7.972 5.518 1.95 1.45
84 KiB (6×7168) 10.9 cdr+norm 8.183 5.811 1.88 1.41
112 KiB (8×7168) 11.37 cdr+norm 8.675 6.306 1.80 1.38
128 KiB (16×4096) 11.51 cdr+norm 8.589 6.398 1.80 1.34
154 KiB (11×7168) 11.98 cdr+norm 9.522 7.109 1.69 1.34
168 KiB (12×7168) 12.24 cdr+norm 9.782 7.343 1.67 1.33
geomean 1.94 1.40

TP=4 (decode)

message size aiter cdr_fused_1stage (us) best exact stock best stock (us) fly_auto (us) vs cdr_fused_1stage vs best stock
8 KiB (1×4096) 10.24 cdr_fused_1stage 10.24 5.432 1.88 1.88
14 KiB (1×7168) 14 cdr_fused_1stage 14 7.002 2.00 2.00
16 KiB (2×4096) 10.73 cdr_fused_1stage 10.73 5.843 1.84 1.84
16 KiB (1×8192) 14.16 cdr_fused_1stage 14.16 7.441 1.90 1.90
28 KiB (2×7168) 14.11 cdr_fused_1stage 14.11 7.664 1.84 1.84
32 KiB (4×4096) 11.62 cdr_fused_1stage 11.62 6.784 1.71 1.71
48 KiB (6×4096) 12.38 cdr_fused_1stage 12.38 7.883 1.57 1.57
56 KiB (4×7168) 15.03 cdr_fused_1stage 15.03 8.819 1.70 1.70
64 KiB (8×4096) 13.74 cdr_fused_1stage 13.74 8.367 1.64 1.64
64 KiB (4×8192) 15.32 cdr_fused_1stage 15.32 10.08 1.52 1.52
70 KiB (5×7168) 15.21 cdr_fused_1stage 15.21 11.36 1.34 1.34
84 KiB (6×7168) 15.97 cdr_fused_1stage 15.97 11.58 1.38 1.38
112 KiB (8×7168) 18.35 cdr_fused_1stage 18.35 12.25 1.50 1.50
128 KiB (16×4096) 20.78 cdr_fused_1stage 20.78 12.55 1.66 1.66
154 KiB (11×7168) 22.1 cdr_fused_1stage 22.1 15.3 1.44 1.44
168 KiB (12×7168) 23.63 cdr+norm 21.28 15.82 1.49 1.34
geomean 1.64 1.63

TP=8 (decode)

message size aiter cdr_fused_1stage (us) best exact stock best stock (us) fly_auto (us) vs cdr_fused_1stage vs best stock
8 KiB (1×4096) 14.4 cdr_fused_1stage 14.4 7.426 1.94 1.94
14 KiB (1×7168) 19.65 cdr_fused_1stage 19.65 8.041¹ 2.44 2.44
16 KiB (2×4096) 15.68 cdr_fused_1stage 15.68 8.256 1.90 1.90
16 KiB (1×8192) 20.8 cdr_fused_1stage 20.8 8.429¹ 2.47 2.47
28 KiB (2×7168) 21.54 cdr_fused_1stage 21.54 10.39¹ 2.07 2.07
32 KiB (4×4096) 21.92 cdr_fused_1stage 21.92 10.44 2.10 2.10
48 KiB (6×4096) 28.86 cdr_fused_1stage 28.86 13.11 2.20 2.20
56 KiB (4×7168) 28.27 cdr_fused_1stage 28.27 14.94 1.89 1.89
64 KiB (8×4096) 36.62 cdr_fused_1stage 36.62 15.79 2.32 2.32
64 KiB (4×8192) 29.71 cdr_fused_1stage 29.71 16.33 1.82 1.82
70 KiB (5×7168) 33 cdr_fused_1stage 33 17.85 1.85 1.85
84 KiB (6×7168) 38.2 cdr+norm 32.07 19.47 1.96 1.65
112 KiB (8×7168) 49.02 cdr+norm 37.99 23.99 2.04 1.58
128 KiB (16×4096) 69.61 cdr+norm 41.81 27.08 2.57 1.54
154 KiB (11×7168) 66.26 cdr+norm 50.62 31.02 2.14 1.63
168 KiB (12×7168) 71.49 cdr+norm 52.2 33.36 2.14 1.56
geomean 2.10 1.91

¹ With AITER_FLY_AR_FUSED_SPLIT=1: the TP8 ladders for hidden 7168 and 8192 spread a row over several workgroups at these sizes. With the default AITER_FLY_AR_FUSED_SPLIT=0, these rows run unsplit at 11.30 µs (1×7168), 12.14 µs (1×8192) and 12.24 µs (2×7168). That is 1.74x, 1.71x and 1.76x faster than cdr_fused_1stage, which brings the TP8 decode geomeans to 1.99x (vs cdr_fused_1stage) and 1.81x (vs best stock).

Prefill shapes

TP=2 (prefill)

message size fly_auto path fly_auto (us) fly_auto SQNR dB best quantized quantized (us) quantized SQNR dB vs quantized best exact exact (us) vs exact
8 MiB (1024×4096) ring 58.43 25.22 hip_fused 103.1 23.08 1.76 rccl+norm 177.3 3.03
14 MiB (1024×7168) ring 100.1 25.22 hip+norm 186.9 23.08 1.87 rccl+norm 299.8 2.99
16 MiB (1024×8192) ring 109 25.22 hip_fused 192.8 23.08 1.77 rccl+norm 339.7 3.12
32 MiB (4096×4096) ring 218.4 25.22 hip_fused 375.2 23.08 1.72 rccl+norm 663.7 3.04
56 MiB (4096×7168) ring 363 25.22 hip+norm 641 23.09 1.77 rccl+norm 1154 3.18
64 MiB (4681×7168) ring 416 25.22 hip+norm 730.1 23.09 1.75 rccl+norm 1302 3.13
64 MiB (8192×4096) ring 442 25.22 hip+norm 728.8 23.09 1.65 rccl+norm 1300 2.94
64 MiB (4096×8192) ring 437.1 25.22 hip+norm 728.9 23.09 1.67 rccl+norm 1300 2.97
112 MiB (8192×7168) ring 705 25.22 hip+norm 1281 23.09 1.82 rccl+norm 2274 3.23
128 MiB (8192×8192) ring 875 25.22 hip+norm 1460 23.09 1.67 rccl+norm 2577 2.95
geomean 1.74 3.06

TP=4 (prefill)

message size fly_auto path fly_auto (us) fly_auto SQNR dB best quantized quantized (us) quantized SQNR dB vs quantized best exact exact (us) vs exact
8 MiB (1024×4096) mesh 137 22.79 hip_fused 1790 21.31 13.06 rccl+norm 263 1.92
14 MiB (1024×7168) mesh 220.1 22.79 hip+norm 3304 21.31 15.01 rccl+norm 441.3 2.00
16 MiB (1024×8192) mesh 237.5 22.79 hip_fused 3772 21.32 15.88 rccl+norm 499.6 2.10
32 MiB (4096×4096) ring 465.3 21.26 hip_fused 7641 21.32 16.42 rccl+norm 970.3 2.08
56 MiB (4096×7168) ring 659.8 21.26 hip+norm 13680 21.32 20.73 rccl+norm 1686 2.56
64 MiB (4681×7168) ring 776.3 21.26 hip+norm 15700 21.32 20.23 rccl+norm 1924 2.48
64 MiB (8192×4096) ring 708.2 21.26 hip_fused 15440 21.32 21.80 rccl+norm 1924 2.72
64 MiB (4096×8192) ring 742.8 21.26 hip_fused 15420 21.32 20.76 rccl+norm 1923 2.59
112 MiB (8192×7168) ring 1259 21.26 hip+norm 27960 21.32 22.20 rccl+norm 3348 2.66
128 MiB (8192×8192) ring 1342 21.26 hip_fused 30950 21.32 23.06 rccl+norm 3822 2.85
geomean 18.60 2.37

TP=8 (prefill)

message size fly_auto path fly_auto (us) fly_auto SQNR dB best quantized quantized (us) quantized SQNR dB vs quantized best exact exact (us) vs exact
8 MiB (1024×4096) mesh 212.5 21.25 hip_fused 5156 20.07 24.27 cdr+norm 570.3 2.68
14 MiB (1024×7168) mesh 316.9 21.25 hip+norm 9154 20.07 28.89 cdr+norm 895.4 2.83
16 MiB (1024×8192) mesh 353.2 21.25 hip_fused 10290 20.07 29.12 cdr+norm 1002 2.83
32 MiB (4096×4096) mesh 669.3 21.25 hip_fused 20710 20.07 30.95 cdr+norm 1873 2.80
56 MiB (4096×7168) mesh 1060 21.25 hip+norm 37250 20.07 35.13 cdr+norm 3122 2.94
64 MiB (4681×7168) mesh 1205 21.26 hip+norm 42670 20.07 35.41 cdr+norm 3654 3.03
64 MiB (8192×4096) mesh 1297 21.25 hip_fused 41670 20.07 32.14 cdr+norm 3650 2.81
64 MiB (4096×8192) mesh 1220 21.26 hip_fused 41690 20.07 34.17 cdr+norm 3649 2.99
112 MiB (8192×7168) mesh 2006 21.25 hip+norm 75330 20.07 37.55 rccl+norm 7333 3.65
128 MiB (8192×8192) mesh 2308 21.25 hip_fused 83600 20.07 36.22 rccl+norm 8377 3.63
geomean 32.13 3.00
Between the regimes (256 KiB–8 MiB, quantized path)

TP=2 (between regimes, quantized path)

message size fly_auto path fly_auto (us) fly_auto SQNR dB best quantized quantized (us) quantized SQNR dB vs quantized best exact exact (us) vs exact
896 KiB (64×7168) ring 27.72 25.25 hip+norm 25.95 23.12 0.94 cdr+norm 25.36 0.91
1 MiB (64×8192) ring 15.99 25.23 hip+norm 27.28 23.11 1.71 rccl+norm 34.24 2.14
2 MiB (256×4096) ring 20.63 25.23 hip+norm 36.36 23.1 1.76 rccl+norm 54.39 2.64
3.5 MiB (256×7168) ring 40.54 25.23 hip+norm 49.22 23.09 1.21 rccl+norm 85.15 2.10
4 MiB (256×8192) ring 34.03 25.22 hip+norm 53.76 23.09 1.58 rccl+norm 95.23 2.80
geomean 1.40 1.98

TP=4 (between regimes, quantized path)

message size fly_auto path fly_auto (us) fly_auto SQNR dB best quantized quantized (us) quantized SQNR dB vs quantized best exact exact (us) vs exact
512 KiB (64×4096) mesh 22.99 22.8 hip+norm 58.94 21.35 2.56 rccl+norm 41.57 1.81
896 KiB (64×7168) mesh 42.31 22.79 hip+norm 116.9 21.33 2.76 rccl+norm 53.1 1.25
1 MiB (64×8192) mesh 33.04 22.8 hip+norm 139.3 21.33 4.21 rccl+norm 56.26 1.70
2 MiB (256×4096) mesh 48.71 22.79 hip_fused 324.1 21.32 6.66 rccl+norm 86.16 1.77
3.5 MiB (256×7168) mesh 83.02 22.8 hip+norm 771.6 21.32 9.29 rccl+norm 130.1 1.57
4 MiB (256×8192) mesh 75.51 22.79 hip_fused 854 21.32 11.31 rccl+norm 144.2 1.91
geomean 5.25 1.65

TP=8 (between regimes, quantized path)

message size fly_auto path fly_auto (us) fly_auto SQNR dB best quantized quantized (us) quantized SQNR dB vs quantized best exact exact (us) vs exact
512 KiB (64×4096) mesh 36.93 21.25 hip+norm 130.5 20.06 3.54 cdr+norm 138.9 3.76
896 KiB (64×7168) mesh 54.28 21.25 hip+norm 322 20.06 5.93 cdr+norm 185.9 3.43
1 MiB (64×8192) mesh 54.76 21.25 hip_fused 365.6 20.07 6.68 cdr+norm 191.7 3.50
2 MiB (256×4096) mesh 101 21.25 hip_fused 1015 20.07 10.05 cdr+norm 238.8 2.36
3.5 MiB (256×7168) mesh 136.3 21.25 hip+norm 2104 20.08 15.44 cdr+norm 324.4 2.38
4 MiB (256×8192) mesh 144.2 21.25 hip+norm 2474 20.08 17.15 cdr+norm 349.7 2.42
geomean 8.48 2.92

PR Self-Review

Reviewed revision

f697884

Behavior and intent

With AITER_FLY_AR=1, fused_allreduce_rmsnorm now tries FlyDSL kernels first: an exact fp32 one-shot all-reduce + residual add + RMSNorm for small (decode) payloads, and INT4 mesh/ring schedules with the RMSNorm applied as an epilogue on the reduced chunk for large (prefill) payloads. A per-(arch, link, world_size) policy and JSON ladders choose the family and configuration. Payloads outside the windows fall through to the existing cdr/RCCL path. The existing behavior is insufficient on PCIe: Aiter's fused 1-stage and QR int4 kernels are slow there (QR int4 is structurally slow at TP>2 because of its un-cached IPC memory), and QR int4 cannot serve non-power-of-two hidden dims. The PR also reworks the FlyQuickAllReduce mesh/ring schedules into an epilogue-based design, so the #6369/#6404 features (Gemma norm, in-place, MXFP4 output, low-latency mesh) carry over to the fused kernels. Default behavior is unchanged without AITER_FLY_AR=1. The row-split one-shot is a further opt-in (AITER_FLY_AR_FUSED_SPLIT=1) because it changes RMSNorm numerics.

Validation and unverified scope

Validated on 8x MI350P (gfx950, PCIe) at TP 2/4/8: python op_tests/multigpu_tests/test_flydsl_quick_allreduce.py passes, and the benchmarks in Test Result (--operation ar_rmsnorm --scenario bench for both multi-GPU tests) produce the speedup tables above with HIP-graph replay timing and an SQNR floor per baseline. The fused one-shot is checked bit-exact on residual_out and bit-identical across ranks against an fp32 rank-order reference. Unverified or not run: MI250X and MI300X (the gfx942 windows and ladders are not re-tuned here and rely on the xGMI tuning), the row-split path in production beyond its dedicated tests, MI355X tuning of gfx950/xGMI beyond the shipped ladders. The pytest suites op_tests/flydsl_tests/test_flydsl_allreduce_policy.py and test_flydsl_allreduce_rank_agreement.py are CPU-only and test_flydsl_quick_allreduce_codec.py needs one GPU. All three run in the standard CI shard. The rank-agreement suite is there because its failure mode is a hang (a rank that declines alone leaves its peers waiting in a collective), which only a multi-process test sees, and it needs no GPU: 28 cases in about 75 s, over gloo, with stand-in engines whose constructor is a collective, as the real IPC handle exchange is. The multi-GPU tests are run by the PR's required CI on MI350X (xGMI) only. They have not run on gfx942 or on PCIe in CI (logs from manual runs are attached in the review reply).

PR-specific question

The CI change is limited to two shell lists: .github/scripts/split_tests.sh adds test_flydsl_allreduce_policy.py, test_flydsl_quick_allreduce_codec.py and test_flydsl_allreduce_rank_agreement.py to the aiter test list, and .github/scripts/aiter_test.sh runs those three with python3 -m pytest -q (as it already does for test_flydsl_pa_decode.py). The skip of the flydsl_allreduce_bench.py helper module is already on main. No workflow file, permission, secret, trigger, or pull_request_target logic changes, and the added entries are fixed repo-relative paths, not PR-controlled text. Fork PR code can only reach the same test runner it already reaches today, with no new privileged path.

Changed op tests

  • op_tests/flydsl_tests/test_flydsl_allreduce_policy.py: CPU-only structural checks of the plain and fused dispatch tables, ladder JSON parsing/validation, env overrides, and backend selectors. It fails if a window overlaps, a ladder is malformed, or an override is accepted where it must be rejected. No canonical test covers the new fused policy.
  • op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py (new in the CI list, CPU-only, about 75 s): multi-process checks that a rank that declines or fails to build FlyDSL (including per-width fused builds) makes every rank decline instead of hanging peers in a collective.
  • op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py: single-GPU codec checks (memory path equals register path, analytic error bound, degenerate groups, block widths and per-world codec defaults). It covers the shared codec module that the schedules use.
  • op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py: multi-GPU exact one-shot verify/bench, extended for the fused form (bit-exact residual_out, padded widths, split rows, split rows with an element above the exchange's range (test_one_shot_allreduce_rmsnorm_split_poison), run-ahead under rank skew, fresh inputs, capture readiness, dispatch), and zero-byte payloads on the plain and fused engines (test_one_shot_allreduce_zero_bytes, a native and a padded width).
  • op_tests/multigpu_tests/test_flydsl_quick_allreduce.py: extended with the fused (ar_rmsnorm) operation next to the plain one; mesh/ring verify and bench, including edge inputs, divisor, transport, run-ahead, padded widths, low latency, Gemma, in-place and zero-byte payloads (test_quick_allreduce_zero_bytes). It absorbs the tests of the deleted _int4_rmsnorm file.
  • op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py: deleted; its coverage (Gemma, in-place, MXFP4, low-latency mesh) is folded into test_flydsl_quick_allreduce.py on the new fused API.
  • op_tests/multigpu_tests/flydsl_allreduce_bench.py: shared timing/reporting harness for both bench scenarios (one process and input, graph replay, rotated rounds, slowest rank, SQNR floor); a helper, not a test, so it is skipped in aiter_test.sh.

samremes and others added 30 commits August 20, 2026 09:12
Drop unused wave-join and single-wave fanout compiles; default and test the fp16 codec.
Compile-only and cache warming belong in developer scripts, not pytest or QRInt4QuadFanout.compile.

Co-authored-by: Cursor <[email protected]>
inttoptr + make_buffer_tensor (nbytes OOB) and BufferCopy128b tiled copies replace the tile/atom/tid arithmetic for local dwordx4 loads and stores. IPC/XGMI fanout stays global_store_dwordx4 nt.
… measured keeper; drop unused codec/force_super/bf16 ALU and qr_int4_mem, compiling via flyc.compile.

Co-authored-by: Cursor <[email protected]>
…R does the same), and time QRInt4 with run_perftest.
gfx942 already lowers vector<2xf16> to v_pk_max/min/mul/add/fma, so the
llvm.inline_asm helpers and f32 absmax round-trip are unnecessary.
The two-shot NT fanout and last-sector handshake are unchanged; gfx942 SQNR vs fp32 all-reduce still passes at TP 2/4/8.

Co-authored-by: Cursor <[email protected]>
TP2 ST=8 was packing the next tile into LDS while wave 0 still loaded the previous one. Also match aiter FlyDSL dtype/device checks and stop sorting IPC group ranks.

Co-authored-by: Cursor <[email protected]>
Each rank already scored vs its local fp32 NCCL all-reduce. The parent
kept rank 0 only, so a broken all-gather on a non-zero rank could pass.

Co-authored-by: Cursor <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fail SQNR on NaN or a zero-power reference with error. Drop the NCCL
fallback for Gloo object gather. Reject a rank or world_size that does
not match the process group.

Co-authored-by: Cursor <[email protected]>
Extend arch support to gfx950, parameterize inbox/launch grid_cap (default
1216 to match HIP QR), and tighten the canonical test bench with --grid-cap
and optional JSON export.

Co-authored-by: Cursor <[email protected]>
IPC inbox setup needs CPU broadcast_object_list and node-local HIP IPC
handles. Fail fast before allocating buffers, matching QuickAllReduce.
Clamp persistent grids to conservative residency limits, harden resource cleanup, and validate lossy collective results across ranks.

Co-authored-by: Cursor <[email protected]>
Fix CI Black failures in qr_int4_kernel.py and test_flydsl_qr_int4.py.

Co-authored-by: Cursor <[email protected]>
@TennyWang1223
TennyWang1223 self-requested a review November 17, 2026 07:46

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

LGTM

@TennyWang1223
TennyWang1223 merged commit 0c04b9d into main Nov 17, 2026
@TennyWang1223
TennyWang1223 deleted the users/vpietila/flydsl-fused-comm-kernels branch November 17, 2026 07:47
ZLkanyo009 added a commit that referenced this pull request Nov 17, 2026
…fly_rms

#7801 set _dcp_merge_max_rows at the end of __init__, after
_init_fly_oneshot(). #5670 merged four minutes earlier and changed the
same region. The squash merge of #7801 (03f9f37) placed the hunk at
the end of _init_fly_rms instead. _init_fly_rms returns early when the
FlyDSL fused AR + RMSNorm engine does not build. The engine builds only
with AITER_FLY_AR=1 on gfx942 or gfx950. Thus:

- On gfx1250 the attribute is never set, so should_custom_dcp_merge
  always returns False and the gfx1250 DCP merge cannot run.
- The rank-agreement test builds a CustomAllreduce with __new__, then
  calls _init_fly_rms. That call now reads _is_gfx1250, which the stand-in
  does not set. test_matching_ranks_build[fused] fails with
  AttributeError on main.

Move the assignment and its comment back to __init__, after
_init_fly_rms(). Also require "not self.disabled". The cross-node
symm_mem failure path disables the communicator and returns before it
sets self._ptr, so the gfx1250 call would raise on it.

Revert the test change of the previous commit. The test file is now
identical to main.

MI308X (gfx942), TP2:
- test_flydsl_allreduce_rank_agreement.py: 28 passed (main: 1 failed,
  27 passed).
- A real CustomAllreduce has _dcp_merge_max_rows == 0 with AITER_FLY_AR
  unset and with AITER_FLY_AR=1. On main the attribute is missing when
  the variable is unset.
valarLip pushed a commit that referenced this pull request Nov 18, 2026
…fly_rms (#8117)

* [FlyDSL] [Test] test_flydsl_allreduce_rank_agreement: set _is_gfx1250 on the __new__-built CustomAllreduce

test_matching_ranks_build[fused] builds a CustomAllreduce with __new__
and sets by hand the attributes that _init_fly_rms reads. Since #7801,
_init_fly_rms also reads self._is_gfx1250 after the engine is built, to
size the gfx1250 DCP merge. __init__ sets this attribute on every
instance, but the stand-in did not. Thus both ranks raised
AttributeError and the case failed on main.

Set it to False. The stand-in host is gfx950 (ARCH), and the FlyDSL
fused backend builds only on gfx942 and gfx950. With True, which is the
module value on a gfx1250 runner, _init_fly_rms calls
dcp_merge_max_rows_gfx1250(self._ptr), and the stand-in has no _ptr.

MI308X (gfx942), main b9e08da: the file gives 1 failed, 27 passed
before this change, and 28 passed after it.

* custom_all_reduce: set _dcp_merge_max_rows in __init__, not in _init_fly_rms

#7801 set _dcp_merge_max_rows at the end of __init__, after
_init_fly_oneshot(). #5670 merged four minutes earlier and changed the
same region. The squash merge of #7801 (03f9f37) placed the hunk at
the end of _init_fly_rms instead. _init_fly_rms returns early when the
FlyDSL fused AR + RMSNorm engine does not build. The engine builds only
with AITER_FLY_AR=1 on gfx942 or gfx950. Thus:

- On gfx1250 the attribute is never set, so should_custom_dcp_merge
  always returns False and the gfx1250 DCP merge cannot run.
- The rank-agreement test builds a CustomAllreduce with __new__, then
  calls _init_fly_rms. That call now reads _is_gfx1250, which the stand-in
  does not set. test_matching_ranks_build[fused] fails with
  AttributeError on main.

Move the assignment and its comment back to __init__, after
_init_fly_rms(). Also require "not self.disabled". The cross-node
symm_mem failure path disables the communicator and returns before it
sets self._ptr, so the gfx1250 call would raise on it.

Revert the test change of the previous commit. The test file is now
identical to main.

MI308X (gfx942), TP2:
- test_flydsl_allreduce_rank_agreement.py: 28 passed (main: 1 failed,
  27 passed).
- A real CustomAllreduce has _dcp_merge_max_rows == 0 with AITER_FLY_AR
  unset and with AITER_FLY_AR=1. On main the attribute is missing when
  the variable is unset.

---------

Co-authored-by: TennyWang1223 <[email protected]>
samremes added a commit that referenced this pull request Nov 19, 2026
… + GEMM integration

- Refresh all 96 gfx950 .co binaries with prologue tile-wide 128-bit plain scale
  LDS staging and bank-conflict-free swizzle.
- Port FlyDSL fused all-reduce + RMSNorm (#5670) and add allreduce_rmsnorm_mx
  with plain row-major e8m0 scales, MXFP4/MXFP8 output, optional norm_bf16
  retention, and padded width masking for D in {8192, 7168, 4096, 3584, 2560}.
- Add prepare_downstream_mx_inputs plus end-to-end multi-GPU seam tests and
  4-arm CUDA-Graph benchmarks feeding downstream MXFP4 and MXFP8 dense GEMMs.

Co-authored-by: Copilot <[email protected]>
jhinpan pushed a commit to jonahbernard/aiter that referenced this pull request Nov 20, 2026
…e_rmsnorm

ROCm#5670 made fused_allreduce_rmsnorm ask each communicator
should_fly_allreduce_rmsnorm() before the paths this test checks. The
CustomAllreduce stand-in from ROCm#8022 binds only the other routing gates,
so the custom_fused case past the Gluon limit raised AttributeError.
ROCm#8022's last CI ran on a base without ROCm#5670.

Bind the real gate with _fly_rms=None, which is its value on gfx1250,
where the FlyDSL fused engine does not build.

(cherry picked from commit 06ae37f)
zufayu pushed a commit that referenced this pull request Nov 20, 2026
…e_rmsnorm (#8313)

#5670 made fused_allreduce_rmsnorm ask each communicator
should_fly_allreduce_rmsnorm() before the paths this test checks. The
CustomAllreduce stand-in from #8022 binds only the other routing gates,
so the custom_fused case past the Gluon limit raised AttributeError.
#8022's last CI ran on a base without #5670.

Bind the real gate with _fly_rms=None, which is its value on gfx1250,
where the FlyDSL fused engine does not build.
tkarttunen added a commit to tkarttunen/sglang that referenced this pull request Nov 23, 2026
… prefill all-reduce

With --enable-aiter-allreduce-fusion, the fused all-reduce + add + RMSNorm was
custom all-reduce only and capped at its 64 MiB pool, so prefill chunks that
QuickReduce serves were never fused. Ask the QuickReduce dispatcher first: when
aiter's FlyDSL kernel (ROCm/aiter#5670) takes the call, it fuses the add and
RMSNorm into the INT4 all-reduce, up to the QuickReduce workspace. Anything it
declines, and anything over 64 MiB, takes the existing path.

Co-authored-by: Cursor <[email protected]>
zufayu pushed a commit that referenced this pull request Dec 3, 2026
…e/prefill kernels (#6277)

* [ASM] [MLA] Fix and optimize the gfx942 MLA decode/prefill kernels

Replace 20 gfx942 MLA code objects with fixed and optimized builds and add
one new kernel (32 heads, qlen 1). Kernel names, kernargs and grids are
unchanged, so every existing caller dispatches as before.

Bugs fixed (stock behavior):
- KV loads above 4 GiB: buffer_load offsets were page_id * stride in 32 bits
  (some kernels also took a 24-bit page id), so pools over 4 GiB read other
  tokens' KV. KV now loads with 64-bit global addresses in every kernel.
- Other 32-bit offset overflows (output/split data, kv_indptr, LSE, Q).
- Missing s_waitcnt before using load results (prologue KV tile, V transpose
  LDS reads, fp8 descales) -> stale data under memory pressure.
- MFMA -> VALU read hazard in the softmax (nondeterministic results).
- LDS races and missing barriers in the a8w8 qseqlen 1/2/4 kernels.
- 32x1 / 64x1 kernels: S == 1 null split pointer fault; the 32-head kernel
  ran one token per workgroup and was not causal for qlen > 1.
- qseqlen-2 a8w8 causal mask, PS empty work items, kv_scale handling in the
  paged qseqlen-4 PS kernel, reads of unwritten splits for qlen >= 9.

Dispatch: gqa_ratio 32, bf16, non-persistent now selects the new
MLA_A16W16_1TG_4W_32mx1_16nx1_Coex0_Msk1_QH16_Q1 kernel when
max_seqlen_q == 1 (new mla_asm.csv row) and the causal any-qlen kernel
otherwise.

Performance matches or beats stock on most measured shapes (up to ~20%
faster); the 64-bit KV addressing costs up to ~1.5% on a few memory-bound
shapes of the a8w8 qseqlen-4 kernels.

Tested on MI300X against an fp32/fp64 reference and a bit-exact oracle,
including KV pools above 4 GiB, injected stalls and 1 h soak runs, and with
op_tests (test_mla.py incl. the CI invocations, test_mla_persistent.py,
test_mla_sparse.py and the other MLA op_tests): all pass.

Signed-off-by: Jonah Bernard <[email protected]>

* [MLA] Extend test_mla_ltx.py gfx942 coverage to every fixed kernel

The gfx942 kv_address check now covers each MLA .co this PR fixes,
except the page_size 64 ds32 kernel. GFX942_PRESETS maps each preset
to the modes (nps / ps / prefill) that reach its kernels. The default
gfx942 run sweeps all of them: 84 cases, 20 kernels.

- FP8 and A16W8 configs, qlen 1-8, 8/16/32/64/128 heads
- mla_prefill_fwd (causal prefill) mode
- causal reference for qlen > 1; FP8-Q tolerance 6e-2
- persistent metadata uses the real Q/KV dtypes on gfx942
  (gfx950 keeps BF16)

gfx950 defaults and presets are unchanged.

Signed-off-by: Jonah Bernard <[email protected]>

* test_mla_ltx: cover the gfx942 page-64 ds32 MLA kernel at 4 GiB

Add qh16_ds32_q1/q2/q4 presets (uint8 KV) for
mla_a16w8_qh16_m16x4_n16x1_coex0_mask1_ps_page64_ds32. The harness packs fp8
nope, fp32 block scales and bf16 rope into 64-token pages and runs the
kv_address cases on them: one page below, across and above the 4 GiB boundary
(page 102,300), plus a 65-page context the metadata splits in two.

Signed-off-by: Jonah Bernard <[email protected]>

* [MLA] Pick the bf16 32-head qSeqLen 1 kernel only on gfx942

asm_mla.cu set config_max_seqlen_q = 1 for bf16 32-head non-persistent
decode with max_seqlen_q == 1 on every arch, but only the gfx942
mla_asm.csv has a qSeqLen 1 row for that config. get_heuristic_kernel_mla
needs an exact match, so gfx950 failed with "cannot get heuristic kernel".
Gate it on arch_id == "gfx942"; other archs use qSeqLen 0 as before.

Signed-off-by: Jonah Bernard <[email protected]>

* [ASM] [MLA] Fix the gfx950 MLA kernels and test the fp8 msk0 kernel in CI

Rebuild 12 gfx950 MLA .co files from the same sources as the gfx942
kernels in this PR (the .text matches the gfx942 builds). KV is read with
64-bit global loads, so pools above 4 GiB no longer wrap, and the
nondeterminism, the non-causal 64-head kernel, the 1-split fault in the
64-head kernel and the bf16-Q/fp8-KV PS fault are fixed.
mla_a8w8_qh128_m32x4_n16x2_msk0 has no gfx942 counterpart: it is the
fp8 128-head msk1 source built with MASK = 0. Kernel names and
mla_asm.csv rows are unchanged.

aiter_test.sh: on gfx950, add a test_mla.py run of non-causal fp8 decode
with qlen 2 and 4 (128 heads), which is the only path that reaches the
msk0 kernel.

Signed-off-by: Jonah Bernard <[email protected]>

* [HIP] [MLA] Add the missing barrier in mla_reduce_v1's massive row loop

In mla_reduce_v1_impl_massive (4 or more splits), warp 0 writes the LSE
scales of a row to p_lds_lse_scale, and every warp then reads them to
scale its part of the output. The row loop had no barrier after the
output pass, so when a block reduces more than one row (qlen > 1, or
folded heads), warp 0 could overwrite the scales with the next row's
while warp 1 was still reading them. Warp 1's dims (256-511) of that
row were then combined with the wrong row's weights.

This is the remaining failure in #6731: with this PR's stage-1 kernels,
the issue's repro (32 heads, qlen 4, 5 splits) gave 167 wrong calls in
400,000 on MI300X, each one token and one head in dims 256-511 only.
With the barrier: 0 in 400,000.

Signed-off-by: Jonah Bernard <[email protected]>

* [MLA] Add a test_mla_reduce case for the row-loop barrier

The previous commit's race needs many splits, many rows per workgroup and
a full GPU; none of the existing cases has all three, so they pass with
or without the barrier. The new case (16 heads, dv 512, 32 tiles x 64
splits x 32 rows) failed on every run without the barrier on MI300X (50
of 50, plus both dtypes of the full test on two GPUs) and passes with it.

Signed-off-by: Jonah Bernard <[email protected]>

* [ASM] [MLA] Apply the causal mask in bf16 128-head decode with qlen > 1

The non-persistent bf16 128-head decode always ran
mla_dec_stage1_bf16_a16w16_subQ128_mqa128, which has no causal mask, so
causal decode with qlen > 1 attended to future tokens (#6733).

Run mla_pfl_bf16_a16w16_causal_subQ128_mqa128 for that case instead. It is
the masked build of the same kernel and takes the decode arguments
unchanged. It skips splits past a query's last token, so stage 2 now uses
the per-query split count for it.

gfx950 ships the same two kernels (identical .text), so the fix covers it
too; it was only tested on gfx942.

Signed-off-by: Jonah Bernard <[email protected]>

* [Test] test_ar_norm_precedence: give the stand-in should_fly_allreduce_rmsnorm

#5670 made fused_allreduce_rmsnorm ask each communicator
should_fly_allreduce_rmsnorm() before the paths this test checks. The
CustomAllreduce stand-in from #8022 binds only the other routing gates,
so the custom_fused case past the Gluon limit raised AttributeError.
#8022's last CI ran on a base without #5670.

Bind the real gate with _fly_rms=None, which is its value on gfx1250,
where the FlyDSL fused engine does not build.

(cherry picked from commit 06ae37f)

* [Test] test_moe_2stage: accept the gfx942 FlyDSL clamped SiLU route

#8178 sends a gfx942 per_Token FP8 SiLU with an active swiglu_limit and no
tuned CK row to the FlyDSL whole-graph backend, which applies the clamp, and
checks the CK limits only when no FlyDSL backend takes the call.
test_plain_fp8_swiglu_limit_dispatch still assumed CK stage 1: it read
md.stage1.keywords on a FlyDSL result (AttributeError on MI300X), and it
expected NotImplementedError for per_Token at inter_dim 192, which FlyDSL
now serves.

The first two hunks are #8294's change. The inter_dim 192 expectation is the
assertion that #8294's own MI300X run still fails on.

* Revert "[Test] test_moe_2stage: accept the gfx942 FlyDSL clamped SiLU route"

This reverts commit fdcd7bd.

* [fused_moe] Keep CK-capable clamped SiLU off the gfx942 FlyDSL default

The whole-graph batch-1 and decode kernels clamp BF16 activations, so a
per-token call that CK can clamp was missing the per-token reference and
crashing the dispatch test on stage1 being None.

Co-authored-by: Cursor <[email protected]>
(cherry picked from commit ca91b9f)

* [MLA] Route gfx950 128-head bf16 causal qlen>1 decode to the masked prefill kernel too

mla_asm_decode_remap only forced ps=0 (and thus the masked-prefill-kernel
selection for causal qlen>1) on gfx942, so gfx950 kept running the plain
persistent decode kernel for this case, which has no per-query causal mask.
Meanwhile mla.py's masked_qh128_bf16 (which drives CAUSAL_PER_QUERY for the
stage-2 reduction) was already set for both gfx942 and gfx950, so stage 2
believed splits past each query's causal horizon were skipped on gfx950 too,
even though stage 1 never skipped them there.

gfx950 already ships and dispatches mla_pfl_bf16_a16w16_causal_subQ128_mqa128.co
(hsa/gfx950/mla/mla_asm.csv) with the 64-bit KV addressing fix from this PR,
so extending the gate just routes to an existing, already-tested kernel.

* Revert "[MLA] Route gfx950 128-head bf16 causal qlen>1 decode to the masked prefill kernel too"

This reverts commit 2cd4f38.

Forcing ps=0 for gfx950 128-head bf16 decode breaks every persistent
128-head bf16 decode on gfx950. The gfx950 block at the end of
mla_asm_decode_remap still tests `persistent`, not `ps`, and remaps the
shape to gqa 32 / qSeqLen 4. The lookup then asks for (gqa 32, ps 0,
qSeqLen 4), which hsa/gfx950/mla/mla_asm.csv does not have, so
test_mla_persistent.py, test_mla_persistent_round_robin.py and
test_mla_sparse.py fail on MI35X with "cannot get heuristic kernel!
... gqa:32 ps:0 ... qseqlen:4".

The CAUSAL_PER_QUERY concern does not need this change.
masked_qh128_bf16 only feeds the stage-2 reduction in the
non-persistent branch of mla_decode_fwd. That branch passes
num_kv_splits_indptr, so persistent is false and ps is already 0 on
gfx950: causal qlen > 1 already selects
mla_pfl_bf16_a16w16_causal_subQ128_mqa128 there. Persistent decode
reduces with mla_reduce_v1 and runs the qh32_qseqlen4 *_ps kernels,
which have causal and msk0 variants.

* [CI] [MLA] Gate the gfx950-only msk0 test on the live GPU arch

get_gfx() returns the last GPU_ARCHS entry. With GPU_ARCHS="gfx950;gfx942"
the gate read gfx942 on a gfx950 GPU and skipped the test; with
"gfx942;gfx950" it would run the gfx950-only kernel on gfx942.
get_gfx_runtime() reads the arch from rocminfo and ignores GPU_ARCHS.

---------

Signed-off-by: Jonah Bernard <[email protected]>
Co-authored-by: amd-bartgips <[email protected]>
Co-authored-by: Jin Pan <[email protected]>
Co-authored-by: jatseng-ai <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Jin Pan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:multi-gpu Trigger multi-GPU op tests on PR CI FlyDSL multigpu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants