Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions c/src/neighbors/cagra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ static void update_device_dataset_same_layout(raft::resources* res_ptr,
auto* idx =
reinterpret_cast<cuvs::neighbors::cagra::device_padded_index<T, uint32_t>*>(box->index_ptr);
RAFT_EXPECTS(idx != nullptr, "cuvsCagraUpdateDataset: null index handle");
idx->update_device_dataset_same_layout(*res_ptr, dataset_view);
idx->update_dataset(*res_ptr, dataset_view);
});
} else if (box->layout == sg_cagra_c_api_index_box::dataset_layout::device_standard) {
RAFT_EXPECTS(device_dataset->mem_type == CUVS_DATASET_MEM_TYPE_DEVICE &&
Expand All @@ -594,12 +594,12 @@ static void update_device_dataset_same_layout(raft::resources* res_ptr,
auto* idx =
reinterpret_cast<cuvs::neighbors::cagra::device_standard_index<T, uint32_t>*>(box->index_ptr);
RAFT_EXPECTS(idx != nullptr, "cuvsCagraUpdateDataset: null index handle");
idx->update_device_dataset_same_layout(*res_ptr, dataset_view);
idx->update_dataset(*res_ptr, dataset_view);
});
} else {
RAFT_FAIL(
"cuvsCagraUpdateDataset: C++ "
"update_device_dataset_same_layout "
"update_dataset "
"requires a device index and dataset");
}
}
Expand Down Expand Up @@ -711,7 +711,7 @@ void _from_args(cuvsResources_t res,
auto dataset_view = cuvs::neighbors::make_device_padded_dataset_view(*res_ptr, mds);
auto* raw = new cuvs::neighbors::cagra::device_padded_index<T, uint32_t>(
*res_ptr, metric);
raw->update_device_dataset_same_layout(*res_ptr, dataset_view);
raw->update_dataset(*res_ptr, dataset_view);
update_graph_from_dlpack(raw);
wrap_CPP_index_in_lifetime_holder_and_bind_to_C_index<
T,
Expand All @@ -721,7 +721,7 @@ void _from_args(cuvsResources_t res,
auto dataset_view = cuvs::neighbors::make_device_standard_dataset_view(mds);
auto* raw = new cuvs::neighbors::cagra::device_standard_index<T, uint32_t>(
*res_ptr, metric);
raw->update_device_dataset_same_layout(*res_ptr, dataset_view);
raw->update_dataset(*res_ptr, dataset_view);
update_graph_from_dlpack(raw);
wrap_CPP_index_in_lifetime_holder_and_bind_to_C_index<
T,
Expand Down
28 changes: 14 additions & 14 deletions cpp/bench/ann/src/cuvs/cuvs_cagra_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ void cuvs_cagra<T, IdxT>::build(const T* dataset, size_t nrow)
*input_dataset_v_ = raft::make_device_matrix_view<const T, int64_t, raft::row_major>(
mds.data_handle(), static_cast<int64_t>(nrow), static_cast<int64_t>(dim_));
auto index = cuvs::neighbors::cagra::build(handle_, params, pdv);
index.update_device_dataset_same_layout(handle_, pdv);
index.update_dataset(handle_, pdv);
index_ = std::make_shared<index_type>(std::move(index));
} else {
auto padded = cuvs::neighbors::make_device_padded_dataset(handle_, mds);
auto view = padded->as_dataset_view();
auto index = cuvs::neighbors::cagra::build(handle_, params, view);
index.update_device_dataset_same_layout(handle_, view);
index.update_dataset(handle_, view);
*dataset_ = std::move(padded->data_);
index_ = std::make_shared<index_type>(std::move(index));
}
Expand Down Expand Up @@ -318,17 +318,17 @@ void cuvs_cagra<T, IdxT>::build(const T* dataset, size_t nrow)
raft::resource::get_cuda_stream(handle_));
cuvs::neighbors::device_padded_dataset_view<T, int64_t> dv(
raft::make_const_mdspan(sub_dataset_buffers_->back().view()), dim_);
sub_index.update_device_dataset_same_layout(handle_, dv);
sub_index.update_dataset(handle_, dv);
} else {
if (cuvs::neighbors::matrix_row_width_matches_cagra_required(sub_dev)) {
auto pdv = cuvs::neighbors::make_device_padded_dataset_view(handle_, sub_dev);
sub_index.update_device_dataset_same_layout(handle_, pdv);
sub_index.update_dataset(handle_, pdv);
} else {
auto padded = cuvs::neighbors::make_device_padded_dataset(handle_, sub_dev);
sub_dataset_buffers_->push_back(std::move(padded->data_));
cuvs::neighbors::device_padded_dataset_view<T, int64_t> pdv(
raft::make_const_mdspan(sub_dataset_buffers_->back().view()), dim_);
sub_index.update_device_dataset_same_layout(handle_, pdv);
sub_index.update_dataset(handle_, pdv);
}
}
}
Expand Down Expand Up @@ -370,12 +370,12 @@ void cuvs_cagra<T, IdxT>::build(const T* dataset, size_t nrow)
if (sub_device && src_sub == req_sub) {
auto pdv_sub = cuvs::neighbors::make_device_padded_dataset_view(handle_, mds_sub);
sub_index = cuvs::neighbors::cagra::build(handle_, params, pdv_sub);
sub_index.update_device_dataset_same_layout(handle_, pdv_sub);
sub_index.update_dataset(handle_, pdv_sub);
} else {
auto padded_sub = cuvs::neighbors::make_device_padded_dataset(handle_, mds_sub);
auto view = padded_sub->as_dataset_view();
auto index = cuvs::neighbors::cagra::build(handle_, params, view);
index.update_device_dataset_same_layout(handle_, view);
index.update_dataset(handle_, view);
sub_dataset_buffers_->push_back(std::move(padded_sub->data_));
sub_index = std::move(index);
}
Expand All @@ -391,12 +391,12 @@ void cuvs_cagra<T, IdxT>::build(const T* dataset, size_t nrow)
if (sub_device && src_sub == req_sub) {
auto pdv_sub = cuvs::neighbors::make_device_padded_dataset_view(handle_, mds_sub);
sub_index = cuvs::neighbors::cagra::build(handle_, params, pdv_sub);
sub_index.update_device_dataset_same_layout(handle_, pdv_sub);
sub_index.update_dataset(handle_, pdv_sub);
} else {
auto padded_sub = cuvs::neighbors::make_device_padded_dataset(handle_, mds_sub);
auto view = padded_sub->as_dataset_view();
auto index = cuvs::neighbors::cagra::build(handle_, params, view);
index.update_device_dataset_same_layout(handle_, view);
index.update_dataset(handle_, view);
sub_dataset_buffers_->push_back(std::move(padded_sub->data_));
sub_index = std::move(index);
}
Expand Down Expand Up @@ -484,7 +484,7 @@ void cuvs_cagra<T, IdxT>::set_search_param(const search_param_base& param,
*dataset_ = raft::make_device_matrix<T, int64_t>(handle_, 0, 0);
cuvs::neighbors::device_padded_dataset_view<T, int64_t> empty_dv(
raft::make_device_matrix_view(static_cast<T const*>(nullptr), 0, this->dim_), this->dim_);
index_->update_device_dataset_same_layout(handle_, empty_dv);
index_->update_dataset(handle_, empty_dv);

// Allocate space using the correct memory resource.
RAFT_LOG_DEBUG("moving dataset to new memory space: %s",
Expand All @@ -497,7 +497,7 @@ void cuvs_cagra<T, IdxT>::set_search_param(const search_param_base& param,
raft::make_device_matrix_view(
dataset_->data_handle(), dataset_->extent(0), dataset_->extent(1)),
this->dim_);
index_->update_device_dataset_same_layout(handle_, dv);
index_->update_dataset(handle_, dv);

need_dataset_update_ = false;
needs_dynamic_batcher_update = true;
Expand Down Expand Up @@ -554,17 +554,17 @@ void cuvs_cagra<T, IdxT>::set_search_dataset(const T* dataset, size_t nrow)
raft::resource::get_cuda_stream(handle_));
cuvs::neighbors::device_padded_dataset_view<T, int64_t> dv(
raft::make_const_mdspan(sub_dataset_buffers_->back().view()), dim_);
sub_index->update_device_dataset_same_layout(handle_, dv);
sub_index->update_dataset(handle_, dv);
} else {
if (cuvs::neighbors::matrix_row_width_matches_cagra_required(sub_dev)) {
auto pdv = cuvs::neighbors::make_device_padded_dataset_view(handle_, sub_dev);
sub_index->update_device_dataset_same_layout(handle_, pdv);
sub_index->update_dataset(handle_, pdv);
} else {
auto padded = cuvs::neighbors::make_device_padded_dataset(handle_, sub_dev);
sub_dataset_buffers_->push_back(std::move(padded->data_));
cuvs::neighbors::device_padded_dataset_view<T, int64_t> pdv(
raft::make_const_mdspan(sub_dataset_buffers_->back().view()), dim_);
sub_index->update_device_dataset_same_layout(handle_, pdv);
sub_index->update_dataset(handle_, pdv);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions cpp/cmake/patches/faiss-1.14-cuvs-26.08.diff
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ index b331fdc..c7b5733 100644
- cuvs_index->update_dataset(raft_handle, dataset);
+ auto dataset_view =
+ cuvs::neighbors::make_device_padded_dataset_view(raft_handle, dataset);
+ cuvs_index->update_device_dataset_same_layout(raft_handle, dataset_view);
+ cuvs_index->update_dataset(raft_handle, dataset_view);
} else {
- auto dataset = raft::make_host_matrix_view<const uint8_t, int64_t>(
+ auto host_dataset = raft::make_host_matrix_view<const uint8_t, int64_t>(
storage_, n_, dim_ / 8);
- cuvs_index->update_dataset(raft_handle, dataset);
+ host_to_device_dataset_ =
+ cuvs::neighbors::make_device_padded_dataset(raft_handle, host_dataset);
+ cuvs_index->update_device_dataset_same_layout(raft_handle,
+ cuvs_index->update_dataset(raft_handle,
+ host_to_device_dataset_->as_dataset_view());
}
store_dataset_ = true;
Expand Down Expand Up @@ -210,15 +210,15 @@ index 755817f..0eb03ae 100644
- cuvs_index->update_dataset(raft_handle, dataset);
+ auto dataset_view =
+ cuvs::neighbors::make_device_padded_dataset_view(raft_handle, dataset);
+ cuvs_index->update_device_dataset_same_layout(raft_handle, dataset_view);
+ cuvs_index->update_dataset(raft_handle, dataset_view);
} else {
- auto dataset = raft::make_host_matrix_view<const data_t, int64_t>(
+ auto host_dataset = raft::make_host_matrix_view<const data_t, int64_t>(
storage_, n_, dim_);
- cuvs_index->update_dataset(raft_handle, dataset);
+ host_to_device_dataset_ =
+ cuvs::neighbors::make_device_padded_dataset(raft_handle, host_dataset);
+ cuvs_index->update_device_dataset_same_layout(raft_handle,
+ cuvs_index->update_dataset(raft_handle,
+ host_to_device_dataset_->as_dataset_view());
}
store_dataset_ = true;
Expand Down
Loading
Loading