Skip to content

build: add CMake package config#28

Merged
voltjia merged 2 commits into
masterfrom
build/add-cmake-package-config
Jul 15, 2026
Merged

build: add CMake package config#28
voltjia merged 2 commits into
masterfrom
build/add-cmake-package-config

Conversation

@voltjia

@voltjia voltjia commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Install InfiniRTConfig.cmake, InfiniRTConfigVersion.cmake, and the namespaced InfiniRT::infinirt target so downstream CMake projects can use find_package(InfiniRT CONFIG REQUIRED).
  • Export relocatable backend dependency metadata and replace the installed-consumer check with a separate CMake project that finds, validates, and links the installed package.
  • Update the consumer example and installation documentation to use CMAKE_PREFIX_PATH and the imported target.

Motivation

Installed InfiniRT prefixes currently expose headers and libinfinirt without a CMake package, so each downstream project must rediscover the include directory, library, language requirement, and backend dependencies. A versioned package config provides a standard downstream interface and avoids exporting backend SDK paths from the build machine.

N/A - no linked issue.

Type of Change

  • feat - new feature / new backend capability / new public API
  • fix - bug fix
  • perf - performance improvement without behavior change
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • Hygon (WITH_HYGON)
  • MetaX (WITH_METAX)
  • Moore (WITH_MOORE)
  • Cambricon (WITH_CAMBRICON)
  • Ascend (WITH_ASCEND)
  • Build system / CMake / generated headers
  • Public headers / installed consumer API
  • Documentation only

Smoke Build and Test Result

All platform checkouts were pinned to commit 9ae8f8fd0b0ac4807a0d8b325fb0d3b2809fb161. NVIDIA, Iluvatar, Moore, Cambricon, and Ascend builds ran in the accelerator-dev/<platform>:latest images with --privileged. MetaX device smoke used its documented image, while the build ran directly on the same host because that image does not contain CMake; the host provides CMake 3.28.3 and the same /opt/maca SDK.

# CPU-only package and installed-consumer validation
cmake -S . -B build-cpu \
  -DCMAKE_BUILD_TYPE=Release \
  -DWITH_CPU=ON \
  -DINFINI_RT_BUILD_TESTING=ON
cmake --build build-cpu -j 8
ctest --test-dir build-cpu --output-on-failure

100% tests passed, 0 tests failed out of 6

# Common accelerator configure/build/test shape
cmake -S . -B build-pr28 \
  -DCMAKE_BUILD_TYPE=Release \
  -DWITH_CPU=ON \
  -DWITH_<PLATFORM>=ON \
  -DINFINI_RT_BUILD_TESTING=ON
cmake --build build-pr28 -j 8
ctest --test-dir build-pr28 --output-on-failure

# Platform options used
-DWITH_NVIDIA=ON
-DWITH_ILUVATAR=ON
-DWITH_METAX=ON
-DWITH_MOORE=ON
-DWITH_CAMBRICON=ON
-DWITH_ASCEND=ON

Each completed platform test set includes test_install and test_install_consumer. The latter configures an external project with an exact version requirement, resolves the installed package through CMAKE_PREFIX_PATH, validates InfiniRT_ENABLED_BACKENDS and every InfiniRT_WITH_<BACKEND> value, links InfiniRT::infinirt, and runs the resulting executable. A negative configure check also confirmed that mismatched expected metadata is rejected.

Device tensor smoke results and image IDs:

NVIDIA:    cuda:0 [1.0]  sha256:dd94fce2f83a180e2271f02f69713de5360aaf916b01e1f7f54173519fd54efd
Iluvatar:  cuda:0 [1.0]  sha256:5dc3abe5c210b9160cc936f42929f9c5b100fefff175af15e67ce0d359b320ce
MetaX:     cuda:0 [1.0]  sha256:f60d250f4409e4c1a7817dce498905382bc58f1ccc291834e1dc1ecfa3bbf7f5
Moore:     musa:0 [1.0]  sha256:70f9b7c621bc01b69a422501f139699d23086dfe0b61df99cc92a1de07025ce6
Cambricon: mlu:0 [1.0]   sha256:d3544201bc7039f328abf137d154b24a89a17fdd48a487dc0ae0bdd6d14a5cf6
Ascend:    npu:0 [1.0]   sha256:7da2cb1fa09f19d55fa8b41edae49d9a1eda7fd87bdbddf2d6a943f68e6a2f2b

InfiniOps downstream validation used current InfiniTensor/InfiniOps master at 296271487beb594a248fd463e5fff14f7ab74293. Its temporary checkout was changed only to consume InfiniRT::infinirt; configuration received CMAKE_PREFIX_PATH and no legacy InfiniRT root, include, or library variables.

-- Using InfiniRT 0.1.0 CMake package: /workspace/infinirt/build/tests/install_consumer_prefix/lib/cmake/InfiniRT
Successfully built infiniops-0.1.0-cp312-cp312-linux_x86_64.whl
Running 70 items in this shard
56 passed, 14 skipped, 8975 deselected in 7.76s

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU Yes full passed 6/6 CPU-only tests passed; also covered in the combined CPU + NVIDIA build.
NVIDIA Yes full passed 8/8 InfiniRT tests passed; InfiniOps downstream smoke: 56 passed, 14 skipped.
Iluvatar Yes full passed 7/7 tests passed in the documented Iluvatar image.
Hygon Yes Blocked ssh hygon (10.211.3.27:22) timed out from the local host and five accelerator hosts; no container or source command ran.
MetaX Yes full passed 7/7 tests passed on the MetaX host with /opt/maca; the documented image supplied the successful device smoke but lacks CMake.
Moore Yes full passed 7/7 tests passed in the documented Moore image.
Cambricon Yes full passed 7/7 tests passed in the documented Cambricon image.
Ascend Yes full passed 7/7 tests passed in the documented Ascend image; the image exhibited the documented post-output exit behavior.
Full `ctest` summary
CPU-only:
100% tests passed, 0 tests failed out of 6
Total Test time (real) = 0.88 sec

NVIDIA:
100% tests passed, 0 tests failed out of 8
Total Test time (real) = 5.73 sec

Iluvatar:
100% tests passed, 0 tests failed out of 7
Total Test time (real) = 0.67 sec

MetaX:
100% tests passed, 0 tests failed out of 7
Total Test time (real) = 1.01 sec

Moore:
100% tests passed, 0 tests failed out of 7
Total Test time (real) = 2.71 sec

Cambricon:
100% tests passed, 0 tests failed out of 7
Total Test time (real) = 2.48 sec

Ascend:
100% tests passed, 0 tests failed out of 7
Total Test time (real) = 2.62 sec

Benchmark / Performance Impact

N/A - this changes CMake package metadata, installation checks, examples, and documentation; runtime implementation and dispatch behavior are unchanged.

Notes for Reviewers

  • Package version 0.1.0 matches the project version used by downstream packaging.
  • CUDA-like packages rediscover CUDAToolkit; MetaX, Moore, Cambricon, and Ascend packages rediscover their SDK runtime targets from consumer-side hints and environment variables. This keeps build-machine SDK paths out of the installed target export.
  • The external consumer compares the complete enabled-backend list and all eight backend flags against the source build, so stale or incomplete package metadata fails during CMake configuration.
  • Please focus on the SDK rediscovery rules for non-NVIDIA backends. The PR remains draft because Hygon could not be reached at the SSH endpoint in the local configuration.
  • The InfiniOps validation demonstrates the intended migration from manual find_path / find_library logic to find_package(InfiniRT CONFIG REQUIRED) and InfiniRT::infinirt.

@voltjia
voltjia marked this pull request as ready for review July 15, 2026 06:07
@voltjia
voltjia merged commit 95c7008 into master Jul 15, 2026
6 checks passed
@voltjia
voltjia deleted the build/add-cmake-package-config branch July 15, 2026 07:30
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