Skip to content

Commit 429e621

Browse files
Merge branch 'fea/cuvs_c_standalone_ci' into pull-request/1438
2 parents 71deda7 + 577f54e commit 429e621

File tree

12 files changed

+374
-60
lines changed

12 files changed

+374
-60
lines changed

.github/workflows/build.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: build
33
on:
44
push:
55
branches:
6-
- "branch-*"
6+
- "main"
77
tags:
88
- v[0-9][0-9].[0-9][0-9].[0-9][0-9]
99
workflow_dispatch:
@@ -34,7 +34,7 @@ concurrency:
3434
jobs:
3535
cpp-build:
3636
secrets: inherit
37-
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.12
37+
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@main
3838
with:
3939
build_type: ${{ inputs.build_type || 'branch' }}
4040
branch: ${{ inputs.branch }}
@@ -65,7 +65,7 @@ jobs:
6565
rust-build:
6666
needs: cpp-build
6767
secrets: inherit
68-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
68+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
6969
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
7070
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
7171
strategy:
@@ -86,7 +86,7 @@ jobs:
8686
go-build:
8787
needs: cpp-build
8888
secrets: inherit
89-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
89+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
9090
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
9191
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
9292
strategy:
@@ -107,7 +107,7 @@ jobs:
107107
java-build:
108108
needs: cpp-build
109109
secrets: inherit
110-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
110+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
111111
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
112112
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
113113
strategy:
@@ -129,7 +129,7 @@ jobs:
129129
python-build:
130130
needs: [cpp-build]
131131
secrets: inherit
132-
uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.12
132+
uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@main
133133
with:
134134
build_type: ${{ inputs.build_type || 'branch' }}
135135
branch: ${{ inputs.branch }}
@@ -139,7 +139,7 @@ jobs:
139139
upload-conda:
140140
needs: [cpp-build, python-build]
141141
secrets: inherit
142-
uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.12
142+
uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@main
143143
with:
144144
build_type: ${{ inputs.build_type || 'branch' }}
145145
branch: ${{ inputs.branch }}
@@ -154,7 +154,7 @@ jobs:
154154
if: github.ref_type == 'branch'
155155
needs: python-build
156156
secrets: inherit
157-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
157+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
158158
with:
159159
arch: "amd64"
160160
branch: ${{ inputs.branch }}
@@ -166,7 +166,7 @@ jobs:
166166
sha: ${{ inputs.sha }}
167167
wheel-build-libcuvs:
168168
secrets: inherit
169-
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.12
169+
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@main
170170
with:
171171
build_type: ${{ inputs.build_type || 'branch' }}
172172
branch: ${{ inputs.branch }}
@@ -180,7 +180,7 @@ jobs:
180180
wheel-publish-libcuvs:
181181
needs: wheel-build-libcuvs
182182
secrets: inherit
183-
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.12
183+
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@main
184184
with:
185185
build_type: ${{ inputs.build_type || 'branch' }}
186186
branch: ${{ inputs.branch }}
@@ -191,7 +191,7 @@ jobs:
191191
wheel-build-cuvs:
192192
needs: wheel-build-libcuvs
193193
secrets: inherit
194-
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.12
194+
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@main
195195
with:
196196
build_type: ${{ inputs.build_type || 'branch' }}
197197
branch: ${{ inputs.branch }}
@@ -203,7 +203,7 @@ jobs:
203203
wheel-publish-cuvs:
204204
needs: wheel-build-cuvs
205205
secrets: inherit
206-
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.12
206+
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@main
207207
with:
208208
build_type: ${{ inputs.build_type || 'branch' }}
209209
branch: ${{ inputs.branch }}

.github/workflows/pr.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- devcontainer
3232
- telemetry-setup
3333
secrets: inherit
34-
uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.12
34+
uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@main
3535
if: always()
3636
with:
3737
needs: ${{ toJSON(needs) }}
@@ -58,7 +58,7 @@ jobs:
5858
changed-files:
5959
needs: telemetry-setup
6060
secrets: inherit
61-
uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.12
61+
uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@main
6262
with:
6363
files_yaml: |
6464
test_cpp:
@@ -134,44 +134,44 @@ jobs:
134134
checks:
135135
needs: telemetry-setup
136136
secrets: inherit
137-
uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.12
137+
uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@main
138138
with:
139139
enable_check_generated_files: false
140140
ignored_pr_jobs: "telemetry-summarize"
141141
conda-cpp-build:
142142
needs: checks
143143
secrets: inherit
144-
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.12
144+
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@main
145145
with:
146146
build_type: pull-request
147147
node_type: cpu16
148148
script: ci/build_cpp.sh
149149
conda-cpp-tests:
150150
needs: [conda-cpp-build, changed-files]
151151
secrets: inherit
152-
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.12
152+
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@main
153153
if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp
154154
with:
155155
build_type: pull-request
156156
script: ci/test_cpp.sh
157157
conda-cpp-checks:
158158
needs: conda-cpp-build
159159
secrets: inherit
160-
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-post-build-checks.yaml@branch-25.12
160+
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-post-build-checks.yaml@main
161161
with:
162162
build_type: pull-request
163163
symbol_exclusions: (void (thrust::|cub::))
164164
conda-python-build:
165165
needs: conda-cpp-build
166166
secrets: inherit
167-
uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.12
167+
uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@main
168168
with:
169169
build_type: pull-request
170170
script: ci/build_python.sh
171171
conda-python-tests:
172172
needs: [conda-python-build, changed-files]
173173
secrets: inherit
174-
uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.12
174+
uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@main
175175
if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python
176176
with:
177177
build_type: pull-request
@@ -262,7 +262,7 @@ jobs:
262262
conda-java-tests:
263263
needs: [conda-cpp-build, changed-files]
264264
secrets: inherit
265-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
265+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
266266
if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_java || fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp
267267
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
268268
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
@@ -283,7 +283,7 @@ jobs:
283283
docs-build:
284284
needs: conda-python-build
285285
secrets: inherit
286-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
286+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
287287
with:
288288
build_type: pull-request
289289
node_type: "gpu-l4-latest-1"
@@ -293,7 +293,7 @@ jobs:
293293
rust-build:
294294
needs: [conda-cpp-build, changed-files]
295295
secrets: inherit
296-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
296+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
297297
if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_rust || fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp
298298
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
299299
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
@@ -331,7 +331,7 @@ jobs:
331331
wheel-build-libcuvs:
332332
needs: checks
333333
secrets: inherit
334-
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.12
334+
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@main
335335
with:
336336
build_type: pull-request
337337
script: ci/build_wheel_libcuvs.sh
@@ -342,7 +342,7 @@ jobs:
342342
wheel-build-cuvs:
343343
needs: wheel-build-libcuvs
344344
secrets: inherit
345-
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.12
345+
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@main
346346
with:
347347
build_type: pull-request
348348
script: ci/build_wheel_cuvs.sh
@@ -351,15 +351,15 @@ jobs:
351351
wheel-tests-cuvs:
352352
needs: [wheel-build-cuvs, changed-files]
353353
secrets: inherit
354-
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.12
354+
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@main
355355
if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python
356356
with:
357357
build_type: pull-request
358358
script: ci/test_wheel_cuvs.sh
359359
devcontainer:
360360
secrets: inherit
361361
needs: telemetry-setup
362-
uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.12
362+
uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@main
363363
with:
364364
arch: '["amd64", "arm64"]'
365365
cuda: '["13.0"]'

.github/workflows/test.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ on:
2525
jobs:
2626
conda-cpp-checks:
2727
secrets: inherit
28-
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-post-build-checks.yaml@branch-25.12
28+
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-post-build-checks.yaml@main
2929
with:
3030
build_type: ${{ inputs.build_type }}
3131
branch: ${{ inputs.branch }}
@@ -34,7 +34,7 @@ jobs:
3434
symbol_exclusions: (void (thrust::|cub::))
3535
conda-cpp-tests:
3636
secrets: inherit
37-
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.12
37+
uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@main
3838
with:
3939
build_type: ${{ inputs.build_type }}
4040
branch: ${{ inputs.branch }}
@@ -43,7 +43,7 @@ jobs:
4343
sha: ${{ inputs.sha }}
4444
conda-python-tests:
4545
secrets: inherit
46-
uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.12
46+
uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@main
4747
with:
4848
build_type: ${{ inputs.build_type }}
4949
branch: ${{ inputs.branch }}
@@ -52,7 +52,7 @@ jobs:
5252
sha: ${{ inputs.sha }}
5353
conda-java-tests:
5454
secrets: inherit
55-
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.12
55+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
5656
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
5757
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
5858
strategy:
@@ -72,7 +72,7 @@ jobs:
7272
script: "ci/test_java.sh"
7373
wheel-tests-cuvs:
7474
secrets: inherit
75-
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.12
75+
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@main
7676
with:
7777
build_type: ${{ inputs.build_type }}
7878
branch: ${{ inputs.branch }}

.github/workflows/trigger-breaking-change-alert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
trigger-notifier:
1313
if: contains(github.event.pull_request.labels.*.name, 'breaking')
1414
secrets: inherit
15-
uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.12
15+
uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@main
1616
with:
1717
sender_login: ${{ github.event.sender.login }}
1818
sender_avatar: ${{ github.event.sender.avatar_url }}

RAPIDS_BRANCH

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
branch-25.12
1+
main

ci/build_standalone_c.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ CMAKE_VERSION=3.31.8
88
CMAKE_ARCH=x86_64
99

1010
dnf install -y \
11-
gcc-toolset-${TOOLSET_VERSION} \
1211
patch \
1312
tar \
14-
make \
15-
wget
13+
make
1614

1715
# Fetch and install CMake.
1816
pushd /usr/local
@@ -40,7 +38,6 @@ RAPIDS_ARTIFACTS_DIR=${RAPIDS_ARTIFACTS_DIR:-"${PWD}/artifacts"}
4038
mkdir -p "${RAPIDS_ARTIFACTS_DIR}"
4139
export RAPIDS_ARTIFACTS_DIR
4240

43-
4441
scl enable gcc-toolset-${TOOLSET_VERSION} -- \
4542
cmake -S cpp -B cpp/build/temp/ \
4643
-DCMAKE_CUDA_HOST_COMPILER=/opt/rh/gcc-toolset-${TOOLSET_VERSION}/root/usr/bin/gcc \

cpp/include/cuvs/neighbors/scann.hpp

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <raft/util/integer_utils.hpp>
3131
#include <rmm/cuda_stream_view.hpp>
3232

33+
#include <cmath>
3334
#include <optional>
3435
#include <variant>
3536

@@ -74,9 +75,20 @@ struct index_params : cuvs::neighbors::index_params {
7475
uint32_t pq_train_iters = 10;
7576

7677
/** whether to apply bf16 quantization of dataset vectors **/
77-
bool bf16_enabled = false;
78-
79-
// TODO - add other scann build params
78+
bool reordering_bf16 = false;
79+
80+
/** Threshold T for computing AVQ eta = (dim - 1) ( T^2 / || x ||^2) / ( 1 - T^2 / || x ||^2)
81+
*
82+
* When quantizing a vector x to x_q, AVQ minimizes the loss function
83+
* L(x, x_q) = eta * || r_para ||^2 + || r_perp ||^2, where
84+
* r = x - x_q, r_para = <r, x> * x / || x ||^2, r_perp = r - r_para
85+
*
86+
* Compared to L2 loss, This produces an x_q which better approximates
87+
* the dot product of a query vector with x
88+
*
89+
* If the threshold is NAN, AVQ is not performed during bfloat16 quant
90+
*/
91+
float reordering_noise_shaping_threshold = NAN;
8092
};
8193

8294
/**
@@ -136,7 +148,7 @@ struct index : cuvs::neighbors::index {
136148
IdxT dim,
137149
uint32_t pq_clusters,
138150
uint32_t pq_num_subspaces,
139-
bool bf16_enabled)
151+
bool reordering_bf16)
140152
: cuvs::neighbors::index(),
141153
metric_(metric),
142154
pq_dim_(pq_dim),
@@ -154,7 +166,7 @@ struct index : cuvs::neighbors::index {
154166
n_rows_(n_rows),
155167
dim_(dim),
156168
bf16_dataset_(raft::make_host_matrix<int16_t, IdxT, raft::row_major>(
157-
bf16_enabled ? n_rows : 0, bf16_enabled ? dim : 0))
169+
reordering_bf16 ? n_rows : 0, reordering_bf16 ? dim : 0))
158170

159171
{
160172
}
@@ -169,7 +181,7 @@ struct index : cuvs::neighbors::index {
169181
dim,
170182
1 << params.pq_bits,
171183
dim / params.pq_dim,
172-
params.bf16_enabled)
184+
params.reordering_bf16)
173185
{
174186
RAFT_EXPECTS(params.pq_bits == 4 || params.pq_bits == 8, "ScaNN only supports 4 or 8 bit PQ");
175187
RAFT_EXPECTS(dim >= params.pq_dim,
@@ -260,9 +272,21 @@ struct index : cuvs::neighbors::index {
260272
raft::device_matrix<float, uint32_t, raft::row_major> pq_codebook_;
261273
raft::host_matrix<uint8_t, IdxT, raft::row_major> quantized_residuals_;
262274
raft::host_matrix<uint8_t, IdxT, raft::row_major> quantized_soar_residuals_;
275+
276+
/* Internally, __nv_bfloat16 is used for float <-> __nv_bfloat16 conversion.
277+
* The bits of __nv_bfloat16 are stored here reinterpreted as int16_t
278+
*
279+
* int16_t is used for two reaosns:
280+
* * OSS ScaNN expects int16_t, so the serialzed bf16_dataset_ can be consumed
281+
* without any additional post-processing
282+
* * For AVQ, we need to find the next bfloat16 number that is larger/smaller than a
283+
* given float. This is equivalent to incrementing/decrementing the mantissa
284+
* in IEEE representation of the bfloat16 number, which in turn is equivalent
285+
* to incrementing/decrementing the int16_t representation
286+
*/
263287
raft::host_matrix<int16_t, IdxT, raft::row_major> bf16_dataset_;
264-
// TODO - add any data, pointers or structures needed
265288
};
289+
266290
/**
267291
* @}
268292
*/

0 commit comments

Comments
 (0)