Skip to content

feat: support CCL AllGather - #61

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

feat: support CCL AllGather#61
GordonYang1 wants to merge 1 commit into
InfiniTensor:masterfrom
GordonYang1:feat/support-ccl-all-gather

Conversation

@GordonYang1

@GordonYang1 GordonYang1 commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds AllGather support to the shared CCL backend abstraction, including native bindings through the existing NCCL and MCCL provider layers for the public infinicclAllGather() API. It also keeps inter-only communicators on the existing OpenMPI staging path during mixed-backend bootstrap flows, corrects the shared OpenMPI/MPICH AllGather staging path to use byte counts for all data types, makes the existing MPI example propagate per-block validation failures, and includes CCL-only plus OpenMPI-assisted AllGather example programs covering out-of-place and canonical in-place flows with correctness and communication-bandwidth reporting.

Changes

  • Public API and Dispatch

    • Enable the existing infinicclAllGather() API for configured CCL backends through generated bridge dispatch without changing its public signature.
    • Use a matching native CCL intra communicator when available, and otherwise delegate to the existing OpenMPI provider when the communicator has only an OpenMPI inter communicator.
    • Return success for a zero-count AllGather after validating the communicator and data type, without requiring non-null buffers or entering a backend.
  • Common CCL Implementation

    • Add a shared provider-oriented CCL AllGather implementation following the existing AllReduce structure.
    • Validate the native communicator backend, device, and handle before dispatch.
    • Map InfiniCCL data types through the configured provider and return NotSupported when the provider cannot represent the requested type.
  • Existing CCL Provider Bindings

    • Extend the existing NCCL and MCCL API wrappers with thin bindings to ncclAllGather() and mcclAllGather().
    • Register AllGather with the existing NCCL and MCCL provider layers.
  • MPI Correctness

    • Treat AllGather as a movement operation in the shared OpenMPI/MPICH implementation by using MPI_BYTE with count * type_size bytes per rank.
    • Add world-size, size_t multiplication, and MPI int count-range checks for staged transfers.
    • Accumulate validation across every gathered source block in the existing MPI example and return a non-zero process status on failure.
  • Examples, Validation, and Metrics

    • Add a thread-per-GPU single-node CCL AllGather example using one shared unique ID and rank-based communicator initialization.
    • Add an OpenMPI-assisted CCL AllGather example that first uses the public AllGather API through the OpenMPI inter communicator to distribute the native unique ID, then initializes the native CCL communicator for GPU data movement.
    • Validate both out-of-place and canonical in-place layouts across every source-rank block and propagate cluster-wide validation failures through the process exit status.
    • Report the contribution size per rank, the complete gathered size per rank, average operation time, algorithm bandwidth as world_size * rank_bytes / time, and bus bandwidth as algorithm bandwidth multiplied by (world_size - 1) / world_size.
    • Parse numeric options without exceptions and guard example buffer-size calculations against overflow.

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 NCCL and MCCL paths for AllGather, avoiding the existing MPI host-staging path when a supported CCL backend and native communicator are available. The shared MPI path remains host-staged, with corrected byte-count handling for movement data types. Other collective operations are intended to remain unchanged. The validation-log timings below are execution references rather than a quantified cross-backend performance comparison.

Known Issues & Future Work

  • The CCL collective backend on this branch now covers AllReduce and AllGather; other CCL collective operations remain future work.
  • AllGather inherits 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 server examples validate float32 payloads on the default stream. Additional data-type and non-default-stream runtime coverage remain future work.
  • The MPI fallback remains host-staged with per-call allocations and rejects per-rank payloads whose byte count exceeds the MPI int count range; chunked transfers remain future work.

Test Results

The implementation commit is e26a2c2917852c348655dd25155a8e0e0ecdbd8f, a single commit directly based on ef4045a2d99837c75c2acd90aae57dacb83172d2. The current-commit evidence contains exactly 15 canonical logs: all 15 targets passed, with Correct: YES 20 times and Correct: NO 0 times. The five additional positive results are the second AllGather layout in each pure CCL and hybrid log plus the two additional expected validation cases in the MPI broadcast log.

All four AllGather execution paths passed with a 1,048,576-element Float32 contribution per rank (4.00 MiB), 2 warm-up iterations, and 20 profiled iterations. The CCL-only and hybrid examples validate both out-of-place and canonical in-place layouts; the heterogeneous MPI example validates its out-of-place layout.

Path Layout Test topology Data per rank / gathered per rank Time Alg BW Bus BW
Pure NCCL Out-of-place 8 NVIDIA A100 GPUs 4.00 / 32.00 MiB 0.242 ms 138.78 GB/s 121.43 GB/s
Pure NCCL In-place 8 NVIDIA A100 GPUs 4.00 / 32.00 MiB 0.236 ms 142.09 GB/s 124.33 GB/s
OpenMPI + NCCL hybrid Out-of-place 8 NVIDIA A100 GPUs 4.00 / 32.00 MiB 0.251 ms 133.78 GB/s 117.06 GB/s
OpenMPI + NCCL hybrid In-place 8 NVIDIA A100 GPUs 4.00 / 32.00 MiB 0.234 ms 143.44 GB/s 125.51 GB/s
Heterogeneous OpenMPI Out-of-place 8 NVIDIA A100 + 8 MetaX C550 GPUs 4.00 / 64.00 MiB 80.735 ms 0.83 GB/s 0.78 GB/s
Pure MCCL Out-of-place 8 MetaX C550 GPUs 4.00 / 32.00 MiB 3.181 ms 10.55 GB/s 9.23 GB/s
Pure MCCL In-place 8 MetaX C550 GPUs 4.00 / 32.00 MiB 3.173 ms 10.58 GB/s 9.25 GB/s

Algorithm bandwidth uses the complete gathered bytes resident on each rank, world_size * rank_bytes / time. Bus bandwidth applies the standard AllGather correction factor, (world_size - 1) / world_size. The values were independently checked while accounting for the displayed time being rounded to three decimal places. They are included as execution evidence, not as a cross-platform benchmark comparison.

  • The pure NCCL and OpenMPI+NCCL configurations each passed both selected targets, 2/2 and 2/2, on all 8 A100 GPUs. Each AllGather log passed both out-of-place and in-place validation; the hybrid log also confirms that the OpenMPI fallback passed before the native NCCL communicator was initialized.
  • The heterogeneous OpenMPI configuration passed all 9 MPI targets on 16 ranks. Ranks 0-7 mapped to NVIDIA devices 0-7, and ranks 8-15 mapped to MetaX devices 0-7.
  • The pure MCCL configuration passed both selected targets on all 8 MetaX C550 GPUs, with ranks 0-7 mapped to devices 0-7, and its AllGather log passed both out-of-place and in-place validation.
  • All five formal run_examples.py invocations returned zero. There were no harness retries, MetaX vendor queue retries, timeouts, missing canonical logs, or recorded finalization errors.

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_gather.log
ccl_all_reduce.log

CCL + MPI on single-node NVIDIA:
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.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_gather.log
ccl_all_reduce.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)

  • N/A- Code is PEP 8 compliant; ruff check passes cleanly on CI (see `.github/workflows/ruff.yml).
  • N/A- 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).
  • N/A- No blank line between the function signature and the body when there is no docstring or comment (CONTRIBUTING.md §Python).
  • N/A- 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).
  • N/A- 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-all-gather branch from c1b5917 to e26a2c2 Compare August 23, 2026 09:32
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