-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contributes to rapidsai/build-planning#33. Proposes packaging `libcuvs` as a wheel, which is then re-used by `cuvs-cu{11,12}`. Similar changes were recently made in RAFT: rapidsai/raft#2531 As part of this, also proposes: * introducing a new CMake option, `CUVS_COMPILE_DYNAMIC_ONLY`, to allow building/installing only the dynamic shared library (i.e. skipping the static library) * enforcing `rapids-cmake`'s preferred CMake style (similar rapidsai/raft#2531 (comment)) * standardizing `clang` pins across the project, and pinning to `clang` 16 for Rust builds (#594 (comment)) ## Notes for Reviewers ### Benefits of these changes * smaller wheels for projects that depend on cuVS (they can dynamically link against `libcuvs` instead of statically linking in the pieces they need) * fewer CI resources used for cuVS wheels (no more re-compiling for every Python minor version) * faster, cheaper cuML wheel builds (rapidsai/cuml#6199 (comment)) * other benefits mentioned in rapidsai/build-planning#33 ### Wheel contents `libcuvs`: * `libcuvs.so` and `libcuvs_c.so` (shared library) * cuVS headers * vendored dependencies (hnswlib) `cuvs`: * `cuvs` Python / Cython code and compiled Cython extensions ### Size changes (CUDA 12, Python 3.12, x86_64) | wheel | num files (before) | num files (this PR) | size (before) | size (this PR) | |:---------------:|------------------:|-----------------:|--------------:|---------------:| | `libcuvs` | --- | 67 | --- | 843M | | `cuvs` | 88 | 84 |845M | 2M | |**TOTAL** | **88** | **131** | **845M** | **845M** | *NOTES: size = compressed, "before" = 2025-01-22 nightlies* <details><summary>how I calculated those (click me)</summary> * nightly commit = rapidsai/cuml@7c715c4 * PR = this PR ```shell docker run \ --rm \ --network host \ --env RAPIDS_NIGHTLY_DATE=2025-01-22 \ --env CUVS_NIGHTLY_SHA=f1de1b2 \ --env CUVS_PR="pull-request/594" \ --env CUVS_PR_SHA="97c56178cd0e07e4b6b138bb0904af78379f1bb3" \ --env RAPIDS_PY_CUDA_SUFFIX=cu12 \ --env WHEEL_DIR_BEFORE=/tmp/wheels-before \ --env WHEEL_DIR_AFTER=/tmp/wheels-after \ -it rapidsai/ci-wheel:cuda12.5.1-rockylinux8-py3.12 \ bash # --- nightly wheels --- # mkdir -p ./wheels-before export RAPIDS_BUILD_TYPE=branch export RAPIDS_REF_NAME="branch-25.02" # cuvs RAPIDS_PY_WHEEL_NAME="cuvs_${RAPIDS_PY_CUDA_SUFFIX}" \ RAPIDS_REPOSITORY=rapidsai/cuvs \ RAPIDS_SHA=${CUVS_NIGHTLY_SHA} \ rapids-download-wheels-from-s3 python ./wheels-before # --- wheels from CI --- # mkdir -p ./wheels-after export RAPIDS_BUILD_TYPE="pull-request" # libcuvs RAPIDS_PY_WHEEL_NAME="libcuvs_${RAPIDS_PY_CUDA_SUFFIX}" \ RAPIDS_REPOSITORY=rapidsai/cuvs \ RAPIDS_REF_NAME="${CUVS_PR}" \ RAPIDS_SHA="${CUVS_PR_SHA}" \ rapids-download-wheels-from-s3 cpp ./wheels-after # cuvs RAPIDS_PY_WHEEL_NAME="cuvs_${RAPIDS_PY_CUDA_SUFFIX}" \ RAPIDS_REPOSITORY=rapidsai/cuvs \ RAPIDS_REF_NAME="${CUVS_PR}" \ RAPIDS_SHA="${CUVS_PR_SHA}" \ rapids-download-wheels-from-s3 python ./wheels-after pip install pydistcheck pydistcheck \ --inspect \ --select 'distro-too-large-compressed' \ ./wheels-before/*.whl \ | grep -E '^checking|files: | compressed' \ > ./before.txt # get more exact sizes du -sh ./wheels-before/* pydistcheck \ --inspect \ --select 'distro-too-large-compressed' \ ./wheels-after/*.whl \ | grep -E '^checking|files: | compressed' \ > ./after.txt # get more exact sizes du -sh ./wheels-after/* ``` </details> ### How I tested this * rapidsai/devcontainers#440 * rapidsai/cuml#6199 Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) - Ben Frederickson (https://github.com/benfred) URL: #594
- Loading branch information
Showing
43 changed files
with
653 additions
and
204 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,30 @@ jobs: | |
node_type: "gpu-v100-latest-1" | ||
run_script: "ci/build_docs.sh" | ||
sha: ${{ inputs.sha }} | ||
wheel-build-libcuvs: | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
with: | ||
build_type: ${{ inputs.build_type || 'branch' }} | ||
branch: ${{ inputs.branch }} | ||
sha: ${{ inputs.sha }} | ||
date: ${{ inputs.date }} | ||
script: ci/build_wheel_libcuvs.sh | ||
# build for every combination of arch and CUDA version, but only for the latest Python | ||
matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) | ||
wheel-publish-libcuvs: | ||
needs: wheel-build-libcuvs | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
with: | ||
build_type: ${{ inputs.build_type || 'branch' }} | ||
branch: ${{ inputs.branch }} | ||
sha: ${{ inputs.sha }} | ||
date: ${{ inputs.date }} | ||
package-name: libcuvs | ||
package-type: cpp | ||
wheel-build-cuvs: | ||
needs: wheel-build-libcuvs | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
with: | ||
|
@@ -99,3 +122,4 @@ jobs: | |
sha: ${{ inputs.sha }} | ||
date: ${{ inputs.date }} | ||
package-name: cuvs | ||
package-type: python |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ jobs: | |
- conda-python-tests | ||
- docs-build | ||
- rust-build | ||
- wheel-build-libcuvs | ||
- wheel-build-cuvs | ||
- wheel-tests-cuvs | ||
- devcontainer | ||
|
@@ -135,10 +136,19 @@ jobs: | |
arch: "amd64" | ||
container_image: "rapidsai/ci-conda:latest" | ||
run_script: "ci/build_rust.sh" | ||
wheel-build-cuvs: | ||
wheel-build-libcuvs: | ||
needs: checks | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
with: | ||
build_type: pull-request | ||
script: ci/build_wheel_libcuvs.sh | ||
# build for every combination of arch and CUDA version, but only for the latest Python | ||
matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) | ||
wheel-build-cuvs: | ||
needs: wheel-build-libcuvs | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
with: | ||
build_type: pull-request | ||
script: ci/build_wheel_cuvs.sh | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2023-2024, NVIDIA CORPORATION. | ||
# Copyright (c) 2023-2025, NVIDIA CORPORATION. | ||
|
||
set -euo pipefail | ||
|
||
package_dir="python/cuvs" | ||
|
||
case "${RAPIDS_CUDA_VERSION}" in | ||
12.*) | ||
EXTRA_CMAKE_ARGS=";-DUSE_CUDA_MATH_WHEELS=ON" | ||
;; | ||
11.*) | ||
EXTRA_CMAKE_ARGS=";-DUSE_CUDA_MATH_WHEELS=OFF" | ||
;; | ||
esac | ||
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" | ||
|
||
# Set up skbuild options. Enable sccache in skbuild config options | ||
export SKBUILD_CMAKE_ARGS="-DDETECT_CONDA_ENV=OFF;-DFIND_CUVS_CPP=OFF${EXTRA_CMAKE_ARGS}" | ||
# Downloads libcuvs wheels from this current build, | ||
# then ensures 'cuvs' wheel builds always use the 'libcuvs' just built in the same CI run. | ||
# | ||
# Using env variable PIP_CONSTRAINT is necessary to ensure the constraints | ||
# are used when creating the isolated build environment. | ||
RAPIDS_PY_WHEEL_NAME="libcuvs_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/libcuvs_dist | ||
echo "libcuvs-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo /tmp/libcuvs_dist/libcuvs_*.whl)" > /tmp/constraints.txt | ||
export PIP_CONSTRAINT="/tmp/constraints.txt" | ||
|
||
ci/build_wheel.sh cuvs ${package_dir} | ||
ci/build_wheel.sh cuvs ${package_dir} python | ||
ci/validate_wheel.sh ${package_dir} final_dist |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2025, NVIDIA CORPORATION. | ||
|
||
set -euo pipefail | ||
|
||
package_name="libcuvs" | ||
package_dir="python/libcuvs" | ||
|
||
rapids-logger "Generating build requirements" | ||
matrix_selectors="cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};cuda_suffixed=true" | ||
|
||
rapids-dependency-file-generator \ | ||
--output requirements \ | ||
--file-key "py_build_${package_name}" \ | ||
--file-key "py_rapids_build_${package_name}" \ | ||
--matrix "${matrix_selectors}" \ | ||
| tee /tmp/requirements-build.txt | ||
|
||
rapids-logger "Installing build requirements" | ||
python -m pip install \ | ||
-v \ | ||
--prefer-binary \ | ||
-r /tmp/requirements-build.txt | ||
|
||
# build with '--no-build-isolation', for better sccache hit rate | ||
# 0 really means "add --no-build-isolation" (ref: https://github.com/pypa/pip/issues/5735) | ||
export PIP_NO_BUILD_ISOLATION=0 | ||
|
||
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" | ||
|
||
ci/build_wheel.sh libcuvs ${package_dir} cpp | ||
ci/validate_wheel.sh ${package_dir} final_dist libcuvs |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2023-2024, NVIDIA CORPORATION. | ||
# Copyright (c) 2023-2025, NVIDIA CORPORATION. | ||
|
||
set -euo pipefail | ||
|
||
mkdir -p ./dist | ||
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" | ||
RAPIDS_PY_WHEEL_NAME="cuvs_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 ./dist | ||
RAPIDS_PY_WHEEL_NAME="libcuvs_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp ./local-libcuvs-dep | ||
RAPIDS_PY_WHEEL_NAME="cuvs_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python ./dist | ||
|
||
# echo to expand wildcard before adding `[extra]` requires for pip | ||
python -m pip install $(echo ./dist/cuvs*.whl)[test] | ||
python -m pip install \ | ||
./local-libcuvs-dep/libcuvs*.whl \ | ||
"$(echo ./dist/cuvs*.whl)[test]" | ||
|
||
python -m pytest ./python/cuvs/cuvs/test |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.