Skip to content

Commit dc9f53d

Browse files
committed
Fix compile errors from merging Dataset Specs (#2858)
Semantic conflicts between this PR and #2858 broke the build after the upstream/main merge: - detail/pq.cuh: vpq_build returns device_vpq_dataset<StoreMathT, IdxT> again. Our edit to the adjacent signature line had taken precedence in the conflict resolution and dropped #2858's return-type fix. - pq.hpp: the dataset branch of make_device_pq_dataset uses the new dataset_view API (data_const_view(), dim()) instead of the removed view()/stride()/extent()/data_handle(). Doc example uses view(). - tiered_index.cu: call cagra::detail::convert_standard_to_padded_index, since the public declaration was removed by this PR. - test_float_uint32_t.cu: as_dataset_view() -> view().
1 parent 0b7d89e commit dc9f53d

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎cpp/include/cuvs/preprocessing/quantize/pq.hpp‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ namespace detail {
271271
*
272272
* Accepts either a row-major mdspan with `value_type`, `extent`, `stride`, and `data_handle` (same
273273
* pattern as `cuvs::neighbors::make_device_padded_dataset`), or any cuVS dense dataset / dataset
274-
* view exposing `data_const_view`, in which case the logical `dim()` is quantized and the row
275-
* padding is skipped. The rows may be device-accessible or host-resident. Device-accessible
274+
* view exposing `data_const_view` and `dim`, in which case the logical `dim()` is quantized and the
275+
* row padding is skipped. The rows may be device-accessible or host-resident. Device-accessible
276276
* rows (device, managed or pinned) with tight row-major storage (logical stride equals dimension)
277277
* are passed through to training as they are; a wider row pitch triggers a contiguous dense copy
278278
* first. Host-resident rows are subsampled for training and encoded in bounded batches, so the
@@ -294,8 +294,8 @@ namespace detail {
294294
* Keep the `device_vpq_dataset` alive; the index holds a non-owning view.
295295
*
296296
* auto pq = cuvs::preprocessing::quantize::pq::make_device_pq_dataset(res, pq_params, padded);
297-
* auto pq_idx = cuvs::neighbors::cagra::update_dataset(res, std::move(idx), pq.as_dataset_view());
298-
* // or: auto idx = cuvs::neighbors::cagra::build(res, cagra_params, pq.as_dataset_view());
297+
* auto pq_idx = cuvs::neighbors::cagra::update_dataset(res, std::move(idx), pq.view());
298+
* // or: auto idx = cuvs::neighbors::cagra::build(res, cagra_params, pq.view());
299299
* @endcode
300300
*/
301301
template <typename SrcT>
@@ -304,13 +304,12 @@ template <typename SrcT>
304304
SrcT const& src)
305305
-> cuvs::neighbors::device_vpq_dataset<half, int64_t>
306306
{
307-
// A cuVS dataset keeps its logical width in `dim()` while `view()` spans the full row pitch.
307+
// A cuVS dataset keeps its logical width in `dim()` while its data view spans the full row pitch.
308308
if constexpr (requires {
309-
src.view();
309+
src.data_const_view();
310310
src.dim();
311-
src.stride();
312311
}) {
313-
auto const rows = src.view();
312+
auto const rows = src.data_const_view();
314313
using value_type = typename decltype(rows)::value_type;
315314
using extents_type = raft::matrix_extent<int64_t>;
316315
return make_device_pq_dataset(
@@ -319,7 +318,7 @@ template <typename SrcT>
319318
raft::mdspan<const value_type, extents_type, raft::layout_stride>{
320319
rows.data_handle(),
321320
raft::make_strided_layout(extents_type{rows.extent(0), int64_t{src.dim()}},
322-
cuda::std::array<int64_t, 2>{int64_t{src.stride()}, 1})});
321+
cuda::std::array<int64_t, 2>{int64_t{rows.stride(0)}, 1})});
323322
} else {
324323
using value_type = typename SrcT::value_type;
325324
static_assert(std::is_same_v<value_type, float> || std::is_same_v<value_type, half> ||

‎cpp/src/neighbors/tiered_index.cu‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ auto convert_standard_to_padded_index(
100100
static_cast<int64_t>(idx.state->ann_rows()),
101101
padded_dataset.dim(),
102102
padded_mds.stride(0));
103-
auto ann_padded_idx = cuvs::neighbors::cagra::convert_standard_to_padded_index(
103+
auto ann_padded_idx = cuvs::neighbors::cagra::detail::convert_standard_to_padded_index(
104104
res, *idx.state->ann_index, ann_padded_view);
105105
next_state->ann_index =
106106
std::make_shared<cuvs::neighbors::cagra::device_padded_index<float, uint32_t>>(

‎cpp/src/preprocessing/quantize/detail/pq.cuh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ void inverse_transform(
338338
template <typename DatasetT, typename MathT, typename IdxT, typename StoreMathT = MathT>
339339
auto vpq_build(const raft::resources& res,
340340
const cuvs::preprocessing::quantize::pq::params& params,
341-
const DatasetT& dataset) -> cuvs::neighbors::device_vpq_dataset<MathT, IdxT>
341+
const DatasetT& dataset) -> cuvs::neighbors::device_vpq_dataset<StoreMathT, IdxT>
342342
{
343343
using label_t = uint32_t;
344344
auto ps = params;

‎cpp/tests/neighbors/ann_cagra/test_float_uint32_t.cu‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ TEST(AnnCagraPq, BuildUpdatePqSearch)
186186
EXPECT_EQ(pq.n_rows(), n_rows);
187187
EXPECT_EQ(pq.dim(), dim);
188188

189-
auto pq_index = cagra::update_dataset(handle, std::move(dense_index), pq.as_dataset_view());
189+
auto pq_index = cagra::update_dataset(handle, std::move(dense_index), pq.view());
190190

191191
auto queries = raft::make_device_matrix<float, int64_t>(handle, n_queries, dim);
192192
raft::copy(queries.data_handle(), dataset.data_handle(), queries.size(), stream);

‎fern/pages/cpp_api/cpp-api-preprocessing-quantize-pq.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ SrcT const& src)
267267
-> cuvs::neighbors::device_vpq_dataset<half, int64_t>;
268268
```
269269

270-
Accepts either a row-major mdspan with `value_type`, `extent`, `stride`, and `data_handle` (same pattern as `cuvs::neighbors::make_device_padded_dataset`), or any cuVS dense dataset / dataset view exposing `data_const_view`, in which case the logical `dim()` is quantized and the row padding is skipped. The rows may be device-accessible or host-resident. Device-accessible rows (device, managed or pinned) with tight row-major storage (logical stride equals dimension) are passed through to training as they are; a wider row pitch triggers a contiguous dense copy first. Host-resident rows are subsampled for training and encoded in bounded batches, so the dense dataset is never staged on the device in full; they must be tightly packed. Empty sources are rejected. The element type must be `float`, `half`, `int8_t` or `uint8_t`.
270+
Accepts either a row-major mdspan with `value_type`, `extent`, `stride`, and `data_handle` (same pattern as `cuvs::neighbors::make_device_padded_dataset`), or any cuVS dense dataset / dataset view exposing `data_const_view` and `dim`, in which case the logical `dim()` is quantized and the row padding is skipped. The rows may be device-accessible or host-resident. Device-accessible rows (device, managed or pinned) with tight row-major storage (logical stride equals dimension) are passed through to training as they are; a wider row pitch triggers a contiguous dense copy first. Host-resident rows are subsampled for training and encoded in bounded batches, so the dense dataset is never staged on the device in full; they must be tightly packed. Empty sources are rejected. The element type must be `float`, `half`, `int8_t` or `uint8_t`.
271271

272272
Typical **CAGRA** usage: build the graph on dense vectors, then attach PQ for search (metric must remain `L2Expanded` for this path). Train PQ from the same CAGRA-padded device layout you used for graph build, keep the `device_vpq_dataset` alive, and call `cagra::update_dataset` with a non-owning view.
273273

0 commit comments

Comments
 (0)