feat: support Gather with OpenMPI backend implementation#29
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b0d6cc1bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
cbb5c53 to
4562d2c
Compare
4562d2c to
e60db1d
Compare
Ziminli
approved these changes
Jun 4, 2026
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
Gathersupport to InfiniCCL with an OpenMPI-based backend implementation, along with an example program for functional verification and basic performance evaluation.Gathercollects one equally-sized block from every rank onto a singlerootrank. The public API is exposed throughinfinicclGather()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_Gatherinternally.Changes
Public Gather API
infinicclGather()ininclude/comm.h;extern "C"entry is produced by the existing auto-generated bridge, so no manual wiring is needed.Base Gather Wrapper
src/base/gather.h;rootrank range, and buffer pointers (the receive buffer is only required onroot) before dispatching to the backend implementation;countas a successful no-op;infinicclInvalidArgumentfor invalid user inputs.OpenMPI-based Gather Implementation
src/ompi/impl/gather.h;MPI_Gather, allocating the host receive buffer only onroot, where the gathered result lands;rootafter);DataTypeto the correspondingMPI_Datatype, and reject acountexceedingINT_MAX.Gather Example
examples/gather.cc;all_reduce,all_gather,reduce_scatter,broadcast, andall_to_all;(rank + 1), and the example verifies thatrootreceives the[1, 2, …, size]blocks in rank order;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
Gatherat 42.343 ms, 2.77 GB/s bus bandwidth, 1.48 GB/s algorithm bandwidth.Known Issues & Future Work
Gatherimplementation 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
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