fix(rccl): keep DDA LL128 AR/AG/RS tier choice rank-uniform under misaligned buffers #16629
<!-- therock-pr-bot-policy-check -->
✅ All Checks Passed — Ready for Review
| Check | Status | Details |
|---|:---:|---|
| 📝 PR Description | ✅ Pass | — |
| ⛔ Forbidden Files | ✅ Pass | — |
| 🧪 Unit Test | ✅ Pass | — |
| 🔎 pre-commit | ✅ Pass | — |
| 🚫 Draft PR | 🔜 To Be Enabled | — |
| 🚩 Feature Flag | 🔜 To Be Enabled | — |
| 📊 Code Coverage | 🔜 To Be Enabled | — |
| 🤖 therock-pr-bot | ✅ Pass | — |
🎉 All checks passed! This PR is ready for review.
📖 Need help? See the Policy FAQ for details on every check and how to fix failures.
<!-- therock-pr-bot-fix-policies -->
🎉 All checks passed! This PR is ready for review.
@cppccppccppc @sunguobao PTAL
Medium
With the alignment check gone, four host microtests still expect misaligned buffers to be rejected, and they now get true:
dda-all-gather-fabric-ll128-test.cc:154-155 AG LL128 0x1008 / 0x2008
dda-reduce-scatter-fabric-ll128-test.cc:195-196 RS LL128 0x1008
dda-all-reduce-fabric-ll-test.cc:321-323 AR one-shot 0x1008 / 0x2001
dda-all-reduce-fabric-ll-test.cc:351-353 AR two-shot 0x1004 / 0x2002
These binaries run in the quick/precheck set (test_categories_micro_dda.yaml). Could we flip them to EXPECT_TRUE, as DdaFabricEligibilityTests.cpp already does?
Medium
No device test runs the kAligned=false instances of ddaAllGatherFabricLL128 (including this new local-copy branch), ddaAllReduceFlatLL128 or the non-PeerPar ddaAllReduceTwoShotLL128. Every misaligned AllGather takes this kernel, and capped AllReduce launches (the registered re-routes at rccl_wrap.cc:2157/2167) keep the non-PeerPar kernels (dda_all_reduce_fabric_ll.cu:290). Could the misaligned-offset cases from DdaAllReduceFabricLL128PeerParTests.cpp:450 cover these too?
Medium
No test checks which instance the four LL128 launchers pick for misaligned buffers: every host launch test uses 0x1000/0x2000. Hardcoding aligned = true here, at line 413, at dda_all_gather_fabric_ll128.cu:94 or at dda_reduce_scatter_fabric_ll128.cu:138 still passes. Could we add a kernel-pointer case per launcher like dda-broadcast-fabric-ll128-test.cc:424?
Low
The per-rank alignment rationale appears at about ten sites in this PR; one short line suffices here.
// Picks this rank's aligned or any-address user-buffer instance; both use the same wire format.
<!-- argus:v1 pr=16629 sha=bc20f1162e70 mode=review -->
ARGUS
Findings
<details>
<summary>1 more finding(s), not posted inline</summary>
projects/rccl/src/algorithms/dda/all_gather/dda_all_gather_fabric_ll128.cu:111 (Low) AR, RS and AG launchers pick kAligned three different ways; sharing ddaArPickAligned/ddaArPickRanksCt via a header would unify them.</details>
Impact
<details>
<summary>Reaches gfx1250; the PR targets gfx1250; 7 test(s) to run, 7 heatmap cell(s) to measure</summary>
Only gfx1250 runs this at runtime: the fabric DDA selectors check IsArchMatch("gfx1250") at rccl_wrap.cc:2146 (AllReduce) and 2430 (AllGather), and ReduceScatter's selector at rccl_wrap.cc:2737 is reached only on fabric-enabled comms. The kernels still compile for every build target. On gfx1250, AllReduce (LL128 one-shot and two-shot, PeerPar and capped non-PeerPar), AllGather LL128 and ReduceScatter LL128 (batched and PeerPar) now pick LL128 for misaligned user buffers in every dtype (fp32, fp16, bf16, fp8). Before, those calls went to VMM, CE-registered, Ring or the kernel path. The registered-window re-routes (eager CE-registered and graph-captured Ring) now land on capped one-warp unaligned kernels. The NRANKS_CT=4/8 unaligned instances and single-node comms are outside the PR's 16-rank (4x4) measurements. Aligned callers run the same instances as before. Reaches gfx1250; the PR targets gfx1250.
Tests that exercise this change
rccl-UnitTestsFixturesDebug quick, DdaFabricEligibilityTest.: pins the AR one-shot/two-shot and AG eligibility that no longer reads buffer alignment (projects/rccl/test/test_categories_fixtures_debug.yaml)rccl-UnitTestsFixturesDebug quick, DdaFabricLL128EligibilityTest.: AG and RS LL128 eligibility with misaligned buffers (projects/rccl/test/test_categories_fixtures_debug.yaml)rccl-UnitTests standard, DdaAllReduceFabricLL128PeerPar.: runs the new misaligned-offset PeerPar AR instances on device (projects/rccl/test/test_categories.yaml)rccl-UnitTestsFixtures standard, DdaAllReduceFabricLL128PeerPar.: same device tests in the fixtures binary (projects/rccl/test/test_categories_fixtures.yaml)rccl-UnitTestsMPI standard, DdaFabricBlockCap.: drives capped DDA launches, the non-PeerPar kernels the re-route now picks for misaligned buffers (projects/rccl/test/test_categories_mpi.yaml)rccl-UnitTestsMPI standard_env_dda_fp8_ll128, DdaFp8MPI_LL128.: end-to-end fabric LL128 tier, whose kernels gained the kAligned template parameter (projects/rccl/test/test_categories_mpi.yaml)rccl-UnitTestsMPI standard_env_dda_fp8_ll128_twoshot, DdaFp8MPI_LL128TwoShot.*: forces the LL128 two-shot AR whose kernel selection now takes the aligned flag (projects/rccl/test/test_categories_mpi.yaml)Heatmap cells to measure, baseline against this PR, interleaved A/B
gfx1250 all_reduce any/sum, 1 node(s), 2 MiB to 4 MiB (not measured in the heatmap): registered eager re-route band at 4 ranks (4 x 512K-1M shards): misaligned windows now take the capped non-PeerPar unaligned LL128 kernel instead of CE-registeredgfx1250 all_reduce any/sum, 1 node(s), 1 MiB to 128 MiB (not measured in the heatmap): misaligned buffers on 4/8-rank comms now run the NRANKS_CT 4/8 unaligned LL128 instances; the PR measured only 16 ranksgfx1250 all_reduce any/sum, 4 node(s), 64 MiB to 256 MiB (not measured in the heatmap): PR reports misaligned LL128 against the old fallback at -3.6% to +17% here; this is the top of the LL128 bandgfx1250 all_reduce any/sum, 4 node(s), 8 MiB to 16 MiB (not measured in the heatmap): registered eager re-route band at 16 ranks, now capped unaligned LL128 for misaligned windowsgfx1250 all_gather any, 1 node(s), 64 KiB to 128 MiB (not measured in the heatmap): misaligned AG now takes the LL128 <T,4/8,false> instances instead of VMM or the kernel pathgfx1250 reduce_scatter any/sum, 1 node(s), 1 MiB to 224 MiB (not measured in the heatmap): misaligned RS now takes the unaligned batched/PeerPar LL128 instances below 8 ranks, unmeasuredgfx1250 reduce_scatter any/sum, 4 node(s), 64 MiB to 256 MiB (not measured in the heatmap): PR reports RS misaligned LL128 within -3.6% to +17% of the fallback here</details>
Bottom line: Worth settling before approval: four host microtests under test/host/algorithms/dda still expect misaligned buffers to be LL128-ineligible and now fail, and no test runs the kAligned=false AllGather, flat AllReduce or non-PeerPar two-shot kernels.
<sub>Comment <code>@argus review</code> to re-run, or <code>@argus re-review</code> after pushing.</sub>
Agreed, fixed in 6b2df196d8. All four now expect true, the AG and RS tests are renamed, and rccl-UnitTestsMicroDdaAllGatherFabricLl128, ...AllReduceFabricLl and ...ReduceScatterFabricLl128 pass.
Fixed in 6b2df196d8. New DdaAllGatherFabricLL128.GathersEveryRankAndSendsEveryPeerAtAnyOffset runs ddaAllGatherFabricLL128<int8_t, 4/8/0, true/false>, including the new local-copy branch, at offsets 0/1/4/8/12, in and out of place. DdaAllReduceFabricLL128PeerPar.WarpPerSliceKernelsMatchTheSumAtAnyOffset runs ddaAllReduceFlatLL128 and the cooperative ddaAllReduceTwoShotLL128 at offsets 0/1/4/8, using bf16 integers because those kernels do not fold in rank order. Both check the result, the guard bytes and the lines every peer unpacks.
Fixed in 6b2df196d8. Added RunLL128_AlignedKernelFrom16ByteOwnBuffersOnly for AR (flat one-shot, coop two-shot, NRANKS_CT 0), RunLL128_StagedWriterAlignedKernelFrom16ByteOwnBuffersOnly for the async wire, the PeerPar fixture variant, and Launch_AlignedKernelFrom16ByteOwnBuffersOnly for AG and RS (batched and PeerPar). Hardcoding aligned = true in any of these launchers now fails a test.
Applied, and the comment moved with the helper into CollCommon.h as ddaPickAligned. I kept the one-line notes at the eligibility checks so nobody re-adds the alignment check there, and at the launchers.
Addressed in 6b2df196d8. Also applied the low finding about the launchers picking kAligned three different ways: ddaPickAligned in CollCommon.h is now shared by the AR, AG and RS launchers. I added JIRA ID : AICOMRCCL-3999 to the description for the policy check. @argus re-review
<!-- argus:v1 pr=16629 sha=6b2df196d8fd mode=re-review -->
ARGUS
This PR changes 1,141 lines across 20 files. A change this size is hard to review
well, for a person and for this bot alike: reviewers lose the thread, defects hide in the
volume, and the feedback arrives too late to be cheap to act on. Splitting it into a
stacked pull request
gives each piece a reviewable diff and keeps the history. This review covers the whole change
regardless.
Impact
<details>
<summary>Reaches gfx1250; the PR targets gfx1250; 8 test(s) to run, 7 heatmap cell(s) to measure</summary>
Only gfx1250 is reached at runtime. The AllReduce, AllGather and ReduceScatter fabric DDA selectors all check IsArchMatch("gfx1250") (rccl_wrap.cc:2146, 2430, 2725); the kernels still compile for every target. On gfx1250, calls whose own sendbuff/recvbuff are not 16B aligned now take LL128 (AR one-shot/two-shot, PeerPar and capped one-warp; AG; RS batched and PeerPar) through the new kAligned=false instances. Before, they went to LL, VMM, CE-registered or Ring, or they hung when ranks were mixed. Aligned callers get the same template instances as before (kAligned defaults to true and the helpers' aligned branch is unchanged), so the only aligned-side change is library size, about +2.3%. Reaches gfx1250; the PR targets gfx1250.
Tests that exercise this change
rccl-UnitTestsFixturesDebug quick, DdaFabricEligibilityTest.: pins AR one-shot/two-shot and AG LL128 eligibility that no longer reads buffer addresses (projects/rccl/test/test_categories_fixtures_debug.yaml)rccl-UnitTestsFixturesDebug quick, DdaFabricLL128EligibilityTest.: AG and RS LL128 eligibility with misaligned buffers (projects/rccl/test/test_categories_fixtures_debug.yaml)test_categories_micro_dda.yaml quick, DdaAllReduce: host microtests for the AR launchers' aligned/any-address kernel pick (projects/rccl/test/test_categories_micro_dda.yaml)test_categories_micro_dda.yaml quick, DdaAllGather: AG LL128 launcher kernel-pointer and eligibility microtests (projects/rccl/test/test_categories_micro_dda.yaml)test_categories_micro_dda.yaml quick, DdaReduceScatter: RS LL128 batched/PeerPar launcher kernel-pointer and eligibility microtests (projects/rccl/test/test_categories_micro_dda.yaml)rccl-UnitTestsFixtures standard, DdaAllGatherFabricLL128.: new device test runs ddaAllGatherFabricLL128<4/8/0, true/false> at offsets 0/1/4/8/12 (projects/rccl/test/test_categories_fixtures.yaml)rccl-UnitTestsFixtures standard, DdaAllReduceFabricLL128PeerPar.: device tests for the misaligned PeerPar and warp-per-slice AR instances (projects/rccl/test/test_categories_fixtures.yaml)rccl-UnitTestsMPI standard_env_dda_fp8_ll128_twoshot, DdaFp8MPI_LL128TwoShot.: end-to-end LL128 two-shot AR, whose kernel pick now takes the aligned flag (projects/rccl/test/test_categories_mpi.yaml)Heatmap cells to measure, baseline against this PR, interleaved A/B
gfx1250 all_reduce any/sum, 2 node(s), 4 MiB to 128 MiB on mi4xx-rccl-scaleup-nightly-dpx (8 GPUs/node), mi4xx-rccl-scaleup-nightly-spx (4 GPUs/node): 8-rank (2-node SPX) misaligned buffers now run the NRANKS_CT=8 unaligned LL128 instances; the PR measured perf only at 4 and 16 ranksgfx1250 all_gather any, 2 node(s), 1 MiB to 256 MiB on mi4xx-rccl-scaleup-nightly-dpx (8 GPUs/node), mi4xx-rccl-scaleup-nightly-spx (4 GPUs/node): misaligned AG at 8 ranks now takes ddaAllGatherFabricLL128<T,8,false> instead of VMM or the kernel pathgfx1250 reduce_scatter any/sum, 2 node(s), 4 MiB to 256 MiB on mi4xx-rccl-scaleup-nightly-dpx (8 GPUs/node), mi4xx-rccl-scaleup-nightly-spx (4 GPUs/node): misaligned RS at 8 ranks now takes the unaligned batched/PeerPar LL128 instances, not measuredgfx1250 all_reduce float/sum, 4 node(s), 64 MiB to 256 MiB (not measured in the heatmap): top of the LL128 band, where the PR reports all-misaligned AR at 2.5-3.6% below the old fallbackgfx1250 reduce_scatter float/sum, 4 node(s), 64 MiB to 256 MiB (not measured in the heatmap): top of the LL128 band, where the PR reports all-misaligned RS at 2.5-3.6% below the old fallbackgfx1250 all_reduce any/sum, 1 node(s), 2 MiB to 4 MiB (not measured in the heatmap): registered eager re-route (rccl_wrap.cc:2167-2186): misaligned windows now land on the capped one-warp unaligned LL128 kernel instead of CE-registeredgfx1250 all_reduce float/sum, 2 node(s), 1 MiB to 32 MiB on mi4xx-rccl-scaleup-nightly-dpx (8 GPUs/node), mi4xx-rccl-scaleup-nightly-spx (4 GPUs/node): aligned control: same instances as before, so no change is expected; confirms nothing moved from the doubled instance count</details>
Bottom line: LGTM.
<sub>Comment <code>@argus review</code> to re-run, or <code>@argus re-review</code> after pushing.</sub>
Resolved by 6b2df196d8.
Resolved by a later commit.
Resolved by 6b2df196d8.
Resolved by 6b2df196d8.
<!-- markdownlint-disable MD013 -->
pr-rocm-systems-16629-oci-rccl-pr-smoke
Builds
All 15 components built.
Failures
No failing tests in this run.
12 tests skipped.
Performance regressions
Thresholds. A reading is marked regressed when its performance drops more than 5% and the change is significant. The run fails when a point drops more than 10% and an adjacent size does too. Performance is bandwidth, or the inverse of latency.
pr-16629_rccl-perf_rocm-10.2-latest vs rocm-10.2-latest_rccl-develop-perf
Readings: flat 2070.
Fails the run: 0 regressed point(s) past 10%, each confirmed by an adjacent size.
No confirmed regressions or improvements.
<!-- markdownlint-disable MD013 -->
pr-rocm-systems-16629-ruby64-rccl-pr-smoke
Builds
All 15 components built.
Failures
No failing tests in this run.
12 tests skipped.
Performance regressions
Thresholds. A reading is marked regressed when its performance drops more than 5% and the change is significant. The run fails when a point drops more than 8% and an adjacent size does too. Performance is bandwidth, or the inverse of latency.
pr-16629_rccl-perf_rocm-10.2-latest vs rocm-10.2-latest_rccl-develop-perf
Readings: flat 2070.
Fails the run: 0 regressed point(s) past 8%, each confirmed by an adjacent size.
No confirmed regressions or improvements.
High level comment here. If we are supporting misaligned buffers, why not just assume that buffers are misaligned? From your results, it didn't look like there was much a difference in performance from the aligned and misaligned code paths. Let me know if I am missing something here. If the slow path is decently fast, then converging to that path is one less thing we have to maintain.
More generally, I was unaware that we wanted DDA to support pointers that are not aligned to 16 bytes. If we expanding the scope, can you let me know? If so, we need to make sure it works on all of the DDA code paths.
You need to be a little bit careful here. For local copies it's fine not to make them device scope if it's a one-time write and the data won't be read by any other WGP. The end of kernel flush should write them to right scope. However, if there's any reuse of this data by any other WGP or even the same WGP in some cases, then you need to be careful here.
Nit: Consider whether these functions are required to maintain these unused args, or whether they could just be removed.
Consider kOffsetRoomBytes
This change makes sense but might warrant a comment.
Just double-checking the use of expectRankOrderFold here. I think this is fine because it is Sum with integer type, but it is misleading.
Nit: consider kOffsetRoomBytes
LGTM from code stand-point, all notes are nits.
High level comment here. If we are supporting misaligned buffers, why not just assume that buffers are misaligned? From your results, it didn't look like there was much a difference in performance from the aligned and misaligned code paths. Let me know if I am missing something here. If the slow path is decently fast, then converging to that path is one less thing we have to maintain.
> More generally, I was unaware that we wanted DDA to support pointers that are not aligned to 16 bytes. If we expanding the scope, can you let me know? If so, we need to make sure it works on all of the DDA code paths.
I was wondering this as well, what is the origin of this requirement?
This does match the existing code path, however. For this review, I'm less concerned, but should watch out for how this would manifest.
corey-derochie-amd
PedramAlizadeh
Motivation
On gfx1250, the DDA fabric LL128 tiers for AllReduce (one-shot and two-shot), AllGather and ReduceScatter were eligible only when the calling rank's own
sendbuffandrecvbuffwere 16-byte aligned. Alignment is a property of each rank's buffers, not of the call, so when some ranks passed misaligned buffers and others did not, the ranks chose different algorithms and every rank hung. For example, with 16 ranks, an fp32 AllReduce of 32 MiB and rank 0's buffers offset by 4 bytes, ranks 1-15 logtaking DDA fabric LL128 two-shot pathwhile rank 0 takes another path. Broadcast was not affected: its LL128 eligibility uses only the byte count, and each rank picks an aligned or any-address kernel for its own buffers. This PR applies the same approach to the other three collectives. As a result, misaligned buffers are no longer limited to the slower fallback paths: they run LL128 too, with no extra memory.Technical Details
The LL128 wire is always aligned peer scratch; only the local loads from
sendbuffand the stores torecvbuffsee the caller's alignment.ddaLL128ArOneShotEligibleCapped,ddaLL128ArTwoShotEligible(dda_all_reduce_fabric_ll.cu),ncclAllGatherDdaFabricLL128EligibleandncclReduceScatterDdaFabricLL128Eligibleno longer check buffer addresses, so eligibility depends only on the message (count, datatype, op, comm) and every rank reaches the same tier. The LL128 kernels (ddaAllReduceFlatLL128,ddaAllReduceFlatLL128PeerPar,ddaAllReduceTwoShotLL128with both wires,ddaAllReduceTwoShotLL128PeerPar,ddaAllGatherFabricLL128,ddaReduceScatterFabricLL128andddaReduceScatterFabricLL128PeerPar) take abool kAligned = truetemplate parameter. They forward it to the existingddaLL128LoadRegs/ddaLL128StoreRegshelpers, which, withkAligned=false, use the memcpy-basedddaLL128UserLoad16B/Store16B<false>accessors that the Broadcast one-shot already uses. The AllGather local copy gets the same treatment. Each launcher computesddaUserBuffers16ByteAligned(sendbuff, recvbuff)and picks the instance through a sharedddaPickAlignedhelper inCollCommon.h. Aligned ranks run exactly the instances they ran before, and both instances use the same wire format, so a mix of aligned and misaligned ranks works together. TheINFOlaunch lines now printaligned=. On gfx1250 a 16-byte memcpy at align 1 compiles to the sameglobal_load_b128/global_store_b128, so the any-address instance needs no peeling or staging buffer. The extra instances growlibrccl.soby about 1.16 MB (+2.3%).The single-node IPC (non-gfx1250) DDA AllReduce, AllGather, ReduceScatter and AllToAll eligibility checks also use
ddaUserBuffers16ByteAlignedand have the same mixed-alignment exposure; they need separate hardware to validate and are not changed here.Issue Tracking
JIRA ID: AICOMRCCL-3999
Test Plan
test/host/algorithms/dda):- The AG, RS and AR one-shot/two-shot LL128 eligibility tests now expect misaligned buffers to stay eligible.
- New kernel-pointer tests check that every LL128 launcher picks the aligned or any-address instance from its own buffers: AR flat, AR two-shot with the coop and async wires, AR PeerPar one-shot and two-shot, AG, and RS batched and PeerPar.
- The AR PeerPar one-shot and two-shot kernels.
- The one-warp-per-slice AR one-shot and two-shot kernels.
- The RS PeerPar kernel.
- A new
DdaAllGatherFabricLL128test.DdaFabricEligibilityTests.cpp, Debug): misaligned buffers stay eligible for AG, AR one-shot, AR two-shot and RS.developagainst this PR, 25 cases:- A rank misaligned by 1, 2 or 4 bytes: rank 0 or rank 5, send-only, recv-only or both, in place and out of place.
- fp32, bf16 and fp8.
- AR 4M-128M, AG 1M-256M, RS 4M-256M, and Broadcast and the LL-tier AR as controls.
- The test fills exact small integers and checks every output element and the bytes just outside the output.
- All aligned.
- One rank misaligned.
- Half the ranks misaligned.
- Every rank at a different offset, with send and recv offsets differing.
- All ranks misaligned.
- Also bf16, fp8 and in-place runs with the varied offsets.
all_reduce_perf,all_gather_perfandreduce_scatter_perfat 16 ranks:- 1M-32M: 200 iterations, 3 repetitions, rotating which build runs first.
- 64K-256M: 2 repetitions.
Test Results
- All DDA host microtests pass.
- All 41 DDA LL128 device tests pass.
- All 228
DdaFabric/DdaIpcEligibility*fixture tests pass.develophangs in all 16 mixed-alignment AR, AG and RS cases. With this PR all 25 cases complete with 0 wrong values, and every rank logs the same LL128 path.develophangs on every mixed pattern on 1 node too (AR at 4M, AG at 1M, RS at 4M). With this PR every pattern gives 0 wrong values. In the LL128 band each pattern is within 2-4% ofdevelop's aligned bandwidth, mostly within 1%.develop.developthrough the fallback): up to 4.9x faster at 16 ranks. At 256M, the top of the band, AR and RS are 2.5-3.6% below the fallback.Summary (algbw vs
developwith aligned buffers, LL128 band, 1 node, 4 ranks)| | develop, all misaligned | one misaligned | half misaligned | every rank a different offset | all misaligned |
|---|---|---|---|---|---|
| AllReduce 4M-64M | 0.48-0.86x | 1.00x (develop hangs) | 1.00x (develop hangs) | 0.98-1.00x (develop hangs) | 0.98-1.00x |
| AllGather 1M-64M | 0.22-0.54x | 0.98-1.00x (develop hangs) | 0.97-1.00x (develop hangs) | 0.98-1.00x (develop hangs) | 0.98-1.00x |
| ReduceScatter 4M-64M | 0.36-0.83x | 0.98-1.00x (develop hangs) | 0.99-1.04x (develop hangs) | 0.97-1.00x (develop hangs) | 0.96-1.02x |