Skip to content

[FlyDSL] QuickAllReduce INT5/INT6 and all-reduce cleanup - #5555

Merged
TennyWang1223 merged 7 commits into
mainfrom
users/msaffari-amd/aiter/flydsl-qr-int6-v2
Nov 11, 2026
Merged

TennyWang1223 merged 7 commits into
mainfrom
users/msaffari-amd/aiter/flydsl-qr-int6-v2

Conversation

@msaffari-amd

@msaffari-amd msaffari-amd commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

FlyDSL quick all-reduce only had an INT4 wire format (~19 dB SQNR). This adds
INT5 and INT6, so the mesh covers the full quality/wire range at FlyDSL's speed.

It also cleans up the FlyDSL all-reduce code: int4 is dropped from names that
now cover every codec, the policy records and constants move into
allreduce_policy.py, both dispatchers share one input check, and the README
and docstrings no longer repeat each other.

gfx950, bf16, HIP-graph. Decode 512x5120, prefill 32768x5120. Default
ladder, mesh with the codec pinned on both laps; SQNR is vs fp32 NCCL.
HIP QuickReduce runs at the same bit width (HIP has no INT5).

TP8:

Codec FlyDSL decode HIP decode FlyDSL prefill HIP prefill
INT4 18.6 µs / 19.1 dB 28.6 µs / 18.3 dB 483 µs / 19.1 dB 1059 µs / 18.3 dB
INT5 21.5 µs / 24.8 dB - 586 µs / 24.8 dB -
INT6 22.5 µs / 30.8 dB 34.9 µs / 30.4 dB 676 µs / 30.8 dB 1136 µs / 30.4 dB

TP4:

Codec FlyDSL decode HIP decode FlyDSL prefill HIP prefill
INT4 24.0 µs / 19.4 dB 33.4 µs / 18.3 dB 902 µs / 19.4 dB 1125 µs / 18.3 dB
INT5 27.8 µs / 25.1 dB - 1139 µs / 25.1 dB -
INT6 30.8 µs / 31.1 dB 44.6 µs / 30.4 dB 1299 µs / 31.1 dB 1477 µs / 30.4 dB

INT4 has the same speed and SQNR as on main.

Technical Details

  • INT5 and INT6 on the mesh: MESH_CODECS = ("int4", "int5", "int6", "fp16").
    • INT5: 1024 B nibbles + 256 B 1-bit plane + 128 B scale = 1408 B, 22 sectors
    • INT6: 1024 B nibbles + 512 B 2-bit plane + 128 B scale = 1664 B, 26 sectors
  • INT5 uses the E5M2 group scale, like INT4 and INT6.
  • _Algorithm.single_codec: the mesh carries one format on both laps and stays
    on INT4 by default.
  • The mesh grid is capped by LDS residency as well as VGPRs, so a wider codec
    never launches more workgroups than fit. The shipping grids are unchanged.
  • Renames, int4 dropped from names:
    • quick_allreduce_int4.py -> quick_allreduce.py, QuickAllReduceInt4 -> FlyQuickAllReduce;
      QuickAllReduceInt4 stays as a temporary alias for vLLM
    • kernels/comm/quick_allreduce_int4.py -> kernels/comm/quick_allreduce_mesh.py
    • kernels/comm/quick_allreduce_int4_ring.py -> kernels/comm/quick_allreduce_ring.py
    • quick_allreduce_int4_ipc.py -> ipc_heap.py; the old module stays as a
      temporary re-export for vLLM
    • test_flydsl_quick_allreduce_int4.py -> test_flydsl_quick_allreduce.py
  • Policy records and constants move from kernels/comm/allreduce_shared.py to
    allreduce_policy.py.
  • eligible_payload_bytes: one input check for both dispatchers.
  • Tests: the multi-GPU pinned-codec test also runs the mesh on INT5 and INT6
    at TP4/TP8 (--extended), and the codec test gets a pytest.main entry point.
  • README and docstring cleanup.

Test Plan

pytest op_tests/flydsl_tests/test_flydsl_allreduce_policy.py \
       op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py \
       op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py
python op_tests/multigpu_tests/test_flydsl_quick_allreduce.py
python op_tests/multigpu_tests/test_flydsl_quick_allreduce.py --extended
python op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py
python op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py

Test Result

All suites pass on gfx950 and gfx942 at TP2/TP4/TP8. Mesh INT5 and INT6 give
the same SQNR on both (TP8: INT5 24.8 dB, INT6 30.8 dB), and INT6 prefill
(32768x5120) runs at TP4 and TP8 on both, on the ST=8 rung at TP8.

PR Self-Review

Reviewed revision

73b5418

Behavior and intent

Most of this PR is cleanup of the FlyDSL all-reduce code, which still carried
int4 in names that cover every codec:

  • QuickAllReduceInt4 -> FlyQuickAllReduce, and the host, kernel, IPC and
    test modules renamed to match (quick_allreduce.py, quick_allreduce_mesh.py,
    quick_allreduce_ring.py, ipc_heap.py, test_flydsl_quick_allreduce.py).
  • Policy records and constants move into allreduce_policy.py.
  • Both dispatchers share one input check, eligible_payload_bytes.
  • README and docstrings no longer repeat each other.

vLLM keeps working through two temporary aliases, QuickAllReduceInt4 and
quick_allreduce_int4_ipc. On top of the cleanup, the mesh takes INT5 and INT6
as opt-in codecs, and its grid is capped by LDS as well as VGPRs. Production
stays on INT4, with the same kernels and speed as main.

Validation and unverified scope

Every command in the Test Plan passed on gfx950 (MI355X) and gfx942 (MI300X),
8 GPUs each, at TP2/TP4/TP8, and --extended passed on gfx942. INT4 was timed
back to back against main at TP4 and TP8, with the same speed. Remaining
unverified: the committed --scenario bench times INT4 only, so the INT5/INT6
speed numbers are not reproducible from it.

PR-specific question

Most changed op tests only follow the renames and moved constants, with no new
case. The new coverage is INT5 in the codec test and mesh INT5/INT6 in the
multi-GPU pinned-codec test; no existing test ran these codecs.

Changed op tests

  • op_tests/multigpu_tests/test_flydsl_quick_allreduce.py: renamed from
    test_flydsl_quick_allreduce_int4.py, tests renamed to drop int4; the
    pinned-codec test also runs mesh INT5/INT6.
  • op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py: adds INT5 cases
    and a pytest.main entry point.
  • op_tests/flydsl_tests/test_flydsl_allreduce_policy.py: follows the moved
    constants, and adds test_eligible_payload_bytes for the shared input check.
  • op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py: follows the
    rename to FlyQuickAllReduce; no new case.
  • op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py: follows
    the renames; no new case.
  • op_tests/multigpu_tests/test_flydsl_one_shot_allreduce.py: follows the moved
    ONESHOT_DEFAULT_GRID_CAP; no new case.
  • op_tests/multigpu_tests/flydsl_allreduce_bench.py: docstring follows the
    test rename; no behavior change.
  • op_tests/multigpu_tests/test_msa_block_select_cp.py: imports UncachedIpcHeap
    from ipc_heap; no behavior change.

Submission Checklist

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Two critical kernel issues remain unresolved and must be fixed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a FlyDSL mesh INT6 QuickAllReduce implementation with host orchestration, kernel support, public export, and multi-GPU validation.

Changes:

  • Adds the host-side INT6 launcher and IPC management.
  • Adds the INT6 mesh kernel and public FlyDSL API export.
  • Adds correctness, SQNR, edge-case, transport, and benchmark tests.
File summaries
File Summary
op_tests/multigpu_tests/test_flydsl_quick_allreduce_int6.py Multi-GPU correctness and performance coverage.
aiter/ops/flydsl/quick_allreduce_int6.py Host-side INT6 engine and launch management.
aiter/ops/flydsl/kernels/quick_allreduce_int6.py INT6 mesh kernel. Critical issues remain in slot reuse synchronization and LDS-aware grid-cap calculation.
aiter/ops/flydsl/__init__.py Public lazy export for the new API.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@zufayu

zufayu commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Advisory review (static + hand-run; not a merge gate). Validation/Perf ran no GPU stage — reasons are on their lines below. Findings tagged [verified] are traced to code/repro.

Admits INT6 as a wire format of the FlyDSL mesh quick all-reduce — the mesh kernel was already codec-generic, so this wires the INT6 codec into MESH_CODECS with its own super-tile ladder, makes the host resolve one codec across both mesh laps, and renames the codec-generic QuickAllReduceInt4 host/kernels/tests to FlyQuickAllReduce / quick_allreduce — lifting mesh accuracy from ~19 dB to ~30 dB SQNR at the same two-shot schedule.*

Review (advisory): 🔴 HIGH RISK
Validation (deterministic): NOT RUN — auto-validation disabled (REVIEW_AUTO_VALIDATE=0) and 4 candidate test targets with no unique one to name; this box is a single gfx942, so the TP2/4/8 collectives cannot run here — an environment gap, not a PR defect.
Perf (advisory): NOT RUN — no multi-GPU host (single gfx942 here); the PR's 30.8 µs / 731 µs table carries no attached output, and no base-vs-head timing exists.

🔴 [verified] The INT6 mesh ladder's ST=8 rung over-launches the persistent kernel on gfx950. MESH_ST_LADDER["int6"] (aiter/ops/flydsl/kernels/quick_allreduce_mesh.py) caps both rungs at grid 1216, which is exactly 4 workgroups/CU on a 304-CU gfx942 — and 4/CU is INT6's hard LDS ceiling, since one workgroup allocates ATOMS × 1664 B = 13,312 B of LDS (4 × 13,312 = 53,248 ≤ 64 KB; 5 × 13,312 = 66,560 > 64 KB). On gfx950 — 256 CUs per this repo's own tuned configs (aiter/configs/a8w8_bpreshuffle_tuned_gemm.csv records cu_num 256 for gfx950; any gfx950 part below 304 CUs behaves the same) — the LDS-safe grid is 4 × 256 = 1024, but clamp_grid_cap passes 1216 through because _RESIDENT_WGS_PER_CU[(8,8)]=6 and [(4,8)]=5 are INT4-measured VGPR numbers (INT4's 9,216 B LDS allows 7/CU) and the new comment's claim that INT6 "runs at these counts on gfx942/gfx950" cannot hold: 6 × 13,312 = 79,872 B exceeds the 64 KB LDS on both arches. At gfx950 + INT6 mesh (AITER_ALL_REDUCE_CODEC=INT6 or rs_codec="int6") + TP4/TP8 + payload > 38 MiB, _pick_st takes the ST=8 rung and _grid_x launches 1,216 blocks (no release fence on xGMI, so no ceil(tiles/8) batching), of which at most 1,024 can be co-resident. Does this deadlock the bid-matched color handshake, or silently leave the 192 unstarted blocks' tiles unwritten — the "over-launching a persistent kernel deadlocks" failure the file's own comment names? The PR's own prefill-calib test shape (32768×5120 = 335 MiB) sits exactly on this rung. Author must key the residency clamp on the codec's LDS — cap the INT6 ST=8 rung at 4 × cu_count or add codec keying to _RESIDENT_WGS_PER_CU — and run the TP4/TP8 INT6 mesh cases on a gfx950 part to confirm which failure mode (or safety) actually obtains.

⚠️ [verified] The patch is stale against the merge target and the rename collides with new drift. applies.txt shows 4 files no longer applying to d231ca0, and the target's aiter/ops/flydsl/one_shot_allreduce.py now imports has_xgmi_peer_links from .quick_allreduce_int4 (added by 1576c1e) — the exact module this PR deletes — alongside a new link= parameter the PR's head version of that file predates. A naive conflict resolution drops the import; OneShotAllReduce.__init__ then NameErrors, and aiter/dist/device_communicators/flydsl_all_reduce.py's try/except converts that into _IMPORT_OK = False: the entire FlyDSL all-reduce path silently disables instead of failing loudly, and any CI on the current head describes a tree that has moved (the policy test and bench were also restructured on the target). Author must rebase onto d231ca0, re-point the has_xgmi_peer_links import to .quick_allreduce, and re-run the restructured policy/bench tests.

⚠️ [verified] The headline latency claims trace to no output. The PR's table (FlyDSL INT6 ~30.2 dB, 30.8 µs decode, 731 µs prefill vs HIP INT6 ~30.4 dB, 34.7/1139 µs) has no attached benchmark output, the Test Plan and Test Result sections are unfilled template comments, bench_comm_allreduce.py ships no mesh-INT6 candidate row (only qr_int6 and ring rs_codec="int6" rows), and no base-vs-head timing exists. The SQNR half I could and did check: an independent numpy re-implementation of the group-16 E4M3 codec gives 30.23 dB for the INT6 mesh at the TP8 512×5120 decode-calib shape (and 19.21 dB for INT4, matching the ~19 dB claim), and the 24.08 dB uniform-512 edge-case arithmetic reproduces exactly — but the latency advantage, the PR's reason to exist, is not checkable by a reviewer as posted. Author must attach the sweep output (test_flydsl_quick_allreduce.py --codec int6, or a new fly_int6 bench row) backing the µs numbers, fill the Test Plan/Test Result sections, and add the mesh-INT6 row so the FlyDSL-vs-HIP comparison is reproducible from the committed bench.

📝 [verified] The public rename ships no compatibility shim. QuickAllReduceInt4 → FlyQuickAllReduce and quick_allreduce_int4 → quick_allreduce remove the old names from aiter/ops/flydsl/init.py's lazy-export table and all, so from aiter.ops.flydsl import QuickAllReduceInt4 (the spelling bench_comm_allreduce.py itself used before this PR) raises at import time. Mitigating: the name is 7 days old (56b244b, 2026-09-09), unreleased (v0.1.21 is 125 commits back), and every in-tree reference is updated. Reviewer should ask whether any in-flight consumer branch (ATOM or a sibling feature branch) already imports the week-old name before the rename lands.

📝 [verified] Both INT6 rungs sit at grid 1216, so one TP8 engine set costs ~281 MiB of IPC inbox heap per rank (ST=8 engine 248 MiB + ST=1 engine 32 MiB + flags) against ~21.5 MiB for the entire INT4 ladder at cap 128 — the same full-grid footprint the host's own comment says INT4's cap-128 rungs were sized to avoid ("Seeding it with the 1216 default instead built a 194 MiB inbox … on every object ever constructed"). A sweep or bench holding several INT6 engine variants live at once multiplies this, and it is uncached IPC heap. Reviewer should ask whether the ST=8 rung needs the full 1216 cap now that the ST=1 rung covers the sub-38 MiB range, or whether ~13× INT4's inbox per engine set is the accepted cost.

@msaffari-amd msaffari-amd changed the title [FlyDSL] Add QuickAllReduceInt6 [FlyDSL] Add QuickAllReduce INT6 and INT5 Sep 21, 2026
@msaffari-amd
msaffari-amd force-pushed the users/msaffari-amd/aiter/flydsl-qr-int6-v2 branch from 0f599b7 to 837a76b Compare September 21, 2026 11:33
@msaffari-amd
msaffari-amd force-pushed the users/msaffari-amd/aiter/flydsl-qr-int6-v2 branch 3 times, most recently from 6cbabf2 to 6d34929 Compare September 30, 2026 11:45
vpietila-amd added a commit that referenced this pull request Oct 14, 2026
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]>
vpietila-amd added a commit that referenced this pull request Oct 14, 2026
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]>
vpietila-amd added a commit that referenced this pull request Oct 16, 2026
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]>
@msaffari-amd
msaffari-amd force-pushed the users/msaffari-amd/aiter/flydsl-qr-int6-v2 branch from 6d34929 to 8aa885b Compare October 22, 2026 11:12
@msaffari-amd msaffari-amd changed the title [FlyDSL] Add QuickAllReduce INT6 and INT5 [FlyDSL] QuickAllReduce INT5/INT6 and all-reduce cleanup Oct 23, 2026
@samremes

Copy link
Copy Markdown
Contributor

Please coordinate the shared IPC utility rename with PR #5670. I suggest converging on aiter/ops/flydsl/ipc_heap.py: this is a common IPC heap utility, not an all-reduce-specific module. Whichever PR merges first should establish the path, and the other PR should adopt it. The monokernel import in the other PR should use the common module too, since that code does not use QuickAllReduce or a quantized collective.

Separately, vLLM imports the current module from vllm/models/deepseek_v41/amd/mono/common/peer_memory.py and vllm/models/kimi_k3/amd/specialized_decode/runtime/peer.py (https://github.com/vllm-project/vllm/blob/main/vllm/models/deepseek_v41/amd/mono/common/peer_memory.py and https://github.com/vllm-project/vllm/blob/main/vllm/models/kimi_k3/amd/specialized_decode/runtime/peer.py). Those imports should be updated in a follow-up vLLM PR to use the agreed common module when that checkout is ready to consume the new AITER path. vLLM does not track AITER main, so this is not an immediate break when either AITER PR merges.

@samremes samremes mentioned this pull request Oct 27, 2026
4 of 10 tasks
@msaffari-amd
msaffari-amd force-pushed the users/msaffari-amd/aiter/flydsl-qr-int6-v2 branch from 1537ccd to 4d48a26 Compare November 9, 2026 14:12
@msaffari-amd
msaffari-amd changed the base branch from users/vpietila/flydsl-comm-kernels to main November 9, 2026 14:14
@msaffari-amd

Copy link
Copy Markdown
Contributor Author

Please coordinate the shared IPC utility rename with PR #5670. I suggest converging on aiter/ops/flydsl/ipc_heap.py: this is a common IPC heap utility, not an all-reduce-specific module. Whichever PR merges first should establish the path, and the other PR should adopt it. The monokernel import in the other PR should use the common module too, since that code does not use QuickAllReduce or a quantized collective.

Separately, vLLM imports the current module from vllm/models/deepseek_v41/amd/mono/common/peer_memory.py and vllm/models/kimi_k3/amd/specialized_decode/runtime/peer.py (https://github.com/vllm-project/vllm/blob/main/vllm/models/deepseek_v41/amd/mono/common/peer_memory.py and https://github.com/vllm-project/vllm/blob/main/vllm/models/kimi_k3/amd/specialized_decode/runtime/peer.py). Those imports should be updated in a follow-up vLLM PR to use the agreed common module when that checkout is ready to consume the new AITER path. vLLM does not track AITER main, so this is not an immediate break when either AITER PR merges.

Thanks, agreed. This PR now uses aiter/ops/flydsl/ipc_heap.py as the common IPC heap module, with the same content as in #5670, and everything in AITER that uses UncachedIpcHeap (all-reduce, the mega-MoE TP kernel and the MSA test) imports it from there.

For vLLM, I kept quick_allreduce_int4_ipc.py as a temporary re-export of ipc_heap, identical to the one in #5670, so the two PRs merge cleanly in either order and vLLM's current imports keep working. It can be removed once the follow-up vLLM PR switches those imports to ipc_heap.

@msaffari-amd
msaffari-amd marked this pull request as ready for review November 9, 2026 16:02
@msaffari-amd
msaffari-amd requested review from a team and a lite review from Copilot November 9, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active moderate issues remain: a public compatibility export was removed, the new INT5 mesh transport path lacks cross-rank coverage, and the codec suite would not actually collect tests under the configured runner.

2 open issues
2 resolved since last review

Review effort: Lite

Comment thread aiter/ops/flydsl/__init__.py Resolved
Copilot AI lite review requested due to automatic review settings November 10, 2026 10:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI lite review requested due to automatic review settings November 10, 2026 12:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI lite review requested due to automatic review settings November 10, 2026 12:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@msaffari-amd

Copy link
Copy Markdown
Contributor Author

Advisory review (static + hand-run; not a merge gate). Validation/Perf ran no GPU stage — reasons are on their lines below. Findings tagged [verified] are traced to code/repro.

_Admits INT6 as a wire format of the FlyDSL mesh quick all-reduce — the mesh kernel was already codec-generic, so this wires the INT6 codec into MESH_CODECS with its own super-tile ladder, makes the host resolve one codec across both mesh laps, and renames the codec-generic QuickAllReduceInt4 host/kernels/tests to FlyQuickAllReduce / quick_allreduce — lifting mesh accuracy from ~19 dB to ~30 dB SQNR at the same two-shot schedule._*

Review (advisory): 🔴 HIGH RISK Validation (deterministic): NOT RUN — auto-validation disabled (REVIEW_AUTO_VALIDATE=0) and 4 candidate test targets with no unique one to name; this box is a single gfx942, so the TP2/4/8 collectives cannot run here — an environment gap, not a PR defect. Perf (advisory): NOT RUN — no multi-GPU host (single gfx942 here); the PR's 30.8 µs / 731 µs table carries no attached output, and no base-vs-head timing exists.

🔴 [verified] The INT6 mesh ladder's ST=8 rung over-launches the persistent kernel on gfx950. MESH_ST_LADDER["int6"] (aiter/ops/flydsl/kernels/quick_allreduce_mesh.py) caps both rungs at grid 1216, which is exactly 4 workgroups/CU on a 304-CU gfx942 — and 4/CU is INT6's hard LDS ceiling, since one workgroup allocates ATOMS × 1664 B = 13,312 B of LDS (4 × 13,312 = 53,248 ≤ 64 KB; 5 × 13,312 = 66,560 > 64 KB). On gfx950 — 256 CUs per this repo's own tuned configs (aiter/configs/a8w8_bpreshuffle_tuned_gemm.csv records cu_num 256 for gfx950; any gfx950 part below 304 CUs behaves the same) — the LDS-safe grid is 4 × 256 = 1024, but clamp_grid_cap passes 1216 through because _RESIDENT_WGS_PER_CU[(8,8)]=6 and [(4,8)]=5 are INT4-measured VGPR numbers (INT4's 9,216 B LDS allows 7/CU) and the new comment's claim that INT6 "runs at these counts on gfx942/gfx950" cannot hold: 6 × 13,312 = 79,872 B exceeds the 64 KB LDS on both arches. At gfx950 + INT6 mesh (AITER_ALL_REDUCE_CODEC=INT6 or rs_codec="int6") + TP4/TP8 + payload > 38 MiB, _pick_st takes the ST=8 rung and _grid_x launches 1,216 blocks (no release fence on xGMI, so no ceil(tiles/8) batching), of which at most 1,024 can be co-resident. Does this deadlock the bid-matched color handshake, or silently leave the 192 unstarted blocks' tiles unwritten — the "over-launching a persistent kernel deadlocks" failure the file's own comment names? The PR's own prefill-calib test shape (32768×5120 = 335 MiB) sits exactly on this rung. Author must key the residency clamp on the codec's LDS — cap the INT6 ST=8 rung at 4 × cu_count or add codec keying to _RESIDENT_WGS_PER_CU — and run the TP4/TP8 INT6 mesh cases on a gfx950 part to confirm which failure mode (or safety) actually obtains.

⚠️ [verified] The patch is stale against the merge target and the rename collides with new drift. applies.txt shows 4 files no longer applying to d231ca0, and the target's aiter/ops/flydsl/one_shot_allreduce.py now imports has_xgmi_peer_links from .quick_allreduce_int4 (added by 1576c1e) — the exact module this PR deletes — alongside a new link= parameter the PR's head version of that file predates. A naive conflict resolution drops the import; OneShotAllReduce.__init__ then NameErrors, and aiter/dist/device_communicators/flydsl_all_reduce.py's try/except converts that into _IMPORT_OK = False: the entire FlyDSL all-reduce path silently disables instead of failing loudly, and any CI on the current head describes a tree that has moved (the policy test and bench were also restructured on the target). Author must rebase onto d231ca0, re-point the has_xgmi_peer_links import to .quick_allreduce, and re-run the restructured policy/bench tests.

⚠️ [verified] The headline latency claims trace to no output. The PR's table (FlyDSL INT6 ~30.2 dB, 30.8 µs decode, 731 µs prefill vs HIP INT6 ~30.4 dB, 34.7/1139 µs) has no attached benchmark output, the Test Plan and Test Result sections are unfilled template comments, bench_comm_allreduce.py ships no mesh-INT6 candidate row (only qr_int6 and ring rs_codec="int6" rows), and no base-vs-head timing exists. The SQNR half I could and did check: an independent numpy re-implementation of the group-16 E4M3 codec gives 30.23 dB for the INT6 mesh at the TP8 512×5120 decode-calib shape (and 19.21 dB for INT4, matching the ~19 dB claim), and the 24.08 dB uniform-512 edge-case arithmetic reproduces exactly — but the latency advantage, the PR's reason to exist, is not checkable by a reviewer as posted. Author must attach the sweep output (test_flydsl_quick_allreduce.py --codec int6, or a new fly_int6 bench row) backing the µs numbers, fill the Test Plan/Test Result sections, and add the mesh-INT6 row so the FlyDSL-vs-HIP comparison is reproducible from the committed bench.

📝 [verified] The public rename ships no compatibility shim. QuickAllReduceInt4 → FlyQuickAllReduce and quick_allreduce_int4 → quick_allreduce remove the old names from aiter/ops/flydsl/init.py's lazy-export table and all, so from aiter.ops.flydsl import QuickAllReduceInt4 (the spelling bench_comm_allreduce.py itself used before this PR) raises at import time. Mitigating: the name is 7 days old (56b244b, 2026-09-09), unreleased (v0.1.21 is 125 commits back), and every in-tree reference is updated. Reviewer should ask whether any in-flight consumer branch (ATOM or a sibling feature branch) already imports the week-old name before the rename lands.

📝 [verified] Both INT6 rungs sit at grid 1216, so one TP8 engine set costs ~281 MiB of IPC inbox heap per rank (ST=8 engine 248 MiB + ST=1 engine 32 MiB + flags) against ~21.5 MiB for the entire INT4 ladder at cap 128 — the same full-grid footprint the host's own comment says INT4's cap-128 rungs were sized to avoid ("Seeding it with the 1216 default instead built a 194 MiB inbox … on every object ever constructed"). A sweep or bench holding several INT6 engine variants live at once multiplies this, and it is uncached IPC heap. Reviewer should ask whether the ST=8 rung needs the full 1216 cap now that the ST=1 rung covers the sub-38 MiB range, or whether ~13× INT4's inbox per engine set is the accepted cost.

Thanks for the detailed review. The PR is now rebased onto main and the description is updated. Going through your points in order:

Validation and perf (no GPU stage). Both are now run on multi-GPU hosts. On gfx950 and gfx942 (MI300X, 8 GPUs), every suite in the Test Plan passes at TP2/TP4/TP8, and on gfx942 the multi-GPU suite also passes with --extended.

🔴 INT6 over-launch on the ST=8 rung.

The per-codec INT6 ladder with grid 1216 is gone. The mesh now uses one ladder for every codec, so INT6 runs at the same grid caps as INT4 (on gfx950, 384 at TP8 and 1024 at TP4).
The residency clamp now also accounts for the codec's LDS: the mesh grid is capped by the workgroups that fit in the CUs' LDS as well as by the VGPR table (_RESIDENT_WGS_PER_CU). A wider codec or a custom ladder with a large grid_cap can no longer launch more workgroups than are resident. The shipping grids do not change.
INT6 at 32768x5120 runs correctly at TP4 and TP8 on both gfx950 and gfx942, on the ST=8 rung at TP8, with no hang and every tile written (TP8: 30.8 dB).
⚠️ Stale patch. Rebased onto main and the conflicts resolved. has_xgmi_peer_links no longer exists on main; the one-shot path imports from allreduce_policy, and the one-shot suite passes. The restructured policy and rank-agreement tests pass.

⚠️ Latency claims and test sections.

The description now has tables measured on gfx950 at TP8 and TP4 for INT4, INT5 and INT6, against HIP QuickReduce at the same bit width, and the Test Plan and Test Result are filled in.
Against main, INT4 has the same speed and SQNR, measured back to back.
The SQNR now comes from the E5M2 group scale: TP8 INT4 19.1 dB, INT5 24.8 dB, INT6 30.8 dB.
The INT5/INT6 rows come from the test's bench path (_bench_rank) with the codec pinned on both laps. The committed --scenario bench times the shipping codec, which is INT4.
Mesh INT5 and INT6 are now in the multi-GPU test: test_quick_allreduce_pinned_codec runs them at TP4 and TP8, on a decode payload and on the 64 MiB top of the mesh window (the ST=8 rung at TP8), with an SQNR floor per codec. They run under --extended and pass on gfx950 and gfx942.
📝 Compatibility shim. QuickAllReduceInt4 stays as a temporary alias of FlyQuickAllReduce, since vLLM's _aiter_ops.py imports it. quick_allreduce_int4_ipc stays as a temporary re-export of ipc_heap, since vLLM imports UncachedIpcHeap from there. Both go once vLLM moves to the new names.

📝 Inbox size. Follows from the first point: INT6 no longer has its own 1216-wide rungs, so its inbox is sized by the same grid caps as INT4.

@msaffari-amd

Copy link
Copy Markdown
Contributor Author

🟡 Changes recommended

Active moderate issues remain: a public compatibility export was removed, the new INT5 mesh transport path lacks cross-rank coverage, and the codec suite would not actually collect tests under the configured runner.

2 open issues

2 resolved since last review

Review effort: Lite

On the INT5 mesh coverage from the Copilot review: test_quick_allreduce_pinned_codec now also runs the mesh on INT5 and INT6 at TP4 and TP8, on a decode payload and on the 64 MiB top of the mesh window (the ST=8 rung at TP8), with an SQNR floor per codec. It runs under --extended, like the other pinned-codec cases. All rows pass on gfx950 and gfx942 with identical output on every rank.

@TennyWang1223 TennyWang1223 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@TennyWang1223
TennyWang1223 merged commit cb4ac34 into main Nov 11, 2026
@TennyWang1223
TennyWang1223 deleted the users/msaffari-amd/aiter/flydsl-qr-int6-v2 branch November 11, 2026 03:05
eppaneamd added a commit that referenced this pull request Nov 11, 2026
…kreduce-sp-rs-ag

main renamed quick_allreduce_int4 to quick_allreduce (QuickAllReduceInt4 to
FlyQuickAllReduce, the kernel module to quick_allreduce_mesh) and moved
MAX_PAYLOAD_BYTES, SUPPORTED_BLOCKS and QUANT_MIN_PAYLOAD_BYTES to
allreduce_policy (#5555). Conflicts: the module docstring and the factory name
of quick_allreduce_mesh.py, and the import block, the class header and a
docstring of quick_allreduce.py. The single-phase modes keep their code; their
renamed references follow in the next commit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Rony Leppänen <[email protected]>
eppaneamd added a commit that referenced this pull request Nov 11, 2026
…kAllReduce rename, test an INT5 mesh

The op test imports the renamed host and kernel modules and the three constants
from allreduce_policy, builds FlyQuickAllReduce, and patches
make_quick_allreduce_mesh_kernel for its slow-reader copy. Error messages and
the README name FlyQuickAllReduce.

The mesh now takes INT4, INT5 or INT6 (#5555). The single-phase modes stay
INT4-only: the kernel builder already refuses another codec, and the op test's
unsupported-engine check gains an INT5 mesh case that says so.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Rony Leppänen <[email protected]>
vpietila-amd added a commit that referenced this pull request Nov 11, 2026
Main's #5555 (QuickAllReduce INT5/INT6 and all-reduce cleanup) upstreamed an
earlier snapshot of this branch with the same renames. Every conflict keeps
this branch's version, with #5555's own additions ported on top:

- INT5 codec (nibble + dense 1-bit plane, bias 16); the extra-bit plane
  helpers take any share (hi_slot_of, _compact_hi, _expand_hi). INT6's bits
  are unchanged.
- Mesh builds INT5 and INT6 on request (MESH_CODECS). The mesh is
  single-codec and stays on INT4 by default: default_codecs moves only the
  ring's reduce-scatter lap to INT6.
- The plain mesh grid is also bounded by LDS residency (mesh_lds_bytes), as
  INT6 at gfx942 TP8 ST=8 overruns 64 KiB at the VGPR-limited occupancy.
  INT4 grids are unchanged.
- eligible_payload_bytes() for the dispatchers; flydsl_backends uses it.
- FlyDSL >= 0.5.0 (#7600). The capture tests watch MlirCompiler.compile
  instead of the removed JitFunction._trace_and_compile.
- Test renames (test_quick_allreduce_int4* -> test_quick_allreduce*) and
  pinned mesh INT5/INT6 cases with 23/29 dB floors.

test_flydsl_quick_allreduce_int4_rmsnorm.py stays deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
amd-pedghazi added a commit to amd-pedghazi/sglang that referenced this pull request Nov 13, 2026
…has no `compile()`

Since ROCm/aiter#5555, `aiter.ops.flydsl.QuickAllReduceInt4` names the
multi-codec `FlyQuickAllReduce`, which preloads its binaries instead of
compiling them. Calling `compile()` on it would fail at server start, so
fall back to the HIP kernel with a warning, as when the class is missing.
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]>
a-sidorova added a commit to a-sidorova/aiter that referenced this pull request Nov 19, 2026
…ice-memory colours

Port of ROCm#7093 onto the post-ROCm#5555 quick all-reduce (mesh/ring kernels in
kernels/comm). Output is bit-identical to before.

* Codec: the quantizer rounds with the fp16 magic number w + (1024 + bias),
  masked to the code width, instead of roundeven + cvt_i16 + bias, for INT4,
  INT5 and INT6. In [1024, 2048) the fp16 ulp is 1 and 1024 + bias is even,
  so the add rounds half to even exactly like roundeven.
  op_tests/test_flydsl_quick_allreduce_quant.py checks every fp16 input of
  every codec against torch (and times the old form).
* Mesh and ring take the inbox bases as kernel arguments (peer0..peer7), so
  the prologue no longer starts with an uncached peer-table load.
* The per-block colours of mesh/ring engines live in ordinary device memory
  (allocated and synchronized at engine construction), since only the
  owning GPU reads or writes them. The one-shot is unchanged.

Not ported from ROCm#7093:
* the flag poll and inbox-load cache policy: already covered upstream by
  transport._load_flag (system-scope atomic poll, no buffer_inv) and the
  sc0 sc1 recv policy;
* the v_rcp_f32 encode scale: bit-identical, but 3-6% slower on some fused
  all-reduce + RMSNorm shapes on gfx950 and no faster on the plain kernel;
* the gfx950 512-thread / 16 KiB-tile engine plans: upstream tunes the
  geometry through its own block knob and ladders.

Co-Authored-By: Claude <[email protected]>
a-sidorova added a commit to a-sidorova/aiter that referenced this pull request Nov 20, 2026
…ice-memory colours

Port of ROCm#7093 onto the post-ROCm#5555 quick all-reduce (mesh/ring kernels in
kernels/comm). Output is bit-identical to before.

* Codec: the quantizer rounds with the fp16 magic number w + (1024 + bias),
  masked to the code width, instead of roundeven + cvt_i16 + bias, for INT4,
  INT5 and INT6. In [1024, 2048) the fp16 ulp is 1 and 1024 + bias is even,
  so the add rounds half to even exactly like roundeven.
  op_tests/test_flydsl_quick_allreduce_quant.py checks every fp16 input of
  every codec against torch (and times the old form).
* Mesh and ring take the inbox bases as kernel arguments (peer0..peer7), so
  the prologue no longer starts with an uncached peer-table load.
* The per-block colours of mesh/ring engines live in ordinary device memory
  (allocated and synchronized at engine construction), since only the
  owning GPU reads or writes them. The one-shot is unchanged.

Not ported from ROCm#7093:
* the flag poll and inbox-load cache policy: already covered upstream by
  transport._load_flag (system-scope atomic poll, no buffer_inv) and the
  sc0 sc1 recv policy;
* the v_rcp_f32 encode scale: bit-identical, but 3-6% slower on some fused
  all-reduce + RMSNorm shapes on gfx950 and no faster on the plain kernel;
* the gfx950 512-thread / 16 KiB-tile engine plans: upstream tunes the
  geometry through its own block knob and ladders.

Co-Authored-By: Claude <[email protected]>
TennyWang1223 added a commit that referenced this pull request Nov 27, 2026
…, gfx950 engine plans (#7093)

* [FlyDSL] QuickAllReduce: magic-number rounding, kernel-arg peers, device-memory colours

Port of #7093 onto the post-#5555 quick all-reduce (mesh/ring kernels in
kernels/comm). Output is bit-identical to before.

* Codec: the quantizer rounds with the fp16 magic number w + (1024 + bias),
  masked to the code width, instead of roundeven + cvt_i16 + bias, for INT4,
  INT5 and INT6. In [1024, 2048) the fp16 ulp is 1 and 1024 + bias is even,
  so the add rounds half to even exactly like roundeven.
  op_tests/test_flydsl_quick_allreduce_quant.py checks every fp16 input of
  every codec against torch (and times the old form).
* Mesh and ring take the inbox bases as kernel arguments (peer0..peer7), so
  the prologue no longer starts with an uncached peer-table load.
* The per-block colours of mesh/ring engines live in ordinary device memory
  (allocated and synchronized at engine construction), since only the
  owning GPU reads or writes them. The one-shot is unchanged.

Not ported from #7093:
* the flag poll and inbox-load cache policy: already covered upstream by
  transport._load_flag (system-scope atomic poll, no buffer_inv) and the
  sc0 sc1 recv policy;
* the v_rcp_f32 encode scale: bit-identical, but 3-6% slower on some fused
  all-reduce + RMSNorm shapes on gfx950 and no faster on the plain kernel;
* the gfx950 512-thread / 16 KiB-tile engine plans: upstream tunes the
  geometry through its own block knob and ladders.

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

* [FlyDSL] QuickAllReduce: block-64 mesh rung below 2 MiB on gfx950 xGMI

The decode-size half of #7093's engine plans, expressed with the existing
geometry knob instead of a new kernel geometry: below 2 MiB a 64-thread
block (4 KiB tile) spreads a payload over 4x the workgroups of block 256,
each with a quarter of the tile. From 2 MiB on the existing rungs stay.

Measured on MI355X (ROCm 10.2, hidden 4096, graph of 10 calls, mean of two
runs) against upstream: TP2 -6..-16%, TP4 -8..-12%, TP8 -6..-10% from 8 KiB
to 1 MiB; no shape slower by more than 1% (255 shapes, TP2/4/8). A sweep of
block x super_tile x grid_cap found nothing better from 4 MiB on.

A different block changes which rank owns which chunk, so outputs below
2 MiB are statistically equivalent to, not bit-identical with, the block
256 rung; the verify's SQNR checks pass.

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

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: TennyWang1223 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants