Repository navigation
[HIP] fea: impl gfx1250 lamport allgather - #7861
Conversation
Route custom_all_gather on gfx1250 (TP2 up to 16 MiB a rank, TP4 up to 8 MiB) to a Lamport one-shot all-gather on the inbox of the Lamport AR + RMSNorm. Drop the address check from the Lamport AR + add gate, which could hang a group whose ranks hold differently aligned operands; an unaligned operand of a Lamport op is now copied rank-locally. Signed-off-by: TennyWang1223 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
🏷️ 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 |
|
@aiter-bot review |
|
aiter-bot — queued behind 3 review(s); expect to start in about 1.6 h. The box reviews one PR at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #7861 — [HIP] fea: impl gfx1250 lamport allgather
Review (advisory):
Validation (deterministic): NOT RUN — auto-validation disabled (REVIEW_AUTO_VALIDATE=0) and this box is 8x gfx942 while the change is gfx1250-only, so the target op_tests/multigpu_tests/test_ag_lamport.py (which returns early on non-gfx1250) could not be run here; environment gap, not a PR defect
Perf (advisory): NOT RUN — the validation target exposes no benchmark entry point and no gfx1250 GPU exists on this box, so the PR's own harness (op_tests/multigpu_tests/gfx1250_poc/test_gfx1250_allgather.py, which times prod against the old route back to back) was not re-run by this review; the 1.08–3.63x tables are the author's runs
Size: 1526 lines / 10 files — over the review bar
Design (advisory): SPLIT — (1) the AR+add/AR+RMS unaligned-operand hang fix (_lamport_aligned, the should_lamport_ar_add address-gate removal, its two test files), (2) the Lamport all-gather itself (lamport_ag_gfx1250 + the two codecs + the escape inbox, the C++/pybind/ops stub, should_lamport_ag routing, test_ag_lamport.py), (3) the gfx1250_poc benchmark rewrite; (1) is a standalone hang fix and ghstack makes the stack cheap
Human: recommend XiaobingZhang review whether the gfx1250 Lamport all-gather of PR #7861 should share the AR+RMSNorm inbox, round counters and AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE cap with the AR+add and AR+RMSNorm ops, and whether the 0xffff → 0x7fff rewrite for fp16/bf16 gathers is acceptable to every consumer of custom_all_gather
get_gfx_runtime() not in SUPPORTED_GFX gate), no CI lane runs gfx1250 HIP tests (default CI is MI35X, the multi-GPU runner is gfx942), and this review's box is 8x gfx942 — so neither the 202+382+40-case correctness runs nor the 1.08–3.63x tables were verified by anything but the author, and a later regression in should_lamport_ag or lamport_ag_gfx1250 would land with no automated check. Reviewer should ask for the test logs and benchmark output to be attached to the PR (or a gfx1250 CI lane) before this production routing lands.
📝 [verified] On the new path a 0xffff half-word of an fp16/bf16 input comes out 0x7fff (lamportCanonicalize in csrc/include/custom_all_reduce_gfx1250.cuh) — NaN→NaN for real float data, but a consumer gathering bit-packed data already viewed as fp16/bf16 gets silently rewritten bits; the PR analyzes ATOM's fp8-paired-into-fp16 case as value-safe and routes int16 through the bit-for-bit codec. Reviewer should ask whether every other gfx1250 consumer of tensor_model_parallel_all_gather(use_custom=True) gathers real float data rather than packed bits.
Route custom_all_gather on gfx1250 (TP2 up to 16 MiB a rank, TP4 up to 8 MiB) to a Lamport one-shot all-gather on the inbox of the Lamport AR + RMSNorm. Drop the address check from the Lamport AR + add gate, which could hang a group whose ranks hold differently aligned operands; an unaligned operand of a Lamport op is now copied rank-locally. Signed-off-by: TennyWang1223 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 88ebffa)
Summary
Add a Lamport one-shot all-gather for gfx1250 and route the custom all-gather to it. On TP2 up to 16 MiB per rank and on TP4 up to 8 MiB,
custom_all_gathernow runslamport_ag_gfx1250for gathers along dim 0 or the last dim. Bothtensor_model_parallel_all_gather(use_custom=True)andCudaCommunicator.all_gathergo throughcustom_all_gather. Above the cap, along other dims, and for rows that are not whole 16B packs, the routing is unchanged.This PR also removes an address check from the Lamport all-reduce + add gate that could hang the group.
Motivation
On gfx1250 the custom all-gather currently runs
ag_ll_gfx1250up to 4 MiB and the barrier kernels above that. In the LL kernel each 16B line carries 12B of payload plus an epoch word, and every call ends with an epoch fan-out over all blocks. The Lamport protocol from #7499 needs neither. Each rank pushes its 16B packs straight into its peers' inboxes, and the peers poll against a sentinel. So a line carries 16B of payload, and there is no barrier and no copy-in. The gather that motivated this is TP4[4, BS, 32]int32 along dim 0 with BS 8–128, a decode case from our test team. It drops from 7.8–8.4 us to 5.0–6.0 us.Changes
custom_all_reduce_gfx1250.cuh):lamport_ag_gfx1250is a one-shot push all-gather on the Lamport inbox of [HIP] fea: impl gfx1250 lamport ar+rms #7499. It uses the same round counters and re-arm, so it interleaves freely with the Lamport AR + RMSNorm and AR + add. A codec, picked by dtype, decides how a reader tells an arrived word from the armed sentinel:all_gather_lamportinmodule_custom_all_reduce_gfx1250. Some inputs cannot be read in place: those not 16B aligned, and those overlapping the output other than as their own dim-0 slice. Such an input is first copied into the registered input pool, as the LL all-gather already does.CustomAllreduce.custom_all_gathertakeslamport_all_gatherwhenshould_lamport_agholds. That requires dim 0 or the last dim, a contiguous input, rows of whole 16B packs, and a size up to the Lamport cap.should_lamport_ar_addused to checkdata_ptr() % 16. When ranks held differently aligned operands, some took Lamport and others took the fallback, and the group hung._lamport_aligned).AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZEnow caps all three Lamport ops. The defaults are unchanged: TP2 16 MiB, TP4 8 MiB. Setting it to0turns all three off.op_tests/multigpu_tests/test_ag_lamport.py(new): correctness only.op_tests/multigpu_tests/gfx1250_poc/test_gfx1250_allgather.py(rewritten): performance plus a dispatch check.test_ar_add_lamport.pyandtest_fused_ar_rms_lamport.py: new cases with unaligned operands on the odd ranks.Performance (if applicable)
Setup: 4x gfx1250 (256 CU), ROCm 10.1, IPC transport, CUDA graph (43 calls × 20 replays, median per rank, slowest rank reported).
ag_ll_gfx1250up to 4 MiB and the barrier kernels above it, reading the captured input in place.tensor_model_parallel_all_gather(use_custom=True)with this PR.TL;DR: Over the shapes × dtypes × dims under the cap, TP2 is 1.08–3.13x faster (median 1.44x) and TP4 is 1.22–3.63x faster (median 1.50x). No case is slower. The median speedup over RCCL is 3.4–4.0x. Inputs above the cap keep the old route.
Decode:
[4, BS, 32]int32 along dim 0Rows of hidden 7168 along dim 0
Model shapes, along the last dim
At the cap
One row past the cap keeps the barrier kernel, so its time is unchanged.
All cases under the cap, by TP, dim and codec
[4, BS, 32]with BS 8–128, plus[M, 7168]with M 1–512. Dtypes are int32, bf16, fp16, int16 and fp32. Each shape is gathered along dim 0 and along the last dim. The edge cases are also included: uint8, fp8, int64, a partial last wave, one pack, the model shapes above, and the cap itself.An input one element off 16B alignment on the odd ranks is copied into the pool first. It still runs 1.02–1.10x faster than before.
The cap is shared with the Lamport AR + RMSNorm and is not raised here. We measured the all-gather with a raised cap:
Raising the cap would also cost another 120 MiB per rank. It would also need an all-gather-only cap, because the AR + RMSNorm is 0.95–1.2x at TP4 14–16 MiB.
Testing
Documentation
This is an internal routing change with no new knob. The behavior of the existing
AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZEis documented next to_LAMPORT_AR_RMS_MAX_BYTES. The fp16/bf16 codec note is in the docstring oflamport_all_gather.Dependencies
Breaking Changes
None. Some notes on behavior:
AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE=0now also turns off the Lamport all-gather.PR Self-Review
Reviewed revision
e442cfc
Behavior and intent
On gfx1250 TP2/TP4, a custom all-gather along dim 0 or the last dim, up to the Lamport cap, now goes through a single Lamport kernel instead of the LL or barrier all-gather. The output is bit for bit the gathered inputs, with one exception: a 0xffff half-word of an fp16/bf16 input becomes 0x7fff. Larger inputs, other dims, TP6/TP8, multi-node groups, other archs and the RCCL path behave as before.
The Lamport AR + add no longer decides from operand addresses. A group whose ranks hold differently aligned operands now runs instead of hanging.
Validation and unverified scope
All runs are on 4x gfx1250, TP2 and TP4.
python op_tests/multigpu_tests/test_ag_lamport.py: 202 cases plus a mixed sequence of 64 calls per TP. Every gather is bit for bit, through both production entries, eager and in graph replays with fresh inputs.python op_tests/multigpu_tests/gfx1250_poc/test_gfx1250_allgather.py: 382 cases.torch.profiler.python op_tests/multigpu_tests/test_allgather.py -t 2and-t 4: all 40 cases have err 0. This includes the cases where the odd ranks' input sits one element into its storage. Those cases hang if the gate looks at addresses.python op_tests/multigpu_tests/test_ar_add_lamport.pyandpython op_tests/multigpu_tests/test_fused_ar_rms_lamport.py: bit for bit. Their mixed sequences (52 and 51 calls per TP) now include unaligned operands on the odd ranks.black --checkandruff check(ruff 0.16.0, as pinned in CI) are clean on the changed Python files.PR-specific question
Changed op tests
op_tests/multigpu_tests/test_ag_lamport.py(new): correctness of the Lamport all-gather on the production path.test_allgather.pygathers random bf16 against a tolerance. It never hits sentinel collisions, the escape codec or the shared inbox.op_tests/multigpu_tests/gfx1250_poc/test_gfx1250_allgather.py(rewritten, not run by CI): timing and dispatch check for the gfx1250 all-gather routes.op_tests/multigpu_tests/test_ar_add_lamport.pyandop_tests/multigpu_tests/test_fused_ar_rms_lamport.py: add operands one element off alignment on the odd ranks only. This is the case where the AR + add gate used to hang.🤖 Generated with Claude Code