Repository navigation
feat(rccl): Scaleup Allreduce using GIN/LSA #10783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
52419aa
add GIN LSA-SDMA Allreduce
nusislam 2cdfde2
build fix
nusislam 69dffcf
graph capture fix
nusislam 2db6721
fix for bf16
nusislam 51fc9ec
add an environment variable for GIN AR
nusislam 7e18e37
Complete merge conflict resolution
Copilot 910b78e
add tests for gin allreduce
nusislam bd1a273
update CMakeList for tests
nusislam 685a01f
Remove accidental module cache lock
Copilot 4288a2e
address review comments
nusislam 5a5b4f7
build fix
nusislam b4858c9
add intra-gpu CTA barrier for gin AR kernel
nusislam 186ecad
address reviews
nusislam 506b3e4
remove unused env variable
nusislam ef0f3d9
Merge branch 'develop' into users/nusislam/gin-ar-pr
nusislam 3e1d90a
Update projects/rccl/src/algorithms/gin/sdma/all_reduce_gin_sdma.h
nusislam c342284
Update projects/rccl/src/algorithms/gin/sdma/gin_all_reduce_sdma.cu
nusislam 21fec7e
address reviews
nusislam 42ea7b1
cleanup
nusislam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /************************************************************************* | ||
|
nusislam marked this conversation as resolved.
Resolved
|
||
| * Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. | ||
| * | ||
| * Host entry points for the GIN-SDMA AllReduce path selected by rcclSelectAllReduce | ||
| * when symmetric windows are used. By default only messages >= 256 MiB | ||
| * (GIN two-shot) take this path; smaller messages use DDA AllReduce. | ||
| * RCCL_GIN_ALLREDUCE_FORCE_ENABLE=1 also enables LSA one-shot (<= 4 MiB) and | ||
| * LSA two-shot ((4 MiB, 256 MiB)). | ||
| * See LICENSE.txt for license information. | ||
| ******************************************************************************/ | ||
|
|
||
| #ifndef GIN_ALL_REDUCE_H_ | ||
| #define GIN_ALL_REDUCE_H_ | ||
|
|
||
| #include "gin_all_reduce_policy.h" | ||
| #include "nccl.h" | ||
| #include "nccl_device.h" | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| struct ncclComm; | ||
|
|
||
| // Size and CTA constants live in gin_all_reduce_policy.h so host unit tests and | ||
| // ncclAllReduceGinSdmaEligible() share one definition. | ||
| // LSA one-shot for messages <= kGinAllReduceLsaOneShotMaxBytes (force-enable only). | ||
| // LSA two-shot for (4 MiB, 256 MiB) (force-enable only). | ||
| // GIN two-shot for messages >= kGinAllReduceGinTwoShotMinBytes (default path). | ||
|
|
||
| // Lazily created on the first eligible AllReduce and torn down with the comm. | ||
| // Declared unconditionally: ncclComm embeds this even when ENABLE_ROCSHMEM_GIN is off. | ||
| // | ||
| // Deliberately holds no per-launch host epoch. All cross-rank synchronization lives on the | ||
| // device (LSA barrier epochs in the resource window, GIN signals and their shadows) and is | ||
| // re-read by the kernel on every launch, which is what lets these collectives be captured | ||
| // into a graph and replayed: a host-side counter baked into a kernel argument at capture time | ||
| // would freeze at its captured value while the device counters kept advancing. | ||
| // intraGpuCtaBar is two device uint32s (arrived, sense) for the GIN two-shot intra-GPU | ||
| // CTA barrier; the pointer is stable, the words themselves advance on the device. | ||
| struct ncclGinAllReduceState { | ||
| bool initialized; | ||
| struct ncclDevComm devComm; | ||
| uint32_t* intraGpuCtaBar; | ||
| }; | ||
|
|
||
| #if defined(ENABLE_ROCSHMEM_GIN) | ||
|
|
||
| // RCCL_GIN_ALLREDUCE_FORCE_ENABLE. Defined in gin_all_reduce_sdma.cu. | ||
| int64_t rcclParamGinAllReduceForceEnable(); | ||
|
|
||
| bool ncclAllReduceGinSdmaEligible(ncclComm* comm, const void* sendbuff, void* recvbuff, size_t count, | ||
| ncclDataType_t datatype, ncclRedOp_t op); | ||
|
|
||
| // True when this AllReduce is a GIN-SDMA candidate that the default size policy | ||
| // left for DDA (message < 256 MiB and RCCL_GIN_ALLREDUCE_FORCE_ENABLE is not 1). | ||
| bool ncclAllReduceGinSdmaYieldToDda(ncclComm* comm, const void* sendbuff, void* recvbuff, size_t count, | ||
| ncclDataType_t datatype, ncclRedOp_t op); | ||
|
|
||
| ncclResult_t ncclAllReduceGinSdma(const void* sendbuff, void* recvbuff, size_t count, ncclDataType_t datatype, | ||
| ncclRedOp_t op, ncclComm* comm, cudaStream_t stream); | ||
|
|
||
| ncclResult_t ncclGinAllReduceFinalize(ncclComm* comm); | ||
|
|
||
| #else | ||
|
|
||
| inline ncclResult_t ncclGinAllReduceFinalize(ncclComm*) { return ncclSuccess; } | ||
|
|
||
| #endif | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /************************************************************************* | ||
| * Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. | ||
| * | ||
| * Size and alignment policy for GIN-SDMA AllReduce. Pure host header included by | ||
| * gin_all_reduce.h so unit tests exercise the same gates | ||
| * ncclAllReduceGinSdmaEligible() uses after the comm / buffer / gfx950 checks pass. | ||
| * See LICENSE.txt for license information. | ||
| ******************************************************************************/ | ||
|
|
||
| #ifndef GIN_ALL_REDUCE_POLICY_H_ | ||
| #define GIN_ALL_REDUCE_POLICY_H_ | ||
|
|
||
| #include <cstddef> | ||
|
|
||
| constexpr int kGinAllReduceLsaCtas = 56; | ||
| constexpr int kGinAllReduceLsaTwoShotCtasPerPeer = 8; | ||
| constexpr int kGinAllReduceLsaTwoShotMaxCtas = kGinAllReduceLsaTwoShotCtasPerPeer * 16; | ||
| constexpr int kGinAllReduceMaxRanks = 8; | ||
|
|
||
| constexpr int kGinAllReduceMinBytes = 512ULL * 1024; | ||
| constexpr int kGinAllReduceLsaThreadsPerCta = 512; | ||
| constexpr size_t kGinAllReduceLsaOneShotMaxBytes = 4ULL * 1024 * 1024; | ||
| constexpr size_t kGinAllReduceLsaTwoShotMidBytes = 32ULL * 1024 * 1024; | ||
|
nusislam marked this conversation as resolved.
Resolved
|
||
| constexpr size_t kGinAllReduceGinTwoShotMinBytes = 256ULL * 1024 * 1024; | ||
|
|
||
| constexpr size_t kGinAllReduceMinPutBytes = 128; | ||
|
|
||
| // Two-shot kernels require a whole number of elements per rank and a 16-byte | ||
| // per-rank slice so vector loads stay aligned. | ||
| inline bool ginAllReduceTwoShotEligible(size_t count, size_t typeSize, int nRanks) { | ||
| if (nRanks <= 0 || typeSize == 0) return false; | ||
| if (count % static_cast<size_t>(nRanks) != 0) return false; | ||
| const size_t countPerRank = count / static_cast<size_t>(nRanks); | ||
| return (countPerRank * typeSize) % 16 == 0; | ||
| } | ||
|
|
||
| inline bool ginAllReduceGinTwoShotEligible(size_t count, size_t typeSize, int nRanks) { | ||
| if (!ginAllReduceTwoShotEligible(count, typeSize, nRanks)) return false; | ||
| const size_t chunkBytes = (count / static_cast<size_t>(nRanks)) * typeSize; | ||
| return chunkBytes >= kGinAllReduceMinPutBytes; | ||
| } | ||
|
|
||
| // Size-only GIN AllReduce policy. forceEnable is RCCL_GIN_ALLREDUCE_FORCE_ENABLE==1. | ||
| // Default: true only for messages >= 256 MiB that pass GIN two-shot alignment. | ||
| // Force: LSA one-shot <= 4 MiB (and >= 512 KiB), LSA two-shot in between, GIN two-shot at 256 MiB+. | ||
| inline bool ginAllReduceSizePolicyEligible(size_t count, size_t typeSize, int nRanks, bool forceEnable) { | ||
| const size_t bytes = count * typeSize; | ||
| if (bytes < kGinAllReduceGinTwoShotMinBytes && !forceEnable) return false; | ||
| if (bytes < static_cast<size_t>(kGinAllReduceMinBytes)) return false; | ||
| // Inclusive 4 MiB: one-shot has no per-rank alignment requirement. Two-shot | ||
| // starts strictly above this, matching ncclAllReduceGinSdmaTyped(). | ||
| if (bytes <= kGinAllReduceLsaOneShotMaxBytes) return true; | ||
| if (bytes >= kGinAllReduceGinTwoShotMinBytes) { | ||
| return ginAllReduceGinTwoShotEligible(count, typeSize, nRanks); | ||
| } | ||
| return ginAllReduceTwoShotEligible(count, typeSize, nRanks); | ||
| } | ||
|
|
||
| // Smaller-than-256 MiB GIN candidates yield to DDA unless FORCE_ENABLE=1. | ||
| inline bool ginAllReduceYieldToDdaBySize(size_t count, size_t typeSize, bool forceEnable) { | ||
| if (forceEnable) return false; | ||
| return count * typeSize < kGinAllReduceGinTwoShotMinBytes; | ||
| } | ||
|
|
||
| #endif | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.