feat: provide CMake config package for find_package(InfiniCCL)#40
Merged
Ziminli merged 1 commit intoJun 26, 2026
Merged
Conversation
Ziminli
requested changes
Jun 25, 2026
Collaborator
|
PR 本身的一些小问题: |
7edf01a to
8d3fa0e
Compare
8d3fa0e to
f50f32e
Compare
Ziminli
approved these changes
Jun 26, 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
InfiniCCL previously shipped no CMake config package, so downstream projects had to wire the integration by hand: set an
INFINICCL_INSTALLenvironment variable, add${INFINICCL_INSTALL}/includemanually, link the absolute path tolibinfiniccl.so, and hand-setINSTALL_RPATH.This PR makes InfiniCCL installable as a first-class CMake package. After
cmake --install, downstream projects consume it withfind_package(InfiniCCL REQUIRED)and link the imported targetInfiniCCL::infiniccl, which already carries the public include directory, the library location, and the runtime search path. All hardware/backend dependencies (CUDA, MPI, NCCL, ...) are linkedPRIVATEinto the shared library, so they are intentionally not propagated as usage requirements — consumers do not need to resolve them just to use InfiniCCL. The change is purely additive and non-breaking: the installedlibinfiniccl.soand headers are unchanged; only export/packaging metadata is added, and the manual-linking path is retained inREADME.mdas an alternative.Changes
CMakeLists.txt)project(InfiniCCL VERSION 0.1.0 ...)) so a package version file can be generated.infiniccltarget in an export set:install(TARGETS infiniccl EXPORT InfiniCCLTargets ...)with explicitLIBRARY/ARCHIVE/RUNTIMEdestinations.InfiniCCLConfig.cmakeandInfiniCCLConfigVersion.cmakeviaCMakePackageConfigHelpers(configure_package_config_file+write_basic_package_version_file,COMPATIBILITY SameMajorVersion).InfiniCCLTargets.cmakeunder${CMAKE_INSTALL_LIBDIR}/cmake/InfiniCCLwith namespaceInfiniCCL::.cmake/InfiniCCLConfig.cmake.in)@PACKAGE_INIT@, include the generated targets file, thencheck_required_components(InfiniCCL).find_dependency(...)calls — the backend libraries arePRIVATEto the shared library; theCMakeFindDependencyMacroinclude is kept as a guarded extension point for any future build that exposes such a dependency through the public interface.README.md)find_package(InfiniCCL)as the recommended approach (with-DCMAKE_PREFIX_PATH/-DInfiniCCL_ROOThints), keeping the existing manual-linking method as a documented alternative.Platform and Backend Affected
This is a build-system / packaging change. It touches no device-specific code (
src/<device>/) and no backend implementation (src/ompi/, ...), and it does not change the compiledlibinfiniccl.so— only how it is exported and installed. No platform- or backend-specific behavior is affected, so no box below is checked.Platform
Backend
Performance Impact
The change only adds install/export metadata; no compiled code or runtime path is altered, and the floating-point reduction paths are byte-for-byte unchanged. For reference, the heterogeneous run (8 ranks, 4 MB per rank,
Float32 + Sum) measuredAllReduceat 9.979 ms (0.69 GB/s bus BW) and in-placeBroadcastat 2.131 ms, matching the pre-change baseline.Known Issues & Future Work
0.1.0as a starting point; there was no prior versioning scheme. It should be bumped as the public surface evolves.find_dependency(...)because CUDA / MPI / NCCL are linkedPRIVATE. A future static-library build (or a public interface that exposes those dependencies) would need to add the correspondingfind_dependency(...)calls incmake/InfiniCCLConfig.cmake.in.icclrunflow) get it automatically; an installed consumer should setCMAKE_INSTALL_RPATH_USE_LINK_PATHor its own RPATH.Test Results
Validated on a NVIDIA–MetaX heterogeneous cluster over the OpenMPI backend via
scripts/run_examples.py(runrun_20260626_060706):server: NVIDIA, 4 GPUs, ranks 0–3 (built with Devices[cpu, nvidia], Backends[ompi]).test: MetaX, 4 GPUs, ranks 4–7 (built with Devices[cpu, metax], Backends[ompi]).float32(4 MB) per rank; 2 warm-up + 20 profiled iterations.Correct: YES(broadcastcovers all 3 scenarios: out-of-place, in-place, legacyBcast).Because this is a build-system change that does not alter the compiled library or any collective's behavior, the full example regression above is the relevant signal: it confirms the rebuilt library and every collective still pass on real heterogeneous hardware. The new package itself was additionally verified by a downstream consumer: a clean-prefix
cmake --installemits the fourlib/cmake/InfiniCCL/*.cmakefiles, and a minimal program using onlyfind_package(InfiniCCL REQUIRED)+target_link_libraries(app PRIVATE InfiniCCL::infiniccl)configures, builds (header resolved transitively, RPATH auto-set), and runsCorrect: YES.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