Repository navigation
feat: support CCL AllToAll - #82
xingjiangjun wants to merge 3 commits into
Conversation
| const bool correct = ValidateResult(h_recv, count_per_peer, size, rank); | ||
|
|
||
| if (rank == 0) { | ||
| PrintMetrics(elapsed_ms, total_bytes, size); | ||
| } | ||
| std::cout << "[Rank " << rank << "] AllToAll validation " | ||
| << (correct ? "passed." : "failed.") << std::endl; |
There was a problem hiding this comment.
line198-199 这个打印需要去掉,可以参考其他示例,用 Validator::ValidateResult(). 保证代码复用和打印格式对齐。
There was a problem hiding this comment.
Updated in 1ab5156. In examples/ccl_mpi_hybrid/all_to_all.cc:32–50, each received element is compared with its own expected value, and the resulting error indicators are passed to Validator::ValidateResult(). This preserves exact checking and rejects NaN/Inf while using the standard output format. Each rank reports its own result, and validation failure produces a nonzero exit status. The duplicate custom pass/fail print was removed. Both ranks passed the Hybrid regression.
There was a problem hiding this comment.
这个 example 的打印和实现形式还是没有对齐。具体说明下:
- 不需要每个 rank 都打印结果,参考其他 examples;
AllToAll的打印可以参考mpi/all_to_all的打印逻辑,大概长这样:
=== Performing AllToAll on GPU Memory ===
Count per peer: 262144 floats
Total per rank: 2097152 floats (8 MB)
Warm-up iterations: 2
Profile iterations: 20
=== AllToAll Results ===
Correct: YES
Sample recv blocks: [src0: 0] [src1: 1000] [src2: 2000] [src3: 3000]
Time: 4.137 ms
Throughput: 3.31 GB/s (Bus BW)
Alg Bandwidth: 1.89 GB/s
InfiniCCL finalized.
保证 ccl_mpi_hybrid/all_to_all 的输出和这个对齐;
3. PrintMetrics 没有复用。还是一样,参考其他 examples,都是直接复用已有的 Metrics:
// Metrics Reporting (Only from rank 0 for cleaner output)
if (rank == 0) {
Metrics metrics{elapsed, total_bytes, size};
metrics.Print();
}- 参考
ccl_mpi_hybrid/all_reduce.cc,RunAllToAllExample()里需要留一些分阶段的 comments,比如// Setup Communicator,// Warm-up and D2H transfer the answer.这种,不然看着比较乱。
总而言之就是参考其他已有的和对应的 examples,保证实现方式和格式大体上都是对齐的,按理来说这就是个模块化的工作。
There was a problem hiding this comment.
Communicator fallback 的这些逻辑目前都不需要。实现直接对标其余实现(e.g., all_reduce, reduce_scatter, all_gather, etc.) 即可。
There was a problem hiding this comment.
Removed DeferredAllToAll and communicator fallback in 1ab5156. The backend-specific implementations now require a matching native communicator and validate its handle (src/backends/ccl/{nccl,mccl}/impl/all_to_all.h:28–47). The obsolete common implementation was removed. To keep Hybrid initialization valid, examples/ccl_mpi_hybrid/all_to_all.cc:95–109 now follows Hybrid AllReduce: initialize the MPI communicator, broadcast the Unique ID in host memory, then initialize the native communicator. Native and Hybrid two-rank regressions passed.
There was a problem hiding this comment.
现在的 ccl AllToAll 实现没有正确利用 ccl 的实现框架。基础实现应该在 backends/ccl/common/ 里,而不是在每个具体的 ccl 后端(e.g., nccl/, mccl) 下都写一遍具体的实现。具体可以参考其他已有的 ccl 通信操作实现,比如 all_reduce。
df07679 to
1ab5156
Compare
1ab5156 to
21eb58a
Compare
Summary
Add native NCCL/MCCL AllToAll using grouped Send/Recv, following the existing CCL framework and example conventions.
This PR is a follow-up to #65, originally contributed by @GordonYang1. It rebases and refines the original CCL AllToAll implementation and aligns the examples with existing project implementations.
Rebased onto upstream
52a48aa(#86). The current diff contains eight files; the MPI backend, MPI example, and public example utilities are unchanged. The latest review fixes are in21eb58a.Changes
src/backends/ccl/common/impl/all_to_all.h.HasInvalidArgs(), following AllGather.Validator::ValidateResult()andMetrics::Print().Platform and Backend Affected
Affected shared implementations are listed below; tested platforms are listed separately.
Platform
Backend
Performance Impact
N/A: this is a functionality PR; example timings are not controlled performance comparisons.
Known Issues & Future Work
Test Results
The nine MPI examples are AllGather, AllReduce, AllToAll, Broadcast, Gather, Reduce, ReduceScatter, Scatter, and Send/Recv. Validation output and process exit codes were checked. AllToAll parameter/status checks also passed on both native backends. Compilation and local clang-format 16 checks passed.
Both platforms used verified source snapshots. The final Native example was rebuilt and rerun after its cleanup; Hybrid tests preceded that Native-only change and its source was unchanged. The committed source matches the final tested snapshot; tests were performed before creating the commit, not rerun solely to change its SHA.
Heterogeneous runs used the OpenMPI backend with native NCCL/MCCL disabled. RDMA/RoCE is not claimed. Send/Recv ranks 0 and 1 were both on NVIDIA. These are correctness checks, not controlled performance measurements.
Current build/test logs and per-rank exit codes are archived locally and have not yet been uploaded. The previous test-log attachment documents the earlier version, not these reruns.
Test Involved Platform
Test Involved Backend
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). Three commits preserve the original contribution and review revisions; squash disposition is left for merge.master— rebased onto52a48aa, including feat: support MCCL'sAllGather,ReduceScatter,Send, andRecv#86.fixup!/squash!/wipcommits remain.Scope and Design
CONTRIBUTING.md§Code/General).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.Api::Check/ReturnStatusconventions rather than new assertion-based handling.CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).Python Specific (if Python files changed)
N/A: no Python files changed.
Testing
Build, CI, and Tooling
clang-format.yml,ruff.yml) passed on21eb58a.Documentation
README.md,CONTRIBUTING.md, or inline docs updated when behavior, build flags, or developer workflow changed.Security and Safety