Skip to content

[HIP] perf(custom_ar): gfx1250 LL two-shot all-reduce for 1 MiB+ messages - #7432

Merged
TennyWang1223 merged 10 commits into
mainfrom
zejun/gfx1250-custom-ar-ll-two-shot
Nov 13, 2026
Merged

TennyWang1223 merged 10 commits into
mainfrom
zejun/gfx1250-custom-ar-ll-two-shot

Conversation

@zejunchen-zejun

@zejunchen-zejun zejunchen-zejun commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

End-to-end result below. No blocking issues known.

On gfx1250, a custom all-reduce of 1–16 MiB takes either the one-shot LL kernel or, above 4 MiB, a one-shot pull. The one-shot LL sends 14× the message per rank at TP8. The pull reads every peer's full input over the fabric.

At TP8 across two MI455X trays this hits Kimi-K3 TP8 decode directly. A c32 step all-reduces [160, 7168] bf16 (2.29 MB) in 47.9 µs, against 39.2 µs on tuned RCCL. A c64 step all-reduces [320, 7168] (4.59 MB) in 157.8 µs, against 42.2 µs.

This PR adds an LL two-shot all-reduce (reduce-scatter + all-gather) for 1 MiB up to ranks × 2 MiB at 4+ ranks. The same message now takes 25.6 µs and 34.5 µs.

Dev record

  • Found:
    • On MI455X a fabric round trip is ~5 µs, the same within a tray and across trays.
    • Remote-store bandwidth grows with the number of stores in flight, to ~1.1 TB/s per GPU.
    • So 1–8 MiB all-reduces are bound by round trips and traffic, not by the link. RCCL DDA's TwoShotLL needs ~40 µs for 1–4 MiB at TP8. aiter's one-shot LL sends (n−1) × size × 2; its pull reads (n−1) × size.
  • Decided:
    • ar_2s_ll_gfx1250 uses ar_ll_gfx1250's LL lines, scratch banks and per-block epochs (d_ll_block_flags_). The two kernels interleave safely and no buffer is added: the reduce-scatter and all-gather slots fit one bank, which caps the two-shot at ranks × 2 MiB.
    • It reads its input in place (no copy-in); all_reduce skips the staging copy for it as for the one-shot.
    • Routing is by size in allreduce() only: no Python change and no new environment variable. AITER_CUSTOM_AR_MAX_SIZE and AITER_CUSTOM_AR_DISABLE_LL keep their meaning.
    • Both LL kernels launch 512-thread blocks once 256-thread blocks would put more than one block on a CU (CU count read at run time). At TP8 the one-shot at 0.57 MB goes from 20.0 to 18.0 µs, level with RCCL.
    • Check use_2s_ll, allreduce_2s_ll and ll_threads_for.
  • Surprised:
    • On gfx1250, a load issued after a remote store in the same wave returns only once that store has completed, about a round trip. The wave also waits (s_wait_xcnt) before it overwrites the data VGPRs of a store in flight.
      • A first version that interleaved loads with remote stores paid a round trip per store.
      • The kernel loads everything a phase needs, then issues all its stores back to back, each from its own VGPRs. Peers are visited as (rank + k) % ngpus, so register arrays are indexed at compile time.
    • A poll loop without the asm volatile("" ::: "memory") barrier that ll_load_b128 carries is deleted by the compiler, and a test with a fixed input still passes. The new regression test negates its inputs every other round.
  • Left undone:
    • Above 8 MiB at TP8 RCCL is faster than the two-shot (14.7 MB: 51 vs 59 µs), so 8 MiB is the useful cap there. A non-LL two-shot could take that range.
    • Above ranks × 2 MiB the custom path is still the one-shot pull, as on main.

Named result

Kimi-K3 TP8+DCP8, MLPerf Endpoints agentic, concurrency 16, two MI455X trays: decode TPOT −4.5%, tok/s/user +4.8%, tok/s/GPU +3.2%. Accuracy is unchanged.

con16 main this PR Δ
tok/s/GPU 95 98 +3.2%
system tok/s 762 785 +3.0%
tok/s/user 69.0 72.3 +4.8%
TPOT p50 13.4 ms 12.8 ms −4.5%
TTFT p50 / p90 0.28 / 0.47 s 0.25 / 0.46 s −11% / −2%
turns completed 1185 in 627 s 1277 in 631 s +7.8%
mean output length 403.5 387.9
inline accuracy 61.88% 61.22% both above the 58.32% bar; 0 failed turns

How it was measured:

  • The image's MLPerf repro kit (rocm/fw-bringup:gfx1250-atom-k3-20261103, /opt/k3/k3-mlperf-repro): agentx, MoE TP8, DSpark 4 drafts, max-num-seqs 32, FP8 KV with block 128, HERD.
  • One measured run per arm: 613 trajectories with a 10-minute issue cap, after a gate and a warmup with other seeds.
  • main: the kit as shipped, AITER_CUSTOM_AR_MAX_SIZE=8388608, default RCCL. It is a separate baseline run of the same kit on another MI455X tray pair.
  • this PR:
    • the kit with this PR's aiter (plus aiter [FlyDSL] optimize dsv4.1, k3, m3 moe perf for gfx1250 #7296's K3 TP8 MoE fix, which the image needs to start);
    • AITER_CUSTOM_AR_MAX_SIZE=8388608, RCCL_DDA_LL_ONESHOT_THRESHOLD=2097152 and RCCL_DDA_LL_TWOSHOT_THRESHOLD=134217728. The two RCCL settings only change RCCL's > 8 MiB (prefill) all-reduces; every decode all-reduce here is ≤ 8 MiB and takes this PR's kernels.

The TPOT drop (−0.6 ms) matches what the per-op numbers below predict for a full c16 decode step, which is 80 tokens: −0.7 ms. That step does one [80, 7168] and one [80, 3584] all-reduce in each of 92 layers.

K3 decode all-reduces per step (attention output [T, 7168] + MoE latent [T, 3584], 92 layers, T = 5 × concurrency, TP8 per-op times below):

concurrency main this PR
c16 4.5 ms 3.8 ms
c32 7.0 ms 4.5 ms
c64 18.9 ms 5.5 ms
c80 21.9 ms 5.6 ms

Gates

  • op_tests/multigpu_tests/test_custom_allreduce.py --regression -t 4 passes with --transport symm and --transport auto. It covers the tail shapes, LL128, the gfx1250 LL mixed sizes, and the new gfx1250 LL two-shot mixed sizes: 200 rounds of 1.15 / 0.36 / 4.59 MB, with the inputs negated every other round.
  • TP8 across two trays: 200 calls per size, each with a fresh random input, from 1 × 7168 to 585 × 7168 bf16. Every result matches an fp32 all-reduce to bf16 rounding: max |err| 0.031–0.059, against 0.14–0.17 for RCCL.
  • No size is slower than on main at TP2, TP4 or TP8 beyond run-to-run noise (tables below):
    • ≤ 512 KiB: same kernel, same launch, within ±3%;
    • 0.5–1 MiB: same kernel, wider blocks;
    • 1–16 MiB: the two-shot replaces the one-shot LL and the pull at 4+ ranks;
    • above 16 MiB: unchanged.
  • TP2 runs only the one-shot, with wider blocks above 512 KiB: within ±2% up to 0.57 MB, 7–24% faster from 0.92 to 4 MiB.
  • black clean. ruff reports only I001 on the test's import block, which main's version of the file reports too. clang-format not run: none in the build image.
Evidence

TP8, two MI455X trays (4 + 4 GPUs) over UALink, bf16, 50 all-reduces captured in one CUDA graph. µs an op, median of 5 replays, slowest rank. RCCL 2.30.7 with RCCL_DDA_LL_ONESHOT_THRESHOLD=2097152 and RCCL_DDA_LL_TWOSHOT_THRESHOLD=134217728; its default settings are slower or equal.

size MB RCCL main this PR kernel (this PR)
1 × 7168 0.01 12.2 10.4 9.9 one-shot
25 × 7168 0.36 15.2 14.5 14.9 one-shot
40 × 7168 0.57 17.2 20.0 18.0 one-shot, 512 threads
64 × 7168 0.92 20.7 22.5 21.0 one-shot, 512 threads
80 × 7168 1.15 29.7 28.8 23.3 two-shot
128 × 7168 1.84 32.8 38.5 23.1 two-shot
160 × 7168 2.29 39.2 47.9 25.6 two-shot
400 × 3584 2.87 40.4 56.3 25.4 two-shot
256 × 7168 3.67 40.7 74.0 26.3 two-shot
320 × 7168 4.59 42.2 157.8 34.5 two-shot, 512 threads
400 × 7168 5.73 42.3 181.7 35.6 two-shot, 512 threads
585 × 7168 8.39 44.3 270.9 40.6 two-shot, 512 threads
1024 × 7168 14.68 53.8 401.9 59.1¹ two-shot; RCCL is faster here, so cap custom at 8 MiB

¹ This size was timed on a second tray pair, which is faster than the first: two-shot 59.1 µs vs RCCL 51.0 there, and 20.2 / 32.5 µs at 2.29 / 4.59 MB.

TP4 and TP2, one MI455X tray, same method, custom path only (main → this PR, µs):

size MB TP4 main TP4 this PR TP2 main TP2 this PR
25 × 7168 0.36 7.5 7.3 5.5 5.7
40 × 7168 0.57 9.9 9.7 6.7 6.8
64 × 7168 0.92 11.9 11.0 8.2 7.2
80 × 7168 1.15 14.3 10.5 10.6 8.1
128 × 7168 1.84 18.4 11.2 11.9 11.1
160 × 7168 2.29 22.6 17.2 15.3 13.0
256 × 7168 3.67 31.9 19.5 20.3 15.5
320 × 7168 4.59 66.2 25.1
400 × 7168 5.73 72.1 26.5
585 × 7168 8.39 100.1 29.1

At TP2 the two-shot is not used: ≤ 4 MiB stays on the one-shot (512-thread blocks above 512 KiB), and above 4 MiB stays on the pull, as on main.

Fabric, MI455X (one thread bouncing a flag; puts of 16 MB per peer):

within a tray across trays
round trip 4.8 µs 5.0 µs
put to 1 peer 0.78–0.80 TB/s 0.77–0.82 TB/s
put to all 7 peers 1.16 TB/s (same run)

…ages

On gfx1250 the custom all-reduce had a flat one-shot LL kernel up to 4 MiB,
which sends (n - 1) x the message per rank (x2 for LL lines), and above that a
one-shot pull (ar_gfx1250_naive_unroll4) that is 4-8x slower than RCCL at TP8.

Add ar_2s_ll_gfx1250, a reduce-scatter + all-gather over the same LL lines,
scratch, banks and per-block epochs as ar_ll_gfx1250, so no buffer is added.
Each rank sends 2 (n - 1) / n x the message (x2 for LL lines), for one more
fabric round trip. It takes inputs from 1 MiB up to world_size x 2 MiB (one
bank of the LL scratch) at 4+ ranks and reads them in place (no copy-in). The
existing knobs keep their meaning: AITER_CUSTOM_AR_MAX_SIZE caps it and
AITER_CUSTOM_AR_DISABLE_LL turns it off with the one-shot LL.

Also launch both LL kernels with 512-thread blocks once 256-thread blocks
would put more than one block on a CU (the CU count is read at run time): at
TP8 the one-shot at 0.57 MB drops from 20.0 to 18.0 us, level with RCCL.

MI455X, TP8 across two trays over UALink, bf16, CUDA graph, us per call:

  size      RCCL*   before   after
  0.57 MB   17.2    20.0     18.0   one-shot, 512-thread blocks
  1.15 MB   29.7    28.8     23.3   two-shot
  2.29 MB   39.2    47.9     25.6
  3.67 MB   40.7    74.0     26.3
  4.59 MB   42.2    157.8    34.5
  8.39 MB   44.3    270.9    40.6
  * RCCL 2.30.7 with RCCL_DDA_LL_ONESHOT_THRESHOLD=2097152 and
    RCCL_DDA_LL_TWOSHOT_THRESHOLD=134217728

Tests: test_custom_allreduce.py gains a gfx1250 LL two-shot mixed-size
regression. It runs two-shot and one-shot sizes back to back and negates the
inputs every other round, so a stale line cannot pass. The --regression suite
passes at TP4 with --transport symm and auto. At TP8 across two trays, 200
calls per size, each with a fresh random input, match an fp32 all-reduce to
bf16 rounding.

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

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7432 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@aiter-bot

aiter-bot commented Nov 4, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 8a8041ac018f · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/multigpu_tests/test_custom_allreduce.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/multigpu_tests/test_custom_allreduce_size_env.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@zejunchen-zejun
zejunchen-zejun marked this pull request as ready for review November 4, 2026 12:29
@zejunchen-zejun
zejunchen-zejun requested review from a team and a balanced review from Copilot November 4, 2026 12:29
@github-actions github-actions Bot added the HIP label Nov 4, 2026

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

The new fast path changes rank accumulation order, breaking tested BF16 numerical behavior, while regression tests leave stale-buffer reuse and TP6 two-shot coverage gaps.

3 open issues
What changed in this PR

This PR adds a gfx1250 two-shot custom all-reduce path to reduce communication traffic for larger messages, while reusing the existing LL scratch buffers and epoch tracking.

Changes:

  • Adds reduce-scatter plus all-gather routing for eligible messages from 1 MiB through ranks × 2 MiB at four or more ranks.
  • Skips input staging for the new path and selects LL block sizes using the GPU’s compute-unit count.
  • Adds mixed-size regression coverage with alternating input signs.
File Description
op_tests/​multigpu_tests/​test_custom_allreduce.py Adds mixed one-shot/two-shot regression cases and alternating inputs.
csrc/​kernels/​custom_all_reduce_gfx1250.cu Skips staging copies for both LL all-reduce paths.
csrc/​include/​custom_all_reduce_gfx1250.cuh Implements the two-shot kernel, dispatch conditions, and adaptive block sizing.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 5, 2026 06:06

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.

🔵 Needs a closer look

The two-shot kernel’s changed accumulation order breaks the established BF16 numerical reference, while regression gaps can hide stale payloads and skip two-shot execution entirely at TP6.

3 open issues

Review effort: Balanced

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

Review summary — #7432 gfx1250 LL two-shot all-reduce

The 1–8 MiB gains are compelling, but two things need to change before merge.

1. Rank-order summation is broken (blocking)

ar_2s_ll_gfx1250 (custom_all_reduce_gfx1250.cuh:449-476) adds the chunk owner's value first, then ranks rank-1, rank-2, .... Since #6954, every other custom-AR path sums ranks in a fixed 0..n-1 order. #6954 removed exactly this owner-first pattern.

  • The result bits now depend on which rank owns an element (its row offset). They also change when a message crosses 1 MiB and switches between one-shot and two-shot, so results are no longer batch-invariant.
  • At TP4, test_custom_allreduce_rank_order.py now sends [97,7168] bf16/fp16 and [512,7168] bf16 through this kernel. Its partials summed in this order give different bits (e.g. bf16 −0.02795 vs −0.02808 expected).
  • The new regression test uses integer-valued inputs, so the fp32 sums are exact and the test cannot catch this.

Fix: poll into w[s] indexed by sender rank (unrolled s = 0..n-1, skipping s == rank, so indexing stays compile-time). Accumulate in rank order with the local value at position rank. Then run test_custom_allreduce_rank_order.py on gfx1250 TP4.

2. Keep the two-shot independent of the LL scratch

The two-shot currently reuses the one-shot LL's state:

  • the peer scratch and banks (d_ll_peers_, flag & 1)
  • the epoch array (d_ll_block_flags_)
  • its size cap (ws × 2 MiB), which is derived from kLLPackCapacity

This couples the two kernels. Any later change to the LL scratch layout or capacity would silently change the two-shot's correctness and routing. Interleaving safety also has to be reasoned about across both kernels.

Please:

  • Give the two-shot its own scratch region in the meta buffer, with its own offset/size constants counted in meta_size(), and its own epoch array.
  • Size that region from the two-shot's own cap, not from kLLPackCapacity.
  • Leave ar_ll_gfx1250, kLLScratchCapBytes / kLLPackCapacity and the LL scratch layout unchanged.

3. Take the upper cap from measurements

Your TP8 data shows RCCL ahead above ~8 MiB (14.68 MB: 59.1 µs vs 51–54 µs). use_2s_ll still accepts up to 16 MiB, and AITER_CUSTOM_AR_MAX_SIZE defaults to 64 MiB, so default configs take the slower path. Set the cap per TP in code from the measured crossover. That cap also sets the size of the new scratch region.

zejunchen-zejun and others added 3 commits November 5, 2026 18:38
ar_2s_ll_gfx1250 reduced the owner's value first, then the other ranks in
descending ring order. Since #6954 every other custom all-reduce sums ranks
0..n-1, with the local value at its own rank. Under the owner-first order an
element's bits depended on which rank owns its chunk, that is, on its offset
in the message. They also changed when a message crossed 1 MiB, between the
one-shot and the two-shot. At TP4, test_custom_allreduce_rank_order.py sends
[97, 7168] bf16/fp16 and [512, 7168] bf16 through this kernel.

The reduce now polls slots s = 0..ngpus-1, where slot s holds rank s's
packet, and sums them in that order with the local value at position rank.
The own slot is loaded too, which keeps the loads free of branches; its
contents go unused. All indices stay compile-time. Built for gfx1250, the
TP8 bf16 kernel takes 56 VGPRs instead of 50, at the same occupancy
(16 waves/SIMD) and with no spills.

The two-shot's mixed-size regression used integer inputs, whose fp32 sums are
exact in any order. It now sums random fp32 partials and checks every round,
bit for bit, against their sum in rank order 0..n-1, at any TP. The message
sizes in bytes are unchanged, and so are the kernels and launch shapes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…50 LL two-shot

The two-shot reused the one-shot LL's state. It carved each LL bank into
chunk-sized reduce-scatter and all-gather regions, shared the LL per-block
epochs, and derived its size cap (world_size x 2 MiB) from kLLPackCapacity.
A change to the LL scratch layout or capacity would therefore have changed
the two-shot's correctness and routing without notice.

- Own scratch: after the fused AR + RMSNorm shard in the meta buffer
  (ar2sScratchOffset). It is counted in meta_size(), so every transport
  zero-initializes it with the rest. It has two banks, each with a
  reduce-scatter and an all-gather region of ar2sMaxBytes / 8 lines. That is
  8 x ar2sMaxBytes a rank: 64 MiB at TP4 and TP8, nothing at TP2 or TP6.
- Own peer table and per-block epochs (d_2s_peers_, d_2s_block_flags_),
  built at construction like the LL tables, so nothing is allocated inside a
  graph capture.
- A per-world-size cap from measurements (ar2sMaxBytes), which also sizes the
  scratch:
  - TP8, two MI455X trays: 8 MiB. The two-shot is ahead of RCCL at 8.39 MB
    (40.6 vs 44.3 us) and behind at 14.68 MB (59.1 vs 51.0 us).
  - TP4: 8 MiB, as before. RCCL within a tray is not measured yet.
  - TP6: off, as it is not measured.
- ar_ll_gfx1250, ag_ll_gfx1250, kLLScratchCapBytes, kLLPackCapacity and the
  LL scratch layout are unchanged. Built for gfx1250, the one-shot and
  all-gather LL kernels keep identical resource usage.

With AITER_CUSTOM_AR_MAX_SIZE unset (64 MiB), an all-reduce of 8-16 MiB at
TP8 now takes the one-shot pull (ar_gfx1250_naive_unroll4), as on main,
rather than the two-shot. Sending it to RCCL by default needs a per-TP
gfx1250 AR cutoff in _resolve_custom_sizes, which is left for the review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 10:50

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. Try requesting a review at a lower effort level.

…nk reuse

Rounds of the mixed-size regression alternated x and -x. A kernel reuses
the same scratch bank every second call of that kernel. For a kernel called
once a round (here the one-shot LL), the bank's previous contents therefore
carried the sign now expected, and accepting a stale line would still have
passed the exact comparison. Rounds now cycle through x, -x and 2x, which is
exact both in fp32 and on bf16 integers. The previous use of any bank, one or
two rounds back, never carries the expected bits.

The test now runs only at TP4 and TP8, where the two-shot runs (ar2sMaxBytes);
at TP6 it only ever exercised the one-shot and the pull.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 10:57

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. Try requesting a review at a lower effort level.

@zejunchen-zejun

zejunchen-zejun commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, @TennyWang1223 . All three points are addressed. The commits sit on top of a merge of main, which brings in #7433:

  • 267f69c covers point 1, rank order.
  • 930c527 covers point 2, own scratch and epochs, and point 3, the per-TP cap.
  • 5c522b3 covers Copilot's two test comments.

1. Rank-order summation (267f69c)

  • The reduce now polls slot s = 0..n-1, where slot s holds rank s's packet. It sums them in that order with the local value at position rank, as ar_ll_gfx1250 does since [HIP] fix(custom_ar): sum ranks in a fixed order on every reduce path #6954. An element's bits no longer depend on which rank owns its chunk, or on whether the one-shot or the two-shot reduced it.
  • I deviated from your sketch in one place. Instead of skipping s == rank, the own slot is loaded too and its contents are ignored. A per-slot if (s != rank) raised the TP8 kernel from 50 to 78 VGPRs and dropped occupancy from 16 to 12 waves/SIMD. Loading every slot gives 56 VGPRs, 16 waves/SIMD and no spills (gfx1250 build, -Rpass-analysis=kernel-resource-usage). Indexing stays compile-time.
  • As you said, the regression's integer inputs could not catch this. It now uses random fp32 partials and compares every round bit for bit with a CPU sum in rank order 0..n-1. That also covers TP8; the partials in test_custom_allreduce_rank_order.py are TP4-only.

2. Own scratch and epochs (930c527)

  • The two-shot has its own region after the AR+RMSNorm shard: ar2sScratchOffset(ws) = arRmsShardOffset(ws) + kArRmsShardBytes. Its size, ar2sScratchBytes(ws), is counted in meta_size(), so every transport zero-initializes it with the rest of the buffer.
  • The region has two banks. Each bank holds a reduce-scatter region and an all-gather region of ar2sMaxBytes / 8 lines at fixed offsets. That makes 8 × cap per rank: 64 MiB at TP4/TP8 and nothing at TP2/TP6.
  • The two-shot has its own peer table and per-block epoch array (d_2s_peers_, d_2s_block_flags_). Both are built in the constructors next to the LL tables, so nothing is allocated during capture.
  • ar_ll_gfx1250, ag_ll_gfx1250, kLLScratchCapBytes / kLLPackCapacity and the LL scratch layout are unchanged. Built for gfx1250, both LL kernels have the same resource usage as before.
  • The only LL-side change left in the PR is the one-shot's launch width from ll_threads_for. It is host-side and independent of the scratch. I'm happy to split it out if you prefer.

3. Cap (930c527)

ar2sMaxBytes(world_size) caps the two-shot and sizes its scratch:

World size Cap Basis
TP8 (two trays) 8 MiB Ahead of RCCL at 8.39 MB (40.6 vs 44.3 µs), behind at 14.68 MB (59.1 vs 51.0 µs).
TP4 (one tray) 8 MiB, as before Ahead of the one-shot pull up to 8.39 MB (29.1 vs 100.1 µs). I still need RCCL numbers within a tray, and will lower the cap if RCCL wins earlier.
TP6 off Not measured.

One caveat on "default configs take the slower path". With AITER_CUSTOM_AR_MAX_SIZE unset (64 MiB), an 8–16 MiB message at TP8 now goes to ar_gfx1250_naive_unroll4, as on main, and not to RCCL. At 14.68 MB that path takes 401.9 µs, against 51–54 µs for RCCL and 59.1 µs for the two-shot it replaces.

Sending these messages to RCCL by default needs the gfx1250 AR cutoff in _resolve_custom_sizes to follow the same per-TP table. That cutoff also gates the fused AR+RMSNorm path, so I left it out. Would you like it in this PR, or as a follow-up to #7433?

Copilot's test comments (5c522b3)

  • Rounds now cycle through x, −x and 2x, all exact, instead of alternating the sign. A bank's previous contents never match the expected bits, for either kernel's epochs.
  • The two-shot regression runs at TP4 and TP8 only, since TP6 no longer takes the two-shot.

@zejunchen-zejun

zejunchen-zejun commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Validation on MI455X (gfx1250), head 5c522b3

Setup

  • Image: the 2026-11-04 gfx1250 ATOM image (torch 2.11.0, ROCm 10.1), with the PR tree JIT-built inside it.
  • Trays: one tray (TP4), and two trays over UALink with the symm transport (TP8).
  • "First revision" is the image's aiter. Its custom all-reduce files are identical to 0f9ba52.
  • Timings:
    • Messages are bf16 [T, 7168]. 50 all-reduces are captured in one CUDA graph. Each rank takes the median of 5 replays, and the slowest rank is reported.
    • Env: AITER_CUSTOM_AR_MAX_SIZE=8388608, RCCL_DDA_LL_ONESHOT_THRESHOLD=2097152, RCCL_DDA_LL_TWOSHOT_THRESHOLD=134217728.
    • Repeated passes agree within about 1 µs, usually 0.5 µs.

Checklist

  • test_custom_allreduce_rank_order.py, TP4: all 15 cases pass.
    • With the first revision it fails exactly the cases that take the two-shot at TP4, on all 4 ranks: bf16 [97,7168], bf16 [512,7168] with use_new True and with use_new False, and fp16 [97,7168].
    • So the test catches the old summation order, and 267f69c fixes it.
  • --regression -t 4: passes with --transport auto (IPC) and with --transport symm.
  • -t 8: the test spawns every rank on one host, so it can't run on 4-GPU trays.
    • I ran its own per-rank functions across two trays, with the arguments its drivers build for TP8.
    • Tail, gfx1250 LL (1000 rounds) and the LL two-shot (200 rounds, fp32 rank order, x/−x/2x) pass on all 8 ranks.
    • Random bf16 partials at 1.15–8.39 MB also match the fp32 rank-order sum bit for bit, at TP4 and at TP8.
  • TP8 timing at 1.15 / 2.29 / 4.59 / 8.39 MB: 22.3 / 24.4 / 34.0 / 41.8 µs. The first revision gives 22.4 / 24.6 / 34.3 / 40.4 on the same trays, and the earlier numbers were 23.3 / 25.6 / 34.5 / 40.6.
    • This is one pass only. TP8 RCCL below 14.68 MB still needs a clean run, because another job started on one tray partway through.
    • RCCL at 14.68 MB: 50.9–51.6 µs.
  • RCCL at TP4: see the table below. RCCL is ahead from 4.24 MB on both transports.

TP4, µs

MB RCCL two-shot, IPC two-shot, symm one-shot pull
1.15 15.4 15.4 10.1 40.1
1.84 16.8 17.0 10.6 43.2
2.29 21.6 17.6 17.1 43.9
3.67 22.8 19.5 18.5 48.5
4.19 23.4 20.8 19.1
4.20 23.7 21.9 19.2
4.24 23.5 26.9 26.3
4.59 23.8 28.9 26.5 64.0
5.73 24.8 29.9 27.2 70.2
8.39 27.6 33.9 30.1 89.3
14.68 41.3 133.5

Notes

  1. The TP4 crossover is a step, not a gradual slope.
    • The two-shot takes 19–22 µs at 4.20 MB (257 blocks) and 26–27 µs at 4.24 MB (259 blocks). That is where its grid of 512-thread blocks passes the 256 CUs.
    • The same point is world_size × 1 MiB: 4 MiB at TP4 and 8 MiB at TP8. 8 MiB is the TP8 cap in this PR.
    • So ar2sMaxBytes = world_size × 1 MiB matches the measurements, which gives 4 MiB at TP4.
    • RCCL's default env gives the same numbers as the tuned one above 2 MiB, so the crossover doesn't depend on the DDA settings.
  2. Lowering the TP4 cap by itself makes 4–8 MiB slower.
    • Those messages would fall through to the one-shot pull: 64–89 µs, against 29–34 µs for the two-shot today and 24–28 µs for RCCL.
    • So the TP4 cap and the gfx1250 RCCL cutoff in _resolve_custom_sizes should move in the same PR. If the cutoff goes in the follow-up, keep TP4 at 8 MiB until then.
    • With the default 64 MiB AITER_CUSTOM_AR_MAX_SIZE, 8–16 MiB at TP4 already takes the pull: 133.5 µs vs 41.3 µs for RCCL at 14.68 MB. That is the same as at TP8 (401.9 vs 51–54 µs).
  3. Cost of the fixes at TP4, two passes per commit. 3313c1e is main merged in, before the fixes.
    • The main merge changes nothing.
    • 267f69c is 0.7–1.8 µs faster at 1.15–3.67 MB on IPC. It is 1.0–2.2 µs (3–8%) slower at 4.59–8.39 MB on both transports.
    • 930c527 is neutral or slightly faster.
    • The slower range is the one RCCL takes anyway once the cap is 4 MiB.
  4. Gain over the PR's base (one-shot LL up to 4 MiB), TP4, 1.15–4.16 MB: the two-shot is 3–38% faster on IPC and 23–44% faster on symm. The 512-thread one-shot launch is 10% faster at 0.92 MB.
  5. IPC vs symm within one tray: at 1.15–1.84 MB the two-shot on IPC is 50–60% slower than on symm (15.4 vs 10.1 µs), and there it only ties RCCL. The first revision shows the same, so this PR didn't cause it.

@haoyangli0109

Copy link
Copy Markdown
Contributor

Suggestion:

  • On gfx1250, give plain all-reduce its own default cutoff per world size, used only when AITER_CUSTOM_AR_MAX_SIZE is unset. An explicit value keeps its current meaning.
  • Apply it in CudaCommunicator.all_reduce, where plain AR chooses between custom and RCCL, rather than in should_custom_ar. The fused AR+RMSNorm paths then keep today's cutoff and need no new measurements, and the fused fallback picks up the new rule through self.all_reduce. test_custom_allreduce.py and test_custom_allreduce_rank_order.py, which assert should_custom_ar above 8 MiB, stay valid.
  • Take the upper bound from C++ (for example a binding that returns max(kLLArMaxBytes, ar2sMaxBytes(ws))) rather than copying the table into Python. The C++ cap then says what the kernel can take and sizes its scratch; the Python default is the measured RCCL crossover, at or below it.

@zejunchen-zejun

Copy link
Copy Markdown
Contributor Author

Thanks @lihaoyang-amd , this split is better than moving the cutoff in _resolve_custom_sizes. I'll take it in this PR.

  • C++ cap = what the kernel takes.

    • ar2sMaxBytes stays 8 MiB at TP4 and TP8, and keeps sizing the scratch.
    • A binding returns max(kLLArMaxBytes, ar2sMaxBytes(ws)) as the upper bound, so Python doesn't copy the table.
    • This corrects note 1 of my validation comment: world_size × 1 MiB is the default cutoff below, not ar2sMaxBytes.
    • Keeping TP4 at 8 MiB means an explicit AITER_CUSTOM_AR_MAX_SIZE=8388608 at TP4 still takes the two-shot (29–34 µs at 4.6–8.4 MB). A lower cap would send it to the one-shot pull instead (64–89 µs).
  • Python default = the measured RCCL crossover. It covers gfx1250 plain all-reduce only, is applied in CudaCommunicator.all_reduce, and is used only when AITER_CUSTOM_AR_MAX_SIZE is unset.

    World size Default Basis
    TP4 4 MiB The two-shot steps from 19–22 µs to 26–27 µs between 4.20 and 4.24 MB; RCCL is 23.4–23.7 µs there.
    TP8 8 MiB At 8.39 MB the two-shot is still ahead: 42.5 µs vs 44.1 µs for RCCL (head, today's TP8 rerun). At 14.68 MB RCCL takes 50.4 µs, where the first revision's two-shot took 59.1 µs.
    TP2, TP6 unchanged Not measured.

    With the env unset, this moves:

    • 4–8 MiB at TP4 from the two-shot (29–34 µs) to RCCL (24–28 µs);
    • 8–16 MiB at TP4 from the pull (133.5 µs at 14.68 MB) to RCCL (41.3 µs);
    • 8–16 MiB at TP8 from the pull (401.9 µs) to RCCL (51–54 µs).
  • Unchanged:

    • The fused AR+RMSNorm paths keep today's cutoff, and their fallback picks up the new default through self.all_reduce.
    • should_custom_ar doesn't change, so the tests that assert it don't either.
  • New test: check that the default applies only when the env is unset and that every rank makes the same choice.

@zejunchen-zejun

Copy link
Copy Markdown
Contributor Author

Hi @TennyWang1223 @haoyangli0109 @zufayu
could you help review the PR again? Thank you

@haoyangli0109 haoyangli0109 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,
But we still need tenny's approval.
cc @TennyWang1223

…nders and pollers in separate waves

Decode-size all-reduces at TP8 were slow in both LL kernels:
- each 16-byte line carried 8 bytes and two flags, so a rank moved 2 x its
  payload on the wire;
- a poll was issued after the same wave's remote stores, and on gfx1250 a
  load after a remote store waits for that store (about a fabric round trip)
  while a peer's line lands in about half of one;
- the one-shot polled the peers one after another and re-read the peer table
  (scalar loads) between its stores.

Both kernels now send 12-byte lines with one flag (a line is a single 16-byte
store and load, so one flag guards it), read the peer bases once before any
store, and poll every peer in one batch. The one-shot runs W senders and W
pollers a block; the two-shot three wave groups (send the reduce-scatter;
poll, reduce and send the all-gather; poll the all-gather). Both still sum in
rank order in fp32 and round once, so results are bit-identical to before.
The two-shot's per-source slots start on 4 KiB boundaries (a misaligned slot
cost ~3 us a call). Blocks: the smallest W with one block a CU. The two-shot
takes over from 768 KiB at TP8 (ar2sMinBytes; 1 MiB elsewhere).

MI455X TP8 across two trays, bf16, 50 all-reduces in one CUDA graph, us an
all-reduce (slowest rank), before -> after:
[40, 3584] 0.29 MB 15.8 -> 11.4, [40, 7168] 0.57 MB 19.1 -> 13.4,
[80, 7168] 1.15 MB 23.8 -> 18.1, [115, 3584] 0.82 MB 22.0 -> 16.9,
[115, 7168] 1.65 MB 26.0 -> 18.1, [320, 7168] 4.59 MB 34.9 -> 26.5.
Checked bit for bit against an fp32 rank-order sum at 28 shapes, with 600
mixed calls interleaving the all-gather, and over CUDA-graph replays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 03:00

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. Try requesting a review at a lower effort level.

@TennyWang1223
TennyWang1223 self-requested a review November 10, 2026 08:16

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

Review summary — #7432 (head 6b28946)

Verdict: Request changes. Up to 5c522b3 the PR was close to mergeable. The blockers come from the last commit 6b28946 and from one promised change that was never pushed.

Previous review points

# Point Status
1 Sum ranks in order 0..n−1 ✅ Fixed in 267f69c
2 Two-shot gets its own scratch and epochs; LL left unchanged ⚠️ Fixed in 930c527, then 6b28946 rewrote ar_ll_gfx1250
3 Per-TP cap taken from measurements ⚠️ Partly done: the C++ cap is in, the promised Python default is missing

Must fix

1. 6b28946 rewrites the one-shot LL kernel, with no PR comment and no posted validation

  • ar_ll_gfx1250 is the path every gfx1250 decode all-reduce of 1 MiB or less takes, at every TP. Point 2 asked to leave it unchanged, and your 11-05 reply said it was.
  • It was pushed after the only approval, so that approval covers 5c522b3, not head.
  • The new U=2/4 sender paths (one-shot messages above ~1.5 MiB, e.g. TP2) are outside the --regression runs you reported.
  • Action: split the one-shot rewrite into its own PR, or post TP2/4/8 correctness and timing for 6b28946. Either way, update the PR description: it still describes the first revision.

2. The one-shot is no longer safe when out aliases inp

  • Sender and poller now run in different waves. A poller writes out[3i+q] as soon as the peers' lines arrive, without waiting for this rank's sender to load in[3i+q].
  • If out == inp, this rank can publish the already-reduced value, and every peer gets a wrong sum with no error.
  • Base was alias-safe because each thread published before it reduced. The all-gather has ll_ag_reads_in_place; all_reduce() has no such check.
  • Action: in all_reduce(), reject an out that overlaps inp on the LL paths, or restore alias safety in the kernel.

3. One flag per 16-byte line requires 16-byte remote atomicity

  • Base lines were [d0, f0, d1, f1] and both flags were checked, which needs only 8-byte atomicity. Both LL all-reduce kernels now carry [d0, d1, d2, flag] and check word 3 only.
  • If a remote global_store_b128 over UALink can be split, a poller can read a new flag with stale data.
  • Action: cite the gfx1250 / UALink spec that guarantees 16-byte single-copy atomicity for system-scope b128 stores and loads to a peer. Otherwise keep a flag per 8 bytes.

4. The default cutoff promised on 11-05 is missing

  • The diff has no Python change, no binding returning max(kLLArMaxBytes, ar2sMaxBytes(ws)), and no cutoff test.
  • With AITER_CUSTOM_AR_MAX_SIZE unset, TP4 4–8 MiB takes the two-shot, which you measured slower than RCCL. 8–16 MiB at TP4/TP8 still takes the pull: 133–402 µs vs 41–54 µs for RCCL.
  • Action: add the cutoff in this PR, or state on the PR that it moves to a linked follow-up.

zejunchen-zejun and others added 2 commits November 11, 2026 03:02
… one-shot safe in place

Review of 6b28946 (#7432):

- Lines carry 8 bytes again, [d0, flag, d1, flag], and a reader takes a line
  only once both flags carry the epoch, so a line has to land atomically per
  8 bytes only. The 12-byte lines with one flag relied on a remote b128 store
  landing atomically as a whole, which no gfx1250 or UALink document
  guarantees.
- The one-shot is safe with recvbuff == sendbuff again. Its sender also
  writes the line to its own scratch, first, and the poller takes the local
  value from that line. So no output is written before its input packet has
  been loaded and sent.
- The two-shot runs send, reduce and gather in three wave groups while one
  block of 3 x 128 threads a CU covers a chunk, else in two, with gather in
  the send group, so a block covers more packets a CU. It takes over from
  the one-shot at 512 KiB at TP8 (1 MiB at TP4, as before).
- Kept from 6b28946: sender and poller waves, batched polls, peer bases
  read once into registers.

MI455X, bf16, CUDA graph, us an all-reduce (slowest rank), 5c522b3 -> this:
  TP8, two trays: 0.29 MB 14.6 -> 12.0, 0.57 MB 17.6 -> 13.5,
                  1.15 MB 22.6 -> 15.3, 1.65 MB 24.3 -> 15.6,
                  4.59 MB 34.2 -> 28.4, 8.39 MB 41.5 -> 39.2
  TP4: 1.15 MB 14.6 -> 10.4, 2.29 MB 17.1 -> 14.2, 4.59 MB 27.5 -> 22.2
  TP2: 1.65 MB 11.7 -> 9.5, 2.29 MB 13.8 -> 11.9

The regression test gets an in-place case (output aliasing the input) that
covers the one-shot with 1, 2 and 4 packets a sender, and the two-shot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the measured crossover

As agreed on #7432 (11-05). On gfx1250, with AITER_CUSTOM_AR_MAX_SIZE unset,
plain all-reduce (CudaCommunicator.all_reduce) runs the custom kernels only
up to about where RCCL becomes faster: 4 MiB at TP2 and TP4, 8 MiB at TP8.
Larger inputs went to the two-shot (TP4, 4-8 MiB) or to the one-shot pull,
which takes 405 us at 14.68 MB at TP8 against 55 us for RCCL.

- New binding ll_ar_max_bytes(world_size): the largest input the LL kernels
  take, max(kLLArMaxBytes, ar2sMaxBytes). The default never exceeds it, so
  Python does not copy the C++ caps.
- An explicit AITER_CUSTOM_AR_MAX_SIZE keeps its meaning. TP6 and gfx9 keep
  the AR cutoff.
- should_custom_ar and the fused AR + RMSNorm paths are unchanged; their
  fallback to all_reduce picks up the default.
- Tests: the default applies only with the env unset
  (test_custom_allreduce_size_env.py), and every rank resolves the same
  cutoff and takes the same path (test_custom_allreduce.py --regression).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 03:03

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. Try requesting a review at a lower effort level.

@zejunchen-zejun

Copy link
Copy Markdown
Contributor Author

Thanks @TennyWang1223. All four points are addressed in two commits on top of 6b28946:

  • a5382b7 covers points 1–3: lines with a flag per 8 bytes, and the one-shot safe in place. It adds an in-place regression.
  • 04c61b7 covers point 4: the default cutoff, the binding and its tests.

I kept the one-shot rewrite in this PR, with the validation below. The PR description is rewritten for the current head. Its Evidence section has the full TP2, TP4 and TP8 tables.

1. The one-shot rewrite and its validation

You're right. On 11-05 I said ar_ll_gfx1250 was unchanged, then changed it after the approval without a word. Sorry about that.

Validation of head 04c61b7. MI455X, image gfx1250-atom-k3-20261106, with this branch JIT-built in it:

  • TP2 and TP4, one tray:
    • test_custom_allreduce.py --regression -t 2 and -t 4 pass with --transport symm and with --transport auto (IPC).
    • test_custom_allreduce_rank_order.py passes at TP4 (15 of 15).
  • TP8, two trays:
    • The test spawns every rank on one host, so I ran its per-rank functions under torchrun, with the arguments its drivers build for TP8.
    • Tail, gfx1250 LL (1000 rounds), LL two-shot (200 rounds, fp32, rank order), in place (200 rounds) and the cutoff check all pass.
  • The U=2/4 paths: the new in-place case runs 0.36, 0.79, 1.57 and 3.67 MB of fp32. At TP2 that is the one-shot with 1, 2 and 4 packets a sender, all of them now in --regression.
  • Timing: 50 all-reduces captured in one CUDA graph, µs per all-reduce, slowest rank. Measured against 5c522b3 on the same trays, back to back.
    • TP8, two trays: 1.06–1.61× at every size from 14 KB to 8.4 MB, and faster than RCCL at all of them.

      MB 5c522b3 04c61b7 RCCL
      0.287 14.6 12.0 14.3
      0.573 17.6 13.5 17.4
      1.147 22.6 15.3 28.8
      1.649 24.3 15.6 32.2
      4.588 34.2 28.4 39.7
      8.387 41.5 39.2 43.7
    • TP4: faster or level at every size except one. For example, 1.15 MB takes 14.6 → 10.4 µs and 4.59 MB 27.5 → 22.2 µs. The exception is 4.20 MB, 20.8 → 21.8 µs, which now goes to RCCL by default.

    • TP2: faster or level at every size except one. For example, 1.65 MB takes 11.7 → 9.5 µs. The exception is 1.15 MB, 8.0 → 8.6 µs.

2. In place

Right. With the poller in its own wave, an output could land before its input was sent. No caller passes out=inp today (custom_all_reduce allocates its output), but all_reduce() allows it. I fixed it in the kernel rather than rejecting the alias:

  • One-shot: the sender also writes its line to its own scratch, first. The poller takes the local value from that line, not from sendbuff. So out[i] is written only after in[i] has been loaded and sent.
  • Two-shot: safe by causality. A peer's result for packet j of chunk c arrives only after rank c has received this rank's contribution, which was loaded before it was sent. The own chunk is read and written by the same thread, in that order.
  • New test: test_allreduce_ll_gfx1250_inplace_regression runs all_reduce(x, out=x) with fp32 inputs that change every round, checked bit for bit against the rank-order sum. It passes at TP2, TP4 and TP8.

3. 16-byte atomicity

I couldn't find a gfx1250 or UALink document that guarantees a remote b128 store lands atomically as a whole. The closest are in LLVM's AMDGPUUsage:

  • "Unsupported IR Constructs" lists "atomic accesses with less than natural alignment or an access size of more than 64 bits".
  • The GFX12.5 cooperative atomics do give atomic accesses to naturally aligned 128-byte regions. But they are undefined for addresses "only reachable through a bus that does not support 128B/256B requests" and for "any other unsupported addresses (TBD, needs refinement)".

6b28946 passed every check we ran, but passing tests doesn't establish the guarantee. So both kernels are back to [d0, flag, d1, flag], with both flags checked. The split waves keep most of the gain. The 12-byte lines were about 1 µs faster at 0.3–0.6 MB at TP8.

The LL all-gather merged in #7555 uses the same 12-byte lines with one flag, so it relies on the same assumption. I suggest a follow-up that moves it back to a flag per 8 bytes, unless we get that guarantee for peer memory.

4. Default cutoff (04c61b7)

As agreed with @haoyangli0109 on 11-05:

  • Binding: ll_ar_max_bytes(world_size) returns max(kLLArMaxBytes, ar2sMaxBytes(ws)), so Python doesn't copy the C++ caps.
  • Default: _GFX1250_PLAIN_AR_MAX_SIZE is the measured RCCL crossover, capped at the binding's value. It is applied in CudaCommunicator.all_reduce (should_custom_plain_ar), on gfx1250 only, and only while AITER_CUSTOM_AR_MAX_SIZE is unset.
World size Default Basis (µs, CUDA graph)
TP2 4 MiB Level with RCCL at 4.19 MB (16.0 vs 15.3). Above 4 MiB TP2 took the pull: 26.6 vs 21.9 at 4.59 MB, 32.6 vs 23.7 at 8.39 MB.
TP4 4 MiB The two-shot leads at 4.59 MB (22.2 vs 24.1). RCCL leads from 5.73 MB (25.8 vs 26.2).
TP8 8 MiB The two-shot leads at 8.39 MB (39.2 vs 43.7). At 14.68 MB the pull takes 405 and RCCL 55.
TP6 unchanged Not measured.

TP2 is new compared with the 11-05 plan. It is measured now, and above 4 MiB it took the pull, which is slower than RCCL.

  • Unchanged: should_custom_ar and the fused AR + RMSNorm paths. Their fallback to all_reduce picks up the default.
  • Tests:
    • test_custom_allreduce_size_env.py checks that the default applies only while the env is unset, and that a set value keeps its meaning.
    • test_custom_allreduce.py --regression checks on every rank that the resolved cutoff, and the path taken around it, is the same on all ranks.

Conflicts with #7499 (gfx1250 Lamport AR + RMSNorm), both additive: the
plain all-reduce cutoff table and the Lamport size table in
custom_all_reduce.py, and the two-shot tables and the Lamport inbox member in
CustomAllreduce. Both kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 06:27

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. Try requesting a review at a lower effort level.

@TennyWang1223
TennyWang1223 self-requested a review November 13, 2026 07:08

@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 484095e into main Nov 13, 2026
@TennyWang1223
TennyWang1223 deleted the zejun/gfx1250-custom-ar-ll-two-shot branch November 13, 2026 07:40
vpietila-amd pushed a commit that referenced this pull request Nov 13, 2026
…ages (#7432)

* [HIP] perf(custom_ar): gfx1250 LL two-shot all-reduce for 1 MiB+ messages

On gfx1250 the custom all-reduce had a flat one-shot LL kernel up to 4 MiB,
which sends (n - 1) x the message per rank (x2 for LL lines), and above that a
one-shot pull (ar_gfx1250_naive_unroll4) that is 4-8x slower than RCCL at TP8.

Add ar_2s_ll_gfx1250, a reduce-scatter + all-gather over the same LL lines,
scratch, banks and per-block epochs as ar_ll_gfx1250, so no buffer is added.
Each rank sends 2 (n - 1) / n x the message (x2 for LL lines), for one more
fabric round trip. It takes inputs from 1 MiB up to world_size x 2 MiB (one
bank of the LL scratch) at 4+ ranks and reads them in place (no copy-in). The
existing knobs keep their meaning: AITER_CUSTOM_AR_MAX_SIZE caps it and
AITER_CUSTOM_AR_DISABLE_LL turns it off with the one-shot LL.

Also launch both LL kernels with 512-thread blocks once 256-thread blocks
would put more than one block on a CU (the CU count is read at run time): at
TP8 the one-shot at 0.57 MB drops from 20.0 to 18.0 us, level with RCCL.

MI455X, TP8 across two trays over UALink, bf16, CUDA graph, us per call:

  size      RCCL*   before   after
  0.57 MB   17.2    20.0     18.0   one-shot, 512-thread blocks
  1.15 MB   29.7    28.8     23.3   two-shot
  2.29 MB   39.2    47.9     25.6
  3.67 MB   40.7    74.0     26.3
  4.59 MB   42.2    157.8    34.5
  8.39 MB   44.3    270.9    40.6
  * RCCL 2.30.7 with RCCL_DDA_LL_ONESHOT_THRESHOLD=2097152 and
    RCCL_DDA_LL_TWOSHOT_THRESHOLD=134217728

Tests: test_custom_allreduce.py gains a gfx1250 LL two-shot mixed-size
regression. It runs two-shot and one-shot sizes back to back and negates the
inputs every other round, so a stale line cannot pass. The --regression suite
passes at TP4 with --transport symm and auto. At TP8 across two trays, 200
calls per size, each with a fresh random input, match an fp32 all-reduce to
bf16 rounding.

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

* [HIP] fix(custom_ar): sum the gfx1250 LL two-shot in rank order

ar_2s_ll_gfx1250 reduced the owner's value first, then the other ranks in
descending ring order. Since #6954 every other custom all-reduce sums ranks
0..n-1, with the local value at its own rank. Under the owner-first order an
element's bits depended on which rank owns its chunk, that is, on its offset
in the message. They also changed when a message crossed 1 MiB, between the
one-shot and the two-shot. At TP4, test_custom_allreduce_rank_order.py sends
[97, 7168] bf16/fp16 and [512, 7168] bf16 through this kernel.

The reduce now polls slots s = 0..ngpus-1, where slot s holds rank s's
packet, and sums them in that order with the local value at position rank.
The own slot is loaded too, which keeps the loads free of branches; its
contents go unused. All indices stay compile-time. Built for gfx1250, the
TP8 bf16 kernel takes 56 VGPRs instead of 50, at the same occupancy
(16 waves/SIMD) and with no spills.

The two-shot's mixed-size regression used integer inputs, whose fp32 sums are
exact in any order. It now sums random fp32 partials and checks every round,
bit for bit, against their sum in rank order 0..n-1, at any TP. The message
sizes in bytes are unchanged, and so are the kernels and launch shapes.

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

* [HIP] refactor(custom_ar): own scratch and a per-TP cap for the gfx1250 LL two-shot

The two-shot reused the one-shot LL's state. It carved each LL bank into
chunk-sized reduce-scatter and all-gather regions, shared the LL per-block
epochs, and derived its size cap (world_size x 2 MiB) from kLLPackCapacity.
A change to the LL scratch layout or capacity would therefore have changed
the two-shot's correctness and routing without notice.

- Own scratch: after the fused AR + RMSNorm shard in the meta buffer
  (ar2sScratchOffset). It is counted in meta_size(), so every transport
  zero-initializes it with the rest. It has two banks, each with a
  reduce-scatter and an all-gather region of ar2sMaxBytes / 8 lines. That is
  8 x ar2sMaxBytes a rank: 64 MiB at TP4 and TP8, nothing at TP2 or TP6.
- Own peer table and per-block epochs (d_2s_peers_, d_2s_block_flags_),
  built at construction like the LL tables, so nothing is allocated inside a
  graph capture.
- A per-world-size cap from measurements (ar2sMaxBytes), which also sizes the
  scratch:
  - TP8, two MI455X trays: 8 MiB. The two-shot is ahead of RCCL at 8.39 MB
    (40.6 vs 44.3 us) and behind at 14.68 MB (59.1 vs 51.0 us).
  - TP4: 8 MiB, as before. RCCL within a tray is not measured yet.
  - TP6: off, as it is not measured.
- ar_ll_gfx1250, ag_ll_gfx1250, kLLScratchCapBytes, kLLPackCapacity and the
  LL scratch layout are unchanged. Built for gfx1250, the one-shot and
  all-gather LL kernels keep identical resource usage.

With AITER_CUSTOM_AR_MAX_SIZE unset (64 MiB), an all-reduce of 8-16 MiB at
TP8 now takes the one-shot pull (ar_gfx1250_naive_unroll4), as on main,
rather than the two-shot. Sending it to RCCL by default needs a per-TP
gfx1250 AR cutoff in _resolve_custom_sizes, which is left for the review.

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

* [HIP] test(custom_ar): vary the LL two-shot regression's inputs on bank reuse

Rounds of the mixed-size regression alternated x and -x. A kernel reuses
the same scratch bank every second call of that kernel. For a kernel called
once a round (here the one-shot LL), the bank's previous contents therefore
carried the sign now expected, and accepting a stale line would still have
passed the exact comparison. Rounds now cycle through x, -x and 2x, which is
exact both in fp32 and on bf16 integers. The previous use of any bank, one or
two rounds back, never carries the expected bits.

The test now runs only at TP4 and TP8, where the two-shot runs (ar2sMaxBytes);
at TP6 it only ever exercised the one-shot and the pull.

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

* [HIP] perf(custom_ar): gfx1250 LL all-reduce lines carry 12 bytes; senders and pollers in separate waves

Decode-size all-reduces at TP8 were slow in both LL kernels:
- each 16-byte line carried 8 bytes and two flags, so a rank moved 2 x its
  payload on the wire;
- a poll was issued after the same wave's remote stores, and on gfx1250 a
  load after a remote store waits for that store (about a fabric round trip)
  while a peer's line lands in about half of one;
- the one-shot polled the peers one after another and re-read the peer table
  (scalar loads) between its stores.

Both kernels now send 12-byte lines with one flag (a line is a single 16-byte
store and load, so one flag guards it), read the peer bases once before any
store, and poll every peer in one batch. The one-shot runs W senders and W
pollers a block; the two-shot three wave groups (send the reduce-scatter;
poll, reduce and send the all-gather; poll the all-gather). Both still sum in
rank order in fp32 and round once, so results are bit-identical to before.
The two-shot's per-source slots start on 4 KiB boundaries (a misaligned slot
cost ~3 us a call). Blocks: the smallest W with one block a CU. The two-shot
takes over from 768 KiB at TP8 (ar2sMinBytes; 1 MiB elsewhere).

MI455X TP8 across two trays, bf16, 50 all-reduces in one CUDA graph, us an
all-reduce (slowest rank), before -> after:
[40, 3584] 0.29 MB 15.8 -> 11.4, [40, 7168] 0.57 MB 19.1 -> 13.4,
[80, 7168] 1.15 MB 23.8 -> 18.1, [115, 3584] 0.82 MB 22.0 -> 16.9,
[115, 7168] 1.65 MB 26.0 -> 18.1, [320, 7168] 4.59 MB 34.9 -> 26.5.
Checked bit for bit against an fp32 rank-order sum at 28 shapes, with 600
mixed calls interleaving the all-gather, and over CUDA-graph replays.

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

* [HIP] fix(custom_ar): gfx1250 LL all-reduce keeps a flag per 8 bytes; one-shot safe in place

Review of 6b28946 (#7432):

- Lines carry 8 bytes again, [d0, flag, d1, flag], and a reader takes a line
  only once both flags carry the epoch, so a line has to land atomically per
  8 bytes only. The 12-byte lines with one flag relied on a remote b128 store
  landing atomically as a whole, which no gfx1250 or UALink document
  guarantees.
- The one-shot is safe with recvbuff == sendbuff again. Its sender also
  writes the line to its own scratch, first, and the poller takes the local
  value from that line. So no output is written before its input packet has
  been loaded and sent.
- The two-shot runs send, reduce and gather in three wave groups while one
  block of 3 x 128 threads a CU covers a chunk, else in two, with gather in
  the send group, so a block covers more packets a CU. It takes over from
  the one-shot at 512 KiB at TP8 (1 MiB at TP4, as before).
- Kept from 6b28946: sender and poller waves, batched polls, peer bases
  read once into registers.

MI455X, bf16, CUDA graph, us an all-reduce (slowest rank), 5c522b3 -> this:
  TP8, two trays: 0.29 MB 14.6 -> 12.0, 0.57 MB 17.6 -> 13.5,
                  1.15 MB 22.6 -> 15.3, 1.65 MB 24.3 -> 15.6,
                  4.59 MB 34.2 -> 28.4, 8.39 MB 41.5 -> 39.2
  TP4: 1.15 MB 14.6 -> 10.4, 2.29 MB 17.1 -> 14.2, 4.59 MB 27.5 -> 22.2
  TP2: 1.65 MB 11.7 -> 9.5, 2.29 MB 13.8 -> 11.9

The regression test gets an in-place case (output aliasing the input) that
covers the one-shot with 1, 2 and 4 packets a sender, and the two-shot.

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

* [HIP] perf(custom_ar): gfx1250 plain all-reduce defaults to RCCL past the measured crossover

As agreed on #7432 (11-05). On gfx1250, with AITER_CUSTOM_AR_MAX_SIZE unset,
plain all-reduce (CudaCommunicator.all_reduce) runs the custom kernels only
up to about where RCCL becomes faster: 4 MiB at TP2 and TP4, 8 MiB at TP8.
Larger inputs went to the two-shot (TP4, 4-8 MiB) or to the one-shot pull,
which takes 405 us at 14.68 MB at TP8 against 55 us for RCCL.

- New binding ll_ar_max_bytes(world_size): the largest input the LL kernels
  take, max(kLLArMaxBytes, ar2sMaxBytes). The default never exceeds it, so
  Python does not copy the C++ caps.
- An explicit AITER_CUSTOM_AR_MAX_SIZE keeps its meaning. TP6 and gfx9 keep
  the AR cutoff.
- should_custom_ar and the fused AR + RMSNorm paths are unchanged; their
  fallback to all_reduce picks up the default.
- Tests: the default applies only with the env unset
  (test_custom_allreduce_size_env.py), and every rank resolves the same
  cutoff and takes the same path (test_custom_allreduce.py --regression).

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
lirui927 pushed a commit that referenced this pull request Nov 16, 2026
…ages (#7432)

* [HIP] perf(custom_ar): gfx1250 LL two-shot all-reduce for 1 MiB+ messages

On gfx1250 the custom all-reduce had a flat one-shot LL kernel up to 4 MiB,
which sends (n - 1) x the message per rank (x2 for LL lines), and above that a
one-shot pull (ar_gfx1250_naive_unroll4) that is 4-8x slower than RCCL at TP8.

Add ar_2s_ll_gfx1250, a reduce-scatter + all-gather over the same LL lines,
scratch, banks and per-block epochs as ar_ll_gfx1250, so no buffer is added.
Each rank sends 2 (n - 1) / n x the message (x2 for LL lines), for one more
fabric round trip. It takes inputs from 1 MiB up to world_size x 2 MiB (one
bank of the LL scratch) at 4+ ranks and reads them in place (no copy-in). The
existing knobs keep their meaning: AITER_CUSTOM_AR_MAX_SIZE caps it and
AITER_CUSTOM_AR_DISABLE_LL turns it off with the one-shot LL.

Also launch both LL kernels with 512-thread blocks once 256-thread blocks
would put more than one block on a CU (the CU count is read at run time): at
TP8 the one-shot at 0.57 MB drops from 20.0 to 18.0 us, level with RCCL.

MI455X, TP8 across two trays over UALink, bf16, CUDA graph, us per call:

  size      RCCL*   before   after
  0.57 MB   17.2    20.0     18.0   one-shot, 512-thread blocks
  1.15 MB   29.7    28.8     23.3   two-shot
  2.29 MB   39.2    47.9     25.6
  3.67 MB   40.7    74.0     26.3
  4.59 MB   42.2    157.8    34.5
  8.39 MB   44.3    270.9    40.6
  * RCCL 2.30.7 with RCCL_DDA_LL_ONESHOT_THRESHOLD=2097152 and
    RCCL_DDA_LL_TWOSHOT_THRESHOLD=134217728

Tests: test_custom_allreduce.py gains a gfx1250 LL two-shot mixed-size
regression. It runs two-shot and one-shot sizes back to back and negates the
inputs every other round, so a stale line cannot pass. The --regression suite
passes at TP4 with --transport symm and auto. At TP8 across two trays, 200
calls per size, each with a fresh random input, match an fp32 all-reduce to
bf16 rounding.

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

* [HIP] fix(custom_ar): sum the gfx1250 LL two-shot in rank order

ar_2s_ll_gfx1250 reduced the owner's value first, then the other ranks in
descending ring order. Since #6954 every other custom all-reduce sums ranks
0..n-1, with the local value at its own rank. Under the owner-first order an
element's bits depended on which rank owns its chunk, that is, on its offset
in the message. They also changed when a message crossed 1 MiB, between the
one-shot and the two-shot. At TP4, test_custom_allreduce_rank_order.py sends
[97, 7168] bf16/fp16 and [512, 7168] bf16 through this kernel.

The reduce now polls slots s = 0..ngpus-1, where slot s holds rank s's
packet, and sums them in that order with the local value at position rank.
The own slot is loaded too, which keeps the loads free of branches; its
contents go unused. All indices stay compile-time. Built for gfx1250, the
TP8 bf16 kernel takes 56 VGPRs instead of 50, at the same occupancy
(16 waves/SIMD) and with no spills.

The two-shot's mixed-size regression used integer inputs, whose fp32 sums are
exact in any order. It now sums random fp32 partials and checks every round,
bit for bit, against their sum in rank order 0..n-1, at any TP. The message
sizes in bytes are unchanged, and so are the kernels and launch shapes.

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

* [HIP] refactor(custom_ar): own scratch and a per-TP cap for the gfx1250 LL two-shot

The two-shot reused the one-shot LL's state. It carved each LL bank into
chunk-sized reduce-scatter and all-gather regions, shared the LL per-block
epochs, and derived its size cap (world_size x 2 MiB) from kLLPackCapacity.
A change to the LL scratch layout or capacity would therefore have changed
the two-shot's correctness and routing without notice.

- Own scratch: after the fused AR + RMSNorm shard in the meta buffer
  (ar2sScratchOffset). It is counted in meta_size(), so every transport
  zero-initializes it with the rest. It has two banks, each with a
  reduce-scatter and an all-gather region of ar2sMaxBytes / 8 lines. That is
  8 x ar2sMaxBytes a rank: 64 MiB at TP4 and TP8, nothing at TP2 or TP6.
- Own peer table and per-block epochs (d_2s_peers_, d_2s_block_flags_),
  built at construction like the LL tables, so nothing is allocated inside a
  graph capture.
- A per-world-size cap from measurements (ar2sMaxBytes), which also sizes the
  scratch:
  - TP8, two MI455X trays: 8 MiB. The two-shot is ahead of RCCL at 8.39 MB
    (40.6 vs 44.3 us) and behind at 14.68 MB (59.1 vs 51.0 us).
  - TP4: 8 MiB, as before. RCCL within a tray is not measured yet.
  - TP6: off, as it is not measured.
- ar_ll_gfx1250, ag_ll_gfx1250, kLLScratchCapBytes, kLLPackCapacity and the
  LL scratch layout are unchanged. Built for gfx1250, the one-shot and
  all-gather LL kernels keep identical resource usage.

With AITER_CUSTOM_AR_MAX_SIZE unset (64 MiB), an all-reduce of 8-16 MiB at
TP8 now takes the one-shot pull (ar_gfx1250_naive_unroll4), as on main,
rather than the two-shot. Sending it to RCCL by default needs a per-TP
gfx1250 AR cutoff in _resolve_custom_sizes, which is left for the review.

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

* [HIP] test(custom_ar): vary the LL two-shot regression's inputs on bank reuse

Rounds of the mixed-size regression alternated x and -x. A kernel reuses
the same scratch bank every second call of that kernel. For a kernel called
once a round (here the one-shot LL), the bank's previous contents therefore
carried the sign now expected, and accepting a stale line would still have
passed the exact comparison. Rounds now cycle through x, -x and 2x, which is
exact both in fp32 and on bf16 integers. The previous use of any bank, one or
two rounds back, never carries the expected bits.

The test now runs only at TP4 and TP8, where the two-shot runs (ar2sMaxBytes);
at TP6 it only ever exercised the one-shot and the pull.

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

* [HIP] perf(custom_ar): gfx1250 LL all-reduce lines carry 12 bytes; senders and pollers in separate waves

Decode-size all-reduces at TP8 were slow in both LL kernels:
- each 16-byte line carried 8 bytes and two flags, so a rank moved 2 x its
  payload on the wire;
- a poll was issued after the same wave's remote stores, and on gfx1250 a
  load after a remote store waits for that store (about a fabric round trip)
  while a peer's line lands in about half of one;
- the one-shot polled the peers one after another and re-read the peer table
  (scalar loads) between its stores.

Both kernels now send 12-byte lines with one flag (a line is a single 16-byte
store and load, so one flag guards it), read the peer bases once before any
store, and poll every peer in one batch. The one-shot runs W senders and W
pollers a block; the two-shot three wave groups (send the reduce-scatter;
poll, reduce and send the all-gather; poll the all-gather). Both still sum in
rank order in fp32 and round once, so results are bit-identical to before.
The two-shot's per-source slots start on 4 KiB boundaries (a misaligned slot
cost ~3 us a call). Blocks: the smallest W with one block a CU. The two-shot
takes over from 768 KiB at TP8 (ar2sMinBytes; 1 MiB elsewhere).

MI455X TP8 across two trays, bf16, 50 all-reduces in one CUDA graph, us an
all-reduce (slowest rank), before -> after:
[40, 3584] 0.29 MB 15.8 -> 11.4, [40, 7168] 0.57 MB 19.1 -> 13.4,
[80, 7168] 1.15 MB 23.8 -> 18.1, [115, 3584] 0.82 MB 22.0 -> 16.9,
[115, 7168] 1.65 MB 26.0 -> 18.1, [320, 7168] 4.59 MB 34.9 -> 26.5.
Checked bit for bit against an fp32 rank-order sum at 28 shapes, with 600
mixed calls interleaving the all-gather, and over CUDA-graph replays.

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

* [HIP] fix(custom_ar): gfx1250 LL all-reduce keeps a flag per 8 bytes; one-shot safe in place

Review of 6b28946 (#7432):

- Lines carry 8 bytes again, [d0, flag, d1, flag], and a reader takes a line
  only once both flags carry the epoch, so a line has to land atomically per
  8 bytes only. The 12-byte lines with one flag relied on a remote b128 store
  landing atomically as a whole, which no gfx1250 or UALink document
  guarantees.
- The one-shot is safe with recvbuff == sendbuff again. Its sender also
  writes the line to its own scratch, first, and the poller takes the local
  value from that line. So no output is written before its input packet has
  been loaded and sent.
- The two-shot runs send, reduce and gather in three wave groups while one
  block of 3 x 128 threads a CU covers a chunk, else in two, with gather in
  the send group, so a block covers more packets a CU. It takes over from
  the one-shot at 512 KiB at TP8 (1 MiB at TP4, as before).
- Kept from 6b28946: sender and poller waves, batched polls, peer bases
  read once into registers.

MI455X, bf16, CUDA graph, us an all-reduce (slowest rank), 5c522b3 -> this:
  TP8, two trays: 0.29 MB 14.6 -> 12.0, 0.57 MB 17.6 -> 13.5,
                  1.15 MB 22.6 -> 15.3, 1.65 MB 24.3 -> 15.6,
                  4.59 MB 34.2 -> 28.4, 8.39 MB 41.5 -> 39.2
  TP4: 1.15 MB 14.6 -> 10.4, 2.29 MB 17.1 -> 14.2, 4.59 MB 27.5 -> 22.2
  TP2: 1.65 MB 11.7 -> 9.5, 2.29 MB 13.8 -> 11.9

The regression test gets an in-place case (output aliasing the input) that
covers the one-shot with 1, 2 and 4 packets a sender, and the two-shot.

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

* [HIP] perf(custom_ar): gfx1250 plain all-reduce defaults to RCCL past the measured crossover

As agreed on #7432 (11-05). On gfx1250, with AITER_CUSTOM_AR_MAX_SIZE unset,
plain all-reduce (CudaCommunicator.all_reduce) runs the custom kernels only
up to about where RCCL becomes faster: 4 MiB at TP2 and TP4, 8 MiB at TP8.
Larger inputs went to the two-shot (TP4, 4-8 MiB) or to the one-shot pull,
which takes 405 us at 14.68 MB at TP8 against 55 us for RCCL.

- New binding ll_ar_max_bytes(world_size): the largest input the LL kernels
  take, max(kLLArMaxBytes, ar2sMaxBytes). The default never exceeds it, so
  Python does not copy the C++ caps.
- An explicit AITER_CUSTOM_AR_MAX_SIZE keeps its meaning. TP6 and gfx9 keep
  the AR cutoff.
- should_custom_ar and the fused AR + RMSNorm paths are unchanged; their
  fallback to all_reduce picks up the default.
- Tests: the default applies only with the env unset
  (test_custom_allreduce_size_env.py), and every rank resolves the same
  cutoff and takes the same path (test_custom_allreduce.py --regression).

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 484095e)
TennyWang1223 added a commit that referenced this pull request Nov 16, 2026
Route the gfx1250 plain all-reduce through Lamport kernels on the shared
Lamport inbox: a one-shot up to 1.25 MiB at TP4 and 9 MiB at TP2, and a
new two-shot (pushed reduce-scatter + all-gather) above it, up to
world_size x the Lamport cap (32 MiB at TP2/TP4). fp16/bf16 only; same
bits as the custom all-reduce (rank-order fp32 sum).

The plain all-reduce cutoff of CudaCommunicator.all_reduce (#7432, 4 MiB
at TP2/TP4, RCCL above) no longer applies to the inputs the Lamport
kernels take: they stay ahead of RCCL up to world_size x the cap. Other
inputs keep the cutoff.

The two-shot's all-gather gets a private inbox of world_size x cap after
the escape inbox (per-rank Lamport buffer 120 -> 152 MiB at TP2/TP4); the
shared inbox, the cap and the other Lamport ops are unchanged.

Signed-off-by: TennyWang1223 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
TennyWang1223 added a commit that referenced this pull request Nov 17, 2026
Route the gfx1250 plain all-reduce through Lamport kernels on the shared
Lamport inbox: a one-shot up to 1.25 MiB at TP4 and 9 MiB at TP2, and a
new two-shot (pushed reduce-scatter + all-gather) above it, up to
world_size x the Lamport cap (32 MiB at TP2/TP4). fp16/bf16 only; same
bits as the custom all-reduce (rank-order fp32 sum).

The plain all-reduce cutoff of CudaCommunicator.all_reduce (#7432, 4 MiB
at TP2/TP4, RCCL above) no longer applies to the inputs the Lamport
kernels take: they stay ahead of RCCL up to world_size x the cap. Other
inputs keep the cutoff.

The two-shot's all-gather gets a private inbox of world_size x cap after
the escape inbox (per-rank Lamport buffer 120 -> 152 MiB at TP2/TP4); the
shared inbox, the cap and the other Lamport ops are unchanged.

Signed-off-by: TennyWang1223 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
zejunchen-zejun added a commit that referenced this pull request Nov 20, 2026
…ort lines

ar_2s_ll_gfx1250 sent LL lines, 8 bytes of payload and two epoch flags in 16
bytes, so a TP8 two-shot put 3.5 x the message on the fabric. Its
replacement, ar_2s_lamport_gfx1250, sends the payload alone. The receiver's
inbox holds a sentinel (all bits set) in every 32-bit word where nothing is
pending. A payload word equal to it is sent as 0x7fffffff (a NaN in fp32 and
NaNs in fp16 / bf16, as the sentinel is), and the reducing rank writes its own
chunk with the same bits. Inbox rounds work as in the other Lamport kernels:
three buffers, a rank-local round counter a wave of packs, the previous
round's buffer re-armed, so CUDA graphs replay as is. It reuses their
constants, line helpers and inbox arming. The reduce-scatter + all-gather,
the in-place read and the rank-order fp32 sum rounded once (bit-identical on
every rank) are unchanged.

Routing: the size range is the same (ar2sMinBytes to ar2sMaxBytes), but
use_2s now needs whole 16-byte packs a chunk, bytes % (16 x world_size)
(8 before). So a TP8 bf16 all-reduce above 4 MiB whose numel is 32 mod 64
takes the pull kernel instead; no shipped TP8 shape is one. At TP4, fp16 /
bf16 on the IPC transport go to the Lamport kernels on the AR + RMSNorm pool
first (select_lamport_ar), as on main.

Launch: at most one block a CU, since a CU running two finishes last (TP8,
7.81 MB: 273 blocks of 2 x 224 threads 45.5 us, 239 of 2 x 256 26.2 us). W
threads a role, the smallest of 64, 128, 256 and 512 that covers a chunk in
cu_count blocks; three wave groups (send, reduce, gather) up to W = 128, two
above. The pollers first sleep through the time before anything can land.

The inbox (48 MiB a rank at TP4 and TP8) starts on a 2 MiB boundary of the
meta buffer. Started where the shard ends, 258 KiB past one, the TP8 call
took 6.7 us longer at 7.81 MB. The meta buffer still shrinks by 15 MB a rank
(TP8 218.4 -> 203.4 MB, TP4 151.3 -> 136.3 MB). CustomAllreduce barriers
after init_custom_ar so that every rank's sentinel fill lands before any
push.

MI455X, TP8 across two trays (symm_mem), bf16 in a CUDA graph, us an
all-reduce, #7432's two-shot -> this one (RCCL): 0.92 MB 13.9 -> 12.6 (20.3),
2.75 MB 20.7 -> 15.5 (40.1), 3.91 MB 25.2 -> 17.9 (39.4), 5.50 MB 29.6 -> 23.5
(39.5), 7.81 MB 38.3 -> 25.4 (42.5), 8.26 MB 39.0 -> 25.9 (42.8). Kimi-K3's
c128 decode all-reduces are [545, 3584] (3.91 MB) and [545, 7168] (7.81 MB).

Tests:
- test_custom_allreduce.py: the two-shot mixed-size and in-place lists add
  sizes whose chunks end in a partial wave of packs. Their regressions cycle
  four exact input variants, so a stale line in any of the three buffers is
  caught. test_allreduce_2s_gfx1250_sentinel_payload feeds a payload word with
  the sentinel's bits.
- gfx1250_poc/test_gfx1250_lamport_allreduce.py names the renamed kernel and
  its 16 x tp divisor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zejunchen-zejun added a commit that referenced this pull request Nov 20, 2026
…ort lines

ar_2s_ll_gfx1250 sent LL lines, 8 bytes of payload and two epoch flags in 16
bytes, so a TP8 two-shot put 3.5 x the message on the fabric. Its
replacement, ar_2s_lamport_gfx1250, sends the payload alone. The receiver's
inbox holds a sentinel (all bits set) in every 32-bit word where nothing is
pending. A payload word equal to it is sent as 0x7fffffff (a NaN in fp32 and
NaNs in fp16 / bf16, as the sentinel is), and the reducing rank writes its own
chunk with the same bits. Inbox rounds work as in the other Lamport kernels:
three buffers, a rank-local round counter a wave of packs, the previous
round's buffer re-armed, so CUDA graphs replay as is. It reuses their
constants, line helpers and inbox arming. The reduce-scatter + all-gather,
the in-place read and the rank-order fp32 sum rounded once (bit-identical on
every rank) are unchanged.

Routing: the size range is the same (ar2sMinBytes to ar2sMaxBytes), but
use_2s now needs whole 16-byte packs a chunk, bytes % (16 x world_size)
(8 before). So a TP8 bf16 all-reduce above 4 MiB whose numel is 32 mod 64
takes the pull kernel instead; no shipped TP8 shape is one. At TP4, fp16 /
bf16 on the IPC transport go to the Lamport kernels on the AR + RMSNorm pool
first (select_lamport_ar), as on main.

Launch: at most one block a CU, since a CU running two finishes last (TP8,
7.81 MB: 273 blocks of 2 x 224 threads 45.5 us, 239 of 2 x 256 26.2 us). W
threads a role, the smallest of 64, 128, 256 and 512 that covers a chunk in
cu_count blocks; three wave groups (send, reduce, gather) up to W = 128, two
above. The pollers first sleep through the time before anything can land.

The inbox (48 MiB a rank at TP4 and TP8) starts on a 2 MiB boundary of the
meta buffer. Started where the shard ends, 258 KiB past one, the TP8 call
took 6.7 us longer at 7.81 MB. The meta buffer still shrinks by 15 MB a rank
(TP8 218.4 -> 203.4 MB, TP4 151.3 -> 136.3 MB). CustomAllreduce barriers
after init_custom_ar so that every rank's sentinel fill lands before any
push.

MI455X, TP8 across two trays (symm_mem), bf16 in a CUDA graph, us an
all-reduce, #7432's two-shot -> this one (RCCL): 0.92 MB 13.9 -> 12.6 (20.3),
2.75 MB 20.7 -> 15.5 (40.1), 3.91 MB 25.2 -> 17.9 (39.4), 5.50 MB 29.6 -> 23.5
(39.5), 7.81 MB 38.3 -> 25.4 (42.5), 8.26 MB 39.0 -> 25.9 (42.8). Kimi-K3's
c128 decode all-reduces are [545, 3584] (3.91 MB) and [545, 7168] (7.81 MB).

Tests:
- test_custom_allreduce.py: the two-shot mixed-size and in-place lists add
  sizes whose chunks end in a partial wave of packs. Their regressions cycle
  four exact input variants, so a stale line in any of the three buffers is
  caught. test_allreduce_2s_gfx1250_sentinel_payload feeds a payload word with
  the sentinel's bits.
- gfx1250_poc/test_gfx1250_lamport_allreduce.py names the renamed kernel and
  its 16 x tp divisor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zejunchen-zejun added a commit that referenced this pull request Nov 21, 2026
…ansport

Review 5992632906, items 1-6: one Lamport two-shot, main's
lamport_ar_2shot_gfx1250, with the fp32 codec and the split layout of the
kernels it replaces.

- lamport_ar_2shot_gfx1250<T, ngpus, BLOCK, ROLES>:
  - LamportArCodec<T>: 2-byte dtypes keep the 16-bit sentinel; fp32 gets a
    32-bit one.
  - ROLES 1 is fused (main's); 2-3 is split: send, reduce and gather wave
    groups, with the pre-poll sleep.
  - Chunks of ceil(packs / ngpus) packs with p < packs guards, so any input
    of whole 16-byte packs runs.
- run_2shot launch:
  - split: W = min(512, roundup32(ceil(part / CUs))), three roles while
    W <= 320, at most one block a CU;
  - fused: add_threads(part).
- Removed ar_2s_lamport_gfx1250 and its 48 MiB inbox, and #7432's
  ar_2s_ll_gfx1250 with its tables and dispatch. The meta buffer a rank goes
  from 144.3 to 80.3 MiB at TP4 and from 208.3 to 144.3 MiB at TP8.
- The Lamport inbox is built on every transport (IPC, symm_mem, VMM). Plain
  all-reduce gets its own cap, _LAMPORT_AR_MAX_BYTES:
  - {2: 16, 4: 8, 8: 1} MiB a sender, so the two-shot takes up to 32 MiB at
    TP2 and TP4 and 8 MiB at TP8;
  - the TP8 inbox is 38 MiB a rank.
- select_lamport_ar returns (two_shot, split):
  - fp16/bf16: the one-shot up to _LAMPORT_AR_1SHOT_MAX_BYTES (TP8 1 MiB
    added);
  - fp32: the LL one-shot up to _LAMPORT_AR_FP32_LL_MAX_BYTES (TP2 1 MiB, else
    none);
  - split in _LAMPORT_AR_SPLIT_BYTES (TP2 (2, 4], TP4 (4, 8], TP8
    (0.25, 4] MiB), fused elsewhere.
  - The TP8 plain cutoff drops from 8 to 4 MiB: past 4 MiB the meta-buffer
    path is the pull.
- Dropped the post-init barrier that only the meta-buffer two-shot needed.
- Tests:
  - two ragged fp32 sizes in _AR2S_GFX1250_MIXED_SIZES;
  - the sentinel test at TP2 too;
  - test_gfx1250_lamport_ar_route in size_env;
  - the PoC's split and fp32 candidates and routes.
  - The "LL kernels" text and the two-bank comment are fixed.

MI455X, production route against main, CUDA graph, slowest rank:
- TP4 over symm_mem, bf16: 1.37-2.06x from 256 KiB to 16 MiB.
- TP4 over IPC: bf16 1.35-1.51x at 5-8 MiB (split); fp32 1.18-2.0x from
  512 KiB to 4 MiB and 1.46-2.87x above, where main took RCCL.
- TP2: fp32 1.16-1.52x from 1.5 to 8 MiB; bf16 unchanged (the one-shot).
- TP8 (two trays, symm_mem): the routes come from timing the two kernels
  merged here.

--regression passes at TP2 (IPC) and TP4 (IPC, symm_mem, VMM). At TP8
(symm_mem, two trays) it passed on these kernels, before the TP8 tables
above changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zufayu pushed a commit that referenced this pull request Nov 27, 2026
…wo-shot, on every transport (#7937)

* [HIP] perf(custom_ar): gfx1250 two-shot all-reduce moves 16-byte Lamport lines

ar_2s_ll_gfx1250 sent LL lines, 8 bytes of payload and two epoch flags in 16
bytes, so a TP8 two-shot put 3.5 x the message on the fabric. Its
replacement, ar_2s_lamport_gfx1250, sends the payload alone. The receiver's
inbox holds a sentinel (all bits set) in every 32-bit word where nothing is
pending. A payload word equal to it is sent as 0x7fffffff (a NaN in fp32 and
NaNs in fp16 / bf16, as the sentinel is), and the reducing rank writes its own
chunk with the same bits. Inbox rounds work as in the other Lamport kernels:
three buffers, a rank-local round counter a wave of packs, the previous
round's buffer re-armed, so CUDA graphs replay as is. It reuses their
constants, line helpers and inbox arming. The reduce-scatter + all-gather,
the in-place read and the rank-order fp32 sum rounded once (bit-identical on
every rank) are unchanged.

Routing: the size range is the same (ar2sMinBytes to ar2sMaxBytes), but
use_2s now needs whole 16-byte packs a chunk, bytes % (16 x world_size)
(8 before). So a TP8 bf16 all-reduce above 4 MiB whose numel is 32 mod 64
takes the pull kernel instead; no shipped TP8 shape is one. At TP4, fp16 /
bf16 on the IPC transport go to the Lamport kernels on the AR + RMSNorm pool
first (select_lamport_ar), as on main.

Launch: at most one block a CU, since a CU running two finishes last (TP8,
7.81 MB: 273 blocks of 2 x 224 threads 45.5 us, 239 of 2 x 256 26.2 us). W
threads a role, the smallest of 64, 128, 256 and 512 that covers a chunk in
cu_count blocks; three wave groups (send, reduce, gather) up to W = 128, two
above. The pollers first sleep through the time before anything can land.

The inbox (48 MiB a rank at TP4 and TP8) starts on a 2 MiB boundary of the
meta buffer. Started where the shard ends, 258 KiB past one, the TP8 call
took 6.7 us longer at 7.81 MB. The meta buffer still shrinks by 15 MB a rank
(TP8 218.4 -> 203.4 MB, TP4 151.3 -> 136.3 MB). CustomAllreduce barriers
after init_custom_ar so that every rank's sentinel fill lands before any
push.

MI455X, TP8 across two trays (symm_mem), bf16 in a CUDA graph, us an
all-reduce, #7432's two-shot -> this one (RCCL): 0.92 MB 13.9 -> 12.6 (20.3),
2.75 MB 20.7 -> 15.5 (40.1), 3.91 MB 25.2 -> 17.9 (39.4), 5.50 MB 29.6 -> 23.5
(39.5), 7.81 MB 38.3 -> 25.4 (42.5), 8.26 MB 39.0 -> 25.9 (42.8). Kimi-K3's
c128 decode all-reduces are [545, 3584] (3.91 MB) and [545, 7168] (7.81 MB).

Tests:
- test_custom_allreduce.py: the two-shot mixed-size and in-place lists add
  sizes whose chunks end in a partial wave of packs. Their regressions cycle
  four exact input variants, so a stale line in any of the three buffers is
  caught. test_allreduce_2s_gfx1250_sentinel_payload feeds a payload word with
  the sentinel's bits.
- gfx1250_poc/test_gfx1250_lamport_allreduce.py names the renamed kernel and
  its 16 x tp divisor.

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

* [HIP] custom_ar: gfx1250 two-shot comments and test text follow main

valarLip's review 5988279188 of e2127e7, items 5 and 6:

- The two-shot's comments point to lamport_ar_1shot_gfx1250 (there is no
  lamport_ar_add_gfx1250 on main). The line helpers serve every Lamport
  kernel.
- The allreduce() comment covers the two-shot as well as the LL one-shot.
- ll_ar_max_bytes and the plain cutoff no longer count the two-shot among
  "the LL kernels".
- The meta size is 48 to 194 MiB.
- The inbox offset cost 7.1 us (33.2 vs 26.1 us, the prototype that changed
  only the offset).
- Tests:
  - the vary_inputs comment says what a pack that three sizes reach reads;
  - the --regression help lists the two-shot mixed sizes and the sentinel
    payload;
  - ll2s / LL2S names become 2s / AR2S.

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

* [HIP] custom_ar: gfx1250 TP8 plain all-reduce stays off the Lamport kernels

At TP8 plain all-reduce never takes the Lamport all-reduce
(lamport_ar_1shot/2shot_gfx1250), even when
AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE sets a Lamport cap there. It keeps
the meta-buffer kernels, ar_2s_lamport_gfx1250 in its range, which is
measured across two trays; the Lamport all-reduce is measured at TP2 and
TP4 only. select_lamport_ar returns None at the world sizes in
_LAMPORT_AR_SKIP_WORLD_SIZES. TP2 and TP4 route as before.

test_custom_allreduce_size_env.py checks the TP8 gate (it fails without
it); the gfx1250 PoC test restates it in expect_route.

Signed-off-by: TennyWang1223 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Revert "[HIP] custom_ar: gfx1250 TP8 plain all-reduce stays off the Lamport kernels"

This reverts commit 741e9530404c5ac58d02a1ae4a4b0e66d1e3ca72.

valarLip's review 5992632906, item 3. The gate decides nothing by default:
TP8 has no Lamport cap, and only the IPC transport builds the Lamport pool.
With a cap set, it changes only single-node TP8 over IPC, while the evidence it
cites was measured across two trays on symm_mem, where it is a no-op. On those
trays the Lamport one-shot and two-shot are the fastest TP8 paths at
8-512 KiB and 5-8 MiB, and the AR + add, AR + RMSNorm and all-gather Lamport
ops were never gated. It also adds a check to every plain all-reduce. TP8
plain all-reduce is routed by size in the next commit instead.

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

* [HIP] custom_ar: gfx1250 all-reduce on one Lamport two-shot, every transport

Review 5992632906, items 1-6: one Lamport two-shot, main's
lamport_ar_2shot_gfx1250, with the fp32 codec and the split layout of the
kernels it replaces.

- lamport_ar_2shot_gfx1250<T, ngpus, BLOCK, ROLES>:
  - LamportArCodec<T>: 2-byte dtypes keep the 16-bit sentinel; fp32 gets a
    32-bit one.
  - ROLES 1 is fused (main's); 2-3 is split: send, reduce and gather wave
    groups, with the pre-poll sleep.
  - Chunks of ceil(packs / ngpus) packs with p < packs guards, so any input
    of whole 16-byte packs runs.
- run_2shot launch:
  - split: W = min(512, roundup32(ceil(part / CUs))), three roles while
    W <= 320, at most one block a CU;
  - fused: add_threads(part).
- Removed ar_2s_lamport_gfx1250 and its 48 MiB inbox, and #7432's
  ar_2s_ll_gfx1250 with its tables and dispatch. The meta buffer a rank goes
  from 144.3 to 80.3 MiB at TP4 and from 208.3 to 144.3 MiB at TP8.
- The Lamport inbox is built on every transport (IPC, symm_mem, VMM). Plain
  all-reduce gets its own cap, _LAMPORT_AR_MAX_BYTES:
  - {2: 16, 4: 8, 8: 1} MiB a sender, so the two-shot takes up to 32 MiB at
    TP2 and TP4 and 8 MiB at TP8;
  - the TP8 inbox is 38 MiB a rank.
- select_lamport_ar returns (two_shot, split):
  - fp16/bf16: the one-shot up to _LAMPORT_AR_1SHOT_MAX_BYTES (TP8 1 MiB
    added);
  - fp32: the LL one-shot up to _LAMPORT_AR_FP32_LL_MAX_BYTES (TP2 1 MiB, else
    none);
  - split in _LAMPORT_AR_SPLIT_BYTES (TP2 (2, 4], TP4 (4, 8], TP8
    (0.25, 4] MiB), fused elsewhere.
  - The TP8 plain cutoff drops from 8 to 4 MiB: past 4 MiB the meta-buffer
    path is the pull.
- Dropped the post-init barrier that only the meta-buffer two-shot needed.
- Tests:
  - two ragged fp32 sizes in _AR2S_GFX1250_MIXED_SIZES;
  - the sentinel test at TP2 too;
  - test_gfx1250_lamport_ar_route in size_env;
  - the PoC's split and fp32 candidates and routes.
  - The "LL kernels" text and the two-bank comment are fixed.

MI455X, production route against main, CUDA graph, slowest rank:
- TP4 over symm_mem, bf16: 1.37-2.06x from 256 KiB to 16 MiB.
- TP4 over IPC: bf16 1.35-1.51x at 5-8 MiB (split); fp32 1.18-2.0x from
  512 KiB to 4 MiB and 1.46-2.87x above, where main took RCCL.
- TP2: fp32 1.16-1.52x from 1.5 to 8 MiB; bf16 unchanged (the one-shot).
- TP8 (two trays, symm_mem): the routes come from timing the two kernels
  merged here.

--regression passes at TP2 (IPC) and TP4 (IPC, symm_mem, VMM). At TP8
(symm_mem, two trays) it passed on these kernels, before the TP8 tables
above changed.

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

* [HIP] custom_ar: gfx1250 TP8 routes from this head's own timings

TP8 across two MI455X trays over symm_mem, this head's kernels, CUDA graph,
bf16 unless noted:
- The one-shot stops at 768 KiB. The split two-shot overtakes it past there:
  9.9 vs 10.3 us at 768 KiB, 11.1 vs 10.5 at 1 MiB.
- fp32 takes the split from the smallest size up to 4 MiB. Against the fused
  layout: 9.0 vs 9.6 us at 16 KiB, 10.1 vs 10.7 at 256 KiB, 10.8 vs 15.5 at
  1 MiB.
- The cap goes back to 4 MiB a sender, so the two-shot runs to 32 MiB. Past
  8 MiB the fused layout stays ahead of RCCL: 33.5 vs 43.2 us at 10 MiB, 66.0
  vs 96.6 at 32 MiB. Its send loop issues every load before its first remote
  store; main's two-shot, which set the 8 MiB cap, did not.
- The code comments quote these numbers in place of the ones taken on the
  kernels before the merge.

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

---------

Signed-off-by: TennyWang1223 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[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.

5 participants