Skip to content

[FlyDSL] [CI] One stage and two-stage ring all-reduce kernels for PCIe interconnects - #5461

Merged
zufayu merged 149 commits into
mainfrom
users/vpietila/flydsl-comm-kernels
Nov 4, 2026
Merged

zufayu merged 149 commits into
mainfrom
users/vpietila/flydsl-comm-kernels

Conversation

@vpietila-amd

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

Copy link
Copy Markdown
Contributor

Motivation

PR #4970 introduced a two-stage int4 quick reduce FlyDS kernel that improved all-reduce throughput over the existing Aiter two-stage/RCCL kernels. Current Aiter all-reduce kernels are written primarily for the xGMI interconnect. This PR optimizes the FlyDSL quick reduce int4 kernel for PCIe interconnects (MI350P) and adds two new kernels: a one-stage lossless and a two-stage ring kernel with int4/int6 codecs. On MI350P, they offer better performance than the existing Aiter production kernels (cross-device-reduce/QR Int4)

MI350P/PCIe

Category Speedup TP=2 Speedup TP=4 Speedup TP=8
Decode: FlyDSL one-shot vs best of Aiter cdr / cdr_naive 1.02x–1.23x (avg: 1.11x) 1.14x–2.12x (avg: 1.70x) 1.49x–2.65x (avg: 2.06x)
Decode: FlyDSL one-shot vs what production runs today (cdr) 1.02x–1.23x (avg: 1.11x) 1.14x–14.15x (avg: 5.09x) 1.49x–44.30x (avg: 9.73x)
Prefill: FlyDSL mesh/ring vs HIP QR INT4 1.64x–1.85x (avg: 1.81x) 15.45x–25.78x (avg: 21.65x) 26.49x–42.61x (avg: 36.48x)
Prefill: FlyDSL mesh/ring vs best of Aiter cdr / cdr_naive / RCCL 2.93x–3.44x (avg: 3.28x) 2.11x–2.96x (avg: 2.63x) 2.49x–4.02x (avg: 3.18x)

For TP=4,8 Aiter's existing QR Int4 seems to have a structural problem on PCIe (un-cached IPC memory is suboptimal) and we have also compared against the exact cross-device-reduce and RCCL kernels against the quantized FlyDSL all-reduce.

MI350P/PCIe, efficiency

Category Efficiency TP=2 Efficiency TP=4 Efficiency TP=8
Decode: aiter 1-stage cdr (cdr or cdr_naive, whichever ran the 1-stage kernel) 0.0291–0.193 (avg: 0.0591) 0.0148–0.0899 (avg: 0.0423) 0.00356–0.342 (avg: 0.0274)
Decode: FlyDSL one-shot (fly_auto) 0.0342–0.213 (avg: 0.0664) 0.0242–0.157 (avg: 0.0755) 0.00977–0.898 (avg: 0.0688)
Prefill: HIP QR int4 0.454–0.527 (avg: 0.501) 0.0325–0.0345 (avg: 0.0335) 0.0123–0.0167 (avg: 0.0149)
Prefill: FlyDSL QRInt4 (fly_auto) 0.757–0.964 (avg: 0.908) 0.512–0.855 (avg: 0.704) 0.324–0.88 (avg: 0.62)

Efficiency is roof us / measured us (higher is better, 1.0 = at the roof), where the roof is the fastest of one-shot / two-shot / ring that TransferBench achieves moving that kernel's wire bytes.

MI325X/xGMI

Category Speedup TP=2 Speedup TP=4 Speedup TP=8
Decode: FlyDSL one-shot vs. best(cdr, cdr_naive) 1.23×–1.42× (avg: 1.32×) 1.38×–1.48× (avg: 1.41×) 0.96×–1.15× (avg: 1.04×)
Prefill: FlyDSL mesh vs. HIP QR int4 1.02×–1.09× (avg: 1.07×) 1.04×–1.11× (avg: 1.08×) 0.95×–1.24× (avg: 1.16×)

MI350X/xGMI

Category Speedup TP=2 Speedup TP=4 Speedup TP=8
Decode: FlyDSL one-shot vs. best(cdr, cdr_naive) 0.97×–1.21× (avg: 1.10×) 1.03×–1.26× (avg: 1.16×) 1.07×–1.33× (avg: 1.15×)
Prefill: FlyDSL mesh vs. HIP QR int4 1.07×–1.65× (avg: 1.31×) 1.26×–1.76× (avg: 1.46×) 1.47×–1.78× (avg: 1.59×)

This PR vs current Aiter main (MI350X/xGMI)

Operation Speedup TP=2 Speedup TP=4 Speedup TP=8
All-reduce (allreduce) 1.05×–1.13× (avg: 1.07×) 1.06×–1.10× (avg: 1.08×) 1.06×–1.21× (avg: 1.13×)
All-reduce + add + RMSNorm (allreduce_rmsnorm) 1.03×–1.11× (avg: 1.08×) 1.03×–1.17× (avg: 1.10×) 1.07×–1.31× (avg: 1.18×)
All-reduce + add + RMSNorm + MXFP4 (allreduce_rmsnorm_mxfp4) 1.03×–1.11× (avg: 1.08×) 1.02×–1.20× (avg: 1.11×) 1.05×–1.34× (avg: 1.19×)

The average is geometric mean of the speedup values.

PR Self-Review

Reviewed revision

c3a44c0

Behavior and intent

Adds FlyDSL all-reduce kernels behind the existing CustomAllreduce and QuickAllReduce slots, opt-in with AITER_FLY_AR=1: an exact one-shot (bf16), an INT4 quick-reduce (mesh and ring), and a fused INT4 all-reduce + RMSNorm (optionally with an MXFP4 output). A per-platform policy table (allreduce_policy.py) chooses the algorithm by arch, link (xGMI or PCIe), world size and payload. Payloads outside a FlyDSL window fall back to the stock path, as before.

Why: on PCIe (MI350P) the stock kernels are slow at all world sizes. The FlyDSL one-shot is 1.5–44× faster at decode sizes, and the INT4 path is 26–43× faster than HIP QR INT4 at prefill sizes (numbers in the PR description). With AITER_FLY_AR unset, nothing changes: no engine is built, and dispatch is the same as on main.

Validation and unverified scope

8× MI350P (gfx950, PCIe), TP=2/4/8, default verify scenario. These ran at 26f2b5e, and 6b18a89 only fixes a CPU test. All three passed:

  • python op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py
  • python op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4.py
  • python op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py

CI runs multi-GPU tests on other supported hardware.

Logs: test_flydsl_one_shot_allreduce.log · test_flydsl_quick_allreduce_int4.log ·
test_flydsl_quick_allreduce_int4_rmsnorm.log

pytest op_tests/flydsl_tests/test_flydsl_allreduce_policy.py test_flydsl_allreduce_rank_agreement.py test_flydsl_quick_allreduce_codec.py and op_tests/multigpu_tests/test_reuse_identical_rank_groups.py: 175 passed, 3 failed. The 3 test_gpu_reuse_* tests fail with hipIpcGetMemHandle invalid argument. They fail the same way on origin/main on this host, so the failure predates this PR.

End-to-end: DeepSeek-V4-Pro, TP8, 8× MI350P, GSM8K (1319 questions). With INT4 off, the score is identical to stock main (95.22 % for both). With INT4 on, it is −0.34 pp (95 % CI −1.16 … +0.48), which is not significant.

gfx950/xGMI: the policy was tuned on gfx950 hardware. The perf tables are in the PR description.

Unverified:

  • No CI runs the PCIe path (logs from manual run attached), and op_tests/flydsl_tests/ is not in aiter_test.sh.
  • gfx942/xGMI (MI300X) was not rerun at 61f0d7d.

PR-specific question

What permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?

The only CI change adds one path, op_tests/multigpu_tests/flydsl_allreduce_bench.py, to the skip_tests list in .github/scripts/aiter_test.sh. That file is a shared timing helper imported by the two FlyDSL tests, and it has no tests of its own. The multi-GPU job would otherwise run it as a test script, because it runs every *.py file in that directory.

The change has no workflow, trigger, permissions:, secret or runner changes. The script runs in the same test job as before, with the same privileges. The change can only make that job run fewer files, so it gives fork code or PR text no new path to a privileged step.

Changed op tests

  • op_tests/flydsl_tests/test_flydsl_allreduce_policy.py (new, CPU): checks the dispatch tables. Windows don't overlap, dispatch is monotone, each ladder matches its window, and gfx950/xGMI never runs the ring. It also checks that AITER_FLY_AR_* overrides cannot enable an algorithm that has no ladder. The policy table is new, so no existing test covers it.
  • op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py (new, CPU): the init votes on every rank's plan. One skewed rank (env, link, import, window, or size bound) turns FlyDSL off on every rank instead of hanging the others. This is the regression test for the init-hang review finding.
  • op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py (new, 1 GPU): checks the INT4/INT6/fp16 wire codecs without IPC. It tests the analytic error bound, E4M3 scale saturation, and that the LDS memory path matches the register path bit for bit. A bug that hits both sides of the real kernel the same way is invisible in an end-to-end all-reduce test.
  • op_tests/multigpu_tests/flydsl_allreduce_bench.py (new helper, no tests): the shared timing and reporting for the two bench scenarios below, so they use one method. CI skips it (see above).
  • op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py (new): checks the one-shot. Results are bit-exact across ranks, and every production rung is covered. It also covers run-ahead and fresh inputs, production dispatch, a skewed rank, and the first call inside a graph capture. The kernel is new, and test_custom_allreduce.py tests only the HIP kernel.
  • op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4.py (extended): before this PR it had one test. Now it also covers the ring, edge inputs, divisors, pinned codecs, and bit-exact fp16 transport. It adds kernel coverage, production dispatch, a skewed rank, and the first call inside a capture. test_quick_all_reduce.py tests only the HIP QR.
  • op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py (extended): adds hidden 6144, the fused mesh ladder, MXFP4 equality, and the first fused call inside a capture with rmsnorm_hidden. test_quick_all_reduce_rmsnorm.py tests only the HIP kernel.
  • op_tests/multigpu_tests/test_reuse_identical_rank_groups.py (extended): adds three CPU tests of the real CudaCommunicator.destroy(). The owner closes its all-reduce slots exactly once, a borrower doesn't close them, and a second destroy() is a no-op. The slots now hold FlyDSL engines with IPC inboxes, which close() releases. The existing suite stubs the communicator, so it never reached this branch.

Technical Details

Documentation: aiter/ops/flydsl/kernels/comm/README.md.

Kernels (aiter/ops/flydsl/kernels/comm/)

  • one_shot_allreduce.py: exact one-shot push all-reduce. bf16 in and out, fp32 accumulation in a fixed rank order, one bf16 rounding, so the result is bit-identical to an fp32 rank-order sum. The inbox needs no flags: a slot holds a NaN sentinel until the peer's data arrives. Three inbox buffers rotate by colour, so a peer one round ahead never writes the buffer being re-armed.
  • quick_allreduce_int4.py: the two-shot mesh (from [FlyDSL] QRInt4: INT4 two-shot all-reduce for gfx942/gfx950 #4970), moved onto the shared codec and transport. The old kernels/quick_allreduce_int4.py is deleted.
  • quick_allreduce_int4_ring.py: the two-shot ring, with 2(N-1) single-destination hops and a wire format (INT4/INT6) for each lap. At TP8 the reduce-scatter lap defaults to INT6, so the ring stays above the 18 dB SQNR floor. Every rank gets the same bits: the owner decodes its own chunk from the packet it quantized.
  • quick_allreduce_codec.py: the INT4, INT6 and FP16 wire codecs (group-16 E4M3 scales). FP16 makes the transport lossless, which the bit-exact transport tests rely on.
  • allreduce_shared.py: tile geometry, the inbox cache policy, the peer store/load primitives and the shared limits. It also holds the policy definition (Window, FamilyPolicy, the rungs).

Host classes (aiter/ops/flydsl/)

  • OneShotAllReduce (one_shot_allreduce.py): new host class for the one-shot kernel.
  • QuickAllReduceInt4 (quick_allreduce_int4.py): gains algorithm="mesh"|"ring", codecs for each lap, inbox memory modes (uncached / finegrained / auto), and super-tile ladders by payload size.
  • allreduce_host_shared.py: IPC inbox setup and link detection (probe_xgmi_peer_links, which reads the KFD link types). PCIe hosts get a fine-grained inbox at TP4 and TP8, because uncached peer writes are serialized per destination on PCIe. xGMI hosts, and PCIe at TP2, get an uncached inbox.
  • allreduce_policy.py: every tuned decision, at two levels.
    1. Which algorithm. FAMILY_POLICIES has one FamilyPolicy per (arch, link, world_size), with one payload window for each algorithm (one-shot, mesh, and ring). A one-shot window ends where the one-shot starts losing to the existing Aiter all-reduce kernels. The mesh/ring boundary is where the ring overtakes the mesh.
    2. Which configuration. ONESHOT_LADDER, MESH_ST_LADDER and RING_ST_LADDER give the kernel configuration (tunable kernel parameters) for a given payload size.

Production dispatch, opt-in with AITER_FLY_AR=1. With the variable unset (or set to 0), existing Aiter behavior is unchanged.

  • QuickAllReduce runs first. Under AITER_QUICK_REDUCE_QUANTIZATION=INT4, it routes bf16 payloads within the mesh or ring window to the FlyDSL engine. Other payloads go to the HIP quick reduce, or fall through.
  • CustomAllreduce puts the exact one-shot in front of the existing kernels, for plain bf16 payloads in the one-shot window (intersected with AITER_CUSTOM_AR_{MIN,MAX}_SIZE). When quantization is enabled, it only sees the payloads that QuickAllReduce didn't take.
  • Engine construction is a collective operation. Every rank must agree (flydsl_utils.all_ranks_agree), so a failure on one rank disables FlyDSL on all ranks. The binaries that the dispatch can select are compiled at init (preload_fly_engines). close() releases the engines, and CudaCommunicator.destroy() closes the slots it owns.
  • Link detection is host-wide: one xGMI link anywhere classifies the node as xGMI, which assumes a node is either all xGMI or all PCIe. The KFD topology is read first; AITER_FLY_AR_LINK env variables is used as a backup when it can't be read.

Environment variables

Variable Effect
AITER_FLY_AR 1 enables the FlyDSL path; any other value, or unset, disables it.
AITER_FLY_AR_LINK xgmi or pcie. Used only if the KFD topology can't be read. If both fail, FlyDSL is not used.
AITER_FLY_AR_{ONESHOT,MESH,RING}_{MIN,MAX}_BYTES Override the window of each algorithm (6 variables).

The bounds are in bytes: the minimum is inclusive, the maximum exclusive. -1 or empty means dispatching uses the default values. none/inf means no upper limit (for maximums only). A maximum of 0 disables the algorithm. Invalid values are ignored, with a warning. If the mesh and ring windows overlap each other, FlyDSL is disabled, with a warning. The README has the full rules.

Test Plan

The FP16 wire codec makes the transport lossless, so the transport can be checked bit for bit against a reference. The one-shot is exact by construction and is checked against an fp32 rank-order sum.

Single-GPU / CPU (op_tests/flydsl_tests/ - not executed by CI)

  • test_flydsl_allreduce_policy.py: policy table invariants, the ladders inside their windows, env-override semantics, link detection.
  • test_flydsl_quick_allreduce_codec.py: INT4/INT6/FP16 codec round-trips and edge values.

Multi-GPU (op_tests/multigpu_tests/, --scenario verify)

  • test_flydsl_one_shot_allreduce.py (new test suite):
    • an accuracy sweep, bit-identical to the rank-order sum;
    • coverage of every production rung;
    • a run-ahead test (back-to-back calls, rank skew);
    • a fresh-input test (new input each call, including the NaN sentinel value);
    • a production-dispatch test.
  • test_flydsl_quick_allreduce_int4.py (existing test suite):
    • ring tests, and SQNR and cross-rank bit-identity checks for mesh and ring;
    • bit-exact transport tests on the FP16 wire;
    • edge inputs, and a kernel-coverage check against the engine's own selection;
    • a run-ahead test at a payload in each schedule's production window;
    • a production-dispatch test.
  • test_reuse_identical_rank_groups.py: CudaCommunicator.destroy() closes the all-reduce slots it owns.

The default sweeps are trimmed to the kernel configurations that the policy selects in production. Option --extended also runs the configurations that production never selects.

Benchmark (--scenario bench): the same two tests time the FlyDSL kernels against the stock kernels on the same payloads:

  • one-shot vs cdr, cdr_naive and rccl;
  • mesh/ring vs the HIP QR INT4.

The harness, op_tests/multigpu_tests/flydsl_allreduce_bench.py, uses HIP-graph replay, one process and one input for every candidate, and rotated rounds.

Test Results (performance)

FlyDSL runs in the configuration that the policy selects. Timing: a HIP graph of 10 calls, 10 timed replays per sample, the median of 12 rotated rounds, the slowest rank.

  • Decode. The exact FlyDSL one-shot is compared with the fastest stock kernel (always cdr or cdr_naive at these sizes), and with what production runs today (cdr, the kernel the one-shot replaces). At TP4 and TP8, cdr picks its ll kernel for small payloads, which is slow on PCIe.

  • Prefill. The FlyDSL mesh or ring is compared with two baselines:

    1. Aiter's QR INT4 (qr_int4), the like-for-like quantized comparison, which degrades sharply above TP=2 on PCIe.
    2. The fastest exact collective of cdr, cdr_naive and RCCL. These were timed with test_flydsl_one_shot_allreduce.py --scenario bench at the same sizes (with AITER_FLY_AR_ONESHOT_MAX_BYTES=none so the bench builds the one-shot for them). The mesh/ring bench times only the HIP QR INT4.

    SQNR is reported next to latency, because QR INT4 is lossy.

TP=2 (decode)

message size fastest stock kernel its latency (µs) FlyDSL one-shot (µs) speedup production today production (µs) speedup vs production
8 KiB (1×4096) cdr:ll 3.77 3.68 1.02x cdr:ll 3.77 1.02x
14 KiB (1×7168) cdr:ll 3.89 3.81 1.02x cdr:ll 3.89 1.02x
16 KiB (2×4096) cdr:ll 3.90 3.81 1.02x cdr:ll 3.90 1.02x
28 KiB (2×7168) cdr:ll 4.37 4.02 1.09x cdr:ll 4.37 1.09x
32 KiB (4×4096) cdr:ll 4.51 4.09 1.10x cdr:ll 4.51 1.10x
48 KiB (6×4096) cdr:ll 5.15 4.35 1.18x cdr:ll 5.15 1.18x
56 KiB (4×7168) cdr:ll 5.43 4.50 1.21x cdr:ll 5.43 1.21x
64 KiB (8×4096) cdr:ll 5.73 4.66 1.23x cdr:ll 5.73 1.23x
70 KiB (5×7168) cdr:ll128_256 5.57 4.84 1.15x cdr:ll128_256 5.57 1.15x
84 KiB (6×7168) cdr:ll128_256 5.73 5.03 1.14x cdr:ll128_256 5.73 1.14x
112 KiB (8×7168) cdr:ll128_256 6.28 5.62 1.12x cdr:ll128_256 6.28 1.12x
128 KiB (16×4096) cdr:ll128_256 6.56 5.95 1.10x cdr:ll128_256 6.56 1.10x
154 KiB (11×7168) cdr:ll128_256 7.06 6.45 1.10x cdr:ll128_256 7.06 1.10x
168 KiB (12×7168) cdr:ll128_256 7.32 6.71 1.09x cdr:ll128_256 7.32 1.09x

TP=2 (prefill, vs Aiter QR INT4)

message size QR INT4 (µs) QR INT4 SQNR (dB) FlyDSL path FlyDSL (µs) FlyDSL SQNR (dB) speedup
8 MiB (1024×4096) 92.70 18.31 mesh 56.66 20.46 1.64x
14 MiB (1024×7168) 168.7 18.32 mesh 91.19 20.45 1.85x
32 MiB (4096×4096) 345.1 18.32 mesh 186.8 20.45 1.85x
56 MiB (4096×7168) 581.3 18.32 mesh 318.0 20.46 1.83x
64 MiB (4681×7168) 665.0 18.32 mesh 362.8 20.46 1.83x
64 MiB (8192×4096) 665.2 18.32 mesh 362.7 20.46 1.83x
112 MiB (8192×7168) 1154.1 18.32 mesh 629.9 20.46 1.83x

TP=2 (prefill, vs the fastest exact kernel of cdr / cdr_naive / RCCL)

message size fastest exact kernel its latency (µs) FlyDSL path FlyDSL (µs) speedup
8 MiB (1024×4096) rccl 165.9 mesh 56.66 2.93x
14 MiB (1024×7168) rccl 281.2 mesh 91.19 3.08x
32 MiB (4096×4096) rccl 627.4 mesh 186.8 3.36x
56 MiB (4096×7168) rccl 1092.9 mesh 318.0 3.44x
64 MiB (4681×7168) rccl 1233.5 mesh 362.8 3.40x
64 MiB (8192×4096) rccl 1233.6 mesh 362.7 3.40x
112 MiB (8192×7168) rccl 2154.2 mesh 629.9 3.42x

TP=4 (decode)

message size fastest stock kernel its latency (µs) FlyDSL one-shot (µs) speedup production today production (µs) speedup vs production
8 KiB (1×4096) cdr_naive:1stage_naive 8.88 4.18 2.12x cdr:ll 19.35 4.63x
14 KiB (1×7168) cdr_naive:1stage_naive 9.11 4.49 2.03x cdr:ll 31.03 6.92x
16 KiB (2×4096) cdr_naive:1stage_naive 9.48 4.63 2.05x cdr:ll 36.26 7.83x
28 KiB (2×7168) cdr_naive:1stage_naive 10.24 5.50 1.86x cdr:ll 61.45 11.17x
32 KiB (4×4096) cdr_naive:1stage_naive 10.62 5.72 1.86x cdr:ll 69.11 12.07x
48 KiB (6×4096) cdr_naive:1stage_naive 11.87 6.91 1.72x cdr:ll 95.40 13.81x
56 KiB (4×7168) cdr_naive:1stage_naive 12.69 7.77 1.63x cdr:ll 110.0 14.15x
64 KiB (8×4096) cdr_naive:1stage_naive 13.52 8.46 1.60x cdr:ll128_256 60.18 7.11x
70 KiB (5×7168) cdr_naive:1stage_naive 14.15 8.89 1.59x cdr:1stage 22.75 2.56x
84 KiB (6×7168) cdr_naive:1stage_naive 15.63 10.07 1.55x cdr:1stage 26.08 2.59x
112 KiB (8×7168) cdr_naive:1stage_naive 18.87 11.40 1.66x cdr:1stage 31.77 2.79x
128 KiB (16×4096) cdr_naive:1stage_naive 20.84 12.44 1.67x cdr:1stage 35.25 2.83x
154 KiB (11×7168) cdr_naive:1stage_naive 22.83 14.54 1.57x cdr:1stage 41.17 2.83x
168 KiB (12×7168) cdr:2stage 17.80 15.62 1.14x cdr:2stage 17.80 1.14x

TP=4 (prefill, vs Aiter QR INT4)

message size QR INT4 (µs) QR INT4 SQNR (dB) FlyDSL path FlyDSL (µs) FlyDSL SQNR (dB) speedup
8 MiB (1024×4096) 1845.4 18.31 mesh 119.4 19.80 15.45x
14 MiB (1024×7168) 3261.9 18.31 mesh 192.5 19.80 16.94x
32 MiB (4096×4096) 7783.2 18.31 ring 347.9 18.26 22.37x
56 MiB (4096×7168) 13789.8 18.31 ring 571.4 18.26 24.13x
64 MiB (4681×7168) 15805.2 18.31 ring 638.6 18.26 24.75x
64 MiB (8192×4096) 15810.8 18.31 ring 638.6 18.26 24.76x
112 MiB (8192×7168) 28075.1 18.31 ring 1089.1 18.26 25.78x

TP=4 (prefill, vs the fastest exact kernel of cdr / cdr_naive / RCCL)

message size fastest exact kernel its latency (µs) FlyDSL path FlyDSL (µs) speedup
8 MiB (1024×4096) rccl 251.7 mesh 119.4 2.11x
14 MiB (1024×7168) rccl 422.1 mesh 192.5 2.19x
32 MiB (4096×4096) rccl 933.6 ring 347.9 2.68x
56 MiB (4096×7168) rccl 1625.6 ring 571.4 2.84x
64 MiB (4681×7168) rccl 1854.5 ring 638.6 2.90x
64 MiB (8192×4096) rccl 1854.3 ring 638.6 2.90x
112 MiB (8192×7168) rccl 3228.0 ring 1089.1 2.96x

TP=8 (decode)

message size fastest stock kernel its latency (µs) FlyDSL one-shot (µs) speedup production today production (µs) speedup vs production
8 KiB (1×4096) cdr_naive:1stage_naive 12.84 5.43 2.36x cdr:ll 85.36 15.72x
14 KiB (1×7168) cdr_naive:1stage_naive 14.51 6.57 2.21x cdr:ll 153.0 23.27x
16 KiB (2×4096) cdr_naive:1stage_naive 14.78 6.80 2.17x cdr:ll 176.2 25.92x
28 KiB (2×7168) cdr_naive:1stage_naive 20.86 8.85 2.36x cdr:ll 297.3 33.61x
32 KiB (4×4096) cdr_naive:1stage_naive 22.15 9.53 2.32x cdr:ll 338.8 35.54x
48 KiB (6×4096) cdr_naive:1stage_naive 30.28 12.17 2.49x cdr:ll 498.4 40.96x
56 KiB (4×7168) cdr_naive:1stage_naive 34.60 13.49 2.56x cdr:ll 578.1 42.84x
64 KiB (8×4096) cdr_naive:1stage_naive 39.15 14.89 2.63x cdr:ll 659.5 44.30x
70 KiB (5×7168) cdr_naive:1stage_naive 43.12 16.27 2.65x cdr:1stage 137.3 8.44x
84 KiB (6×7168) cdr:2stage 30.27 18.28 1.66x cdr:2stage 30.27 1.66x
112 KiB (8×7168) cdr:2stage 36.04 23.21 1.55x cdr:2stage 36.04 1.55x
128 KiB (16×4096) cdr:2stage 40.12 26.09 1.54x cdr:2stage 40.12 1.54x
154 KiB (11×7168) cdr:2stage 48.40 30.96 1.56x cdr:2stage 48.40 1.56x
168 KiB (12×7168) cdr:2stage 49.39 33.14 1.49x cdr:2stage 49.39 1.49x

TP=8 (prefill, vs Aiter QR INT4)

message size QR INT4 (µs) QR INT4 SQNR (dB) FlyDSL path FlyDSL (µs) FlyDSL SQNR (dB) speedup
8 MiB (1024×4096) 5243.9 18.31 mesh 198.0 19.50 26.49x
14 MiB (1024×7168) 9127.0 18.31 mesh 298.9 19.50 30.54x
32 MiB (4096×4096) 21120.0 18.31 ring 599.4 21.12 35.23x
56 MiB (4096×7168) 37285.9 18.31 ring 917.7 21.12 40.63x
64 MiB (4681×7168) 42633.3 18.31 ring 1021.6 21.12 41.73x
64 MiB (8192×4096) 42703.3 18.31 ring 1022.1 21.12 41.78x
112 MiB (8192×7168) 75465.6 18.31 ring 1771.1 21.12 42.61x

TP=8 (prefill, vs the fastest exact kernel of cdr / cdr_naive / RCCL)

message size fastest exact kernel its latency (µs) FlyDSL path FlyDSL (µs) speedup
8 MiB (1024×4096) cdr_naive:2stage_naive 493.3 mesh 198.0 2.49x
14 MiB (1024×7168) cdr_naive:2stage_naive 813.6 mesh 298.9 2.72x
32 MiB (4096×4096) cdr_naive:2stage_naive 1776.5 ring 599.4 2.96x
56 MiB (4096×7168) cdr:2stage 3043.7 ring 917.7 3.32x
64 MiB (4681×7168) cdr:2stage 3577.2 ring 1021.6 3.50x
64 MiB (8192×4096) cdr:2stage 3567.7 ring 1022.1 3.49x
112 MiB (8192×7168) rccl 7120.7 ring 1771.1 4.02x

Submission Checklist

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]>
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision c3a44c01fa67 · 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

Adds FlyDSL all-reduce kernels behind the existing `CustomAllreduce` and `QuickAllReduce` slots, opt-in with `AITER_FLY_AR=1`: an exact one-shot (bf16), an INT4 quick-reduce (mesh and ring), and a fused INT4 all-reduce + RMSNorm (optionally with an MXFP4 output). A per-platform policy table (`allreduce_policy.py`) chooses the algorithm by arch, link (xGMI or PCIe), world size and payload. Payloads outside a FlyDSL window fall back to the stock path, as before.

Why: on PCIe (MI350P) the stock kernels are slow at all world sizes. The FlyDSL one-shot is 1.5–44× faster at decode sizes, and the INT4 path is 26–43× faster than HIP QR INT4 at prefill sizes (numbers in the PR description). With `AITER_FLY_AR` unset, nothing changes: no engine is built, and dispatch is the same as on `main`.

Validation and unverified scope

8× MI350P (gfx950, PCIe), TP=2/4/8, default `verify` scenario. These ran at `26f2b5e`, and `6b18a89` only fixes a CPU test. All three passed:

- `python op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py`
- `python op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4.py`
- `python op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py`

CI runs multi-GPU tests on other supported hardware.

Logs: [test_flydsl_one_shot_allreduce.log](https://github.com/user-attachments/files/34142356/test_flydsl_one_shot_allreduce.log) · [test_flydsl_quick_allreduce_int4.log](https://github.com/user-attachments/files/34142402/test_flydsl_quick_allreduce_int4.log) · 
[test_flydsl_quick_allreduce_int4_rmsnorm.log](https://github.com/user-attachments/files/34142397/test_flydsl_quick_allreduce_int4_rmsnorm.log)

`pytest op_tests/flydsl_tests/test_flydsl_allreduce_policy.py test_flydsl_allreduce_rank_agreement.py test_flydsl_quick_allreduce_codec.py` and `op_tests/multigpu_tests/test_reuse_identical_rank_groups.py`: 175 passed, 3 failed. The 3 `test_gpu_reuse_*` tests fail with `hipIpcGetMemHandle` invalid argument. They fail the same way on `origin/main` on this host, so the failure predates this PR.

End-to-end: DeepSeek-V4-Pro, TP8, 8× MI350P, GSM8K (1319 questions). With INT4 off, the score is identical to stock `main` (95.22 % for both). With INT4 on, it is −0.34 pp (95 % CI −1.16 … +0.48), which is not significant.

gfx950/xGMI: the policy was tuned on gfx950 hardware. The perf tables are in the PR description.

Unverified:

- No CI runs the PCIe path (logs from manual run attached), and `op_tests/flydsl_tests/` is not in `aiter_test.sh`.
- gfx942/xGMI (MI300X) was not rerun at `61f0d7d`.

PR-specific question

> What permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?

The only CI change adds one path, `op_tests/multigpu_tests/flydsl_allreduce_bench.py`, to the `skip_tests` list in `.github/scripts/aiter_test.sh`. That file is a shared timing helper imported by the two FlyDSL tests, and it has no tests of its own. The multi-GPU job would otherwise run it as a test script, because it runs every `*.py` file in that directory.

The change has no workflow, trigger, `permissions:`, secret or runner changes. The script runs in the same test job as before, with the same privileges. The change can only make that job run fewer files, so it gives fork code or PR text no new path to a privileged step.

Changed op tests

- `op_tests/flydsl_tests/test_flydsl_allreduce_policy.py` (new, CPU): checks the dispatch tables. Windows don't overlap, dispatch is monotone, each ladder matches its window, and gfx950/xGMI never runs the ring. It also checks that `AITER_FLY_AR_*` overrides cannot enable an algorithm that has no ladder. The policy table is new, so no existing test covers it.
- `op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py` (new, CPU): the init votes on every rank's plan. One skewed rank (env, link, import, window, or size bound) turns FlyDSL off on every rank instead of hanging the others. This is the regression test for the init-hang review finding.
- `op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py` (new, 1 GPU): checks the INT4/INT6/fp16 wire codecs without IPC. It tests the analytic error bound, E4M3 scale saturation, and that the LDS memory path matches the register path bit for bit. A bug that hits both sides of the real kernel the same way is invisible in an end-to-end all-reduce test.
- `op_tests/multigpu_tests/flydsl_allreduce_bench.py` (new helper, no tests): the shared timing and reporting for the two `bench` scenarios below, so they use one method. CI skips it (see above).
- `op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py` (new): checks the one-shot. Results are bit-exact across ranks, and every production rung is covered. It also covers run-ahead and fresh inputs, production dispatch, a skewed rank, and the first call inside a graph capture. The kernel is new, and `test_custom_allreduce.py` tests only the HIP kernel.
- `op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4.py` (extended): before this PR it had one test. Now it also covers the ring, edge inputs, divisors, pinned codecs, and bit-exact fp16 transport. It adds kernel coverage, production dispatch, a skewed rank, and the first call inside a capture. `test_quick_all_reduce.py` tests only the HIP QR.
- `op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py` (extended): adds hidden 6144, the fused mesh ladder, MXFP4 equality, and the first fused call inside a capture with `rmsnorm_hidden`. `test_quick_all_reduce_rmsnorm.py` tests only the HIP kernel.
- `op_tests/multigpu_tests/test_reuse_identical_rank_groups.py` (extended): adds three CPU tests of the real `CudaCommunicator.destroy()`. The owner closes its all-reduce slots exactly once, a borrower doesn't close them, and a second `destroy()` is a no-op. The slots now hold FlyDSL engines with IPC inboxes, which `close()` releases. The existing suite stubs the communicator, so it never reached this branch.

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
  • ADVISORY — new op test op_tests/multigpu_tests/flydsl_allreduce_bench.py has no obvious assertion/check in the available patch

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.

@vpietila-amd

Copy link
Copy Markdown
Contributor Author

@zufayu @TennyWang1223 Thanks for the reviews. The new head is 26f2b5e and I've tried to address your findings as much as possible.

# Finding Status Commit
Tenny 1 / zufayu 2 The first launch can be inside graph capture Fixed, also for the fused all-reduce + RMSNorm 93ee607, 52ffba5
Tenny 2 / zufayu 1 Init can hang if ranks disagree Fixed 785ac2d
Tenny 4 / zufayu 3 No gfx950/xGMI data, ring ladder copied from gfx942 Ring ladder removed, TP2 one-shot window narrowed, tuned on gfx950 7da3ee6, 26f2b5e
Tenny 5 No PCIe CI coverage MI350P logs at 26f2b5e attached (manual run, not CI) —
Tenny 3 INT4 at decode sizes, end-to-end accuracy DSv4-Pro TP8 GSM8K on MI350P: no measurable loss. —

1. The first launch is no longer inside graph capture (93ee607)

preload_fly_engines now compiles each served binary and also loads its HIP module, on the engine's device. Before, it only compiled. Every binary that the dispatcher can route to is loaded at init, so the first call does no JIT and no module load, even if it is inside a capture.

  • New helper preload_launcher in aiter/ops/flydsl/allreduce_host_shared.py. It builds the ExecutionEngine of every compiled artifact, which loads the module. OneShotAllReduce.preload and QuickAllReduceInt4.preload uses it.
  • This uses FlyDSL internals (JitFunction._mem_cache and the artifact's ExecutionEngine), because FlyDSL has no public load API. If the FlyDSL internals change, the helper raises. all_ranks_agree then disables FlyDSL on every rank: it does not hang.
  • New tests: test_one_shot_allreduce_first_call_in_capture and test_quick_allreduce_first_call_in_capture. They set up the production communicator with AITER_FLY_AR=1 and make no eager call. They check that every served binary is loaded after init (launcher_loaded), capture the first launch of every served config in one graph, and check that the replays match the reference.

The fused all-reduce + RMSNorm has the same guarantee (52ffba5). QuickAllReduceInt4.allreduce_rmsnorm and allreduce_rmsnorm_mxfp4 run their own binaries, and before this change the first fused call compiled one of them. Unlike the plain all-reduce, whose binaries take the payload size at runtime, a fused binary is specialized on the row width.

  • The caller declares its row widths in the constructor: QuickAllReduceInt4(..., rmsnorm_hidden=(8192,)). The constructor, builds the fused engines, and compiles and loads every fused binary that each width can select: gemma_norm on and off, MXFP4 on and off (gfx950), and the low-latency and occupancy-pinned builds. It launches none of them. compile_rmsnorm(hidden) does the same after construction.
  • A fused call at a width that was never prepared raises under capture - no change to the existing behaviour at main.
  • New test, in test_flydsl_quick_allreduce_int4_rmsnorm.py: the constructor gets rmsnorm_hidden, and there is no eager fused call. It checks that every fused binary is loaded after init, captures the first call of every fused binary of the width in one graph, and checks the replays against an fp32 reference.

2. Ranks agree before they build any engine (785ac2d)

Each rank first computes a plan locally: flydsl version, arch, link, world size, the policy after the AITER_FLY_AR_* overrides, and the payload range that the AITER_CUSTOM_AR_{MIN,MAX}_SIZE bounds give (one-shot) or the quantization regime and codecs (quick-reduce). If a rank declines, the plan provides the reason. The ranks exchange their plans in one all_gather_object on the CPU group (flydsl_utils.all_ranks_agree_on_plan) before any engine collective. They build only if all plans are the same.

  • Every check that can differ between ranks (import, AITER_FLY_AR, arch, link detection, policy lookup) is now inside the plan.
  • Every rank that reaches the FlyDSL init votes. A rank that declines alone cannot leave its peers waiting.
  • New CPU test op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py: all ranks match, FlyDSL off on all ranks, and the last rank differing in one input: AITER_FLY_AR, link, flydsl import, the window override, and AITER_CUSTOM_AR_MAX_SIZE (one-shot) or AITER_QUICK_REDUCE_QUANTIZATION (quick-reduce). New GPU tests test_one_shot_allreduce_dispatch_skewed_rank and test_quick_allreduce_dispatch_skewed_rank turn FlyDSL off on one rank and check that every rank finishes init with FlyDSL off.

3. gfx950/xGMI (7da3ee6, plus data)

Each ladder table now has a row only where the policy table enables that algorithm. An AITER_FLY_AR_<ALG>_{MIN,MAX}_BYTES override can no longer enable an algorithm that has no tuned ladder for the platform: the override is ignored with a warning. So gfx950/xGMI runs only the one-shot and the mesh, and both were tuned on gfx950. The PR description has the updated numbers.

4. PCIe (MI350P)

8× MI350P (gfx950, PCIe) at 26f2b5e, TP=2/4/8. All checks pass:

  • One-shot: bit-identical to the reference for every shape. Every production rung is covered. Run-ahead and fresh-input checks: 0 mismatches.
  • Quick-reduce INT4: SQNR 18.3–21.1 dB, all ranks bit-identical, the fp16-wire transport is bit-exact. Every production kernel is covered.
  • Fused AR + RMSNorm: output SQNR 37.3 / 33.9 / 30.8 dB (TP2/4/8), identical to the unfused path, and MXFP4 matches.
  • Rank agreement: with one rank skewed, all ranks finish init with FlyDSL off.
  • First call in capture: 0 unloaded binaries, and the replays match the reference (plain and fused, hidden 4096 and 6144).

Logs: test_flydsl_one_shot_allreduce.log · test_flydsl_quick_allreduce_int4.log ·
test_flydsl_quick_allreduce_int4_rmsnorm.log

5. INT4 at decode sizes (Tenny 3)

DeepSeek-V4-Pro, TP8 on 8× MI350P, GSM8K (all 1319 questions, 5-shot, greedy). The reference is stock Aiter main. DeepSeek V4 has hidden dim h=7168, which means 14KiB per token.
For GSM8K suite, this will exercise the decode path of the shipped INT4 quick-reduce.

DeepSeek-V4-Pro-Base has GSM8K score of 92.6 % (exact match, 8-shot) according to the Base Model table of the
DeepSeek-V4-Pro model card

Arm strict-match
base: stock Aiter main 95.22 % (1256)
exact: this PR, INT4 off 95.22 % (1256)
flyqr: this PR, INT4 on (≥ 96 KiB) 94.77 % (1249)
flyqr_floor: this PR, INT4 only ≥ 8 MiB 94.54 % (1246)
  • With INT4 off, the score is identical to main.
  • The 8 MiB floor for run flyqr_floor was chosen based on the existing HIP QRInt4 floor.
  • With INT4 on, the paired difference is −0.34 pp, so no measurable loss. Keeping decode-sized payloads exact (flyqr_floor) does not change accuracy (beoynd noise).
  • INT4 does flip more individual answers, with no net loss. No garbage output was observed.

vpietila-amd added a commit that referenced this pull request Oct 30, 2026
…sed QR RMSNorm, gfx950/xGMI retune)

Ported:
- FAMILY_POLICIES gfx950/xGMI TP2 one-shot window 64 MiB -> 4 MiB.
- MESH_ST_LADDER gfx950/xGMI retune (one b256 rung per TP).
- Policy test import fix (strict CustomAllreduce is_weak_contiguous).
- main: Gluon gfx1250 fused AR+RMSNorm hooks in communicator_cuda.

Superseded by this branch's fused design, not ported:
- QuickAllReduceInt4 fused RMSNorm (rmsnorm_hidden, compile_rmsnorm,
  runtime eps, MESH_NORM_LADDER): replaced by FlyQuickAllReduceRMSNorm,
  whose eps is already a launch argument, whose widths are prepared by
  FlyDSLAllReduceRMSNorm (hiddens / AITER_FLY_AR_FUSED_HIDDENS / prime),
  and whose ladders come from fused_allreduce_ladders.json.
- #6404 12-atom tiles for hidden 6144: the row-block geometry builds 6144
  natively (block 768) at TP2/4/8, and rows are addressed per row in i64.
- quick_allreduce_int4.py kernel/host and its RMSNorm test: deleted here.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@zufayu

zufayu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@TennyWang1223 The CI is green and the PR is mergeable. As the primary reviewer, could you please confirm whether this is ready to merge?

@zufayu
zufayu merged commit 8f1d6bd into main Nov 4, 2026
34 of 35 checks passed
eppaneamd added a commit that referenced this pull request Nov 4, 2026
Conflict resolution only. Upstream #5461 moved the FlyDSL INT4 quick all-reduce
kernel to kernels/comm/ and rewrote the host class, so this takes main's host
file and accepts the deletion of kernels/quick_allreduce_int4.py. The
reduce-scatter / all-gather modes are not on the tree after this commit (the
new op test does not run here); the next commit ports them onto main's mesh
kernel.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
eppaneamd added a commit that referenced this pull request Nov 4, 2026
…odes onto the #5461 mesh kernel

Re-apply the sequence-parallel modes of this PR on the kernel and host that
#5461 rewrote (per-rank binaries, peers-only publish/wait, runtime n_blocks,
inbox memory modes, engines keyed by (super_tile, block)) and on the E5M2 group
scale of #7258.

Kernel (kernels/comm/quick_allreduce_int4.py): make_quick_allreduce_int4_kernel
takes mode="ar" | "rs" | "ag". "rs" and "ag" run one phase of the INT4 mesh on
its own, for super_tile=1, the 8-atom tile and no fused norm. Rank d owns a
contiguous block of N / world_size bytes; the tile machinery is unchanged and
only the HBM address of an atom moves, through a full / shard layout local to the
mesh kernel (_sp_payload_io) with the runtime n_blocks stride. Both modes send
through the all-gather slots and start every round with a payload-free `ready`
flag, since a single phase has no second-phase guard against inbox reuse.
Unlike the all-reduce, which adds its own share from registers, "rs" quantizes
this rank's own partial through the codec and accumulates every rank in rank
order with the same dequant, so a row's value does not depend on which rank owns
it. The JIT symbol gets an `_rs` / `_ag` suffix and the single-phase builds pin
waves_per_eu to the plain kernel's residency.

Host (quick_allreduce_int4.py): reduce_scatter(inp, out), all_gather(inp, out)
and compile_sp(full, shard). They run on the super_tile=1 engine at the default
block (shared inbox and colors) and raise for the ring, an inbox other than
"uncached", or a ladder without that engine. There is no min_bytes floor.
compile_sp now loads both builds with preload_launcher like preload: it checks
the shapes, launches nothing and overwrites nothing, and takes no stream. A
single-phase launch under CUDA graph capture raises unless its build is loaded.
check_tensors is split out of check_payload (same behaviour and signature) for
the pair check.

README documents the modes. The op test imports from kernels.comm and builds its
engine from a one-rung ladder instead of super_tile / grid_cap.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Rony Leppänen <[email protected]>
Boss2002n pushed a commit that referenced this pull request Nov 5, 2026
Resolve the conflict in custom_all_reduce.py by keeping both
_fits_custom_ar_size (this branch) and _should_fly_oneshot (main, #5461).

Port test_flydsl_allreduce_rank_agreement.py from the removed
_resolve_car_max_size to _resolve_custom_sizes(...).ar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpietila-amd added a commit that referenced this pull request Nov 5, 2026
Merged with c3a44c0 (the tip of the already squash-merged #5461 branch) as
the merge base, so only the fused branch's own commits are compared against
main. Resolutions:
- Port #7258 (E5M2 group scale, RS_INT6_MIN_WORLD=4, SCALE_CODEC_TAG) into the
  renamed quick_allreduce{,_mesh,_ring}.py, test_flydsl_quick_allreduce.py and
  allreduce_policy.py.
- Keep both test entries in .github/scripts/split_tests.sh.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
amd-sriram added a commit to amd-sriram/vllm that referenced this pull request Nov 9, 2026
ROCm/aiter#5461 replaced QuickAllReduceInt4.compile(inp, out) with
preload(). AITER v0.1.28.post1 has it, and vLLM's INT4 QuickReduce init
still calls compile(), so with VLLM_ROCM_USE_AITER=1 and
VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=INT4 every worker dies at start-up
with AttributeError. Keep compile() when the class has it; otherwise
call preload() and run one warm-up all-reduce, as compile() did.

Adds a two-GPU test that builds the FlyDSL INT4 QuickReduce and runs a
BF16 all-reduce on it.

Signed-off-by: Sriram Kumar <[email protected]>
amd-sriram added a commit to amd-sriram/vllm that referenced this pull request Nov 9, 2026
ROCm/aiter#5461 replaced QuickAllReduceInt4.compile(inp, out) with
preload(). AITER v0.1.28.post1 has it, and vLLM's INT4 QuickReduce init
still calls compile(), so with VLLM_ROCM_USE_AITER=1 and
VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=INT4 every worker dies at start-up
with AttributeError. Keep compile() when the class has it; otherwise
call preload() and run one warm-up all-reduce, as compile() did.

Adds a two-GPU test that builds the FlyDSL INT4 QuickReduce and runs a
BF16 all-reduce on it.

Signed-off-by: Sriram Kumar <[email protected]>
amd-sriram added a commit to amd-sriram/vllm that referenced this pull request Nov 9, 2026
ROCm/aiter#5461 replaced QuickAllReduceInt4.compile(inp, out) with
preload(). AITER v0.1.28.post1 has it, and vLLM's INT4 QuickReduce init
still calls compile(), so with VLLM_ROCM_USE_AITER=1 and
VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=INT4 every worker dies at start-up
with AttributeError. Keep compile() when the class has it; otherwise
call preload() and run one warm-up all-reduce, as compile() did.

Adds a two-GPU test that builds the FlyDSL INT4 QuickReduce and runs a
BF16 all-reduce on it.

Signed-off-by: Sriram Kumar <[email protected]>
Co-authored-by: Rony Leppänen <[email protected]>
TennyWang1223 pushed a commit that referenced this pull request Nov 17, 2026
* Land INT4 quad-fanout QR in aiter FlyDSL ops with a TP8 correctness test.

* Use layout views for LDS pack and ST inbox without regressing ST=8 wall.

Drop unused wave-join and single-wave fanout compiles; default and test the fp16 codec.

* Stop QR INT4 tests and host from mutating COMPILE_ONLY.

Compile-only and cache warming belong in developer scripts, not pytest or QRInt4QuadFanout.compile.

Co-authored-by: Cursor <[email protected]>

* Model local HBM payload as FlyDSL views; keep remote NT stores explicit.

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.

* New QR kernel/host/test files should use aiter MIT + AMD 2026 only; they were not FlyDSL-main originals.

* Drop the quad_fanout variant suffix from the only INT4 QuickReduce pipeline so the public API is QRInt4.

* Default QRInt4 to ST=8 and keep only ST∈{1,8} so the host matches the measured keeper; drop unused codec/force_super/bf16 ALU and qr_int4_mem, compiling via flyc.compile.

Co-authored-by: Cursor <[email protected]>

* Skip color 0 after wrap so it never matches the unset sentinel (HIP QR does the same), and time QRInt4 with run_perftest.

* Compile QRInt4 WORLD∈{2,4,8} via HIP-style kRankAtoms so TP4/TP2 work; WORLD=8 stays kRankAtoms=1.

Co-authored-by: Cursor <[email protected]>

* IPC helper is a FlyDSL copy so keep Apache-2.0 copyright 2025; match aiter vendored dual header.

Co-authored-by: Cursor <[email protected]>

* Replace QR INT4 packed-math inline asm with native FlyDSL f16x2 ops.

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.

* Spell out QR INT4 RS/AG and lower the flag wait as a Python while.

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

* Reduce torch surface in qrint4 kernel

* Join ST sub-tiles before LDS reuse and tighten QRInt4 host checks.

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

* Assert QRInt4 SQNR on every rank.

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

* Apply suggestions from ruff

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Match black wrapping and apply small Copilot host/test guards.

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

* Enable gfx950 FlyDSL QRInt4 with configurable grid cap.

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

* Run black on qr_int4_kernel.py after merging main.

* Reject NCCL and multi-node groups in QRInt4 with explicit errors.

IPC inbox setup needs CPU broadcast_object_list and node-local HIP IPC
handles. Fail fast before allocating buffers, matching QuickAllReduce.

* Shorten QRInt4 process-group rejection messages.

Co-authored-by: Cursor <[email protected]>

* Fix QR INT4 launch safety and validation

Clamp persistent grids to conservative residency limits, harden resource cleanup, and validate lossy collective results across ranks.

Co-authored-by: Cursor <[email protected]>

* Address QR INT4 review feedback

Co-authored-by: samremes <[email protected]>

* Apply Black formatting after merging origin/main.

Fix CI Black failures in qr_int4_kernel.py and test_flydsl_qr_int4.py.

Co-authored-by: Cursor <[email protected]>

* Fix QR INT4 E4M3 boundary encoding

* Reject >32bit offset

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Add automatic QRInt4 cleanup

* Avoid QRInt4 AOT import cycle

* Harden QRInt4 validation and test collection

* Fix QR INT4 E4M3 reserved-zero underflow after exponent clamp.

Reserve byte 0x00 for true +0 only after packing so clamped positive scales cannot collapse, and add TP2 fill cases for underflow, overflow, and zero.

Co-authored-by: Cursor <[email protected]>

* Drop duplicate QRInt4 lazy-import key after merging main.

Co-authored-by: Cursor <[email protected]>

* Spawn QRInt4 test ranks instead of re-entering the file with --rank.

Match HIP QR: Pool + spawn, return row dicts, keep argparse on main() only. Drop PYTHONPATH/arch env overrides and out.zero_(); time spawn workers with cuda.Event.

Co-authored-by: Cursor <[email protected]>

* Make QRInt4 test comments self-contained.

State what each threshold, fill, and CLI flag does today, and record why the
spawn ranks must time with cuda events instead of the profiler timer.

Co-authored-by: Cursor <[email protected]>

* Resolve the QRInt4 device index before set_device.

torch.cuda.set_device rejects torch.device("cuda") without an index, so the
current-device fallback in _cuda_index was unreachable. Resolve the index
first, select that integer, and keep self.device as the resolved cuda:N.

Co-authored-by: Cursor <[email protected]>

* Rename FlyDSL QR INT4 to QuickAllReduceInt4 and drop leftover globals/asm.

Move host and IPC out of kernels/, export QuickAllReduceInt4 only, and keep
module constants that actually couple host tile math, LDS, and codec layout.
Use fx.min, llvm.StoreOp(nontemporal=True) for NT fanout, llvm.amdgcn.s.setreg
for FP16_OVFL, and inline readfirstlane at the inbox descriptor.

Leave buffer_inv sc1 as inline asm: the flag poll is a non-atomic sc1
buffer_load (L2 bypass, not L1), so the miss path still needs an L1
invalidate, and llvm.amdgcn.buffer.wbinvl1.sc cannot select on gfx942/gfx950.

* Format QuickAllReduceInt4 host and tests with ruff and black.

* Move FlyDSL QR INT4 tests to multigpu_tests and fix HIP alloc rounding.

Collect the suite with the 8-GPU job instead of single-GPU op_tests.
Round uncached HIP mallocs to 4 KiB so small grid_cap inboxes still
export, and feed MODE setreg through as_ir_value instead of fx.arith.

* [FlyDSL] Extract quick-allreduce transport and codec into shared modules

The ring and one-shot schedules that follow need the same tile geometry,
inbox cache policy, peer store/load primitives and wire codec that the
mesh kernel had inlined. Split them out so all three agree byte for byte
rather than carrying three copies of the same magic numbers:

  quick_allreduce_shared  geometry, _INBOX_POLICY, peer store/load, LDS
  quick_allreduce_codec   INT4/INT6/FP16 wire formats and the E4M3 scale

The mesh kernel becomes codec- and inbox-policy-generic as a result, and
is renamed to match its new module. Two behavioural changes ride along.

Fix the buffer cache-modifier encoding. These are LLVM CPol bits, which
the backend renames for CDNA: bit 0 (GLC) prints as `sc0`, bit 1 (SLC) as
`nt`, bit 4 (SCC) as `sc1`; bit 2 exists in the encoding but CDNA has no
use for it and it emits nothing. The previous values were 4 for "NT" and
2 for "sc1", so the payload load carried no cache hint at all and the
flag spin load got `nt` instead of bypassing L2 -- a spin that can be
answered from a stale line. They are now 2 and `sc0 | sc1`.

Make the flag spin load bypass L1 as well. `sc1` alone only bypasses L2;
`sc0 sc1` is what LLVM emits for a system-scope load and is what lets the
retry loop run without a fence in its body.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add inbox memory modes, codec selection and an ST ladder to the host

The uncached IPC inbox the host has always allocated is right on xGMI and
catastrophic on PCIe: peer writes into uncached memory serialize per
destination, so throughput collapses as the fanout widens (MI350P, INT4
mesh: 55 GB/s to one peer, 4.45 to two, 1.44 to three, against 33.5
fine-grained). Give the host an `inbox_memory` knob over the kernel's
existing cache-policy table, defaulting to "auto", which reads the real
per-peer link type out of KFD rather than guessing from the arch string
-- MI350X and MI350P both report gfx950 and want opposite answers.

With a cacheable inbox a publish costs an L2 writeback, so the super-tile
that was a fixed constructor argument becomes a payload-size ladder:
`_pick_st` selects a rung, `_grid_x` hands each block a whole super-tile
so the batching is real, and `_MIN_BATCH_BLOCKS` stops it trading the
whole machine away at small sizes (MI350P, 32x7168, TP4: 61.95 us
unbounded against 23.98 with the grid left alone).

Also adds `rs_codec`/`ag_codec` with an AITER_ALL_REDUCE_CODEC override,
`min_bytes` gating with `is_beneficial`, `variant()` for reporting which
binary a size actually runs, and `has_xgmi_peer_links` for the dispatcher.

The IPC heap grows a device check on every allocation. Several
byte-identical copies of libamdhip64 are typically mapped into one
process and they do not share device state, so the first one resolved by
soname can allocate on the wrong GPU -- every peer write then crosses to
the wrong device. Pick the mapped copy that reports torch's bound device,
and assert the allocation landed where it was meant to.

The page rounding hipIpcGetMemHandle needs moves from alloc_uncached to
alloc, which is where the inbox is now allocated from.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add the ring schedule for quick-allreduce

The mesh writes to every one of the N-1 peers on both laps. On a PCIe
host a GPU has one shared x16 uplink, so those interleaved destinations
contend for it; the ring instead makes every step a single contiguous run
into exactly one peer's inbox. Same wire volume -- 2(N-1)/N of the
payload, which is bandwidth optimal (Patarasuk & Yuan, JPDC 69(2), 2009)
-- traded for per-destination locality, over 2(N-1) hops instead of two.

The ring pays for that in accuracy: its reduce-scatter lap requantizes
the running partial N-1 times where the mesh requantizes once, and the
partial's extremum grows with the contributions folded in. Hence the
per-lap codec knobs -- the reduce-scatter lap widens to INT6 at TP8 to
hold the 18 dB SQNR floor, while the all-gather lap forwards received
bytes untouched and stays INT4.

Registered as algorithm="ring" alongside the mesh, with its own
super-tile set (1, 8, 16, 32) and payload-size ladder. It is not the
default and is structurally worse at decode sizes and on xGMI; the
dispatcher that follows picks between them.

clamp_grid_cap now falls back to the smallest measurement for a world
size when a super-tile is not in the residency table, instead of raising:
the table was measured on the mesh and does not cover ST=16 or ST=32.
Under-launching a persistent kernel is always safe, so the fallback errs
small; an unknown arch or world size still raises.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add the exact one-shot all-reduce and the schedule policy table

Both quantized schedules are two-shot, so their latency floor is two
serialized fabric traversals plus a grid-wide handshake between the laps.
At decode sizes that floor dominates and the quantization buys nothing --
the collective is not the bottleneck there, and INT4 charges ~36 dB of
SQNR for microseconds.

OneShotAllReduce is the decode-regime answer: one round, no grid-wide
barrier, bf16 in, fp32 accumulate, bf16 out, no codec. Each rank pushes
its whole tile into every peer's inbox, publishes a colour flag, waits
for N flags, then reduces N copies out of its own inbox. That trades wire
volume for round trips -- (N-1)*S pushed against a two-shot's 2(N-1)/N*S
-- so where it stops paying is a function of N, which is what max_bytes
gates on. It needs no LDS: thread t's 16 B lands at the same offset in
every destination, so it pushes straight from registers.

It reuses the IPC inbox, peer table and cache-policy table from the
quantized schedules verbatim, which is what the shared transport module
was extracted for.

allreduce_policy holds the size boundaries between the three families,
per (link, world_size), fitted from measurement. It is a pure table plus
env overrides -- no kernels, no torch -- so the dispatcher and the hosts
can both read it without an import cycle. Accuracy defaults to "exact",
which makes the quantized families unreachable until a caller opts in
with AITER_FLY_AR_ACCURACY=fast.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Dispatch the FlyDSL all-reduce family from CudaCommunicator

FlyDSLAllReduce owns one engine per reachable schedule and routes a
payload to the family allreduce_policy picks for its size, link type and
world size. CudaCommunicator consults it ahead of quick-reduce and custom
all-reduce.

It leads the chain because, at the default AITER_FLY_AR_ACCURACY=exact,
the only reachable family is the exact one-shot -- fp32 accumulate, one
bf16 rounding, comparable with cross_device_reduce rather than quantized
-- and it declines every payload above that ceiling, so the caller falls
through unchanged. AITER_FLY_AR_ACCURACY=fast unlocks the quantized
mesh/ring for larger payloads.

The whole path is opt-in: with AITER_FLY_AR unset the dispatcher
disables itself in its constructor and the chain is exactly as before.
Every unsupported condition -- no flydsl, wrong arch, NCCL group,
multi-node group, unsupported world size -- is an early return that
leaves `disabled` set, and should_fly_all_reduce is a pure predicate that
answers False rather than raising.

A communicator built with reuse_from borrows the engine rather than
owning it, so destroy() only closes the IPC inboxes on the group that
built them.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add codec, policy and one-shot all-reduce tests

test_flydsl_allreduce_policy is CPU-only: it checks that the family
boundaries partition by size, that the ladders are ascending and reach
every super-tile they name, and that the env overrides apply where the
tables say they do.

test_flydsl_quick_allreduce_codec runs on a single GPU with no IPC, so it
covers the wire formats in isolation from the transport: INT4/INT6/FP16
round-trips, the E4M3 scale at both ends of its range, and the codec
resolution rules.

Two of its cases move with the E4M3 fixes rather than against them. They
were written against an encoder that saturated the exponent field alone,
so 512 encoded as 256 and an outlier decoded *smaller* than the ceiling
it passed; and against one where a positive extremum small enough to
encode as 0x00 collided with the reserved-zero byte and took its whole
group to zero at 1e-3. Both now assert the fixed behaviour -- monotonic
saturation past the ceiling, and a sub-floor extremum that rounds
coarsely instead of vanishing -- plus that exact zero still encodes as
exact zero.

test_flydsl_one_shot_allreduce spawns real ranks and checks the one-shot
is bit-identical to a torch all-reduce, not merely close, at TP2/4/8. It
lives in multigpu_tests because it needs more than one GPU.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Cover both schedules and the transport in the INT4 all-reduce test

The test gated only on SQNR, which cannot tell a transport bug from a
codec one: a chunk-addressing or flag-protocol fault and a codec
regression both show up as a worse number. Run the same cases over the
fp16 passthrough wire format, where the whole reduce is lossless on an
exact-grid input, and gate those on bit-identity with the fp32 reference
instead. A ring variant with one lap fp16 and the other int4 names which
lap is responsible when only one of them is.

Every case now runs on both the mesh and the ring. The ring's
reduce-scatter lap requantizes N-1 times where the mesh requantizes once,
so its SQNR falls with N -- 22.2 dB at TP2, 18.7 at TP4, ~15 at TP8
all-INT4. Defaulting that lap to INT6 at TP8 lifts it to ~21 dB, so one
18 dB floor now covers both schedules; the all-INT4 TP8 configuration is
still reachable through AITER_ALL_REDUCE_CODEC and keeps its own case at
the floor it actually delivers.

Cases that share a (world_size, algorithm, super_tile) group now ride a
single spawn and are memoized for the session. _run_rank already looped
over a list of shapes; this just stops calling it with one-element lists,
which is most of the wall time back on a file that is now 46 cases.

Adds a degenerate-input case (all-zero and far-sub-floor groups) that
pins the encode-reciprocal clamp: a zero extremum decodes to a zero
scale, and before the clamp that reached the codec as Inf and 0 * Inf
poisoned the whole tile. INT6 has four times less headroom there than
INT4, so it is the schedule that needs it.

The predicted super-tile now compares against the engine's clamped ST=1
grid rather than the requested grid_cap, which is what the host's own
selection compares against.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add the all-reduce benchmark, roofline and policy-fitting scripts

bench_comm_allreduce sweeps every all-reduce candidate available on the
host -- RCCL, custom all-reduce, HIP quick-reduce, and the three FlyDSL
schedules -- over a shape list, on one process group, and reports
latency, achieved bandwidth and SQNR per candidate. Candidates that
cannot run a given shape are reported as declined rather than silently
skipped, so a sweep says which alternatives a winner actually beat.

transferbench_roofline turns a TransferBench point-to-point measurement
into a per-schedule lower bound: each family's wire volume as a function
of payload and world size, divided by the measured fabric rate. That is
what separates "this kernel is slow" from "this kernel is at the wire".

fit_allreduce_policy consumes a sweep and emits the family boundaries in
allreduce_policy's format, so the tables there are reproducible from
measurement rather than hand-maintained.

The shapes/ CSVs are the sweep lists the current policy tables were
fitted from: a small and a large payload sweep, and one that holds the
payload fixed while varying hidden to separate size effects from shape
effects.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Improve benchmarking script to run in fast mode by default.

* Fixed heuristics for the exact mode.

* Fix bugs in the benchmarking script.

* Update heuristics for xGMI interconnect.

* Fix classification of FlyDSL auto-deducted kernel in benchmarking script.

* Remove unintended Git modules.

* Add two new tuning knobs: workgroup size and ability to read ranks own contribution from registers instead of IPC inbox (self-skip).

* Update PCIe heuristics.

* Refactor FlyDSL all-rduce kernels integration to comms dispatcher.

* [FlyDSL] Scope OneShotAllReduce to its device instead of set_device

Mirrors what #4970 did for QuickAllReduceInt4: construction, launch and close
run under torch.cuda.device(), so building the engine no longer changes the
caller's current device.

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

* [FlyDSL] Address agent review feedback on the all-reduce dispatch

- Add a GPU-free regression test for the P1 finding: both FlyDSL selectors
  must decline a weakly- but not strictly-contiguous tensor (a full-storage
  transpose) instead of letting the engine raise after dispatch committed.
- Document the host-wide xGMI detection and the uniform-node assumption it
  relies on (P3).
- Drop a stray argument from the quick-reduce FlyDSL init log call; it had
  one more argument than placeholders.
- Re-run black (trailing whitespace, assert formatting back to main's) and
  suppress SIM102 on a const_expr guard, matching the other FlyDSL kernels.

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

* [FlyDSL] Move all-reduce tooling out of the multi-GPU test directory

The multi-GPU CI job runs every .py under op_tests/multigpu_tests/ as a
script, so tooling there ran as tests: fit_allreduce_policy.py failed on its
required argument and bench_comm_allreduce.py ran a full sweep.

- Remove fit_allreduce_policy.py and the sweep shape CSVs it was fed.
- Move bench_comm_allreduce.py and transferbench_roofline.py to
  op_tests/op_benchmarks/flydsl/, which CI does not execute, and update
  their usage text. --shape-csv stays as a user option.

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

* Remove fragile tests. Refactor multi-GPU tests for all-reduce to follow Aiter testing guidelines. Add the full kernel information to human readable kernel name.

* Black and ruff fixes. Improve comments about the use of CUDA events in the FluyDSL all-reduce tests.

* Add self-skip and block tunign knobs to two-steage mesh all-reduce.

* Use fx.generic_load, fx.generic_store, and fx.memory_fence to replace the inline ASM.

* Use system scope memory fence for releasing inboxes.

* Use uncached memory on PCIe when world size is two.

* Update aiter/ops/flydsl/kernels/quick_allreduce_int4.py

Address GitHub bot feedback.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Remove probe from 1-stage kernel.

* Remove the legacy buffer_ops.buffer_load and buffer_ops.buffer_store. Extract shared layout definition. Clen-up code.

* Ensure communicator initialization only compiles the relevant all-reduce instances.

* Trim the test suite for one-shot and quick all-reduce kernels.

* Collect shared all-reduce host wrapper assets to a shared module.

* Heuristics for xGMI interconnect.

* Update PCIe heuristics after the latest run.

* Add more cases to the benchmarking script.

* Addres black and ruff findings.

* Remove the custom logic for loading the HIP runtime library.

* Optimize memory fences for PCIe TP=2 case when uncached IPC memory is used.

* Fix a wrap-around bug in one-shot all-reduce.

* Improve benchmarking script such that it doesn't have bias towards FlyDSL instances.

* Optimized syncscope for xGMI interconnect.

* Update PCIe heuristics for TP=2 and for TP=4.

* Update xGMI heuristics. Introduce an env variable to override the min message size for FlyDSL one-stage all-reduce.

* Use _preload_compiled from TensorShim to run JIT compilation outside HIP graph capture.

* Black and ruff fixes.

* Add a Lamport (flagless) variant of the FlyDSL one-shot all-reduce.

The payload is its own flag: inbox slots hold a sentinel (bf16 NaN 0xFFFF in
every half-word) until a peer's data lands, the receiver polls all of its
sources together until no half-word is the sentinel, then re-arms the slot
two rounds ahead in a 3-buffer rotation. Senders rewrite a sentinel
half-word in their own payload to 0x7FFF, which is still NaN. That removes
the vmcnt(0) drain, both barriers and the flag round trip from every tile.

- kernel: `lamport` const_expr in make_one_shot_allreduce_kernel; uncached
  inbox only. The poll re-reads through relaxed system-scope atomics
  (_poll_v4i32) so the spin cannot be deleted. The first tile is peeled so
  its input load overlaps the colour load.
- IPC: UncachedIpcHeap.alloc takes a fill byte and synchronizes after the
  memset, so a late fill cannot erase a peer's first push.
- host: `lamport` is the 7th ONESHOT_LADDER field and an OneShotAllReduce
  knob; AITER_FLY_AR_ONESHOT_LAMPORT=0|1 pins it from the environment.
  Every shipped rung keeps lamport=False in this commit.
- tests: --lamport knob, Lamport spot configs at TP2/TP8, and a 300-call
  fresh-input stress checked bit for bit against a rank-order reference.
- bench: fly_1stage_lp and _lp variants of the pinned fly1s grid.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Ship the Lamport one-shot on xGMI and drop the one-shot floors there.

Sweep on 8x MI325X (gfx942), graph timing. Best Lamport config vs the flag
one-shot: TP2 -3..-23%, TP4 -3..-14%, TP8 -19..-41%. It ties or beats
cross_device_reduce down to 2 KiB at every world size, so the xGMI
min_bytes floors (56/48/112 KiB) go to 0.

ONESHOT_LADDER xGMI, all skip_self + lamport, atoms=1, cap 128:
  TP2  b128 to 256 KiB (one round), then b256
  TP4  b256
  TP8  b128

PCIe rungs stay on the flag variant (not measured).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Make Lamport all-reduce the default and add heuristics.

* Make self-skip default on one-shot and two-shot mesh algorithms. Redeuce the number of benchmarked configurations.

* Remove redundant/obsolete instances from benchmarking.

* Transferbench roofline fixes.

* Clean-up TransferBench runner script.

* Benchmarking script fixes.

* Move FlyDSL communication kernels into a single directory.

* Black & ruff fixes.

* Address first part of the code review feedback.

* Remove separate benchmarking scripts.

* Expand test scripts to run the benchmarking.

* Add gfx950/xGMI all-reduce policy rows; never pick the ring there.

The FlyDSL family policy was measured on gfx942 for xGMI. On gfx950/xGMI
(MI355X) the bench scenario of the all-reduce op tests shows:

* The ring never beats the mesh: 1.03x-1.16x slower at TP2 up to 512 MiB,
  2.2x-5.7x slower at TP4/TP8. The 128 MiB mesh_max sent large payloads to
  it; mesh_max is now unbounded there.
* cross_device_reduce's 2-stage kernel beats both the one-shot and the
  mesh over a wide middle range at TP4/TP8, so the one-shot ceiling drops to
  cdr's 2-stage switch and the mesh floor rises to where the mesh overtakes
  cdr (960 KiB at TP4, 1600 KiB at TP8). At TP2 the one-shot beats cdr up
  to 3 MiB and the mesh up to 448 KiB.

Rows measured on one arch live in ARCH_FAMILY_POLICY, keyed by
(arch, link, world_size), and replace the FAMILY_POLICY row on that arch
only; gfx942 keeps its rows. The resolvers and max_payload_bytes take an
optional arch, defaulting to this host's.

End to end through CudaCommunicator.all_reduce under graph capture (INT4
regime), against the old rows: never slower (within noise), 1.17x-1.54x at
TP4/TP8 mid-range, 2.47x (TP4) and 5.44x (TP8) at 256 MiB. Against stock
production with FlyDSL off: >= 0.99x at every size.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Make the all-reduce tuning ladders and policy records dataclasses.

Review feedback on #5461: ladder rungs were bare tuples, so every reader had
to know the field order.

* OneShotRung (min_bytes, atoms, grid_cap, fanout, block) and TwoShotRung
  (min_bytes, super_tile, grid_cap, block) replace the tuples of
  ONESHOT_LADDER, MESH_ST_LADDER and RING_ST_LADDER, and pick_rung() is the
  one implementation of "last rung at or below the payload" for both hosts.
* The records live in kernels/comm/allreduce_shared.py next to the rungs:
  FamilyPolicy, OneShotPolicy and QuantPolicy move there from
  allreduce_policy, with NO_MAX. allreduce_policy re-exports them.
* The mesh ladder comment described an older table; it now matches the
  rungs.
* OneShotAllReduce dropped a grid_cap ceiling branch that could not run:
  any grid_cap pins the configuration.

No behaviour change. Verified with the policy unit tests and both
multi-GPU verify scenarios on gfx950 (TP2/4/8).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Make the all-reduce heuristics readable from one module.

allreduce_policy.py now holds every tuned decision, in two levels, with a
module docstring that draws the payload axis:

* Level 1, which kernel: FamilyPolicy fields are renamed to say what they
  bound, in payload order -- oneshot_min, oneshot_max (was
  oneshot_max_exact), quant_min (was oneshot_max, which was not a one-shot
  maximum but the mesh floor), mesh_max, quant_max (was max_bytes).
  route() composes the two slots in CudaCommunicator.all_reduce order and
  returns oneshot / mesh / ring / fallback; the policy unit tests and the
  INT4 bench use it instead of private copies. The bench's copy reported
  "oneshot" for payloads that go to cross_device_reduce.
* Level 2, which configuration: ONESHOT_LADDER, MESH_ST_LADDER and
  RING_ST_LADDER move here from the kernel modules, which never used them.

No behaviour change: the rows keep their values under the new names. The
environment overrides keep their meaning. Verified with the policy unit
tests (plus a route() test for the gfx950/xGMI rows) and both multi-GPU
verify scenarios on gfx950.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Collect the all-reduce limits and shared constants in one place.

Review feedback on #5461: limits were restated across modules, and the ring
had a payload floor of its own that mirrored the policy by hand.

* kernels/comm/allreduce_shared.py has a "Limits" section: SUPPORTED_ARCHS,
  SUPPORTED_WORLDS, LINKS, SUPPORTED_BLOCKS, PAYLOAD_ALIGN_BYTES,
  MAX_PAYLOAD_BYTES, QUANT_MIN_PAYLOAD_BYTES and NO_MAX. The policy, the
  hosts, the codec, the one-shot kernel, CustomAllreduce, QuickAllReduce and
  the op tests import them instead of keeping their own copies (three
  SUPPORTED_ARCHS, two SUPPORTED_BLOCKS, two SUPPORTED_WORLDS, and the
  "pcie"/"xgmi" literals).
* The ring's standalone floor (_RING_MIN_PAYLOAD_BYTES_BY_WORLD, 4-12 MiB)
  is gone. It claimed to mirror mesh_max but matched no policy row, and
  production never used it (dispatch passes min_bytes=0). Both schedules
  now refuse the same thing on their own: payloads under
  QUANT_MIN_PAYLOAD_BYTES, the accuracy guard.
* The tuned constants MIN_BATCH_BLOCKS and RS_INT6_MIN_WORLD move to
  allreduce_policy with the rest of the tuning.
* The hosts' identical payload checks, link resolution, arch check and
  group checks become shared helpers: check_payload, resolve_link,
  require_arch, check_world_size and _validate_ipc_process_group.

Verified with the policy unit tests, both multi-GPU verify scenarios and
bench smoke runs on gfx950.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Code clean-up after refactoring the family policy and rungs for tuning ladders.

* Refactor FamilyPolicy to use explicit windows per algorithm. Clean-up the host wrappers to simply how the rungs of tuning ladders are used.

* Run only the production configs by default in the all-reduce tests.

* Clean-up comments and doc strings in ring all-reduce kernel.

* Ensure ring all-reduce gives bit.identical output for every rank. Add tests that execute production all-reduce dispatch. Fixed one-shot all-reduce window handling for th exact mode. Add an env variable to specify the interconnect type. Fix other small review findings.

* Rename factory for quick reduce ring kernel.

* Fix black issues, improve tests, and fix exact one-shot all-reduce window.

* Simplify handling of the one-shot all-reduce window.

* Rename all-reduce host side assets to have host prefix in the filename.

* Fix black and ruff.

* Small re-tune for PCIe.

* Add op_tests/multigpu_tests/flydsl_allreduce_bench.py on the test skip list since it contains no actual tests, only infrastructure.

* Address co-pilot review feedback.

* [FlyDSL] Rename the quick all-reduce assets to allow more codecs.

Mechanical rename, no behaviour change. The mesh and ring schedules carry
INT4, INT6 and FP16 wire formats, so the names stop saying INT4:

* kernels/comm/quick_allreduce_int4.py      -> quick_allreduce_mesh.py
* kernels/comm/quick_allreduce_int4_ring.py -> quick_allreduce_ring.py
* quick_allreduce_int4.py                   -> quick_allreduce.py
* quick_allreduce_int4_ipc.py               -> quick_allreduce_ipc.py
* test_flydsl_quick_allreduce_int4.py       -> test_flydsl_quick_allreduce.py
* QuickAllReduceInt4 -> FlyQuickAllReduce,
  make_quick_allreduce_int4_kernel -> make_quick_allreduce_mesh_kernel

The identifiers match PR #5555 so the two branches rename identically.
mega_moe_tp imports the IPC helper under its new name.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* [FlyDSL] Fused all-reduce + residual add + RMSNorm kernels.

One-shot, mesh and ring kernels gain a ``fusion="rmsnorm"`` build that runs
residual-add + RMSNorm as the epilogue of the all-reduce, with the tile sized
to one token row (``block = hidden / (8 * atoms)``) so the norm reduces
within a workgroup:

* ``kernels/comm/quick_allreduce_fusions.py``: the shared epilogue and the
  row-to-workgroup geometry, the padded geometry for widths with no native
  one (per-row bounded buffer descriptors mask the pad lanes), and the HBM
  exchange word that joins a row split over ``split`` workgroups.
* One-shot: split rows, padded widths and the self-skip; the plain launch
  passes the (unused) fused operands of the shared kernel signature.
* Mesh and ring: the epilogue per tile (mesh) or per chunk inside the ring
  pipeline. The ring's owner hands the epilogue the decoded packet, as the
  plain path does, so every rank ends with the same bits.
* ``validate_block`` accepts any 128-thread multiple up to 1024 besides the
  plain menu (``BLOCK_ALIGN``/``MAX_BLOCK`` in ``allreduce_shared``).

Host classes ``OneShotAllReduceRMSNorm`` and ``FlyQuickAllReduceRMSNorm``
build one engine per (hidden, rung) lazily or up front (``hiddens=``).

Policy, in the idiom of the plain one (``allreduce_policy``):
``FUSED_FAMILY_POLICIES`` of ``FamilyPolicy`` per (arch, link, world_size),
``FUSED_ONESHOT_LADDER`` of ``FusedOneShotRung``, ``FUSED_{MESH,RING}_ST_LADDER``
of ``FusedTwoShotRung`` and ``FUSED_QR_ROW_ATOMS``. ``AITER_FLY_AR_ACCURACY``
(default ``exact``) picks the quantized or the exact windows; overrides are
``AITER_FLY_AR_FUSED_<ALG>_{MIN,MAX}_BYTES``. Window maxima are exclusive now,
as in the plain policy. gfx950/xGMI reuses the gfx942/xGMI tables until tuned.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* [FlyDSL] Dispatch the fused all-reduce + RMSNorm in production.

``FlyDSLAllReduceRMSNorm`` lives in ``QuickAllReduce`` and owns one engine per
family the fused policy enables in the current ``AITER_FLY_AR_ACCURACY`` mode.
``CudaCommunicator.fused_allreduce_rmsnorm`` asks it first; a payload outside
every window, or a width no family can build, falls through to aiter's own
fused kernels.

Widths are built before capture (``AITER_FLY_AR_FUSED_HIDDENS``, ``hiddens=``,
``prime()`` or a warmup call); inside a capture an unbuilt width declines
rather than building. ``preload_fly_engines`` passes the hidden dim to the
fused engines' ``preload``.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* [FlyDSL] Tests for the fused all-reduce + RMSNorm.

* Policy unit tests for the fused tables: coverage of every platform,
  monotone dispatch, exact mode is one-shot only, ladder well-formedness,
  ``FUSED_QR_ROW_ATOMS``, overrides separate from the plain ones, accuracy
  mode and ``AITER_FLY_AR_FUSED_HIDDENS``.
* Codec tests at the row-sized blocks the fused builds use.
* ``--operation ar|ar_rmsnorm`` in both multi-GPU tests; verify runs both
  unless one is named.
* One-shot: SQNR on ``out`` and bit-exact ``residual_out`` at native and
  padded widths, pinned atoms/block, split rows (repeat, magnitude, slice
  lag), run-ahead and fresh inputs, and GPU-free geometry checks. Its ranks
  are subprocesses of the script (``--rank``); a user run's arguments are no
  longer parsed by the worker parser.
* Mesh/ring: SQNR, bit-exact residual on the lossless wire (native, padded
  and pinned super-tile), padded widths on INT4, mesh rank agreement and
  host-side geometry checks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* [FlyDSL] Bench the fused all-reduce + RMSNorm, and pinned candidates.

The bench scenario of both multi-GPU tests takes ``--operation``:

* ``ar`` (default): the plain all-reduce, as before.
* ``ar_rmsnorm``: the fused kernels. The one-shot test times
  ``OneShotAllReduceRMSNorm`` against ``CustomAllreduce``'s fused kernel at
  both stage counts and against ``cdr``/``rccl`` + ``rmsnorm2d_fwd_with_add``,
  and reports ``prod`` (``CudaCommunicator.fused_allreduce_rmsnorm`` with
  FlyDSL off) and the fused policy's ``route``. The quick test times each
  ``FlyQuickAllReduceRMSNorm`` schedule against the HIP quick all-reduce's
  fused kernel and against the HIP quick all-reduce + norm.

``--candidates PATH`` reads pinned FlyDSL configurations from a candidate
file (``flydsl_allreduce_bench.load_candidates``: name, operation, algorithm,
one column per knob, sets) and times each as one more column of the same
spawn, so the stock kernels are timed once and the rotation covers every
candidate; ``--candidate-set`` selects rows by tag. This is what the tuning
suite drives in place of the removed standalone benchmark.

``graded_replay`` grades several outputs, and ``fused_reference`` is the
shared fp32 reference of the fused operation.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* [FlyDSL] Test a policy whose one-shot window is unbounded.

A one-shot that wins at every size, in both modes, is the answer a fit gives
on some platforms. Check that FamilyPolicy accepts it and selects the
one-shot at any payload.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* [FlyDSL] Tune the all-reduce tables from the tests' bench scenario.

The tuning suite moves to op_tests/multigpu_tests/flydsl_allreduce_tuning and
drives the bench scenario of the two multi-GPU tests instead of the removed
standalone benchmark:

* candidates.csv (generated by gen_candidates.py, checked by
  ``--check``) lists the pinned configurations the sweeps time, in sets:
  ``sweep``, ``validate``, ``fused``, ``fused_qr`` and ``smoke``. The fused
  grids are generated from the kernels' row geometries.
* bench_io.py reads the tests' ``--csv`` output into the fits' columns, and
  names the shipping engines and the stock kernels under fixed keys.
* fit_allreduce_policy.py joins the one-shot and mesh/ring CSVs of a shape,
  reconstructs the shipped dispatcher (``fly_auto``) from the policy in the
  ``--accuracy`` mode, and prints ``FamilyPolicy`` rows of ``Window``s and
  ``OneShotRung``/``TwoShotRung`` ladders keyed by (arch, link, world_size),
  checked by building them. Thresholds are half-open, as ``Window`` and
  ``select_rung`` are.
* fused/fit_fused.py and fused/analyze_fused.py do the same for the fused
  tables (``FUSED_FAMILY_POLICIES``, ``FusedOneShotRung``,
  ``FusedTwoShotRung``, ``FUSED_QR_ROW_ATOMS``).
* tune.sh keeps its commands. ``check`` also parses a pinned flydsl version
  that carries an environment marker.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Docstring updates.

* Remove unnecessary AITER_FLY_AR_ACCURACY env variable. Split all-reduce + RMSNorm fusion between QuickReduce and CustomAllReduce dispatchers. Update FlyDSL comm kernels Readme.

* Remove tuning scripts and files from source control.

* Consolidate all-reduce limits and move tunning ladder rungs and policies from kernel files to the shared host assets. Remove unnecessary default definitions.

* Black & ruff fixes.

* WIP: Refactor fused all-reduce into a separate epilogue.

* Improve benchmarking scripts.

* Compile all rungs within a window on the first call of a given width. Remove pytest from the fused all-reduce tests. Make row splitting an opt-in feature and fix the handing of NaN and Inf values. Document row splitting limitations in Readme.

* Add FlyDSL all-reduce pytests to CI run.

* Add a common check for the fused aliasing. Remove double routing for fused all-reduce dispatching. Ensure tests run the production geometry.

* Ensure all ranks resolve the same policies.

* Small clean-up.

* Make tuning ladders per hidden dim. Read the ladder from a JSON configuration file.

* Increase timeout in benchmarking script because of JIT compilation.

* Fix quick reduce benchmarking sweep.

* Increase timeout for the quick reduce benchmark due to JIT compilation.

* Update FamilyPolicies and tuning ladders after tunign sweep.

* Remove dead code.

* Fix black & ruff.

* Ruff fix.

* Document and tidy the fused QuickReduce RMSNorm Gemma/MXFP4 support

README, epilogue docs and test comments now describe the runtime Gemma
operand and the MXFP4 epilogue variant.

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

* Port the #6369 low-latency fused-norm build to the mesh epilogue design

The mesh RMSNorm epilogue gains a latency option with a prefetch hook that
loads the residual ahead of the exchanges. A ladder rung may select it
(optional latency field, default false), and the host builds it as separate
engines with two resident workgroups per CU. It is correct but slower than the
default build on gfx950 TP8 hidden 2048, so no shipped rung uses it.

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

* Restrict the low-latency fused build to xGMI ladders

#6369's low-latency build targeted gfx950 over xGMI; over PCIe it measured
slower than the default build, so the ladder loader rejects a latency rung on
any other link. No shipped rung uses it. Also add --bench-only and a grid cap
override to the fused QuickReduce test, for measuring it on an xGMI box.

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

* Rename latency to low_latency for fused all-reduce.

* Add a separate facade for FlyQuickAllReduce.

* Enable benchmarking the low-latency fused all-reduce.

* Consolidate the fused all-reduce tests.

* Black and ruff fixes.

* Move tuning ladder JSON config under configs/comm directory.

* Readme update.

* Fix GPU detection in the benchmarking scripts.

* Relax requirement that row must fit in one rank's chunk for mesh all-reduce.

* List candidates in test/benchmarking scripts. Add option to benchmark only direct Aiter competitors for tuning.

* Fix building low-latency assets.

* Update FamilyPolicy and tunning ladders for gfx950/xGMI combination.

* Ensure tests cover the shipped instances. Remove tests for non-shipped instances.

* Update tuning ladders for gfx950/xGMI after tuning sweep.

* Fix black and ruff.

* Update tuning ladders and policy after re-tunign sweep for gfx950/PCIe.

* Ensure all ranks agree on which FlyDSL all-reduce needs to be built. Add CPU test to verify the rank agreement logic and append to GPU tests to have  a case where one rank has FlyDSL all-reduce disabled.

* Load all-reduce kernels onto device at initialization. This ensures that possible HIP graph capture doesn't include module loads. Add tests where first call takes place inside a graph capture (no wram-up).

* Remove ring ladders that are not shipped.

* Fix black & ruff.

* Test fix after merge.

* Fix performance regression for fused all-reduce + RMSNorm.

* allow fused all-reduce + RMSNorm inside the HIP graph capture.

* Update TP=2 ring algorithm window policy for gfx950/xGMI.

* Fix failing policy test.

* Add a check that build and launch are outside HIP graph capture.

* Cache the check for hidden dim support. Add tunning ladders for new hidden dims.

* Rename shared IPC assets.

* Fix use sites of ipc?heap. Add compatibility layer.

* Ensure FlyDSL fused path declines if one rank fails to build for a given hidden dim. Update Readme. Add tests.

* Address Copilot code review findings.

* Fix black and ruff.

* Fix Aiter bot findings.

* Black and ruff fixes.

* Fix black.

* Add tests for zero bytes messages. Fix handling of zero bytes messages in one-shot all-reduce and quick-allreduce.

* Create alias class QuickAllReduceInt4 for vLLM.

* Add test test_flydsl_allreduce_rank_agreement.py to CI run.

* Add a test that checks the limits for row splitting in the one-shot fused all-reduce. Document limits in the Readme.

* Fix black and ruff.

* Fix min bytes for the vLLM alias.

* Fix quick-allreduce test execution for gfx942.

* Fix tests for all-reduce ring algorithm on PCIe.

* Update comment strings and Readme after FlyDSL 0.5.0 changes.

---------

Co-authored-by: Sami Remes <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: samremes <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…e interconnects (ROCm#5461)

* Land INT4 quad-fanout QR in aiter FlyDSL ops with a TP8 correctness test.

* Use layout views for LDS pack and ST inbox without regressing ST=8 wall.

Drop unused wave-join and single-wave fanout compiles; default and test the fp16 codec.

* Stop QR INT4 tests and host from mutating COMPILE_ONLY.

Compile-only and cache warming belong in developer scripts, not pytest or QRInt4QuadFanout.compile.

Co-authored-by: Cursor <[email protected]>

* Model local HBM payload as FlyDSL views; keep remote NT stores explicit.

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.

* New QR kernel/host/test files should use aiter MIT + AMD 2026 only; they were not FlyDSL-main originals.

* Drop the quad_fanout variant suffix from the only INT4 QuickReduce pipeline so the public API is QRInt4.

* Default QRInt4 to ST=8 and keep only ST∈{1,8} so the host matches the measured keeper; drop unused codec/force_super/bf16 ALU and qr_int4_mem, compiling via flyc.compile.

Co-authored-by: Cursor <[email protected]>

* Skip color 0 after wrap so it never matches the unset sentinel (HIP QR does the same), and time QRInt4 with run_perftest.

* Compile QRInt4 WORLD∈{2,4,8} via HIP-style kRankAtoms so TP4/TP2 work; WORLD=8 stays kRankAtoms=1.

Co-authored-by: Cursor <[email protected]>

* IPC helper is a FlyDSL copy so keep Apache-2.0 copyright 2025; match aiter vendored dual header.

Co-authored-by: Cursor <[email protected]>

* Replace QR INT4 packed-math inline asm with native FlyDSL f16x2 ops.

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.

* Spell out QR INT4 RS/AG and lower the flag wait as a Python while.

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

* Reduce torch surface in qrint4 kernel

* Join ST sub-tiles before LDS reuse and tighten QRInt4 host checks.

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

* Assert QRInt4 SQNR on every rank.

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

* Apply suggestions from ruff

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Match black wrapping and apply small Copilot host/test guards.

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

* Enable gfx950 FlyDSL QRInt4 with configurable grid cap.

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

* Run black on qr_int4_kernel.py after merging main.

* Reject NCCL and multi-node groups in QRInt4 with explicit errors.

IPC inbox setup needs CPU broadcast_object_list and node-local HIP IPC
handles. Fail fast before allocating buffers, matching QuickAllReduce.

* Shorten QRInt4 process-group rejection messages.

Co-authored-by: Cursor <[email protected]>

* Fix QR INT4 launch safety and validation

Clamp persistent grids to conservative residency limits, harden resource cleanup, and validate lossy collective results across ranks.

Co-authored-by: Cursor <[email protected]>

* Address QR INT4 review feedback

Co-authored-by: samremes <[email protected]>

* Apply Black formatting after merging origin/main.

Fix CI Black failures in qr_int4_kernel.py and test_flydsl_qr_int4.py.

Co-authored-by: Cursor <[email protected]>

* Fix QR INT4 E4M3 boundary encoding

* Reject >32bit offset

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Add automatic QRInt4 cleanup

* Avoid QRInt4 AOT import cycle

* Harden QRInt4 validation and test collection

* Fix QR INT4 E4M3 reserved-zero underflow after exponent clamp.

Reserve byte 0x00 for true +0 only after packing so clamped positive scales cannot collapse, and add TP2 fill cases for underflow, overflow, and zero.

Co-authored-by: Cursor <[email protected]>

* Drop duplicate QRInt4 lazy-import key after merging main.

Co-authored-by: Cursor <[email protected]>

* Spawn QRInt4 test ranks instead of re-entering the file with --rank.

Match HIP QR: Pool + spawn, return row dicts, keep argparse on main() only. Drop PYTHONPATH/arch env overrides and out.zero_(); time spawn workers with cuda.Event.

Co-authored-by: Cursor <[email protected]>

* Make QRInt4 test comments self-contained.

State what each threshold, fill, and CLI flag does today, and record why the
spawn ranks must time with cuda events instead of the profiler timer.

Co-authored-by: Cursor <[email protected]>

* Resolve the QRInt4 device index before set_device.

torch.cuda.set_device rejects torch.device("cuda") without an index, so the
current-device fallback in _cuda_index was unreachable. Resolve the index
first, select that integer, and keep self.device as the resolved cuda:N.

Co-authored-by: Cursor <[email protected]>

* Rename FlyDSL QR INT4 to QuickAllReduceInt4 and drop leftover globals/asm.

Move host and IPC out of kernels/, export QuickAllReduceInt4 only, and keep
module constants that actually couple host tile math, LDS, and codec layout.
Use fx.min, llvm.StoreOp(nontemporal=True) for NT fanout, llvm.amdgcn.s.setreg
for FP16_OVFL, and inline readfirstlane at the inbox descriptor.

Leave buffer_inv sc1 as inline asm: the flag poll is a non-atomic sc1
buffer_load (L2 bypass, not L1), so the miss path still needs an L1
invalidate, and llvm.amdgcn.buffer.wbinvl1.sc cannot select on gfx942/gfx950.

* Format QuickAllReduceInt4 host and tests with ruff and black.

* Move FlyDSL QR INT4 tests to multigpu_tests and fix HIP alloc rounding.

Collect the suite with the 8-GPU job instead of single-GPU op_tests.
Round uncached HIP mallocs to 4 KiB so small grid_cap inboxes still
export, and feed MODE setreg through as_ir_value instead of fx.arith.

* [FlyDSL] Extract quick-allreduce transport and codec into shared modules

The ring and one-shot schedules that follow need the same tile geometry,
inbox cache policy, peer store/load primitives and wire codec that the
mesh kernel had inlined. Split them out so all three agree byte for byte
rather than carrying three copies of the same magic numbers:

  quick_allreduce_shared  geometry, _INBOX_POLICY, peer store/load, LDS
  quick_allreduce_codec   INT4/INT6/FP16 wire formats and the E4M3 scale

The mesh kernel becomes codec- and inbox-policy-generic as a result, and
is renamed to match its new module. Two behavioural changes ride along.

Fix the buffer cache-modifier encoding. These are LLVM CPol bits, which
the backend renames for CDNA: bit 0 (GLC) prints as `sc0`, bit 1 (SLC) as
`nt`, bit 4 (SCC) as `sc1`; bit 2 exists in the encoding but CDNA has no
use for it and it emits nothing. The previous values were 4 for "NT" and
2 for "sc1", so the payload load carried no cache hint at all and the
flag spin load got `nt` instead of bypassing L2 -- a spin that can be
answered from a stale line. They are now 2 and `sc0 | sc1`.

Make the flag spin load bypass L1 as well. `sc1` alone only bypasses L2;
`sc0 sc1` is what LLVM emits for a system-scope load and is what lets the
retry loop run without a fence in its body.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add inbox memory modes, codec selection and an ST ladder to the host

The uncached IPC inbox the host has always allocated is right on xGMI and
catastrophic on PCIe: peer writes into uncached memory serialize per
destination, so throughput collapses as the fanout widens (MI350P, INT4
mesh: 55 GB/s to one peer, 4.45 to two, 1.44 to three, against 33.5
fine-grained). Give the host an `inbox_memory` knob over the kernel's
existing cache-policy table, defaulting to "auto", which reads the real
per-peer link type out of KFD rather than guessing from the arch string
-- MI350X and MI350P both report gfx950 and want opposite answers.

With a cacheable inbox a publish costs an L2 writeback, so the super-tile
that was a fixed constructor argument becomes a payload-size ladder:
`_pick_st` selects a rung, `_grid_x` hands each block a whole super-tile
so the batching is real, and `_MIN_BATCH_BLOCKS` stops it trading the
whole machine away at small sizes (MI350P, 32x7168, TP4: 61.95 us
unbounded against 23.98 with the grid left alone).

Also adds `rs_codec`/`ag_codec` with an AITER_ALL_REDUCE_CODEC override,
`min_bytes` gating with `is_beneficial`, `variant()` for reporting which
binary a size actually runs, and `has_xgmi_peer_links` for the dispatcher.

The IPC heap grows a device check on every allocation. Several
byte-identical copies of libamdhip64 are typically mapped into one
process and they do not share device state, so the first one resolved by
soname can allocate on the wrong GPU -- every peer write then crosses to
the wrong device. Pick the mapped copy that reports torch's bound device,
and assert the allocation landed where it was meant to.

The page rounding hipIpcGetMemHandle needs moves from alloc_uncached to
alloc, which is where the inbox is now allocated from.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add the ring schedule for quick-allreduce

The mesh writes to every one of the N-1 peers on both laps. On a PCIe
host a GPU has one shared x16 uplink, so those interleaved destinations
contend for it; the ring instead makes every step a single contiguous run
into exactly one peer's inbox. Same wire volume -- 2(N-1)/N of the
payload, which is bandwidth optimal (Patarasuk & Yuan, JPDC 69(2), 2009)
-- traded for per-destination locality, over 2(N-1) hops instead of two.

The ring pays for that in accuracy: its reduce-scatter lap requantizes
the running partial N-1 times where the mesh requantizes once, and the
partial's extremum grows with the contributions folded in. Hence the
per-lap codec knobs -- the reduce-scatter lap widens to INT6 at TP8 to
hold the 18 dB SQNR floor, while the all-gather lap forwards received
bytes untouched and stays INT4.

Registered as algorithm="ring" alongside the mesh, with its own
super-tile set (1, 8, 16, 32) and payload-size ladder. It is not the
default and is structurally worse at decode sizes and on xGMI; the
dispatcher that follows picks between them.

clamp_grid_cap now falls back to the smallest measurement for a world
size when a super-tile is not in the residency table, instead of raising:
the table was measured on the mesh and does not cover ST=16 or ST=32.
Under-launching a persistent kernel is always safe, so the fallback errs
small; an unknown arch or world size still raises.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add the exact one-shot all-reduce and the schedule policy table

Both quantized schedules are two-shot, so their latency floor is two
serialized fabric traversals plus a grid-wide handshake between the laps.
At decode sizes that floor dominates and the quantization buys nothing --
the collective is not the bottleneck there, and INT4 charges ~36 dB of
SQNR for microseconds.

OneShotAllReduce is the decode-regime answer: one round, no grid-wide
barrier, bf16 in, fp32 accumulate, bf16 out, no codec. Each rank pushes
its whole tile into every peer's inbox, publishes a colour flag, waits
for N flags, then reduces N copies out of its own inbox. That trades wire
volume for round trips -- (N-1)*S pushed against a two-shot's 2(N-1)/N*S
-- so where it stops paying is a function of N, which is what max_bytes
gates on. It needs no LDS: thread t's 16 B lands at the same offset in
every destination, so it pushes straight from registers.

It reuses the IPC inbox, peer table and cache-policy table from the
quantized schedules verbatim, which is what the shared transport module
was extracted for.

allreduce_policy holds the size boundaries between the three families,
per (link, world_size), fitted from measurement. It is a pure table plus
env overrides -- no kernels, no torch -- so the dispatcher and the hosts
can both read it without an import cycle. Accuracy defaults to "exact",
which makes the quantized families unreachable until a caller opts in
with AITER_FLY_AR_ACCURACY=fast.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Dispatch the FlyDSL all-reduce family from CudaCommunicator

FlyDSLAllReduce owns one engine per reachable schedule and routes a
payload to the family allreduce_policy picks for its size, link type and
world size. CudaCommunicator consults it ahead of quick-reduce and custom
all-reduce.

It leads the chain because, at the default AITER_FLY_AR_ACCURACY=exact,
the only reachable family is the exact one-shot -- fp32 accumulate, one
bf16 rounding, comparable with cross_device_reduce rather than quantized
-- and it declines every payload above that ceiling, so the caller falls
through unchanged. AITER_FLY_AR_ACCURACY=fast unlocks the quantized
mesh/ring for larger payloads.

The whole path is opt-in: with AITER_FLY_AR unset the dispatcher
disables itself in its constructor and the chain is exactly as before.
Every unsupported condition -- no flydsl, wrong arch, NCCL group,
multi-node group, unsupported world size -- is an early return that
leaves `disabled` set, and should_fly_all_reduce is a pure predicate that
answers False rather than raising.

A communicator built with reuse_from borrows the engine rather than
owning it, so destroy() only closes the IPC inboxes on the group that
built them.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add codec, policy and one-shot all-reduce tests

test_flydsl_allreduce_policy is CPU-only: it checks that the family
boundaries partition by size, that the ladders are ascending and reach
every super-tile they name, and that the env overrides apply where the
tables say they do.

test_flydsl_quick_allreduce_codec runs on a single GPU with no IPC, so it
covers the wire formats in isolation from the transport: INT4/INT6/FP16
round-trips, the E4M3 scale at both ends of its range, and the codec
resolution rules.

Two of its cases move with the E4M3 fixes rather than against them. They
were written against an encoder that saturated the exponent field alone,
so 512 encoded as 256 and an outlier decoded *smaller* than the ceiling
it passed; and against one where a positive extremum small enough to
encode as 0x00 collided with the reserved-zero byte and took its whole
group to zero at 1e-3. Both now assert the fixed behaviour -- monotonic
saturation past the ceiling, and a sub-floor extremum that rounds
coarsely instead of vanishing -- plus that exact zero still encodes as
exact zero.

test_flydsl_one_shot_allreduce spawns real ranks and checks the one-shot
is bit-identical to a torch all-reduce, not merely close, at TP2/4/8. It
lives in multigpu_tests because it needs more than one GPU.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Cover both schedules and the transport in the INT4 all-reduce test

The test gated only on SQNR, which cannot tell a transport bug from a
codec one: a chunk-addressing or flag-protocol fault and a codec
regression both show up as a worse number. Run the same cases over the
fp16 passthrough wire format, where the whole reduce is lossless on an
exact-grid input, and gate those on bit-identity with the fp32 reference
instead. A ring variant with one lap fp16 and the other int4 names which
lap is responsible when only one of them is.

Every case now runs on both the mesh and the ring. The ring's
reduce-scatter lap requantizes N-1 times where the mesh requantizes once,
so its SQNR falls with N -- 22.2 dB at TP2, 18.7 at TP4, ~15 at TP8
all-INT4. Defaulting that lap to INT6 at TP8 lifts it to ~21 dB, so one
18 dB floor now covers both schedules; the all-INT4 TP8 configuration is
still reachable through AITER_ALL_REDUCE_CODEC and keeps its own case at
the floor it actually delivers.

Cases that share a (world_size, algorithm, super_tile) group now ride a
single spawn and are memoized for the session. _run_rank already looped
over a list of shapes; this just stops calling it with one-element lists,
which is most of the wall time back on a file that is now 46 cases.

Adds a degenerate-input case (all-zero and far-sub-floor groups) that
pins the encode-reciprocal clamp: a zero extremum decodes to a zero
scale, and before the clamp that reached the codec as Inf and 0 * Inf
poisoned the whole tile. INT6 has four times less headroom there than
INT4, so it is the schedule that needs it.

The predicted super-tile now compares against the engine's clamped ST=1
grid rather than the requested grid_cap, which is what the host's own
selection compares against.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [FlyDSL] Add the all-reduce benchmark, roofline and policy-fitting scripts

bench_comm_allreduce sweeps every all-reduce candidate available on the
host -- RCCL, custom all-reduce, HIP quick-reduce, and the three FlyDSL
schedules -- over a shape list, on one process group, and reports
latency, achieved bandwidth and SQNR per candidate. Candidates that
cannot run a given shape are reported as declined rather than silently
skipped, so a sweep says which alternatives a winner actually beat.

transferbench_roofline turns a TransferBench point-to-point measurement
into a per-schedule lower bound: each family's wire volume as a function
of payload and world size, divided by the measured fabric rate. That is
what separates "this kernel is slow" from "this kernel is at the wire".

fit_allreduce_policy consumes a sweep and emits the family boundaries in
allreduce_policy's format, so the tables there are reproducible from
measurement rather than hand-maintained.

The shapes/ CSVs are the sweep lists the current policy tables were
fitted from: a small and a large payload sweep, and one that holds the
payload fixed while varying hidden to separate size effects from shape
effects.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Improve benchmarking script to run in fast mode by default.

* Fixed heuristics for the exact mode.

* Fix bugs in the benchmarking script.

* Update heuristics for xGMI interconnect.

* Fix classification of FlyDSL auto-deducted kernel in benchmarking script.

* Remove unintended Git modules.

* Add two new tuning knobs: workgroup size and ability to read ranks own contribution from registers instead of IPC inbox (self-skip).

* Update PCIe heuristics.

* Refactor FlyDSL all-rduce kernels integration to comms dispatcher.

* [FlyDSL] Scope OneShotAllReduce to its device instead of set_device

Mirrors what ROCm#4970 did for QuickAllReduceInt4: construction, launch and close
run under torch.cuda.device(), so building the engine no longer changes the
caller's current device.

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

* [FlyDSL] Address agent review feedback on the all-reduce dispatch

- Add a GPU-free regression test for the P1 finding: both FlyDSL selectors
  must decline a weakly- but not strictly-contiguous tensor (a full-storage
  transpose) instead of letting the engine raise after dispatch committed.
- Document the host-wide xGMI detection and the uniform-node assumption it
  relies on (P3).
- Drop a stray argument from the quick-reduce FlyDSL init log call; it had
  one more argument than placeholders.
- Re-run black (trailing whitespace, assert formatting back to main's) and
  suppress SIM102 on a const_expr guard, matching the other FlyDSL kernels.

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

* [FlyDSL] Move all-reduce tooling out of the multi-GPU test directory

The multi-GPU CI job runs every .py under op_tests/multigpu_tests/ as a
script, so tooling there ran as tests: fit_allreduce_policy.py failed on its
required argument and bench_comm_allreduce.py ran a full sweep.

- Remove fit_allreduce_policy.py and the sweep shape CSVs it was fed.
- Move bench_comm_allreduce.py and transferbench_roofline.py to
  op_tests/op_benchmarks/flydsl/, which CI does not execute, and update
  their usage text. --shape-csv stays as a user option.

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

* Remove fragile tests. Refactor multi-GPU tests for all-reduce to follow Aiter testing guidelines. Add the full kernel information to human readable kernel name.

* Black and ruff fixes. Improve comments about the use of CUDA events in the FluyDSL all-reduce tests.

* Add self-skip and block tunign knobs to two-steage mesh all-reduce.

* Use fx.generic_load, fx.generic_store, and fx.memory_fence to replace the inline ASM.

* Use system scope memory fence for releasing inboxes.

* Use uncached memory on PCIe when world size is two.

* Update aiter/ops/flydsl/kernels/quick_allreduce_int4.py

Address GitHub bot feedback.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Remove probe from 1-stage kernel.

* Remove the legacy buffer_ops.buffer_load and buffer_ops.buffer_store. Extract shared layout definition. Clen-up code.

* Ensure communicator initialization only compiles the relevant all-reduce instances.

* Trim the test suite for one-shot and quick all-reduce kernels.

* Collect shared all-reduce host wrapper assets to a shared module.

* Heuristics for xGMI interconnect.

* Update PCIe heuristics after the latest run.

* Add more cases to the benchmarking script.

* Addres black and ruff findings.

* Remove the custom logic for loading the HIP runtime library.

* Optimize memory fences for PCIe TP=2 case when uncached IPC memory is used.

* Fix a wrap-around bug in one-shot all-reduce.

* Improve benchmarking script such that it doesn't have bias towards FlyDSL instances.

* Optimized syncscope for xGMI interconnect.

* Update PCIe heuristics for TP=2 and for TP=4.

* Update xGMI heuristics. Introduce an env variable to override the min message size for FlyDSL one-stage all-reduce.

* Use _preload_compiled from TensorShim to run JIT compilation outside HIP graph capture.

* Black and ruff fixes.

* Add a Lamport (flagless) variant of the FlyDSL one-shot all-reduce.

The payload is its own flag: inbox slots hold a sentinel (bf16 NaN 0xFFFF in
every half-word) until a peer's data lands, the receiver polls all of its
sources together until no half-word is the sentinel, then re-arms the slot
two rounds ahead in a 3-buffer rotation. Senders rewrite a sentinel
half-word in their own payload to 0x7FFF, which is still NaN. That removes
the vmcnt(0) drain, both barriers and the flag round trip from every tile.

- kernel: `lamport` const_expr in make_one_shot_allreduce_kernel; uncached
  inbox only. The poll re-reads through relaxed system-scope atomics
  (_poll_v4i32) so the spin cannot be deleted. The first tile is peeled so
  its input load overlaps the colour load.
- IPC: UncachedIpcHeap.alloc takes a fill byte and synchronizes after the
  memset, so a late fill cannot erase a peer's first push.
- host: `lamport` is the 7th ONESHOT_LADDER field and an OneShotAllReduce
  knob; AITER_FLY_AR_ONESHOT_LAMPORT=0|1 pins it from the environment.
  Every shipped rung keeps lamport=False in this commit.
- tests: --lamport knob, Lamport spot configs at TP2/TP8, and a 300-call
  fresh-input stress checked bit for bit against a rank-order reference.
- bench: fly_1stage_lp and _lp variants of the pinned fly1s grid.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Ship the Lamport one-shot on xGMI and drop the one-shot floors there.

Sweep on 8x MI325X (gfx942), graph timing. Best Lamport config vs the flag
one-shot: TP2 -3..-23%, TP4 -3..-14%, TP8 -19..-41%. It ties or beats
cross_device_reduce down to 2 KiB at every world size, so the xGMI
min_bytes floors (56/48/112 KiB) go to 0.

ONESHOT_LADDER xGMI, all skip_self + lamport, atoms=1, cap 128:
  TP2  b128 to 256 KiB (one round), then b256
  TP4  b256
  TP8  b128

PCIe rungs stay on the flag variant (not measured).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Make Lamport all-reduce the default and add heuristics.

* Make self-skip default on one-shot and two-shot mesh algorithms. Redeuce the number of benchmarked configurations.

* Remove redundant/obsolete instances from benchmarking.

* Transferbench roofline fixes.

* Clean-up TransferBench runner script.

* Benchmarking script fixes.

* Move FlyDSL communication kernels into a single directory.

* Black & ruff fixes.

* Address first part of the code review feedback.

* Remove separate benchmarking scripts.

* Expand test scripts to run the benchmarking.

* Add gfx950/xGMI all-reduce policy rows; never pick the ring there.

The FlyDSL family policy was measured on gfx942 for xGMI. On gfx950/xGMI
(MI355X) the bench scenario of the all-reduce op tests shows:

* The ring never beats the mesh: 1.03x-1.16x slower at TP2 up to 512 MiB,
  2.2x-5.7x slower at TP4/TP8. The 128 MiB mesh_max sent large payloads to
  it; mesh_max is now unbounded there.
* cross_device_reduce's 2-stage kernel beats both the one-shot and the
  mesh over a wide middle range at TP4/TP8, so the one-shot ceiling drops to
  cdr's 2-stage switch and the mesh floor rises to where the mesh overtakes
  cdr (960 KiB at TP4, 1600 KiB at TP8). At TP2 the one-shot beats cdr up
  to 3 MiB and the mesh up to 448 KiB.

Rows measured on one arch live in ARCH_FAMILY_POLICY, keyed by
(arch, link, world_size), and replace the FAMILY_POLICY row on that arch
only; gfx942 keeps its rows. The resolvers and max_payload_bytes take an
optional arch, defaulting to this host's.

End to end through CudaCommunicator.all_reduce under graph capture (INT4
regime), against the old rows: never slower (within noise), 1.17x-1.54x at
TP4/TP8 mid-range, 2.47x (TP4) and 5.44x (TP8) at 256 MiB. Against stock
production with FlyDSL off: >= 0.99x at every size.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Make the all-reduce tuning ladders and policy records dataclasses.

Review feedback on ROCm#5461: ladder rungs were bare tuples, so every reader had
to know the field order.

* OneShotRung (min_bytes, atoms, grid_cap, fanout, block) and TwoShotRung
  (min_bytes, super_tile, grid_cap, block) replace the tuples of
  ONESHOT_LADDER, MESH_ST_LADDER and RING_ST_LADDER, and pick_rung() is the
  one implementation of "last rung at or below the payload" for both hosts.
* The records live in kernels/comm/allreduce_shared.py next to the rungs:
  FamilyPolicy, OneShotPolicy and QuantPolicy move there from
  allreduce_policy, with NO_MAX. allreduce_policy re-exports them.
* The mesh ladder comment described an older table; it now matches the
  rungs.
* OneShotAllReduce dropped a grid_cap ceiling branch that could not run:
  any grid_cap pins the configuration.

No behaviour change. Verified with the policy unit tests and both
multi-GPU verify scenarios on gfx950 (TP2/4/8).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Make the all-reduce heuristics readable from one module.

allreduce_policy.py now holds every tuned decision, in two levels, with a
module docstring that draws the payload axis:

* Level 1, which kernel: FamilyPolicy fields are renamed to say what they
  bound, in payload order -- oneshot_min, oneshot_max (was
  oneshot_max_exact), quant_min (was oneshot_max, which was not a one-shot
  maximum but the mesh floor), mesh_max, quant_max (was max_bytes).
  route() composes the two slots in CudaCommunicator.all_reduce order and
  returns oneshot / mesh / ring / fallback; the policy unit tests and the
  INT4 bench use it instead of private copies. The bench's copy reported
  "oneshot" for payloads that go to cross_device_reduce.
* Level 2, which configuration: ONESHOT_LADDER, MESH_ST_LADDER and
  RING_ST_LADDER move here from the kernel modules, which never used them.

No behaviour change: the rows keep their values under the new names. The
environment overrides keep their meaning. Verified with the policy unit
tests (plus a route() test for the gfx950/xGMI rows) and both multi-GPU
verify scenarios on gfx950.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Collect the all-reduce limits and shared constants in one place.

Review feedback on ROCm#5461: limits were restated across modules, and the ring
had a payload floor of its own that mirrored the policy by hand.

* kernels/comm/allreduce_shared.py has a "Limits" section: SUPPORTED_ARCHS,
  SUPPORTED_WORLDS, LINKS, SUPPORTED_BLOCKS, PAYLOAD_ALIGN_BYTES,
  MAX_PAYLOAD_BYTES, QUANT_MIN_PAYLOAD_BYTES and NO_MAX. The policy, the
  hosts, the codec, the one-shot kernel, CustomAllreduce, QuickAllReduce and
  the op tests import them instead of keeping their own copies (three
  SUPPORTED_ARCHS, two SUPPORTED_BLOCKS, two SUPPORTED_WORLDS, and the
  "pcie"/"xgmi" literals).
* The ring's standalone floor (_RING_MIN_PAYLOAD_BYTES_BY_WORLD, 4-12 MiB)
  is gone. It claimed to mirror mesh_max but matched no policy row, and
  production never used it (dispatch passes min_bytes=0). Both schedules
  now refuse the same thing on their own: payloads under
  QUANT_MIN_PAYLOAD_BYTES, the accuracy guard.
* The tuned constants MIN_BATCH_BLOCKS and RS_INT6_MIN_WORLD move to
  allreduce_policy with the rest of the tuning.
* The hosts' identical payload checks, link resolution, arch check and
  group checks become shared helpers: check_payload, resolve_link,
  require_arch, check_world_size and _validate_ipc_process_group.

Verified with the policy unit tests, both multi-GPU verify scenarios and
bench smoke runs on gfx950.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Code clean-up after refactoring the family policy and rungs for tuning ladders.

* Refactor FamilyPolicy to use explicit windows per algorithm. Clean-up the host wrappers to simply how the rungs of tuning ladders are used.

* Run only the production configs by default in the all-reduce tests.

* Clean-up comments and doc strings in ring all-reduce kernel.

* Ensure ring all-reduce gives bit.identical output for every rank. Add tests that execute production all-reduce dispatch. Fixed one-shot all-reduce window handling for th exact mode. Add an env variable to specify the interconnect type. Fix other small review findings.

* Rename factory for quick reduce ring kernel.

* Fix black issues, improve tests, and fix exact one-shot all-reduce window.

* Simplify handling of the one-shot all-reduce window.

* Rename all-reduce host side assets to have host prefix in the filename.

* Fix black and ruff.

* Small re-tune for PCIe.

* Add op_tests/multigpu_tests/flydsl_allreduce_bench.py on the test skip list since it contains no actual tests, only infrastructure.

* Address co-pilot review feedback.

* Remove dead code.

* Fix black & ruff.

* Ruff fix.

* Update tuning ladders for gfx950/xGMI after tuning sweep.

* Fix black and ruff.

* Ensure all ranks agree on which FlyDSL all-reduce needs to be built. Add CPU test to verify the rank agreement logic and append to GPU tests to have  a case where one rank has FlyDSL all-reduce disabled.

* Load all-reduce kernels onto device at initialization. This ensures that possible HIP graph capture doesn't include module loads. Add tests where first call takes place inside a graph capture (no wram-up).

* Remove ring ladders that are not shipped.

* Fix black & ruff.

* Fix performance regression for fused all-reduce + RMSNorm.

* allow fused all-reduce + RMSNorm inside the HIP graph capture.

* Update TP=2 ring algorithm window policy for gfx950/xGMI.

* Fix failing policy test.

* Address Copilot code review findings.

* Fix black and ruff.

* Fix Aiter bot findings.

---------

Co-authored-by: Sami Remes <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: samremes <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
lcskrishna added a commit to lcskrishna/vllm that referenced this pull request Nov 19, 2026
Since Nov 8, crsuse2-m2m-v3-108's docker daemon cannot reach containerd, so
no container starts there. Spur still schedules jobs on it: the rank there
failed its first docker step while rank 0 waited out HEALTH_TIMEOUT_S
(90 min) for its endpoint, and the Nov 9 nightly passed no cell. The TP
cells of Kimi-K2.6, Kimi-K3 and MiniMax-M3.1 have failed at start-up since
Nov 7 as well: ROCm/aiter#5461 renamed QuickAllReduceInt4.compile() to
preload(), and vllm-project#65995, which handles that, merged on Nov 9
but is not in the nightly image yet.

- After the image pull, run_xPyD_disagg.slurm starts a throwaway container
  and rejects the node like a busy one (PREFLIGHT-REJECTED) when docker's
  error names containerd or the daemon. A failed pull alone may be the
  registry's fault, so it doesn't count.
- A rank whose setup fails (preflight, the AINIC swap or the vLLM patch
  bake) writes the completion sentinel, and rank 0's health gate gives up
  once it appears, so such a job ends in about a minute.
- drive.py keeps every node a preflight rejection names out of the rest of
  the run, by submitting with EXCLUDE_NODES (sbatch --exclude), and lists
  those nodes in summary.md. MX_EXCLUDE adds nodes up front.
- TP layouts bake in the vLLM part of vllm-project#65995 by default. Once the image has
  it, apply_vllm_patches.sh skips it as already applied.

The rejection path ran locally against stub docker, rocm-smi and ss
commands, not yet on the cluster.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants