Skip to content

Commit 40e960f

Browse files
Merge branch 'main' into add-max-node-id-parameter
2 parents b27ad1b + d0c54f0 commit 40e960f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1516
-1296
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/faiss/gpu/utils/CuvsUtils.cu b/faiss/gpu/utils/CuvsUtils.cu
2+
index 1ec32179c..3751dfa62 100644
3+
--- a/faiss/gpu/utils/CuvsUtils.cu
4+
+++ b/faiss/gpu/utils/CuvsUtils.cu
5+
@@ -31,6 +31,7 @@
6+
7+
#include <thrust/copy.h>
8+
#include <thrust/gather.h>
9+
+#include <thrust/iterator/counting_iterator.h>
10+
#include <thrust/reduce.h>
11+
12+
namespace faiss {

cpp/cmake/patches/faiss_override.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"file" : "${current_json_dir}/faiss-1.13-cuvs-26.02.diff",
1515
"issue" : "Multiple fixes for cuVS and RMM compatibility",
1616
"fixed_in" : ""
17+
},
18+
{
19+
"file" : "${current_json_dir}/faiss-1.13-cuvs-26.04.diff",
20+
"issue" : "Multiple fixes for cuVS compatibility",
21+
"fixed_in" : ""
1722
}
1823
]
1924
}

cpp/include/cuvs/neighbors/hnsw.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct index : cuvs::neighbors::index {
161161
/**
162162
@brief Set ef for search
163163
*/
164-
virtual void set_ef(int ef) const;
164+
virtual void set_ef(int ef) const = 0;
165165

166166
/**
167167
@brief Get file path for disk-backed index

cpp/src/cluster/detail/agglomerative.cuh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55

66
#pragma once
77

8+
#include <raft/core/copy.cuh>
9+
#include <raft/core/device_mdspan.hpp>
10+
#include <raft/core/host_mdspan.hpp>
811
#include <raft/core/resource/cuda_stream.hpp>
912
#include <raft/core/resource/thrust_policy.hpp>
1013
#include <raft/core/resources.hpp>
14+
#include <raft/matrix/init.cuh>
1115
#include <raft/util/cuda_utils.cuh>
1216
#include <raft/util/cudart_utils.hpp>
1317

@@ -108,9 +112,15 @@ void build_dendrogram_host(raft::resources const& handle,
108112
std::vector<value_idx> mst_dst_h(n_edges);
109113
std::vector<value_t> mst_weights_h(n_edges);
110114

111-
raft::update_host(mst_src_h.data(), rows, n_edges, stream);
112-
raft::update_host(mst_dst_h.data(), cols, n_edges, stream);
113-
raft::update_host(mst_weights_h.data(), data, n_edges, stream);
115+
raft::copy(handle,
116+
raft::make_host_vector_view(mst_src_h.data(), n_edges),
117+
raft::make_device_vector_view(rows, n_edges));
118+
raft::copy(handle,
119+
raft::make_host_vector_view(mst_dst_h.data(), n_edges),
120+
raft::make_device_vector_view(cols, n_edges));
121+
raft::copy(handle,
122+
raft::make_host_vector_view(mst_weights_h.data(), n_edges),
123+
raft::make_device_vector_view(data, n_edges));
114124

115125
raft::resource::sync_stream(handle, stream);
116126

@@ -138,9 +148,15 @@ void build_dendrogram_host(raft::resources const& handle,
138148
U.perform_union(aa, bb);
139149
}
140150

141-
raft::update_device(children, children_h.data(), n_edges * 2, stream);
142-
raft::update_device(out_size, out_size_h.data(), n_edges, stream);
143-
raft::update_device(out_delta, out_delta_h.data(), n_edges, stream);
151+
raft::copy(handle,
152+
raft::make_device_vector_view(children, n_edges * 2),
153+
raft::make_host_vector_view(children_h.data(), n_edges * 2));
154+
raft::copy(handle,
155+
raft::make_device_vector_view(out_size, n_edges),
156+
raft::make_host_vector_view(out_size_h.data(), n_edges));
157+
raft::copy(handle,
158+
raft::make_device_vector_view(out_delta, n_edges),
159+
raft::make_host_vector_view(out_delta_h.data(), n_edges));
144160
}
145161

146162
template <typename value_idx>
@@ -236,7 +252,8 @@ void extract_flattened_clusters(raft::resources const& handle,
236252

237253
// Handle special case where n_clusters == 1
238254
if (n_clusters == 1) {
239-
thrust::fill(thrust_policy, labels, labels + n_leaves, 0);
255+
raft::matrix::fill(
256+
handle, raft::make_device_vector_view<value_idx>(labels, n_leaves), value_idx(0));
240257
} else {
241258
/**
242259
* Compute levels for each node

cpp/src/cluster/detail/connectivities.cuh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

@@ -9,11 +9,13 @@
99
#include "./kmeans_common.cuh"
1010
#include <cuvs/cluster/agglomerative.hpp>
1111
#include <cuvs/distance/distance.hpp>
12+
#include <raft/core/copy.cuh>
13+
#include <raft/core/device_mdspan.hpp>
14+
#include <raft/core/host_mdspan.hpp>
1215
#include <raft/core/resource/cuda_stream.hpp>
1316
#include <raft/core/resource/thrust_policy.hpp>
1417
#include <raft/core/resources.hpp>
1518
#include <raft/linalg/map.cuh>
16-
#include <raft/linalg/unary_op.cuh>
1719
#include <raft/sparse/convert/csr.cuh>
1820
#include <raft/sparse/coo.hpp>
1921
#include <raft/util/cuda_utils.cuh>
@@ -85,9 +87,9 @@ struct distance_graph_impl<Linkage::KNN_GRAPH, value_idx, value_t> {
8587
bool self_loop = row == col;
8688
return (self_loop * std::numeric_limits<value_t>::max()) + (!self_loop * val);
8789
},
88-
rows_view,
89-
cols_view,
90-
vals_in_view);
90+
raft::make_const_mdspan(rows_view),
91+
raft::make_const_mdspan(cols_view),
92+
raft::make_const_mdspan(vals_in_view));
9193

9294
raft::sparse::convert::sorted_coo_to_csr(
9395
knn_graph_coo.rows(), knn_graph_coo.nnz, indptr.data(), m + 1, stream);
@@ -144,7 +146,7 @@ void pairwise_distances(const raft::resources& handle,
144146
raft::make_device_vector_view<value_idx, value_idx>(indptr, m),
145147
[=] __device__(value_idx idx) { return idx * m; });
146148

147-
raft::update_device(indptr + m, &nnz, 1, stream);
149+
raft::copy(handle, raft::make_device_scalar_view(indptr + m), raft::make_host_scalar_view(&nnz));
148150

149151
// TODO: It would ultimately be nice if the MST could accept
150152
// dense inputs directly so we don't need to double the memory
@@ -157,11 +159,14 @@ void pairwise_distances(const raft::resources& handle,
157159
// self-loops get max distance
158160
auto data_view = raft::make_device_vector_view<value_t, value_idx>(data, nnz);
159161

160-
raft::linalg::map_offset(handle, data_view, [=] __device__(value_idx idx) {
161-
value_t val = data[idx];
162-
bool self_loop = idx % m == idx / m;
163-
return (self_loop * std::numeric_limits<value_t>::max()) + (!self_loop * val);
164-
});
162+
raft::linalg::map_offset(
163+
handle,
164+
data_view,
165+
[=] __device__(value_idx idx, value_t val) {
166+
bool self_loop = idx % m == idx / m;
167+
return (self_loop * std::numeric_limits<value_t>::max()) + (!self_loop * val);
168+
},
169+
raft::make_const_mdspan(data_view));
165170
}
166171

167172
/**

0 commit comments

Comments
 (0)