Repository navigation
[HIP] fea: impl lamport allreduce on gfx9 - #7452
Conversation
Signed-off-by: TennyWang1223 <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
- test_custom_allreduce_lamport.py: call endswith once with a tuple (ruff 0.16.0 PIE810) - black-format test_custom_allreduce_lamport.py and the lamportAllReduce signature in aiter/ops/custom_all_reduce.py Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: TennyWang1223 <[email protected]>
- lamportKernel: two-shot up to 2MB at TP2, 1MB at TP4/TP8 (was 64MB). On MI350X (gfx950) the original dispatch is as fast or faster above these sizes (TP8 down to 0.90x); one set of caps keeps gfx942 and gfx950 free of regressions. gfx942 gives up its 1.01-1.27x two-shot gain above the caps. - kLamportTwoShotMaxBytes 64MB -> 2MB: lamport IPC buffer per rank TP2/4/8 387.75/391.5/399MB -> 15.75/19.5/27MB. - test_custom_allreduce_lamport.py: forced two-shot up to 2MB, default sweep up to 4MB (one size past the largest two-shot per n), resize check positions within the new two-shot capacity. Verified on MI308X (gfx942): full lamport sweep (156 cases, bitwise), test_custom_allreduce.py bf16 graph/eager. Not yet re-run on gfx950. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: TennyWang1223 <[email protected]>
|
@aiter-bot review |
|
aiter-bot — queued behind 1 review(s); expect to start in about 50 min. The box reviews one PR at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #7452 — [HIP] fea: impl lamport allreduce on gfx9
Review (advisory):
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 (auto-validation disabled) and no GPU access on this review box (permission denied to /dev/kfd, torch sees 0 devices), so the multi-GPU target op_tests/multigpu_tests/test_custom_allreduce_lamport.py could not be run; environment gap, not a PR defect
Perf (advisory): NOT RUN — no usable GPU on this review box (the harness needs 2–8 ranks); environment gap, not a PR defect — the PR's own base-vs-head tables (origin via AITER_CUSTOM_AR_DISABLE_LAMPORT=1 vs the default dispatch, 20-replay medians of a 10-call graph, slowest rank, both archs, both capture paths) are the author's runs, unverified here
_LAMPORT_GFX = ("gfx942", "gfx950") in aiter/dist/device_communicators/custom_all_reduce.py), but per the PR's own unverified list the exact head revision was never run on gfx950 — the MI350X tables predate the dispatch caps and the inbox shrink — so an arch-specific lamport defect would hang every TP rank on MI350X with no test having ever executed there. Author must re-run test_custom_allreduce_lamport.py on gfx950 at this head (or drop gfx950 from _LAMPORT_GFX until that run exists) before merge.
📝 [verified] The PR states the fused AR + residual / AR + RMSNorm crossovers (_AR_RESIDUAL_MAX_BYTES, should_fuse_ar_rms in aiter/dist/device_communicators/custom_all_reduce.py) were not re-tuned, and since the PR's own tables claim plain all-reduce is up to ~1.5x faster inside the lamport caps, some fused-vs-plain decisions may now sit on the wrong side of the crossover. Reviewer should ask whether the threshold re-tune is tracked as a follow-up.
📝 [verified] kLamportMaxPacks = 512 * 80 in csrc/include/custom_all_reduce.cuh (the 640KB one-shot inbox) states its purpose — the forced-kernel tuning ceiling — but not where 512*80 itself comes from, so a future resize of the one-shot range has no stated basis to start from. Reviewer should ask for the derivation next to the constant.
Resolve the conflict with the gfx9 lamport allreduce (#7452) in CustomAllreduce init: gfx1250 sets up the lamport AR + RMSNorm inbox, other archs the lamport allreduce. Add TODOs on both inits for when each arch gets the other lamport op. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the custom_all_reduce.cu conflict (keep main's useFp8Quant and lamportSkipsCopyIn helpers) and adapt the dispatch to the lamport path of ROCm#7452, which runs ahead of every other path and has no addend input: - allreduce: with an addend, lamport reduces the staged sum unless the fused LL / LL128 add is faster (fused_add_beats_lamport). On gfx950 that is TP2 up to the fused caps, TP4 up to 48 KB, TP8 up to 24 KB; elsewhere lamport, as for a separate add. - runs_one_shot / uses_1stage_ar: ask lamportDispatch first (lamport one-shot counts as one-shot, two-shot does not). - test_custom_allreduce_add.py: cover the 24 / 48 KB cutovers and the lamport one-shot / two-shot boundaries (59 sizes).
…gments test AITER v0.1.29 (ROCm/aiter#7452) enables lamport all-reduce by default on gfx942/gfx950. For 2-byte messages up to 2 MiB at TP2 it reads the input in place and skips the copy-in to the registered buffer. The test's (128, 8192) bf16 input is exactly 2 MiB, so the unguarded capture records no memcpy and `capture_allreduce(unguarded) == 1` fails, although results are correct. A 4 MiB message stays above every lamport limit, so it still exercises the staging copy that the test guards. Verified on MI355 with the build vllm-project#15798 image: the original test fails with lamport on and passes with AITER_CUSTOM_AR_DISABLE_LAMPORT=1; the updated test passes with lamport on and off; the full file passes (6 passed). Co-Authored-By: Claude <[email protected]> Signed-off-by: josh schell <[email protected]>
Summary
Adds a Lamport (barrier-free) all-reduce path to the gfx9 custom all-reduce, for bf16/fp16 on gfx942 and gfx950. It replaces
origin_custom_ar(LL / LL128 / 1-stage / 2-stage) for small and medium messages:lamport_ar_1shot_ws(1shot)lamport_ar_2shot_ws(2shot)origin_custom_ar(unchanged)AITER_CUSTOM_AR_DISABLE_LAMPORT=1restores the original dispatch. gfx1250 is not affected.Motivation
origin_custom_arkernel synchronizes ranks through theSignalbarrier before it touches peer buffers, and 2-stage pays this twice. For decode-sized messages this handshake is a large part of the time.Changes
csrc/include/custom_all_reduce.cuh):lamport_ar_1shot_wsandlamport_ar_2shot_ws. Wave64, 2-byte dtypes only._ws= wave split: a block isngpuswaves, and wavewtalks only to rank(rank + w) % ngpus.CustomAllreduce::lamportKernel): the ranges in the table above. They are bounded by gfx950, see Performance.origin_custom_ar: fp32, the fp16open_fp8_quantbranch,use_new=False, and two-shot sizes that are not a multiple of16 * tpbytes.csrc/kernels/custom_all_reduce.cu):all_reduce()skips the memcpy into the registered pool for messages Lamport takes. An input that is not 16B aligned is still copied in, and still runs the same Lamport kernel.aiter/dist/device_communicators/custom_all_reduce.py):_initLamportallocates the inbox buffer and fills it with the sentinel. The on/off verdict is AND-ed across ranks.lamportBufferSize,initLamport,lamportKernel(which kernel the dispatch picks),lamportAllReduce(forces one kernel, for tests and tuning).Performance (if applicable)
Method:
test_custom_allreduce_lamport.py, bf16, H = 7168 / 8192, CUDA graph, registered input. Time = median of 20 replays of a 10-call graph / 10, slowest rank. Before =origin_custom_ar(AITER_CUSTOM_AR_DISABLE_LAMPORT=1). After = what the default dispatch runs. Speedup = before / after.Key numbers, inside the Lamport ranges:
On the copy-in path the gain is larger, because Lamport also skips the memcpy (gfx950: 1.13–1.85x). Those numbers are left out of the tables.
Why the caps are 2 MB / 1 MB / 1 MB: they are the largest sizes where Lamport is not slower on gfx950. Above them, on gfx950, the original dispatch is as fast or faster (two-shot vs origin: TP2 0.96–0.99x, TP4 0.98–1.01x, TP8 0.90–1.00x, measured up to 64 MB). One set of caps serves both archs.
Cost on gfx942: gfx942 does not regress above the caps, but it gives up a gain there. At TP4 / TP8 for 1.75–2 MB, a forced two-shot is still 1.21–1.42x faster than
origin_custom_ar(e.g. TP8 2 MB: 19.1 µs vs 27.2 µs; forced kernel, measured on d0b868b). Per-arch caps could recover this in a follow-up.Both tables were measured before the caps were added. Inside the caps the kernels are unchanged. Rows marked
originare past the caps and now run the original dispatch, so After = Before.MI308X (gfx942)
origin_custom_ar(µs)MI350X (gfx950)
origin_custom_ar(µs)Testing
Documentation
No guide in the repo lists the custom all-reduce env vars or kernels. The switch, the size ranges and the buffer size are documented next to the code (
_DISABLE_LAMPORT_ENV,_initLamport,CustomAllreduce::lamportKernel).Dependencies
Breaking Changes
None in the API. Behavior changes on gfx942 / gfx950 only:
AITER_CUSTOM_AR_DISABLE_LAMPORT=1on every rank.PR Self-Review
Reviewed revision
d0b868b
Behavior and intent
tensor_model_parallel_all_reduce/CustomAllreduce.all_reducefor bf16/fp16 messages inside the ranges above runslamport_ar_1shot_ws/lamport_ar_2shot_wsinstead oforigin_custom_ar. Copy-in calls skip the memcpy for those messages.origin_custom_arpays a cross-rankSignalhandshake (twice for 2-stage). Lamport replaces it with data-as-signal inboxes: 1.00–1.53x faster across both archs inside the ranges.use_new=False, messages above the caps, all_gather / reduce_scatter / all fused ops (AR + RMSNorm, AR + residual), and gfx1250.Validation and unverified scope
Hardware: 8 × MI308X (gfx942), xGMI. Commands (with this repo on
PYTHONPATH):Results on d0b868b (gfx942):
origin_custom_ar(0.98–1.03x, noise).test_custom_allreduce.pybf16 / fp16 × graph / eager,test_custom_allreduce_fp8.py,test_custom_allreduce_rank_order.py(no failed ranks). Lamport off:test_custom_allreduce.pybf16 graph / eager.Unverified:
test_custom_allreduce_capture_registration.pyandtest_custom_allreduce_graph_buffer_reuse.py: fail in setup with torch 2.8 (notorch._C._accelerator_setAllocatorSettings), before any all-reduce. Need a newer torch.PR-specific question
Which arch, dtype and shape select the Lamport path, and what keeps other inputs out:
_initLamportand AND-ed across ranks. OtherwiseinitLamportnever runs,lamport_stays null, andlamportKernelreturnsnone.lamportDispatchrequireselem_size == 2anduse_new.allreduce<T>checks underif constexpr (sizeof(T) == 2). The fp16 fp8-quant branch leaves_all_reducebeforeallreduce<T>.16 * tp. Anything else runsorigin_custom_ar.allreduce<T>already requires whole 16B packs.std::minwithtwoShotMaxBytes()).runOneShot/runTwoShotthrow on anything past capacity rather than overrun the inbox.Changed op tests
op_tests/multigpu_tests/test_custom_allreduce_lamport.py(new). Runs each TP as two process groups, Lamport on and off.test_custom_allreduce.pychecksorigin_custom_aragainst a tolerance. It cannot force a kernel, compare Lamport on/off in one run, or catch a missed re-arm (stale data that is still numerically close).🤖 Generated with Claude Code