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
Generate the RaBitQ matmul rotation with the shared IVF-PQ helper
Following review feedback, the matmul rotator now reuses the random rotation
IVF-PQ draws instead of its own host-side Gram-Schmidt.

- The body of ivf_pq's internal make_rotation_matrix moves verbatim to
  cpp/src/preprocessing/detail/rotation_matrix.cuh as
  cuvs::preprocessing::detail::make_rotation_matrix, with the RNG state as an
  explicit argument. ivf_pq::helpers::make_rotation_matrix forwards with
  RngState(7), so IVF-PQ's matrices are unchanged.
- init_state_matmul calls it with force_random_rotation and
  RngState(params.seed). That moves an O(D^3) host step to the GPU
  (make_rotator: 372 ms -> 3.5 ms at D=1024, 8.5 s -> 15 ms at D=3072),
  improves orthogonality at large D, and uses the full 64-bit seed (the host
  mt19937 truncated it to 32 bits).
- rotate_matmul applies the stored row-major matrix as y = R x (cublasSgemm
  OP_T), the orientation IVF-PQ uses. The QR factor is not sign-normalized, so
  the matrix itself is not exactly Haar; in this orientation that only flips
  the signs of output coordinates, under which RaBitQ's codes mirror and its
  factors and estimates stay the same.
- raft::random::normal sizes its grid by the SM count, so the same seed gives
  a different matrix on a different GPU model. The C++ and C docs therefore
  drop the "store the seed and re-run make_rotator" recipe: callers keep the
  rotator's buffers alongside the codes. The docs also state the y = R x
  orientation.

fht_kac is untouched.

Tested on an RTX PRO 6000 (sm_120a):
- PREPROCESSING_TEST 368/368, RABITQ_C_TEST 2/2.
- ivf_pq::helpers::make_rotation_matrix output byte-identical to the previous
  commit for five shapes, including the identity and non-square cases.
- make_rotator(matmul) equals the helper's draw for the same seed, including a
  seed above 2^32.
- Negating random rows of R leaves transform()'s factors bit-identical and
  mirrors the codes, for dims 100/128/1000, ex_bits 1/3/7, both output modes,
  with and without a centroid.
- fht_kac transform output byte-identical to the previous commit over 40
  configurations; matmul output differs, as expected with a new matrix.
  • Loading branch information
Stardust-SJF committed Oct 29, 2026
commit 93ea43304b8318103fce9ffc2524f9141e1b05b2
12 changes: 7 additions & 5 deletions c/include/cuvs/preprocessing/quantize/rabitq.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct cuvsRabitqQuantizerParams {
/** Random-rotation implementation. */
enum cuvsRabitqRotatorKind rotator;
/**
* Seed for the host RNG that draws the rotation state and the random probe
* Seed for the RNGs that draw the rotation state and the random probe
* vectors used to estimate the constant scaling factor.
*/
uint64_t seed;
Expand Down Expand Up @@ -115,9 +115,10 @@ CUVS_EXPORT cuvsError_t cuvsRabitqQuantizerParamsDestroy(cuvsRabitqQuantizerPara
* representation: codes produced with one rotator are only comparable to
* queries transformed by the very same rotator. There is deliberately no
* serialization API, so the caller owns this handle and is responsible for
* keeping it alongside the codes (either by storing the seed and re-running
* cuvsRabitqRotatorMake, or by copying the buffers returned by
* cuvsRabitqRotatorGetState into its own index format).
* keeping it alongside the codes, by copying the buffers returned by
* cuvsRabitqRotatorGetState into its own index format. Re-running
* cuvsRabitqRotatorMake with the same params reproduces them only on the same
* GPU model and library version.
*
* A rotator is an independent peer of the quantizer: neither contains the
* other, and a single rotator may be shared by several quantizers.
Expand Down Expand Up @@ -418,7 +419,8 @@ CUVS_EXPORT cuvsError_t cuvsRabitqRotatorGetPaddedDim(cuvsRabitqRotator_t rotato
*
* The shape and dtype depend on cuvsRabitqRotatorGetKind:
* - ::CUVS_RABITQ_ROTATOR_KIND_MATMUL fills in the `padded_dim x padded_dim`
* row-major float32 rotation matrix.
* row-major float32 rotation matrix `R`; cuvsRabitqRotate maps each row `x`
* to `R x`.
* - ::CUVS_RABITQ_ROTATOR_KIND_FHT_KAC fills in the packed sign bits of the four
* Kac's-walk passes, a `4 * padded_dim / 8` element uint8 vector.
*
Expand Down
13 changes: 7 additions & 6 deletions cpp/include/cuvs/preprocessing/quantize/rabitq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct params {
/** Random-rotation implementation. */
rotator_kind rotator = rotator_kind::fht_kac;
/**
* Seed for the host RNG that draws the rotation state and the random probe
* Seed for the RNGs that draw the rotation state and the random probe
* vectors used to estimate the constant scaling factor.
*/
uint64_t seed = 12345ULL;
Expand All @@ -98,9 +98,10 @@ struct params {
* `params::seed` - but it *is* part of the code representation: codes produced
* with one rotator are only comparable to queries transformed by the very same
* rotator. There is deliberately no serialization API here, so the caller owns
* this object and is responsible for keeping it alongside the codes (e.g. by
* storing `params::seed` and re-running make_rotator, or by embedding the
* buffers below in its own index format).
* this object and is responsible for keeping it alongside the codes, by
* embedding the buffers below in its own index format. Re-running make_rotator
* with the same `params` reproduces them only on the same GPU model and
* library version.
*
* A rotator is an independent peer of the quantizer: neither contains the
* other, and a single rotator may be shared by several quantizers.
Expand All @@ -118,8 +119,8 @@ struct rotator {
*/
int64_t padded_dim = 0;
/**
* `padded_dim x padded_dim` row-major random orthogonal matrix.
* Empty unless `kind == rotator_kind::matmul`.
* `padded_dim x padded_dim` row-major random orthogonal matrix `R`; rotate()
* maps each row `x` to `R x`. Empty unless `kind == rotator_kind::matmul`.
*/
raft::device_matrix<float, int64_t, raft::row_major> rotation_matrix;
/**
Expand Down
36 changes: 7 additions & 29 deletions cpp/src/neighbors/ivf_pq/ivf_pq_build_common.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "../../core/nvtx.hpp"
#include "../../preprocessing/detail/rotation_matrix.cuh"
#include "ivf_pq_build.cuh"
#include <cuvs/distance/distance.hpp>
#include <cuvs/neighbors/common.hpp>
Expand Down Expand Up @@ -232,34 +233,6 @@ void reset_index(const raft::resources& res, index<int64_t>* index)
index->inds_ptrs().data_handle(), index->inds_ptrs().size(), stream);
}

void make_rotation_matrix(raft::resources const& handle,
bool force_random_rotation,
uint32_t n_rows,
uint32_t n_cols,
float* rotation_matrix,
raft::random::RngState rng = raft::random::RngState(7ULL))
{
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope(
"ivf_pq::make_rotation_matrix(%u * %u)", n_rows, n_cols);
auto stream = raft::resource::get_cuda_stream(handle);
bool inplace = n_rows == n_cols;
uint32_t n = std::max(n_rows, n_cols);
if (force_random_rotation || !inplace) {
rmm::device_uvector<float> buf(inplace ? 0 : n * n, stream);
float* mat = inplace ? rotation_matrix : buf.data();
raft::random::normal(handle, rng, mat, n * n, 0.0f, 1.0f);
raft::linalg::detail::qrGetQ_inplace(handle, mat, n, n, stream);
if (!inplace) { raft::copy_matrix(rotation_matrix, n_cols, mat, n, n_cols, n_rows, stream); }
} else {
uint32_t stride = n + 1;
auto rotation_matrix_view =
raft::make_device_vector_view<float, uint32_t>(rotation_matrix, n * n);
raft::linalg::map_offset(handle, rotation_matrix_view, [stride] __device__(uint32_t i) {
return static_cast<float>(i % stride == 0u);
});
}
}

void extract_centers(raft::resources const& res,
const cuvs::neighbors::ivf_pq::index<int64_t>& index,
raft::device_matrix_view<float, int64_t, raft::row_major> cluster_centers)
Expand Down Expand Up @@ -290,7 +263,12 @@ void make_rotation_matrix(
uint32_t rot_dim = rotation_matrix.extent(0);
uint32_t dim = rotation_matrix.extent(1);

make_rotation_matrix(res, force_random_rotation, rot_dim, dim, rotation_matrix.data_handle());
cuvs::preprocessing::detail::make_rotation_matrix(res,
force_random_rotation,
rot_dim,
dim,
rotation_matrix.data_handle(),
raft::random::RngState(7ULL));
}

void pad_centers_with_norms(
Expand Down
63 changes: 63 additions & 0 deletions cpp/src/preprocessing/detail/rotation_matrix.cuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION.
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include "../../core/nvtx.hpp"

#include <raft/core/device_mdspan.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resources.hpp>
#include <raft/linalg/detail/qr.cuh>
#include <raft/linalg/map.cuh>
#include <raft/random/rng.cuh>
#include <raft/util/cudart_utils.hpp>

#include <rmm/device_uvector.hpp>

#include <algorithm>
#include <cstdint>

namespace cuvs::preprocessing::detail {

/**
* Fill `rotation_matrix` with an `n_rows x n_cols` random orthogonal matrix (the identity when
* the matrix is square and `force_random_rotation` is false), drawn from `rng`. Shared by IVF-PQ
* and the RaBitQ quantizer.
*
* The matrix is the Q factor of a Gaussian matrix, read back row-major, so it is meant to be
* applied as `y = R x`. QR does not normalize the signs of its triangular factor's diagonal, so the
* matrix itself is not exactly Haar-distributed; applied as `y = R x` that only flips the signs of
* output coordinates.
*/
inline void make_rotation_matrix(raft::resources const& handle,
bool force_random_rotation,
uint32_t n_rows,
uint32_t n_cols,
float* rotation_matrix,
raft::random::RngState rng)
{
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope(
"preprocessing::make_rotation_matrix(%u * %u)", n_rows, n_cols);
auto stream = raft::resource::get_cuda_stream(handle);
bool inplace = n_rows == n_cols;
uint32_t n = std::max(n_rows, n_cols);
if (force_random_rotation || !inplace) {
rmm::device_uvector<float> buf(inplace ? 0 : n * n, stream);
float* mat = inplace ? rotation_matrix : buf.data();
raft::random::normal(handle, rng, mat, n * n, 0.0f, 1.0f);
raft::linalg::detail::qrGetQ_inplace(handle, mat, n, n, stream);
if (!inplace) { raft::copy_matrix(rotation_matrix, n_cols, mat, n, n_cols, n_rows, stream); }
} else {
uint32_t stride = n + 1;
auto rotation_matrix_view =
raft::make_device_vector_view<float, uint32_t>(rotation_matrix, n * n);
raft::linalg::map_offset(handle, rotation_matrix_view, [stride] __device__(uint32_t i) {
return static_cast<float>(i % stride == 0u);
});
}
}

} // namespace cuvs::preprocessing::detail
72 changes: 19 additions & 53 deletions cpp/src/preprocessing/quantize/detail/rabitq/rotator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Imported from the standalone RaBitQ GPU quantizer. Behaviour unchanged;
* only include paths, error macros and the enclosing namespace differ.
* Imported from the standalone RaBitQ GPU quantizer. Behaviour unchanged
* except for the matmul rotator: its matrix comes from the shared
* preprocessing helper and is applied as y = P x.
*/

//
// Rotator state generation and launchers — matmul and fht_kac.
// The random orthogonal matrix is generated on the CPU via modified
// Gram-Schmidt so this file has no Eigen dependency.
// The random orthogonal matrix comes from the preprocessing helper that
// IVF-PQ uses too.
//

#include "../../../detail/rotation_matrix.cuh"
#include "fht.cuh"
#include "rotator.cuh"

Expand All @@ -25,6 +27,7 @@

#include <cmath>
#include <cstdint>
#include <limits>
#include <random>
#include <vector>

Expand All @@ -43,45 +46,6 @@ inline int64_t floor_log2(int64_t x)
return r;
}

// ---------------------------------------------------------------------------
// Modified Gram-Schmidt on a random Gaussian D×D matrix. Produces Q that is
// orthonormal in rows; equivalent to Q from a QR decomposition modulo sign
// conventions. Numerically stable enough for the few-thousand dimensions used
// by RaBitQ. Output is row-major.
// ---------------------------------------------------------------------------
std::vector<float> random_orthogonal_matrix(int64_t D, uint64_t seed)
{
const size_t d = static_cast<size_t>(D);
std::vector<float> M(d * d);
std::mt19937 gen(static_cast<uint32_t>(seed));
std::normal_distribution<float> dist(0.0f, 1.0f);
for (size_t i = 0; i < d * d; ++i)
M[i] = dist(gen);

// Modified Gram-Schmidt on rows (in double for stability).
std::vector<double> row(d);
for (size_t i = 0; i < d; ++i) {
for (size_t k = 0; k < d; ++k)
row[k] = M[i * d + k];

for (size_t j = 0; j < i; ++j) {
double dot = 0.0;
for (size_t k = 0; k < d; ++k)
dot += row[k] * M[j * d + k];
for (size_t k = 0; k < d; ++k)
row[k] -= dot * M[j * d + k];
}

double norm_sq = 0.0;
for (size_t k = 0; k < d; ++k)
norm_sq += row[k] * row[k];
double inv_norm = 1.0 / std::sqrt(norm_sq);
for (size_t k = 0; k < d; ++k)
M[i * d + k] = static_cast<float>(row[k] * inv_norm);
}
return M;
}

/// 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 Down Expand Up @@ -116,14 +80,16 @@ int64_t flip_bytes(int64_t D) { return 4 * D / 8; }
// State generation
// ---------------------------------------------------------------------------

void init_state_matmul(cudaStream_t stream, uint64_t seed, int64_t D, float* d_P_out)
void init_state_matmul(raft::resources const& res, uint64_t seed, int64_t D, float* d_P_out)
{
RAFT_EXPECTS(D > 0, "rotator: padded dimension must be positive");
std::vector<float> h_P = random_orthogonal_matrix(D, seed);
RAFT_CUDA_TRY(cudaMemcpyAsync(
d_P_out, h_P.data(), sizeof(float) * h_P.size(), cudaMemcpyHostToDevice, stream));
// h_P is plain host memory and dies with this scope.
RAFT_CUDA_TRY(cudaStreamSynchronize(stream));
RAFT_EXPECTS(D > 0 && D <= std::numeric_limits<uint16_t>::max(),
"rotator: matmul padded dimension must be in [1, 65535]");
cuvs::preprocessing::detail::make_rotation_matrix(res,
true,
static_cast<uint32_t>(D),
static_cast<uint32_t>(D),
d_P_out,
raft::random::RngState(seed));
}

void init_state_fht_kac(cudaStream_t stream, uint64_t seed, int64_t D, uint8_t* d_flip_out)
Expand Down Expand Up @@ -158,10 +124,10 @@ void rotate_matmul(raft::resources const& res,
const float beta = 0.0f;
auto cublas_h = raft::resource::get_cublas_handle(res);
RAFT_CUBLAS_TRY(cublasSetStream(cublas_h, raft::resource::get_cuda_stream(res)));
// Row-major row-of-A (size D) is reinterpreted as column-of-A in column-major;
// compute C = P · A by calling sgemm with leading dims = D in both inputs.
// Row-major row-of-A (size D) is reinterpreted as column-of-A in column-major,
// and row-major P reads as P^T; compute C = P · A by transposing it back.
RAFT_CUBLAS_TRY(cublasSgemm(cublas_h,
CUBLAS_OP_N,
CUBLAS_OP_T,
CUBLAS_OP_N,
static_cast<int>(D),
static_cast<int>(N),
Expand Down
17 changes: 9 additions & 8 deletions cpp/src/preprocessing/quantize/detail/rabitq/rotator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Imported from the standalone RaBitQ GPU quantizer. Behaviour unchanged;
* only include paths, error macros and the enclosing namespace differ.
* Imported from the standalone RaBitQ GPU quantizer. Behaviour unchanged
* except for the matmul rotator: its matrix comes from the shared
* preprocessing helper and is applied as y = P x.
*/

//
Expand Down Expand Up @@ -45,16 +46,16 @@ namespace cuvs::preprocessing::quantize::rabitq::detail {
[[nodiscard]] int64_t flip_bytes(int64_t D);

// ---------------------------------------------------------------------------
// State generation. Writes into device buffers provided by the caller. The
// draw happens on the host (std::mt19937, identical to the standalone code),
// so both calls stage through pinned-free host memory and therefore
// synchronize `stream` before returning.
// State generation. Writes into device buffers provided by the caller.
// ---------------------------------------------------------------------------

/// Fill `d_P_out` (D * D floats, row-major) with a random orthogonal matrix.
void init_state_matmul(cudaStream_t stream, uint64_t seed, int64_t D, float* d_P_out);
/// Fill `d_P_out` (D * D floats, row-major) with a random orthogonal matrix,
/// drawn on the device with the preprocessing helper IVF-PQ uses too.
void init_state_matmul(raft::resources const& res, uint64_t seed, int64_t D, float* d_P_out);

/// Fill `d_flip_out` (`flip_bytes(D)` bytes) with the Kac's-walk sign bits.
/// The draw happens on the host (std::mt19937, identical to the standalone
/// code), so this stages through host memory and synchronizes `stream`.
void init_state_fht_kac(cudaStream_t stream, uint64_t seed, int64_t D, uint8_t* d_flip_out);

// ---------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/preprocessing/quantize/rabitq.cu
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ rotator make_rotator(raft::resources const& res, params const& params, int64_t d
if (rot.kind == rotator_kind::matmul) {
rot.rotation_matrix = raft::make_device_matrix<float, int64_t, raft::row_major>(
res, rot.padded_dim, rot.padded_dim);
detail::init_state_matmul(
stream, params.seed, rot.padded_dim, rot.rotation_matrix.data_handle());
detail::init_state_matmul(res, params.seed, rot.padded_dim, rot.rotation_matrix.data_handle());
} else {
rot.flip_bits =
raft::make_device_vector<uint8_t, int64_t>(res, detail::flip_bytes(rot.padded_dim));
Expand Down
8 changes: 3 additions & 5 deletions cpp/tests/preprocessing/rabitq_quantization.cu
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ class RabitqQuantizationTest : public ::testing::TestWithParam<RabitqQuantizatio
verify_shape(pipe.rotator, pipe.quantizer);
verify_state(pipe.rotator);

// The peers built on their own must be interchangeable with the pipeline's:
// that is what makes the header's "store the seed and re-run make_rotator"
// recipe safe.
// The peers built on their own must be interchangeable with the pipeline's.
auto rot = make_rotator(handle_, p, ps_.dim);
auto quant = make_quantizer(handle_, p, ps_.dim);
verify_shape(rot, quant);
Expand Down Expand Up @@ -569,8 +567,8 @@ const std::vector<RabitqQuantizationInputs> generate_inputs_narrow()
{rotator_kind::matmul, rotator_kind::fht_kac},
{1u, 3u},
{true});
// dim = 960 exercises the non-power-of-two FHT with trunc_dim = 512. Only one
// matmul instance there: its rotation matrix costs O(dim^3) host work.
// dim = 960 exercises the non-power-of-two FHT with trunc_dim = 512, and one
// matmul instance covers the same width.
auto fht_960 = raft::util::itertools::product<RabitqQuantizationInputs>(
{13, 1000}, {960}, {rotator_kind::fht_kac}, {3u}, {true});
auto matmul_960 = raft::util::itertools::product<RabitqQuantizationInputs>(
Expand Down