Repository navigation
[HIP] perf(custom_ar): one gfx1250 Lamport two-shot replaces the LL two-shot, on every transport - #7937
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (6)
Post TP4 before/after numbers and a TP4 --regression run at head. The TP4 table was "measured earlier, one round each". Its weakest rows are 2–4 MiB (0.98x at [320,3584] 2.29 MB, then 1.02–1.04x), which sit right after the 3x128 → 2x256 switch (custom_all_reduce_gfx1250.cuh:2531-2545). Please post ≥2 alternating rounds at head covering 1.7–4 MiB, the 2 MiB switch, and TP4 4–8 MiB (2x512). The PR's own comment moves TP4 4.59 MB from 22.2 µs (base) to 26.8 µs (custom_all_reduce.py:254-256). Also add one TP8 point in 0.5–0.92 MB, the new floor window with the s_sleep delay.
Reuse the existing Lamport helpers instead of copying them. These are identical to existing helpers apart from their names:
ar2s_u32x4/ar2s_store/ar2s_load(.cuh:511-529) matchlamport_u32x4/lamport_store_b128/lamport_load_b128(:1320-1338).kAr2sBuffers(:239) matcheskLamportBuffers(:1251).- The literal 32 (
:580-584,:702-704,:2471) should bekLamportWave(:1252). ensure_2s_tables_(:2464-2476) repeats the init steps ofinit_lamport_ar_rms(:2599-2607).- The protocol comment (
:470-481) restates:1235-1242.
Move kLamportBuffers / kLamportWave above :236, because ar2sScratchBytes uses them. Move the three helpers below the AITER_GFX1250_HAVE_B128 / llx_v4u_gptr block (~:300), then call them from both kernels. Only kAr2sSentinel, ar2s_canonical and ar2s_pending need to be new, since the 32-bit sentinel is required.
Make the test inputs actually catch a stale line in the two-shot inbox. At test_custom_allreduce.py:393-406 the inputs cycle through 3 values (x, -x, 2x), and the kernel rotates through 3 inbox buffers, so a stale line from 3 calls earlier carries exactly the expected bits. In a CPU model of the real size lists, the test cannot detect a missing re-arm in the pack groups that only the 7.81 MB call reaches: 1575 of 3815 at TP4 and 788 of 1908 at TP8. Use 4 exact variants (x, -x, 2x, -2x); the model then shows 0 undetected groups. Fix the "one or two rounds back" comment too.
Nits (required here, small)
- NaN bits differ across ranks. The owner writes raw
rto its own chunk while peers getrc(.cuh:659-664). Writercthere, aslamport_ar_rmsnorm_gfx1250already canonicalises its local operand (:1381-1383). No test feeds a 0xffffffff payload word, so add one: set one fp32 word to bits 0xffffffff in one rank's input, then assert there is no hang, NaN appears at that position, and the bits are identical on every rank. - Fix comments that are wrong or not backed by posted data.
test_custom_allreduce.py:304-319: the real shapes are TP8 3x64/3x128/2x256 and TP4 3x128/2x256/2x512. 7.81 MB ends in a partial group at TP8 only. At TP2/TP6 all five sizes take the one-shot LL.- The perf numbers at
.cuh:215-219,.cuh:2526-2530andcustom_all_reduce.py:254-257do not match the posted table (e.g. 26.6/43.5 vs 25.9/42.8). The TP4 8.39 MB figure (29.0 vs RCCL 29.7) is not in it at all.
- Correct the PR body. "Routing and size cutoffs unchanged" is wrong:
use_2snow requiresbytes % (16*ws)(.cuh:2399-2402), so for TP8 bf16 with numel ≡ 32 mod 64 above 4 MiB the call falls back to the naive pull. Please confirm no shipped TP8 shape hits this.
Questions
- 16-byte
sendbuff/recvbuffaccess has nodata_ptr % 16check, unlike the siblinglamport_ar_addpath (custom_all_reduce.py:2408). Is that acceptable? Any guard must be rank-uniform. - Is the symm_mem meta base 2 MiB aligned, as
.cuh:252-256claims?
Reviewed at 7025b9d (deep; 3 hunters + 2 C1 verifiers + 1 C2, plus 2 extra votes from a parallel pass). Already fixed: n/a (first review).
|
Thanks @valarLip. Action required1. TP4 before/after, TP4
You're right that the comment showed TP4 4.59 MB at 22.2 µs before and 26.8 µs after. By default, TP4 plain all-reduce 2. The Lamport helpers are reused.
3. The test inputs now catch a stale line.
Nits
Questions16-byte access without a
So I added no guard. If you want one, a rank-uniform form would test Is the symm_mem meta base 2 MiB aligned? No API guarantees it, so the comment no longer claims it.
|
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (7)
1. Rebase onto main and keep one Lamport two-shot. Main gained lamport_ar_2shot_gfx1250 (#7927, main .cuh ~1889-2057) after this branch was cut. It is the same protocol as the rewritten ar_2s_lamport_gfx1250 (.cuh:565-715): reduce-scatter + all-gather pushed as 16 B lines, kLamportBuffers rotation re-arming (round+2)%3, a counter per kLamportWave wave, rank-order fp32 sum. What differs is the 32-bit sentinel (fp32), the meta-buffer inbox (every transport), TP8 by default, and the launch shape. Please merge them into one kernel and delete the other:
- extend #7927's kernel with a 32-bit codec (
LamportAgEscapealready shows the pattern), plus your launch shape and a TP8 cap; or - route
select_lamport_ar's two-shot to yours, adding the short-chunk and unaligned-copy support.
Pick the direction from a TP4 IPC bf16 A/B over 1.25-8 MiB. When you rebase, the one conflict (init_lamport_ar_rms) must keep main's 2x cluster_partials, the escape-inbox 0 fill and the two-shot AG inbox 0xff fill. Taking this side writes out of bounds in the FP8 amax pass. Pointing arm_lamport_inbox_ at the whole pool arms the escape inbox with 0xff.
2. Post build, --regression and perf numbers on the rebased head. No CI lane builds or runs gfx1250: multi-GPU CI is MI350X, the 2s tests return at _is_gfx1250, and the branch conflicts, so no PR CI ran. Your list of unverified items at 2fd7800 is still open: build, --regression TP4/TP8 (IPC + symm_mem), TP8 0.5-0.92 MB.
- TP4 IPC fp16/bf16 now goes to #7927's kernel, which also lifts the 4 MiB cutoff. Your TP4 table no longer describes it, so drop our r47 TP4 4-8 MiB / 2x512 ask.
- Instead post TP4 fp32 or VMM/symm_mem at 1-4 MiB vs base, plus the item 1 A/B.
3. Fix text that is wrong on main. .cuh:216-221 ("plain all-reduce stops at 4 MiB by default") is false for TP4 IPC fp16/bf16. custom_all_reduce.py:255 ("TP4 … the two-shot leads at 4.19 MB") now means #7927's kernel, and the line dropped "RCCL from 5.73 MB", the only stated reason for the TP4 cutoff. .cuh:235-237 and :502 name only lamport_ar_rmsnorm as user/twin.
4. Update gfx1250_poc/test_gfx1250_lamport_allreduce.py (on main) for the rename. :158 matches "ar_2s_ll_gfx1250", so ar_2s_lamport_gfx1250 counts as no kernel and "route ok" is False for every TP4 two-shot case (m=128-512, default args); :137 still uses % (8 * tp). Use "ar_2s_lamport_gfx1250" and 16 * tp, and rename the LL2S_* constants and docstrings.
Nits (required here, small; missed in r47)
.cuh:261"264 KiB past a boundary": Signal is 264192 B = 258 KiB. Same in the PR body.- The 7025b9d message says "same routing (use_2s; … unchanged)", but
use_2snow needsbytes % (16*ws). Fix the squash message. custom_all_reduce.py_init_ipccomment (~:1925): meta is not "Signal (~34 KB) + LL staging scratch". Point to the.cuhlayout comment.
Reviewed at 2fd7800 (deep; 3 hunters + C2 + 5 C1 verifiers). Already fixed: Lamport helper reuse, 4 test variants, owner NaN bits + sentinel test, test-shape/perf comments, PR-body routing note.
2fd7800 to
e2127e7
Compare
|
Thanks @valarLip. The branch is rebased onto main as one commit, 1. One Lamport two-shot: I'll keep this kernel, unless the A/B says otherwise.
The conflict (
2. Build,
The TP4 IPC bf16 table is out of the description, and the 4–8 MiB / 2 × 512 ask is dropped, as you said. 3. Text fixed for main
4. Nits
On the earlier meta base question:
|
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (6)
1. Keep one Lamport two-shot (r49 item 1, still open). ar_2s_lamport_gfx1250 (.cuh:541-721) and lamport_ar_2shot_gfx1250 (.cuh:1993-2161) now run the same protocol: 16 B payload lines, kLamportBuffers rotation, per-kLamportWave rounds, (round+2)%3 re-arm, rank-order fp32 sum, p0..p7 inboxes. Before this PR the meta-buffer two-shot was an LL kernel, so this diff creates the duplicate. The differences are parameters. The 32-bit codec also covers 2-byte dtypes, and #7927's ragged chunks are its p < packs guards. kAr2sSentinel also restates LamportAgEscape::kOnes. Merge them and delete one in this PR, not after an A/B. Merging also fixes item 2.
2. Take ragged chunks instead of tightening use_2s to bytes % (16*ws) (.cuh:3276-3280). Sizes that are a multiple of 8·ws but not 16·ws leave the two-shot on the default path:
- TP8 4–8 MiB go to the naive pull (
py:258cites the pull at 405 µs at 14.68 MB). - TP8 0.5–4 MiB and TP4 1–4 MiB (fp32; fp16/bf16 off IPC) go to the LL one-shot.
- No shipped hidden size hits this; only hidden ≡ 32 mod 64 with odd T does.
Use part = ceil(packs/ngpus) plus p < packs, as lamport_ar_2shot_gfx1250 does (.cuh:2052-2064). Do not re-add an 8-byte LL fallback kernel. Either way, the PR body and squash message must list every routing change, not "one case".
3. Post build, --regression (TP4/TP8, IPC + symm_mem) and perf on this head (r49 item 2, still open). No CI lane builds or runs gfx1250, and the tests return early off gfx1250. The PR body still says "pending at 2fd7800".
4. Fix the PR body.
- "264 KiB" should be 258 KiB (r49 Nit 1: only the
.cuhwas fixed). - "Reviewed revision / Pending at 2fd7800" is stale.
- The TP4 IPC table is still there, though you said you removed it.
- "Above 4 MiB TP4 plain AR goes to RCCL" is false for fp16/bf16 on IPC (
select_lamport_ar). - "Changed op tests" omits the gfx1250_poc file (aiter-bot FAIL).
5. Fix code text the PR made wrong.
.cuh:543-544:lamport_ar_add_gfx1250does not exist; point tolamport_ar_1shot_gfx1250..cuh:4054-4057: the comment aboveif(use_2s(...))describes only the LL flag-in-data lane..cu:113-114andpy:260: the two-shot is not one of "the LL kernels"..cuh:331-332: the line helpers are also used by 1shot / 2shot / ag.py:1990: "tens of MiB" is 48–194 MiB..cuh:265-266and the PR body: "6.7 us longer (33.2 vs 26.1 us)" does not add up, since 33.2 − 26.1 = 7.1.
6. Fix the test text.
test_custom_allreduce.py:507-508: where three sizes reach a wave, the line 3 rounds back is the same size one iteration earlier, not "another size's line".:880-882: the--regressionhelp omits the two-shot mixed test and the new sentinel test.:422/:600/:923:LL2S/ll2snames remain, while the poc file was renamed.
Reviewed at e2127e7 (deep; hunters H1–H3 + B3 + C2, 2 C1 verifiers, Stage D). CPU checks found no protocol, layout or arming bug: an inbox-protocol model, launch-bounds replay, meta layout per TP, and the init_lamport_ar_rms merge. Already fixed: helper reuse, 4 input variants, owner NaN bits + sentinel test, poc rename, r49 text items 3a–d, _init_ipc comment, squash message (use_2s grain).
…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]>
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]>
…ernels 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]>
941dd41 to
741e953
Compare
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]>
|
@valarLip Thanks for the review. The seven items are addressed in two commits:
1. One Lamport two-shot. Done as you described: main's
2. Ragged chunks.
3.
4. One block a CU.
5.
Each run: tail, LL mixed sizes, two-shot mixed sizes (the ragged ones included), LL in place, two-shot sentinel payload (now at TP2 too), plain cutoff. Also at this head:
6. Text.
7. PR body and squash text are rewritten for this head:
Still open: TP8 at 2.5–3 MiB.
Previous head (741e953) → this head, production route, µs (MI455X, CUDA graph, slowest rank, mean of two alternating rounds)TP8, two trays, symm_mem
TP4, one tray, IPC
TP4, one tray, symm_mem
TP2, one tray, IPC
fp32 at small sizes: LL one-shot vs the two-shot (what sets
|
| size | LL one-shot | two-shot fused | split | RCCL | two-shot / LL | route (this head) |
|---|---|---|---|---|---|---|
| 16 KiB | 11.1 | 9.6 | 9.0 | 11.5 | 0.86 | fused |
| 32 KiB | 11.0 | 9.9 | 9.3 | 11.8 | 0.90 | fused |
| 64 KiB | 11.7 | 10.1 | 9.5 | 12.1 | 0.87 | fused |
| 128 KiB | 13.5 | 10.1 | 9.8 | 12.7 | 0.75 | fused |
| 192 KiB | 14.0 | 10.4 | 10.0 | 13.2 | 0.74 | fused |
| 256 KiB | 14.6 | 10.7 | 10.1 | 13.8 | 0.73 | fused |
| 384 KiB | 15.5 | 14.4 | 10.3 | 14.8 | 0.93 | split |
| 512 KiB | 16.5 | 14.4 | 10.4 | 16.1 | 0.87 | split |
| 768 KiB | 18.9 | 14.6 | 10.6 | 18.1 | 0.77 | split |
| 1 MiB | 21.2 | 15.5 | 10.8 | 20.4 | 0.73 | split |
| 1.25 MiB | 28.0 | 15.0 | 11.9 | 27.2 | 0.53 | split |
| 1.5 MiB | 32.0 | 15.0 | 12.2 | 28.5 | 0.47 | split |
| 2 MiB | 36.4 | 15.9 | 12.6 | 32.4 | 0.44 | split |
TP4, one tray, IPC
| size | LL one-shot | two-shot fused | split | RCCL | two-shot / LL | route (this head) |
|---|---|---|---|---|---|---|
| 16 KiB | 7.5 | 7.3 | 7.8 | 7.2 | 0.98 | fused |
| 32 KiB | 7.7 | 7.5 | 8.1 | 7.5 | 0.98 | fused |
| 64 KiB | 7.9 | 7.7 | 8.3 | 7.6 | 0.98 | fused |
| 128 KiB | 8.2 | 7.9 | 8.5 | 7.8 | 0.97 | fused |
| 192 KiB | 8.5 | 8.4 | 8.7 | 8.1 | 0.98 | fused |
| 256 KiB | 8.9 | 8.4 | 8.8 | 8.3 | 0.95 | fused |
| 384 KiB | 9.6 | 8.5 | 8.9 | 8.9 | 0.89 | fused |
| 512 KiB | 10.1 | 8.6 | 9.0 | 9.4 | 0.84 | fused |
| 768 KiB | 11.2 | 8.7 | 9.1 | 10.4 | 0.78 | fused |
| 1 MiB | 12.2 | 8.9 | 9.3 | 11.5 | 0.72 | fused |
| 1.25 MiB | 17.4 | 9.0 | 10.7 | 15.7 | 0.52 | fused |
| 1.5 MiB | 18.2 | 9.2 | 10.7 | 16.3 | 0.51 | fused |
| 2 MiB | 20.1 | 9.7 | 10.9 | 17.1 | 0.49 | fused |
TP4, one tray, symm_mem
| size | LL one-shot | two-shot fused | split | RCCL | two-shot / LL | route (this head) |
|---|---|---|---|---|---|---|
| 16 KiB | 7.5 | 7.3 | 7.8 | 7.2 | 0.98 | fused |
| 32 KiB | 7.6 | 7.6 | 8.1 | 7.4 | 1.00 | fused |
| 64 KiB | 7.8 | 7.8 | 8.4 | 7.6 | 1.00 | fused |
| 128 KiB | 8.0 | 8.0 | 8.6 | 7.8 | 1.00 | fused |
| 192 KiB | 8.3 | 8.5 | 8.7 | 8.0 | 1.02 | fused |
| 256 KiB | 8.7 | 8.6 | 8.8 | 8.3 | 0.98 | fused |
| 384 KiB | 9.2 | 8.6 | 8.9 | 8.8 | 0.94 | fused |
| 512 KiB | 9.7 | 8.6 | 9.0 | 9.3 | 0.88 | fused |
| 768 KiB | 10.9 | 8.7 | 9.1 | 10.3 | 0.80 | fused |
| 1 MiB | 11.9 | 8.9 | 9.3 | 11.4 | 0.75 | fused |
| 1.25 MiB | 16.2 | 9.1 | 10.8 | 15.7 | 0.56 | fused |
| 1.5 MiB | 17.7 | 9.3 | 10.9 | 16.2 | 0.52 | fused |
| 2 MiB | 19.4 | 9.8 | 11.0 | 17.0 | 0.51 | fused |
TP2, one tray, IPC
| size | LL one-shot | two-shot fused | split | RCCL | two-shot / LL | route (this head) |
|---|---|---|---|---|---|---|
| 16 KiB | 6.2 | 6.9 | 7.4 | 6.4 | 1.11 | LL |
| 32 KiB | 6.3 | 7.0 | 7.6 | 6.6 | 1.11 | LL |
| 64 KiB | 6.5 | 7.2 | 7.7 | 6.6 | 1.12 | LL |
| 128 KiB | 6.6 | 7.4 | 8.0 | 6.7 | 1.12 | LL |
| 192 KiB | 6.7 | 7.5 | 8.1 | 6.8 | 1.12 | LL |
| 256 KiB | 6.8 | 7.6 | 8.2 | 6.9 | 1.12 | LL |
| 384 KiB | 6.9 | 7.6 | 8.2 | 7.0 | 1.11 | LL |
| 512 KiB | 7.1 | 7.7 | 8.3 | 7.1 | 1.09 | LL |
| 768 KiB | 7.6 | 7.8 | 10.2 | 7.4 | 1.02 | LL |
| 1 MiB | 8.0 | 7.9 | 10.3 | 7.7 | 0.98 | LL |
| 1.25 MiB | 11.6 | 8.0 | 10.5 | 11.7 | 0.69 | fused |
| 1.5 MiB | 11.9 | 8.1 | 10.6 | 11.9 | 0.68 | fused |
| 2 MiB | 12.6 | 8.2 | 10.8 | 12.2 | 0.65 | fused |
|
@TennyWang1223 @valarLip Could you please take a look at current head Tenny, could you give it the primary communications review? valarLip, could you re-review and update the existing |
One conflict: the _init_ipc meta-size comment in aiter/dist/device_communicators/custom_all_reduce.py. The old-arch line is main's (#5918 put the LL scratch in meta_size()); the gfx1250 lines are this PR's.
|
conflict |
Conflicts with #8559 (gfx1250 Lamport AR + RMSNorm split sends): - lamport_ar_2shot_gfx1250 keeps this branch's kernel. #8559 made the round counters [2][slot / 32] (tx, rx) and has every Lamport kernel advance both, as a split lamport_ar_rmsnorm_gfx1250 reads the rx counters; both branches of this kernel now do (advance_round). - LamportArRms keeps num_cus, which #8559 dropped with the cluster path: run_2shot's split layout (a block a CU) reads it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#8012 @ c3b4113, head 2026-11-16T06:45:00Z) Applied as the PR diff onto the rebased 1116 tree; PR state: draft. Conflicts resolved by keeping both sides (both PRs add different opt-in routes next to each other): communicator_cuda.py (#8015 Lamport one-shot check, then this PR's INT4 two-shot check), custom_all_reduce.py (constants, both symm_mem inits, both init methods), custom_all_reduce_gfx1250.h / pybind (main's #7927 allreduce_lamport and fused AR+RMS+quant declarations kept next to this PR's q4 declarations). (cherry picked from commit 1bb791e) Rebase onto main 12-03: #8015 (one-shot + symm_mem inbox) is not carried: main's #7937 final builds the Lamport inbox on every transport and routes plain all-reduce itself (should_lamport_ar(inp, two_shot)). So _LAMPORT_AR_MAX_SIZE / _init_lamport_symm / should_lamport_ar / lamport_all_reduce and the communicator's one-shot branch from #8015 are left out; the symm_mem init calls main's _init_lamport_ar_rms, then this PR's _init_lamport_q4_2s(symm=True). pybind keeps main's allreduce_lamport(split=False) next to the q4 bindings.
Summary
On gfx1250, plain all-reduce has one two-shot now: main's Lamport
lamport_ar_2shot_gfx1250, extended with an fp32 codec and a split layout. It replaces #7432's LL two-shotar_2s_ll_gfx1250. The Lamport inbox is now built on every transport, so its kernels also run over symm_mem (TP8 across trays) and VMM.lamport_ar_2shot_gfx1250<T, ngpus, BLOCK, ROLES>.ROLES= 1 is main's fused layout: one lane takes all three steps of a pack. 2 or 3 is the split layout: send, reduce and gather in wave groups, one block a CU.ceil(packs / ngpus)packs withp < packsguards, so any input of whole 16-byte packs runs.ar_2s_ll_gfx1250and its tables, so the meta buffer is 64 MiB a rank smaller at TP4 and TP8;ar_2s_lamport_gfx1250and its 48 MiB inbox;_LAMPORT_AR_SKIP_WORLD_SIZES.[545, 3584]goes 23.8 → 14.8 µs and[545, 7168]43.5 → 20.3 µs.Motivation
ar_2s_lamport_gfx1250repeated main's Lamport two-shot: the same sentinel,(round + 2) % 3re-arm, per-wave round counter and rank-order fp32 sum. They differed only in launch shape and in where their inbox lived. The earlier kernel's inbox sat in the uncached meta buffer, which cost 1–4 µs a call in a tray. Review asked for one kernel: main's, with the 32-bit codec and a layout parameter.Changes
Kernel and host side (
csrc/include/custom_all_reduce_gfx1250.cuh,csrc/kernels/custom_all_reduce_gfx1250.cu,.h, pybind)LamportArCodec<T>.lamport_ar_2shot_gfx1250<T, ngpus, BLOCK, ROLES>, main's kernel with:ROLES(1 fused, 2 or 3 split);part = ceil(packs / ngpus), withp < packsguards on every load and store. Lanes past the message only re-arm.run_2shot(…, split).add_threads(part)lanes a block (64, 256 or 512).delay×s_sleep(16): 4 up to W = 64, else 8.allreduce_lamport(…, two_shot, split). Dispatches fp32 to the two-shot only; the one-shot stays 2-byte.ar_2s_ll_gfx1250, its peer and block-flag tables,use_2s_ll/allreduce_2s_lland its dispatch.Python (
aiter/dist/device_communicators/custom_all_reduce.py,aiter/ops/custom_all_reduce.py)_init_lamport_ar_rmsruns on every transport._alloc_lamport_inboxbuilds the inbox:symm_mem.emptyand a rendezvous. If the peers cannot be mapped, every rank turns the Lamport ops off.VMMBufferandvmm_exchange._LAMPORT_AR_MAX_BYTES{2: 16, 4: 8, 8: 4} MiB: plain all-reduce's own cap, a sender's slot of the inbox, apart from the AR + RMSNorm cap._LAMPORT_AR_RMS_MAX_BYTES, still off at TP8 by default.AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZEoverrides both caps, as it did; 0 turns every Lamport op off.select_lamport_ar(inp)returns(two_shot, split)or None, from shapes, dtype and the cap only, so every rank picks the same kernel. Its tables:_LAMPORT_AR_1SHOT_MAX_BYTESgains TP8;_LAMPORT_AR_FP32_LL_MAX_BYTESand_LAMPORT_AR_SPLIT_BYTES._GFX1250_PLAIN_AR_MAX_SIZE[8]: 8 → 4 MiB. Without the LL two-shot, the meta-buffer path past 4 MiB is the pull, far behind RCCL. Sizes the Lamport all-reduce takes are not capped by it._LAMPORT_AR_SKIP_WORLD_SIZES, and the post-init barrier this PR had added for the meta-buffer two-shot. The Lamport init keeps its barrier after arming the inbox.Routes, gfx1250 plain all-reduce, defaults
Main takes RCCL past its last range.
Past those ranges (world_size × the cap): RCCL. With every Lamport op off: the LL one-shot up to 4 MiB, RCCL above.
Memory a rank
Performance
MI455X, ROCm 10.1,
rocm/fw-bringup:gfx1250-atom-k3-20261119, RCCL 2.30.4.6c25a7f46. TP2 and TP4 were timed onca3a7e0ad. Their routes and kernels have not changed since: the later commits change only the TP8 tables and merge main, which touches none of these files.mainisafc300d7f.prodistensor_model_parallel_all_reducewith the server's RCCL settings (RCCL_DDA_LL_ONESHOT_THRESHOLD=2097152,RCCL_DDA_LL_TWOSHOT_THRESHOLD=134217728).[545, 3584]and[545, 7168]bf16.TP8, two trays, symm_mem: main → this PR
TP4, one tray, IPC: main → this PR
TP4, one tray, symm_mem: main → this PR
TP2, one tray, IPC: main → this PR
This PR's kernels side by side (bf16 and fp32): the 1-shot / fused / split / LL crossovers behind the routes
TP8, two trays, symm_mem, bf16
TP8, two trays, symm_mem, fp32
TP4, one tray, IPC, bf16
TP4, one tray, IPC, fp32
TP4, one tray, symm_mem, bf16
TP4, one tray, symm_mem, fp32
TP2, one tray, IPC, bf16
TP2, one tray, IPC, fp32
Testing
The kernel changes are gfx1250 only. On gfx9, the Python changes leave the Lamport caps at 0 and
select_lamport_arreturns None, as before; symm_mem and VMM init are gfx1250 only.Documentation
The routes and their measurements are in the comments of the tables they set (
custom_all_reduce.py) and ofrun_2shot(.cuh).Dependencies
Breaking Changes
None for users. Internal signatures:
allreduce_lamport_gfx1250gainssplit=Falseand takes fp32 withtwo_shot=True.CustomAllreduce.select_lamport_arreturns(two_shot, split)or None instead of a bool.PR Self-Review
Reviewed revision
6c25a7f46Behavior and intent
On gfx1250, plain all-reduce routes by size to one Lamport kernel family on every transport.
Validation and unverified scope
All on MI455X, at the head
6c25a7f46.op_tests/multigpu_tests/test_custom_allreduce.py --regressionpassed:--transport symm) and VMM (AITER_CUSTOM_AR_FORCE_VMM=1).--regressionpassed, with the same checks.gfx1250_poc/test_gfx1250_lamport_allreduce.pyat TP2 and TP4, bf16 and fp32: routes as restated, every kernel bit-exact, 99-call mixed sequences;test_fused_ar_rms_lamport.py,test_ar_add_lamport.pyandtest_ag_lamport.pyat TP2 and TP4;pytest test_custom_allreduce_size_env.py: 17 passed.select_lamport_aron CPU for TP2, TP4 and TP8 defaults: 27 sizes × bf16 and fp32, 162 cases.PR-specific question
What selects the changed path:
CustomAllreducebuilds the Lamport inbox only there, and symm_mem and VMM are gfx1250 only.select_lamport_ar→should_lamport_ar(two_shot=True)requires:bytes % 16 == 0and0 < bytes <= world_size × cap._LAMPORT_AR_1SHOT_MAX_BYTES,_LAMPORT_AR_FP32_LL_MAX_BYTESand_LAMPORT_AR_SPLIT_BYTESpick it.What keeps unsupported inputs out, in C++:
ar_packsthrows on a partial pack or past the inbox's world_size × slot packs.allreduce_lamportthrows beforeinit_lamport_ar_rms, and on a one-shot of a 4-byte dtype..cuwrapper takes fp16, bf16 and fp32 only, with a contiguous output of the input's dtype and size.p < packsguards; lanes past it only re-arm.Changed op tests
op_tests/multigpu_tests/test_custom_allreduce.py:_AR2S_GFX1250_MIXED_SIZESgains two ragged fp32 sizes. 655 364 and 1 597 444 have numel 4 mod 8, so no world size cuts them into whole packs a chunk. They fall in the ranges where TP8 splits and fuses, and the list runs at TP2, TP4 and TP8. Without them, nothing fails if the chunk grain goes back to16 × ngpus.op_tests/multigpu_tests/test_custom_allreduce_size_env.py: CPU tests of the size gates.test_gfx1250_lamport_ar_routepinsselect_lamport_arat every route boundary: per world size, dtype and layout, and at an unmeasured world size.op_tests/multigpu_tests/gfx1250_poc/test_gfx1250_lamport_allreduce.py: the PoC restates the routing rules independently and checks every rank's kernel against them.LAMPORT_AR_SKIP_TP.🤖 Generated with Claude Code