feat: support Scatter with OpenMPI backend implementation#34
Open
GordonYang1 wants to merge 2 commits into
Open
feat: support Scatter with OpenMPI backend implementation#34GordonYang1 wants to merge 2 commits into
Scatter with OpenMPI backend implementation#34GordonYang1 wants to merge 2 commits into
Conversation
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
This PR adds collective
Scattersupport to InfiniCCL with an OpenMPI-based backend implementation, along with an example program for functional verification and basic performance evaluation.Scatterdistributes one equally-sized block from a singlerootrank to every rank (the inverse ofGather). The public API is exposed throughinfinicclScatter()with the signature(sendbuff, recvbuff, count, datatype, root, comm, stream), consistent with the existing rooted collectives. The current implementation host-stages device buffers and delegates to a blockingMPI_Scatterinternally.Changes
Public Scatter API
infinicclScatter()ininclude/comm.h;extern "C"entry is produced by the existing auto-generated bridge, so no manual wiring is needed.Base Scatter Wrapper
src/base/scatter.h;rootrank range, and buffer pointers (the receive buffer is required on every rank, while the send buffer is only required onroot) before dispatching to the backend implementation;countas a successful no-op;infinicclInvalidArgumentfor invalid user inputs.OpenMPI-based Scatter Implementation
src/ompi/impl/scatter.h;MPI_Scatter, allocating the host send buffer only onroot, which holds the per-rank blocks to be distributed;rootbefore, host-to-device of the received block on every rank after);DataTypeto the correspondingMPI_Datatype, and reject acountexceedingINT_MAX.Scatter Example
examples/scatter.cc;all_reduce,all_gather,reduce_scatter,broadcast, andall_to_all;rootfills the block destined for rankrwith(r + 1), and each rank verifies that it received its own(rank + 1)block;Platform and Backend Affected
Platform
Backend
Performance Impact
This PR adds a new collective and does not change the performance of existing operations. For reference, the heterogeneous run (16 ranks, 4 MB per rank) measured
Scatterat 61.420 ms, 1.91 GB/s bus bandwidth, 1.02 GB/s algorithm bandwidth.Known Issues & Future Work
Scatterimplementation is blocking and does not overlap communication with computation. Future work may introduce stream-aware asynchronous execution.malloc/freeon every invocation. Future work may add reusable buffer pools, allocator caching, and pinned host memory to reduce per-call overhead.countlarger thanINT_MAXinstead of splitting it intoINT_MAX-bounded chunks (as the point-to-point path does). Future work may add chunking for very large transfers.root, zero-count calls, mismatched-buffer validation, and large-count stress cases.Test Results
Validated on a MetaX–NVIDIA heterogeneous cluster over the OpenMPI backend via
scripts/run_examples.py:server: NVIDIA, 8 GPUs, ranks 0–7 (built with Devices[cpu, nvidia], Backends[ompi]).test: MetaX, 8 GPUs, ranks 8–15 (built with Devices[cpu, metax], Backends[ompi]).float32(4 MB) per rank; 2 warm-up + 20 profiled iterations.Test Involved Platform
Test Involved Backend
all_gather.log
all_reduce.log
all_to_all.log
broadcast.log
gather.log
reduce.log
reduce_scatter.log
scatter.log
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)
ruff checkpasses cleanly on CI (see.github/workflows/ruff.yml).ruff format --checkpasses cleanly — if not, runruff formatand commit the result.CONTRIBUTING.md§Python).pytest.skipmessages without terminal period) are honored where applicable (CONTRIBUTING.md§Python).CONTRIBUTING.md§Python).if,for, and similar control-flow statements (CONTRIBUTING.md§Python).return, except when it directly follows a control-flow statement (CONTRIBUTING.md§Python).CONTRIBUTING.md§Python).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