Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
742dba9
Fuse RaBitQ block reductions into one templated blockReduceSumN<N>
Stardust-SJF Jul 24, 2026
22172a1
Fix rescale-search shared-memory races by restructuring
Stardust-SJF Jul 25, 2026
f3a31aa
Add a standalone RaBitQ quantizer under preprocessing/quantize
Stardust-SJF Jul 26, 2026
1a5e2a3
Make the RaBitQ quantizer detail layer stream- and resource-aware
Stardust-SJF Jul 26, 2026
2c64068
Rename the RaBitQ factories init_* -> make_*
Stardust-SJF Jul 27, 2026
36028d1
Add the C API for the RaBitQ preprocessing quantizer
Stardust-SJF Jul 28, 2026
a2c5747
Merge branch 'main' into cuvs_ivf_rabitq_syn_fix_fused
tfeher Aug 3, 2026
2a1c334
Replace the RaBitQ glue kernels with raft primitives
Stardust-SJF Oct 29, 2026
93ea433
Generate the RaBitQ matmul rotation with the shared IVF-PQ helper
Stardust-SJF Oct 29, 2026
3af40d4
Add cuvsRabitqRotatorMakeFromState to restore a saved rotator
Stardust-SJF Oct 29, 2026
33020da
Batch RaBitQ transform() internally, sized to the L2 cache
Stardust-SJF Oct 29, 2026
69d8b96
Fix 32-bit factor index overflow in the RaBitQ full-factor kernel
Stardust-SJF Oct 29, 2026
e8cd13c
Accept host input in RaBitQ transform()
Stardust-SJF Oct 29, 2026
1618145
Rename pipeline to quantizer and the old quantizer to encoder in RaBitQ
Stardust-SJF Oct 30, 2026
140fab3
Merge branch 'pull-request/2362' into cuvs_ivf_rabitq_standalone_quan…
achirkin Nov 2, 2026
128268a
Merge branch 'main' into cuvs_ivf_rabitq_syn_fix_fused
achirkin Nov 2, 2026
e837738
Merge remote-tracking branch 'sjf/cuvs_ivf_rabitq_syn_fix_fused' into…
achirkin Nov 2, 2026
b5ccd94
Merge remote-tracking branch 'rapidsai/main' into pull-request/2362
achirkin Nov 2, 2026
42fcdfb
Merge branch 'pull-request/2362' into cuvs_ivf_rabitq_standalone_quan…
achirkin Nov 2, 2026
a6ad49e
Merge branch 'main' into cuvs_ivf_rabitq_standalone_quantizer
achirkin Nov 3, 2026
89d518e
Spec-based dataset api
achirkin Nov 3, 2026
8f1b9ce
Fix style
achirkin Nov 3, 2026
4a9e8f3
Fix style
achirkin Nov 3, 2026
f02247a
Merge branch 'cuvs_ivf_rabitq_standalone_quantizer' into fea-rabitq-spec
achirkin Nov 3, 2026
7db6e2f
Fix build errors
achirkin Nov 3, 2026
28ccd92
Merge branch 'cuvs_ivf_rabitq_standalone_quantizer' into fea-rabitq-spec
achirkin Nov 3, 2026
afb5f91
Merge pull request #1 from achirkin/fea-rabitq-spec
Stardust-SJF Nov 4, 2026
82b1325
Merge branch 'main' into cuvs_ivf_rabitq_standalone_quantizer
achirkin Nov 4, 2026
8e68cde
Merge remote-tracking branch 'rapidsai/main' into cuvs_ivf_rabitq_sta…
achirkin Nov 4, 2026
c6632a7
Fix the symbol visibility
achirkin Nov 4, 2026
d42a40a
Merge remote-tracking branch 'public/main' into cuvs_ivf_rabitq_stand…
Stardust-SJF Nov 5, 2026
a7f80d5
Throw instead of exiting on unsupported RaBitQ FHT dimensions
Stardust-SJF Nov 5, 2026
12ed643
Opt in to more shared memory for the RaBitQ scaling-factor kernel
Stardust-SJF Nov 5, 2026
2e5d05a
Request shared memory in the RaBitQ quantize kernels only when needed
Stardust-SJF Nov 5, 2026
b3db6d9
Forward the rescale sample counts to the RaBitQ full-factor path
Stardust-SJF Nov 5, 2026
2cc3b97
Document that RaBitQ delta is computed from signed code levels
Stardust-SJF Nov 5, 2026
6d27955
Document the 16-bit code requirement for RaBitQ ex_bits = 8
Stardust-SJF Nov 5, 2026
0a1302e
Show the RaBitQ delta formulas in the API page tables
Stardust-SJF Nov 5, 2026
3a5fa14
Update cpp/include/cuvs/preprocessing/quantize/rabitq.hpp
Stardust-SJF Nov 11, 2026
d3c0cab
Update cpp/tests/preprocessing/rabitq_quantization.cu
Stardust-SJF Nov 11, 2026
d916649
Apply the review cleanups to the RaBitQ quantizer
Stardust-SJF Nov 11, 2026
b741b07
Use cub::BlockReduce for the RaBitQ quantizer block reductions
Stardust-SJF Nov 11, 2026
c11432f
Take mdspan views in the RaBitQ quantizer detail layer
Stardust-SJF Nov 12, 2026
94ed09e
Use raft::warpReduce for the RaBitQ quantizer warp sums
Stardust-SJF Nov 22, 2026
1540b4c
Add missing cub includes
tfeher Nov 23, 2026
049f6d6
Merge branch 'release/26.12' into cuvs_ivf_rabitq_standalone_quantizer
tfeher Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply the review cleanups to the RaBitQ quantizer
Rename transform_batch_rows to get_transform_batch_size and say what it
computes. Replace the rotator's local rd_up and floor_log2 helpers with
raft::alignTo and std::bit_width; both give the same values for every
reachable dimension.

Use the shorter workspace wording from the review in all four transform()
docs (two C++ overloads, two C functions), drop the trailing space it left,
and regenerate the API pages.
  • Loading branch information
Stardust-SJF committed Nov 11, 2026
commit d916649517ae06637b7312437859ea3ced6d37b8
12 changes: 6 additions & 6 deletions c/include/cuvs/preprocessing/quantize/rabitq.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ CUVS_EXPORT cuvsError_t cuvsRabitqRotate(cuvsResources_t res,
* `cuvsRabitqQuantizerParams::ex_bits + 1` bit value, so `codes` must be
* `n_rows x padded_dim`.
*
* Rows are processed in internal batches, so the temporary float buffer holding
* the rotated residuals, allocated from the workspace resource, covers one batch
* rather than the whole dataset (a pool workspace resource is recommended).
* Rows are processed in internal batches. A temporary float buffer is used
* internally to store the rotated residuals. This is allocated from the workspace
* resource. (A pool workspace resource is recommended.)
*
* `dataset` may also be in host memory (kDLCPU). Its rows are then copied to the
* device one batch at a time, and are no longer read once the call returns.
Expand Down Expand Up @@ -340,9 +340,9 @@ CUVS_EXPORT cuvsError_t cuvsRabitqTransform(cuvsResources_t res,
* used for approximate-distance estimation during search:
* `factors[i] = { f_add, f_rescale, f_error }`.
*
* Rows are processed in internal batches, so the temporary float buffer holding
* the rotated residuals, allocated from the workspace resource, covers one batch
* rather than the whole dataset (a pool workspace resource is recommended).
* Rows are processed in internal batches. A temporary float buffer is used
* internally to store the rotated residuals. This is allocated from the workspace
* resource. (A pool workspace resource is recommended.)
* As for cuvsRabitqTransform, `dataset` may also be in host memory.
*
* The rotated centroid is an internal temporary as well. A search
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/cuvs/preprocessing/quantize/rabitq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void rotate(raft::resources const& res,
* is written per padded dimension; each holds an unsigned
* `params::ex_bits + 1` bit value, so `codes` must be `n_rows x padded_dim`.
*
* Rows are processed in internal batches. A temporary float buffer is used
* Rows are processed in internal batches. A temporary float buffer is used
* internally to store the rotated residuals. This is allocated from the workspace
* resource. (A pool workspace resource is recommended.)
*
Expand Down Expand Up @@ -459,9 +459,9 @@ void transform(raft::resources const& res,
* ones used for approximate-distance estimation during search:
* `factors[i] = { f_add, f_rescale, f_error }`.
*
* Rows are processed in internal batches, so the temporary float buffer holding
* the rotated residuals, allocated from the workspace resource, covers one batch
* rather than the whole dataset (a pool workspace resource is recommended).
* Rows are processed in internal batches. A temporary float buffer is used
* internally to store the rotated residuals. This is allocated from the workspace
* resource. (A pool workspace resource is recommended.)
* As for the `(delta, vl)` overload, `dataset` may also be on host.
*
* The rotated centroid is an internal temporary as well. A search implementation
Expand Down
17 changes: 4 additions & 13 deletions cpp/src/preprocessing/quantize/detail/rabitq/rotator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
#include <raft/core/error.hpp>
#include <raft/core/resource/cublas_handle.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/util/cuda_dev_essentials.cuh>
#include <raft/util/cuda_rt_essentials.hpp>

#include <cublas_v2.h>

#include <bit>
#include <cmath>
#include <cstdint>
#include <limits>
Expand All @@ -35,17 +37,6 @@ namespace cuvs::preprocessing::quantize::rabitq::detail {

namespace {

inline int64_t rd_up(int64_t dim, int64_t mult) { return ((dim + mult - 1) / mult) * mult; }

inline int64_t floor_log2(int64_t x)
{
int64_t r = 0;
while (x >>= 1) {
++r;
}
return r;
}

/// Derived fht_kac parameters. Recomputed on every launch from the PADDED
/// dimension, matching the standalone rotator (see its commit "Derive the
/// FHT-Kac segment size from the padded dim": the segment size follows the
Expand All @@ -60,7 +51,7 @@ struct fht_kac_derived {

inline fht_kac_derived derive_fht_kac(int64_t D)
{
const int64_t bottom_log = floor_log2(D);
const int64_t bottom_log = std::bit_width(static_cast<uint64_t>(D)) - 1;
const int64_t trunc_dim = int64_t{1} << bottom_log;
return fht_kac_derived{
trunc_dim, static_cast<int>(bottom_log), 1.0f / std::sqrt(static_cast<float>(trunc_dim))};
Expand All @@ -72,7 +63,7 @@ inline fht_kac_derived derive_fht_kac(int64_t D)
// Sizes
// ---------------------------------------------------------------------------

int64_t padded_dim(int64_t dim) { return rd_up(dim, 32); }
int64_t padded_dim(int64_t dim) { return raft::alignTo(dim, int64_t{32}); }

int64_t flip_bytes(int64_t D) { return 4 * D / 8; }

Expand Down
16 changes: 8 additions & 8 deletions cpp/src/preprocessing/quantize/rabitq.cu
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void check_factors(int64_t n_rows,
}

/**
* Rows per internal transform() batch.
* Calculate the number of rows per internal transform() batch.
*
* Every stage after the input read (pad, rotate, centroid subtraction, quantize)
* sweeps the batch's `batch x padded_dim` residual scratch, so a batch whose
Expand All @@ -140,11 +140,11 @@ void check_factors(int64_t n_rows,
* centroid, padding) and fragmentation. Host input adds `staging_row_bytes` per
* row for the buffers its rows are copied into.
*/
[[nodiscard]] auto transform_batch_rows(raft::resources const& res,
rabitq::encoder const& q,
rabitq::rotator<float> const& rot,
int64_t n_rows,
size_t staging_row_bytes) -> int64_t
[[nodiscard]] auto get_transform_batch_size(raft::resources const& res,
rabitq::encoder const& q,
rabitq::rotator<float> const& rot,
int64_t n_rows,
size_t staging_row_bytes) -> int64_t
{
constexpr int64_t kMinL2Rows = 2048;
constexpr int64_t kMaxL2Rows = 65536;
Expand Down Expand Up @@ -262,7 +262,7 @@ void transform_impl(raft::resources const& res,
auto stream = raft::resource::get_cuda_stream(res);
auto workspace = raft::resource::get_workspace_resource_ref(res);
const int64_t batch =
transform_batch_rows(res, q, rot, n_rows, staging_row_bytes<Accessor>(res, q.dim));
get_transform_batch_size(res, q, rot, n_rows, staging_row_bytes<Accessor>(res, q.dim));
rmm::device_uvector<float> residuals(
static_cast<size_t>(batch) * static_cast<size_t>(q.padded_dim), stream, workspace);
rmm::device_uvector<float> rotated_centroid(
Expand Down Expand Up @@ -314,7 +314,7 @@ void transform_full_impl(raft::resources const& res,
auto stream = raft::resource::get_cuda_stream(res);
auto workspace = raft::resource::get_workspace_resource_ref(res);
const int64_t batch =
transform_batch_rows(res, q, rot, n_rows, staging_row_bytes<Accessor>(res, q.dim));
get_transform_batch_size(res, q, rot, n_rows, staging_row_bytes<Accessor>(res, q.dim));
rmm::device_uvector<float> residuals(
static_cast<size_t>(batch) * static_cast<size_t>(q.padded_dim), stream, workspace);
// The full-factor formula always reads the rotated centroid; the detail layer
Expand Down
4 changes: 2 additions & 2 deletions fern/pages/c_api/c-api-preprocessing-quantize-rabitq.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ DLManagedTensor* vl);

Performs the whole chain: zero-pad `dim -> padded_dim`, rotate, optionally subtract the rotated centroid, then quantize the residuals. One code element is written per padded dimension; each holds an unsigned `cuvsRabitqQuantizerParams::ex_bits + 1` bit value, so `codes` must be `n_rows x padded_dim`.

Rows are processed in internal batches, so the temporary float buffer holding the rotated residuals, allocated from the workspace resource, covers one batch rather than the whole dataset (a pool workspace resource is recommended).
Rows are processed in internal batches. A temporary float buffer is used internally to store the rotated residuals. This is allocated from the workspace resource. (A pool workspace resource is recommended.)

`dataset` may also be in host memory (kDLCPU). Its rows are then copied to the device one batch at a time, and are no longer read once the call returns. Pinned (kDLCUDAHost) and managed tensors are device-accessible and are read in place. `centroid` and the outputs must be on device.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Expand Down Expand Up @@ -442,7 +442,7 @@ DLManagedTensor* factors);

Same chain as cuvsRabitqTransform, but the per-vector factors are the ones used for approximate-distance estimation during search: `factors[i] = { f_add, f_rescale, f_error }`.

Rows are processed in internal batches, so the temporary float buffer holding the rotated residuals, allocated from the workspace resource, covers one batch rather than the whole dataset (a pool workspace resource is recommended). As for cuvsRabitqTransform, `dataset` may also be in host memory.
Rows are processed in internal batches. A temporary float buffer is used internally to store the rotated residuals. This is allocated from the workspace resource. (A pool workspace resource is recommended.) As for cuvsRabitqTransform, `dataset` may also be in host memory.

The rotated centroid is an internal temporary as well. A search implementation that needs it can reproduce it exactly by zero-padding `centroid` to `padded_dim` and calling cuvsRabitqRotate with the same rotator.

Expand Down
4 changes: 2 additions & 2 deletions fern/pages/cpp_api/cpp-api-preprocessing-quantize-rabitq.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ raft::device_vector_view<float, int64_t> vl);

Performs the whole chain: zero-pad `dim -> padded_dim`, rotate, optionally subtract the rotated centroid, then quantize the residuals. One code element is written per padded dimension; each holds an unsigned `params::ex_bits + 1` bit value, so `codes` must be `n_rows x padded_dim`.

Rows are processed in internal batches, so the temporary float buffer holding the rotated residuals, allocated from the workspace resource, covers one batch rather than the whole dataset (a pool workspace resource is recommended).
Rows are processed in internal batches. A temporary float buffer is used internally to store the rotated residuals. This is allocated from the workspace resource. (A pool workspace resource is recommended.)

`dataset` may also be on host. Its rows are then copied to the device one batch at a time into workspace buffers, and are no longer read once the call returns; `centroid` and the outputs are on device either way. Host input is bound by the host-to-device copy, which is about twice as fast from pinned memory (e.g. raft::make_pinned_matrix, passed as a raft::host_matrix_view) as from pageable memory. A stream pool on `res` (raft::resource::set_cuda_stream_pool) overlaps copying each batch with quantizing the previous one.

Expand Down Expand Up @@ -603,7 +603,7 @@ raft::device_matrix_view<float, int64_t, raft::row_major> factors);

Same chain as the `(delta, vl)` overload, but the per-vector factors are the ones used for approximate-distance estimation during search: `factors[i] = { f_add, f_rescale, f_error }`.

Rows are processed in internal batches, so the temporary float buffer holding the rotated residuals, allocated from the workspace resource, covers one batch rather than the whole dataset (a pool workspace resource is recommended). As for the `(delta, vl)` overload, `dataset` may also be on host.
Rows are processed in internal batches. A temporary float buffer is used internally to store the rotated residuals. This is allocated from the workspace resource. (A pool workspace resource is recommended.) As for the `(delta, vl)` overload, `dataset` may also be on host.

The rotated centroid is an internal temporary as well. A search implementation that needs it can reproduce it exactly by zero-padding `centroid` to `padded_dim` and calling rotate() with the same rotator.

Expand Down