Skip to content

feat: support CCL Send and Recv - #60

Open
GordonYang1 wants to merge 1 commit into
InfiniTensor:masterfrom
GordonYang1:feat/support-ccl-send-recv
Open

feat: support CCL Send and Recv#60
GordonYang1 wants to merge 1 commit into
InfiniTensor:masterfrom
GordonYang1:feat/support-ccl-send-recv

Conversation

@GordonYang1

Copy link
Copy Markdown
Collaborator

Summary

This PR adds Send and Recv support to the shared CCL backend abstraction, including native bindings through the existing NCCL and MCCL provider layers for the public infinicclSend() and infinicclRecv() APIs. It also teaches Send and Recv dispatch to follow the backend/device combination stored in the communicator for mixed-backend flows, adds generated-bridge dependency tracking for header-only operation implementations, and includes CCL-only plus OpenMPI-assisted Send/Recv example programs covering native point-to-point flows.

Changes

  • Public API and Dispatch

    • Enable the existing infinicclSend() and infinicclRecv() APIs for configured CCL backends through generated bridge dispatch.
    • Redispatch Send and Recv according to the initialized backend and device stored in the supplied communicator.
    • Keep MPI-only communicators on their initialized MPI backend while selecting the native CCL backend after rank-based communicator initialization.
  • Common CCL Implementation

    • Add shared CCL Send and Recv implementations following the existing provider-oriented AllReduce structure.
    • Validate the CCL communicator instance and map InfiniCCL data types through the configured provider before dispatch.
    • Return NotSupported when the selected provider cannot represent the requested data type.
  • Existing CCL Provider Bindings

    • Extend the existing NCCL and MCCL API wrappers with thin bindings to ncclSend(), ncclRecv(), mcclSend(), and mcclRecv().
    • Register Send and Recv with the existing NCCL and MCCL provider layers.
  • Bridge Generation

    • Track base, backend, and device headers as generated bridge dependencies.
    • Regenerate the bridge when a header-only operation implementation is added, removed, or changed.
    • Add a contract test for the bridge dependency manifest and custom-command inputs.
  • Examples and Validation

    • Add a thread-per-GPU single-node CCL Send/Recv example using one shared unique ID.
    • Add an OpenMPI-assisted CCL Send/Recv example that uses OpenMPI for rank discovery and unique-ID broadcast, then initializes a native CCL communicator for GPU point-to-point communication.
    • Validate a matched one-way transfer from rank 0 to rank 1 and propagate validation failures through the process exit status.
    • Add backend-selection tests covering supported-provider lookup, OpenMPI inter_comm provider fallback, and unsupported communicator combinations.

Platform and Backend Affected

Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU

Backend

  • OpenMPI
  • MPICH
  • NCCL
  • MCCL

Performance Impact

  • No performance impact
  • Performance improved
  • Performance regression possible

This adds GPU-native CCL paths for Send and Recv, avoiding the existing MPI host-staging paths when a supported CCL backend is selected. Existing MPI point-to-point operations are intended to remain unchanged.

Known Issues & Future Work

  • CCL operation support now covers AllReduce, Send, and Recv; other CCL operations remain future work.
  • Send and Recv inherit the backend/device combinations and data type support of the existing CCL providers; this PR does not add a new provider or device integration.
  • The CCL examples validate one matched, one-way float32 transfer from rank 0 to rank 1 on the default stream. Multi-peer, bidirectional, grouped, additional-data-type, and non-default-stream coverage remain future work. The heterogeneous MPI Send/Recv regression also transfers between ranks 0 and 1 on the NVIDIA node, so it is not a cross-vendor point-to-point test.
  • The shared example Metrics helper applies the AllReduce bus-bandwidth factor to point-to-point communication, so the Bus BW printed by the CCL Send/Recv examples is not used as a performance result. Correctness validation and elapsed time are unaffected.

Test Results

Test Involved Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU

Test Involved Backend

  • OpenMPI
  • MPICH
  • NCCL
  • MCCL

Pure CCL (NCCL) on single-node NVIDIA:
ccl_all_reduce.log
ccl_send_recv.log

CCL + MPI on single-node NVIDIA:
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_send_recv.log

MPI on Heterogeneous Cluster:
mpi_all_gather.log
mpi_all_reduce.log
mpi_all_to_all.log
mpi_broadcast.log
mpi_gather.log
mpi_reduce.log
mpi_reduce_scatter.log
mpi_scatter.log
mpi_send_recv.log

Pure CCL (MCCL) on single-node MetaX:
ccl_all_reduce.log
ccl_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.
  • 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++).
  • N/A- 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)

  • Code is PEP 8 compliant; ruff check passes cleanly on CI (see `.github/workflows/ruff.yml).
  • ruff format --check passes cleanly — if not, run ruff format and commit the result.
  • N/A- Comments are complete English sentences, starting with a capital letter and ending with punctuation; Markdown backticks are used for code references (CONTRIBUTING.md §Python).
  • N/A- Framework-specific conventions (e.g. lowercase pytest.skip messages without terminal period) are honored where applicable (CONTRIBUTING.md §Python).
  • No blank line between the function signature and the body when there is no docstring or comment (CONTRIBUTING.md §Python).
  • A blank line is present before and after if, for, and similar control-flow statements (CONTRIBUTING.md §Python).
  • N/A- A blank line appears before each return, except when it directly follows a control-flow statement (CONTRIBUTING.md §Python).
  • N/A- Docstrings (if any) follow PEP 257 (CONTRIBUTING.md §Python).
  • Type hints are added / kept consistent with the surrounding code.

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

  • N/A- 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.

@GordonYang1
GordonYang1 force-pushed the feat/support-ccl-send-recv branch from 9c73657 to cd0a469 Compare August 14, 2026 04:48
@GordonYang1
GordonYang1 force-pushed the feat/support-ccl-send-recv branch from cd0a469 to 64f4e04 Compare August 14, 2026 07:14
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