Skip to content

feat(ccl): support NCCL/MCCL Broadcast with a carrier-aware dispatch policy - #94

Merged
Ziminli merged 2 commits into
masterfrom
feat/support-ccl-broadcast
Nov 24, 2026
Merged

Ziminli merged 2 commits into
masterfrom
feat/support-ccl-broadcast

Conversation

@Ziminli

@Ziminli Ziminli commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add the CCL Broadcast support for the NCCL and MCCL backends, along with a dispatch-policy mechanism to preserve hybrid communicator behavior.

Broadcast already 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

    • Add src/dispatch_policy.h declaring the Policy enum (kStatic default, kCarrierAware for dual-implementation collectives, AND kRole and kFanOut reserved) and the DispatchPolicy<Key> trait, defaulted to kStatic.
    • Add a protected RedirectToCarrier member template to Operation<Key> in src/operation.h: the policy gate, the winner check, the carried-check, and the one-hop carrier re-dispatch are all dependent on Key, so they instantiate only at real call sites where every BackendEnabled specialization is visible.
    • Only the static priority winner may redirect, and only when it is carried by neither communicator slot; the redirected call lands directly in the carrier's Execute, so there is no recursion. Runtime cost is two communicator-slot reads plus a few enum compares per call.
  • CCL Broadcast and Bcast

    • Add src/backends/ccl/common/impl/broadcast.h: CclBroadcastImpl issues the native call on the intra communicator after the established validation ladder.
    • Register NCCL/MCCL implementations and BackendEnabled markers for both Broadcast and Bcast, with automatic C-ABI bridge generation.
    • Add NCCL/MCCL API wrappers without configure-time capability probes, as broadcast is supported by all relevant SDKs.
    • Enable kCarrierAware dispatch for Broadcast, preserving MPI-only and hybrid bootstrap behavior while using native CCL broadcasts whenever available.
  • Examples

    • Add examples/ccl/broadcast.cc (thread-per-GPU) and examples/ccl_mpi_hybrid/broadcast.cc mirroring examples/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

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU
  • T-Head PPU
  • Ascend NPU

Backend

  • OpenMPI
  • MPICH
  • NCCL/RCCL
  • MCCL
  • CNCL
  • HCCL

Performance Impact

  • No performance impact
  • Performance improved
  • Performance regression possible

Hybrid data-plane broadcasts no longer round-trip through MPI_Bcast host 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

  • kRole and kFanOut are declared but unconsumed. They are reserved for the lifecycle APIs (CommInitAll/CommInitRank dual-implementation selection and CommDestroy fan-out) planned as future works;
  • Dual-implementation collectives other than Broadcast deliberately stay on kStatic. Opting an operation in is mechanical (one specialization plus one helper call) once agreed.

Test Results

Test Involved Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU
  • T-Head PPU
  • Ascend NPU

Test Involved Backend

  • OpenMPI
  • MPICH
  • NCCL/RCCL
  • MCCL
  • CNCL
  • HCCL

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

Every contributor must verify every item below before requesting
review. Tick each box only after the check has actually been performed —
do not tick speculatively. If an item truly does not apply, replace the
checkbox with N/A and briefly explain why in an inline comment.

Title, Branch, and Commits

  • PR title follows Conventional Commits (e.g. feat: …, fix(nccl): …).
  • Branch name follows <type>/xxx-yyyy-zzzz where <type> matches the PR title's Conventional Commits type and words are joined with hyphens (see CONTRIBUTING.md §Branches).
  • Each commit message follows Conventional Commits.
  • Small PR is a single squashable commit; or, for a large PR, every commit is meaningful, well-formed, and independently reviewable (see CONTRIBUTING.md §Pull Requests).
  • No stray merge commits from master — the branch is rebased cleanly on top of the current master.
  • No fixup! / squash! / wip commits remain.

Scope and Design

  • Changes are minimal — no unrelated modifications were introduced (CONTRIBUTING.md §Code/General).
  • No dead code, commented-out blocks, debug prints, printf/std::cout/print(...) left behind, or TODO without an owner and issue link.
  • No unrelated formatting churn that would obscure the diff.
  • N/A- Public API changes (if any) are intentional, documented, and reflected in affected callers/tests.

General Code Hygiene

  • The code is self-explanatory; comments were added only where the intent or rationale is non-obvious (CONTRIBUTING.md §Code/General).
  • Every modified or added file ends with a single trailing newline (CONTRIBUTING.md §Code/General).
  • No trailing whitespace, inconsistent indentation, or mixed formatting styles remain.
  • Identifiers referenced in comments or error messages are wrapped in Markdown backticks (e.g. the `AllReduce` implementation) (CONTRIBUTING.md §Code/General).
  • All comments and error messages are in English (CONTRIBUTING.md §Code/General).
  • Comments and error messages are complete sentences — capitalized first letter, terminal punctuation — unless the language/framework convention says otherwise (CONTRIBUTING.md §Code/General; §Python).

C++ Specific (if C++ files changed)

  • Code follows the Google C++ Style Guide strictly.
  • clang-format (version 16, per .github/workflows/clang-format.yml) has been run against all modified applicable files; the diff is clean.
  • No exceptions are thrown. Error paths use assert with messages that include at least __FILE__, __LINE__, and __func__ (CONTRIBUTING.md §C++).
  • Error and warning message wording follows the LLVM Coding Standards (CONTRIBUTING.md §C++).
  • Constructor initializer list order matches member declaration order (CONTRIBUTING.md §C++).
  • Exactly one blank line between classes, between classes and functions, and between functions (CONTRIBUTING.md §C++).
  • Exactly one blank line between members (functions and variables) within a class (CONTRIBUTING.md §C++).
  • Exactly one blank line before and after the contents of a namespace (CONTRIBUTING.md §C++).

Python Specific (if Python files changed)

  • N/A. No Python files were changed.

Testing

  • All applicable example programs have been built and tested successfully on at least one supported heterogeneous cluster setup.

Build, CI, and Tooling

  • N/A- New backends or devices have been added to auto-detection in CMakeLists.txt under if(AUTO_DETECT_DEVICES) or to if(AUTO_DETECT_BACKENDS) if applicable.
  • Both CI workflows (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.
  • N/A- Any user-visible breaking change is called out explicitly under "Summary" and in the commit/PR title with a ! or BREAKING CHANGE: footer.

Security and Safety

  • No secrets, access tokens, internal URLs, customer data, or personal hardware identifiers have been committed.
  • N/A- Third-party code is license-compatible and attributed.
  • No unsafe pointer arithmetic, uninitialized reads, or missing bounds checks were introduced.

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.
@Ziminli Ziminli self-assigned this Nov 24, 2026
@Ziminli
Ziminli merged commit eed517b into master Nov 24, 2026
2 checks passed
@Ziminli
Ziminli deleted the feat/support-ccl-broadcast branch November 24, 2026 08:42
@Ziminli Ziminli mentioned this pull request Nov 24, 2026
41 of 52 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant