Skip to content

Commit dfe612b

Browse files
authored
Rust publishing updates (#789)
This PR adds automation for publishing the `cuvs` and `cuvs-sys` rust crates. I updated the rust usage [README](https://github.com/rapidsai/cuvs/pull/789/files#diff-bcb0eb230db7a19167a81000c18bfb176049613f522d077479aa702384af7097) to include simple steps to import the `cuvs` module in any consuming rust project. I've added conda environment files that would facilitate the installation steps described in the [README](https://github.com/rapidsai/cuvs/pull/789/files#diff-bcb0eb230db7a19167a81000c18bfb176049613f522d077479aa702384af7097). --- **Testing the changes in this PR included the following steps**: - I first replicated local builds of the `cuvs` rust module. - Then I attempted a build of the rust example in the `examples` directory which imports the current `cuvs` library as is, and successfully ran the rust example project. - I updated the rust bindings to use different package names and published both as: - [jawe-cuvs-iii](https://crates.io/crates/jawe-cuvs-iii) (cuvs) - [jave-cuvs-sys-iii](https://crates.io/crates/jawe-cuvs-sys-iii) (cuvs-sys) - I published by running the `publish-rust.yaml` workflow. First run can be found [here](https://github.com/rapidsai/cuvs/actions/runs/14158410647/job/39660631194), and a second run [here](https://github.com/rapidsai/cuvs/actions/runs/14205715742/job/39802866340). - After publishing, I locally compiled the example rust module by importing the published modules (`jawe-cuvs-iii` & `jawe-cuvs-sys-iii`) and was able to successfully run the example rust project - I also tested the build & imports on both ARM and AMD architectures. <details> <summary>Cargo run output </summary> ``` # cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s Running `target/debug/cuvs-rust-example` using ivf_pq::index_params nrows 65536, dim 512, n_lists 256, pq_dim 128 [ 18669][17:16:49:911962][info ] optimizing graph [ 18669][17:16:50:057608][info ] Graph optimized, creating index Indexed 65536x512 datapoints into cagra index Neighbors [[0, 6880, 12927, 59705, 45003, 33779, 39003, 56796, 6491, 34338], [1, 28206, 47512, 44788, 14031, 49376, 43330, 3429, 41428, 49044], [2, 45154, 4777, 62753, 45378, 13104, 4082, 46221, 65234, 45638], [3, 41243, 59296, 4950, 55157, 32839, 42927, 10811, 37504, 57827]], shape=[4, 10], strides=[10, 1], layout=Cc (0x5), const ndim=2 Distances [[0.0, 68.72183, 69.83197, 70.23868, 71.08637, 71.15034, 71.60148, 71.71672, 71.82242, 71.90005], [0.0, 68.85643, 69.43584, 69.72554, 69.883835, 70.03081, 70.05081, 70.1477, 70.169556, 70.26346], [0.0, 69.09878, 69.42933, 70.06172, 70.10106, 70.16475, 70.19414, 70.64023, 70.64905, 70.71358], [0.0, 64.99479, 65.39395, 66.827286, 66.99862, 67.110855, 67.57162, 67.779526, 67.964035, 68.002716]], shape=[4, 10], strides=[10, 1], layout=Cc (0x5), const ndim=2 ``` </details>
1 parent 51ac562 commit dfe612b

File tree

6 files changed

+159
-1
lines changed

6 files changed

+159
-1
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
node_type: "gpu-l4-latest-1"
4848
run_script: "ci/build_rust.sh"
4949
sha: ${{ inputs.sha }}
50+
rust-publish:
51+
needs: rust-build
52+
secrets: inherit
53+
uses: ./.github/workflows/publish-rust.yaml
5054
go-build:
5155
needs: cpp-build
5256
secrets: inherit
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: publish
2+
3+
on:
4+
workflow_call:
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
rust-publish:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: rapidsai/ci-conda:latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Check if release build
18+
id: check_release
19+
run: |
20+
if rapids-is-release-build; then
21+
echo "is_release=true" >> $GITHUB_OUTPUT
22+
else
23+
echo "is_release=false" >> $GITHUB_OUTPUT
24+
fi
25+
- name: Setup and publish crates
26+
if: steps.check_release.outputs.is_release == 'true'
27+
run: |
28+
. /opt/conda/etc/profile.d/conda.sh
29+
30+
rapids-dependency-file-generator \
31+
--output conda \
32+
--file-key rust \
33+
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" \
34+
| tee env.yaml
35+
36+
rapids-mamba-retry env create --yes -f env.yaml -n rust
37+
38+
set +eu
39+
conda activate rust
40+
set -eu
41+
42+
LIBCLANG_PATH=$(dirname "$(find /opt/conda -name libclang.so | head -n 1)")
43+
export LIBCLANG_PATH
44+
echo "LIBCLANG_PATH=$LIBCLANG_PATH"
45+
46+
# Publish sys crate first
47+
pushd ./rust/cuvs-sys
48+
cargo publish --token ${CARGO_REGISTRY_TOKEN}
49+
popd
50+
51+
# Wait for crates.io index update
52+
sleep 30
53+
54+
# Publish main crate
55+
pushd ./rust/cuvs
56+
cargo publish --token ${CARGO_REGISTRY_TOKEN}
57+
popd
58+
env:
59+
CARGO_REGISTRY_TOKEN: ${{ secrets.GPUTESTER_CRATES_TOKEN }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file is generated by `rapids-dependency-file-generator`.
2+
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
3+
channels:
4+
- rapidsai
5+
- rapidsai-nightly
6+
- dask/label/dev
7+
- conda-forge
8+
- nvidia
9+
dependencies:
10+
- c-compiler
11+
- clang-tools==16.0.6
12+
- clang==16.0.6
13+
- cmake>=3.30.4
14+
- cuda-cudart-dev
15+
- cuda-nvcc
16+
- cuda-nvtx-dev
17+
- cuda-profiler-api
18+
- cuda-version=12.8
19+
- cxx-compiler
20+
- gcc_linux-aarch64=13.*
21+
- libclang==16.0.6
22+
- libcublas-dev
23+
- libcurand-dev
24+
- libcusolver-dev
25+
- libcusparse-dev
26+
- libcuvs==25.4.*,>=0.0.0a0
27+
- libraft==25.4.*,>=0.0.0a0
28+
- make
29+
- nccl>=2.19
30+
- ninja
31+
- rust
32+
- sysroot_linux-aarch64==2.28
33+
name: rust_cuda-128_arch-aarch64
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file is generated by `rapids-dependency-file-generator`.
2+
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
3+
channels:
4+
- rapidsai
5+
- rapidsai-nightly
6+
- dask/label/dev
7+
- conda-forge
8+
- nvidia
9+
dependencies:
10+
- c-compiler
11+
- clang-tools==16.0.6
12+
- clang==16.0.6
13+
- cmake>=3.30.4
14+
- cuda-cudart-dev
15+
- cuda-nvcc
16+
- cuda-nvtx-dev
17+
- cuda-profiler-api
18+
- cuda-version=12.8
19+
- cxx-compiler
20+
- gcc_linux-64=13.*
21+
- libclang==16.0.6
22+
- libcublas-dev
23+
- libcurand-dev
24+
- libcusolver-dev
25+
- libcusparse-dev
26+
- libcuvs==25.4.*,>=0.0.0a0
27+
- libraft==25.4.*,>=0.0.0a0
28+
- make
29+
- nccl>=2.19
30+
- ninja
31+
- rust
32+
- sysroot_linux-64==2.28
33+
name: rust_cuda-128_arch-x86_64

dependencies.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ files:
8181
- depends_on_libcuvs
8282
- depends_on_cuvs
8383
rust:
84-
output: none
84+
output: conda
85+
matrix:
86+
cuda: ["12.8"]
87+
arch: [x86_64, aarch64]
8588
includes:
8689
# clang/libclang only needed for bindgen support
8790
- clang

examples/rust/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,29 @@ This template project provides a drop-in sample to for using cuVS in a rust proj
55
First, please refer to our [installation docs](https://docs.rapids.ai/api/cuvs/stable/build.html#cuda-gpu-requirements) for the minimum requirements to use cuVS. Note that you will have to have the libcuvs.so and libcuvs_c.so binaries installed to compile this example project.
66

77
Once the minimum requirements are satisfied, this example template application can be built using 'cargo build', and this directory can be copied directly in order to build a new application with cuVS.
8+
9+
You may follow these steps to quickly get set up:
10+
11+
```bash
12+
conda env create --name rust -f conda/environments/rust_cuda-128_arch-x86_64.yaml
13+
conda activate rust
14+
```
15+
You may prefer to use `mamba`, as it provides significant speedup over `conda`.
16+
17+
1. Set up the required environment variables:
18+
```bash
19+
LIBCLANG_PATH=$(dirname "$(find /opt/conda -name libclang.so | head -n 1)")
20+
export LIBCLANG_PATH
21+
echo "LIBCLANG_PATH=$LIBCLANG_PATH"
22+
```
23+
24+
2. Add the cuvs dependency in your project:
25+
```TOML
26+
# Cargo.toml
27+
[dependencies]
28+
cuvs = ">=24.6.0"
29+
#...rest of your dependencies
30+
```
31+
Then you can run your project with `cargo run`.
32+
33+
See [main.rs](./src/main.rs) for an example implementation.

0 commit comments

Comments
 (0)