|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. |
| 2 | + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. |
3 | 3 | * SPDX-License-Identifier: Apache-2.0 |
4 | 4 | */ |
5 | 5 | #pragma once |
@@ -85,38 +85,9 @@ void cuvs_cagra_hnswlib<T, IdxT>::build(const T* dataset, size_t nrow) |
85 | 85 | // when the data set is on host, we can pass it directly to HNSW |
86 | 86 | bool dataset_is_on_host = raft::get_device_for_address(dataset) == -1; |
87 | 87 |
|
88 | | - // re-use the CAGRA wrapper to parse build params |
89 | | - auto bps = build_param_.cagra_build_params; |
90 | | - // Not very conveniently, the CAGRA wrapper resolves parameters after the dataset shape is known, |
91 | | - // so it takes a lambda to do it. Even though we know the shape, we want to use the wrapper as-is, |
92 | | - // so we just modify that lambda. |
93 | | - bps.cagra_params = [dataset_is_on_host, orig_cagra_params = bps.cagra_params]( |
94 | | - auto dataset_extents, auto metric) { |
95 | | - auto params = orig_cagra_params(dataset_extents, metric); |
96 | | - params.attach_dataset_on_build = !dataset_is_on_host; |
97 | | - return params; |
98 | | - }; |
99 | | - cuvs_cagra<T, IdxT> cagra_wrapper{this->metric_, this->dim_, bps}; |
100 | | - |
101 | | - // build the CAGRA index |
102 | | - cagra_wrapper.build(dataset, nrow); |
103 | | - auto& cagra_index = *cagra_wrapper.get_index(); |
104 | | - |
105 | | - // pass the dataset directly to HNSW if it's on the host |
106 | | - std::optional<raft::host_matrix_view<const T, int64_t>> opt_dataset_view = std::nullopt; |
107 | | - if (dataset_is_on_host) { |
108 | | - opt_dataset_view.emplace( |
109 | | - raft::make_host_matrix_view<const T, int64_t>(dataset, nrow, this->dim_)); |
110 | | - } |
111 | | - |
| 88 | + auto dataset_view = raft::make_host_matrix_view<const T, int64_t>(dataset, nrow, this->dim_); |
112 | 89 | // convert the index to HNSW format |
113 | | - hnsw_index_ = cuvs::neighbors::hnsw::from_cagra( |
114 | | - handle_, build_param_.hnsw_index_params, cagra_index, opt_dataset_view); |
115 | | - |
116 | | - // special treatment in save/serialize step |
117 | | - if (cagra_index.dataset_fd().has_value() && cagra_index.graph_fd().has_value()) { |
118 | | - cagra_ace_build_ = true; |
119 | | - } |
| 90 | + hnsw_index_ = cuvs::neighbors::hnsw::build(handle_, build_param_.hnsw_index_params, dataset_view); |
120 | 91 | } |
121 | 92 |
|
122 | 93 | template <typename T, typename IdxT> |
|
0 commit comments