Repository navigation
feat(ccl): support NCCL/MCCL Broadcast with a carrier-aware dispatch policy - #94
Merged
Merged
Conversation
Add the `DispatchPolicy` trait and `Policy` enum in `src/dispatch_policy.h`. The default `kStatic` keeps static priority selection for every existing operation, so behavior is unchanged. `kCarrierAware` operations follow an enabled backend carried by the communicator when the highest-priority backend is attached to neither slot; `kRole` and `kFanOut` are declared but reserved for lifecycle APIs. The check and the one-hop re-dispatch live in `Operation<Key>::RedirectToCarrier` and only run for opted-in operations.
Add NCCL and MCCL implementations for `Broadcast` and `Bcast`, with examples.
41 of 52 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add the CCL
Broadcastsupport for the NCCL and MCCL backends, along with a dispatch-policy mechanism to preserve hybrid communicator behavior.Broadcastalready had a base definition and an OpenMPI implementation, but no CCL backend. Since CCL backends have higher static priority than OpenMPI, naively enabling CCL would route UniqueId exchanges on MPI-only communicators to unsupported CCL implementations.This PR introduces Policy/DispatchPolicy and RedirectToCarrier to allow kCarrierAware operations to follow the backend actually carried by the communicator. Broadcast opts in: MPI-only and hybrid bootstrap communications use OpenMPI, while CCL and hybrid data broadcasts use native NCCL/MCCL implementations. All other operations retain their existing behavior through the default kStatic policy.
Changes
Dispatch Policy Mechanism
src/dispatch_policy.hdeclaring thePolicyenum (kStaticdefault,kCarrierAwarefor dual-implementation collectives, ANDkRoleandkFanOutreserved) and theDispatchPolicy<Key>trait, defaulted tokStatic.RedirectToCarriermember template toOperation<Key>insrc/operation.h: the policy gate, the winner check, the carried-check, and the one-hop carrier re-dispatch are all dependent onKey, so they instantiate only at real call sites where everyBackendEnabledspecialization is visible.Execute, so there is no recursion. Runtime cost is two communicator-slot reads plus a few enum compares per call.CCL
BroadcastandBcastsrc/backends/ccl/common/impl/broadcast.h:CclBroadcastImplissues the native call on the intra communicator after the established validation ladder.BackendEnabledmarkers for bothBroadcastandBcast, with automatic C-ABI bridge generation.kCarrierAwaredispatch forBroadcast, preserving MPI-only and hybrid bootstrap behavior while using native CCL broadcasts whenever available.Examples
examples/ccl/broadcast.cc(thread-per-GPU) andexamples/ccl_mpi_hybrid/broadcast.ccmirroringexamples/mpi/broadcast.cc: out-of-place, in-place, and legacy in-place (infinicclBcast) scenarios with warm-up, profiled iteration, and validation for each.Platform and Backend Affected
Platform
Backend
Performance Impact
Hybrid data-plane broadcasts no longer round-trip through
MPI_Bcasthost staging: a communicator carrying NCCL now broadcasts on-device with the native call. The policy check itself costs two pointer loads and a few enum compares (well under 1 ns, negligible next to a microsecond-scale collective), and non-opted operations compile the helper body away entirely.Known Issues & Future Work
kRoleandkFanOutare declared but unconsumed. They are reserved for the lifecycle APIs (CommInitAll/CommInitRankdual-implementation selection andCommDestroyfan-out) planned as future works;Broadcastdeliberately stay onkStatic. Opting an operation in is mechanical (one specialization plus one helper call) once agreed.Test Results
Test Involved Platform
Test Involved Backend
NVIDIA (NCCL+OMPI):
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_all_to_all.log
ccl_mpi_hybrid_broadcast.log
ccl_mpi_hybrid_gather.log
ccl_mpi_hybrid_reduce.log
ccl_mpi_hybrid_scatter.log
ccl_mpi_hybrid_send_recv.log
MetaX (MCCL+OMPI):
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_all_to_all.log
ccl_mpi_hybrid_broadcast.log
ccl_mpi_hybrid_gather.log
ccl_mpi_hybrid_reduce.log
ccl_mpi_hybrid_scatter.log
ccl_mpi_hybrid_send_recv.log
Moore Threads (MCCL+OMPI):
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_all_to_all.log
ccl_mpi_hybrid_broadcast.log
ccl_mpi_hybrid_gather.log
ccl_mpi_hybrid_reduce.log
ccl_mpi_hybrid_scatter.log
ccl_mpi_hybrid_send_recv.log
HYGON (RCCL+OMPI):
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_all_to_all.log
ccl_mpi_hybrid_broadcast.log
ccl_mpi_hybrid_gather.log
ccl_mpi_hybrid_reduce.log
ccl_mpi_hybrid_scatter.log
ccl_mpi_hybrid_send_recv.log
Checklist
Title, Branch, and Commits
feat: …,fix(nccl): …).<type>/xxx-yyyy-zzzzwhere<type>matches the PR title's Conventional Commits type and words are joined with hyphens (seeCONTRIBUTING.md§Branches).CONTRIBUTING.md§Pull Requests).master— the branch is rebased cleanly on top of the currentmaster.fixup!/squash!/wipcommits remain.Scope and Design
CONTRIBUTING.md§Code/General).printf/std::cout/print(...)left behind, orTODOwithout an owner and issue link.General Code Hygiene
CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).the `AllReduce` implementation) (CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General; §Python).C++ Specific (if C++ files changed)
clang-format(version 16, per.github/workflows/clang-format.yml) has been run against all modified applicable files; the diff is clean.assertwith messages that include at least__FILE__,__LINE__, and__func__(CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).Python Specific (if Python files changed)
Testing
Build, CI, and Tooling
CMakeLists.txtunderif(AUTO_DETECT_DEVICES)or toif(AUTO_DETECT_BACKENDS)if applicable.clang-format.yml,ruff.yml) are green locally (or expected to be green on CI).Documentation
README.md,CONTRIBUTING.md, or inline docs updated when behavior, build flags, or developer workflow changed.!orBREAKING CHANGE:footer.Security and Safety