Skip to content

Commit 032506d

Browse files
committed
merge commit
2 parents 0da946c + 2922045 commit 032506d

File tree

64 files changed

+980
-1370
lines changed

Some content is hidden

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

64 files changed

+980
-1370
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ repos:
9292
pass_filenames: false
9393
language: python
9494
additional_dependencies: [gitpython]
95+
- id: cargo-fmt
96+
name: cargo-fmt
97+
entry: cargo fmt --manifest-path rust/Cargo.toml --all
98+
pass_filenames: false
99+
files: rust/.*
100+
language: rust
95101
- repo: https://github.com/codespell-project/codespell
96102
rev: v2.2.2
97103
hooks:

cpp/cmake/modules/ConfigureCUDA.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,8 @@ list(APPEND CUVS_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr)
4848
list(APPEND CUVS_CXX_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM")
4949
list(APPEND CUVS_CUDA_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM")
5050
# make sure we produce smallest binary size
51-
list(APPEND CUVS_CUDA_FLAGS -Xfatbin=-compress-all)
52-
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA"
53-
AND (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.9 AND CMAKE_CUDA_COMPILER_VERSION
54-
VERSION_LESS 13.0)
55-
)
56-
list(APPEND CUVS_CUDA_FLAGS -Xfatbin=--compress-level=3)
57-
endif()
51+
include(${rapids-cmake-dir}/cuda/enable_fatbin_compression.cmake)
52+
rapids_cuda_enable_fatbin_compression(VARIABLE CUVS_CUDA_FLAGS TUNE_FOR rapids)
5853

5954
# Option to enable line info in CUDA device compilation to allow introspection when profiling /
6055
# memchecking

cpp/cmake/patches/faiss.diff

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
{
22
"packages" : {
33
"faiss" : {
4-
"version": "1.11.0",
4+
"version": "1.12.0",
55
"git_url": "https://github.com/facebookresearch/faiss.git",
6-
"git_tag": "v1.11.0",
7-
"patches" : [
8-
{
9-
"file" : "${current_json_dir}/faiss.diff",
10-
"issue" : "Apply RAFT breaking changes",
11-
"fixed_in" : ""
12-
}
13-
]
6+
"git_tag": "v1.12.0"
147
}
158
}
169
}

cpp/include/cuvs/neighbors/cagra.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,9 @@ void serialize_to_hnswlib(
19751975
* @note: When device memory is sufficient, the dataset attached to the returned index is allocated
19761976
* in device memory by default; otherwise, host memory is used automatically.
19771977
*
1978+
* @note: This API only supports physical merge (`merge_strategy = MERGE_STRATEGY_PHYSICAL`), and
1979+
* attempting a logical merge here will throw an error.
1980+
*
19781981
* Usage example:
19791982
* @code{.cpp}
19801983
* using namespace raft::neighbors;

cpp/include/cuvs/neighbors/nn_descent.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, NVIDIA CORPORATION.
2+
* Copyright (c) 2024-2025, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,7 +54,6 @@ struct cuvsNNDescentIndexParams {
5454
size_t max_iterations;
5555
float termination_threshold;
5656
bool return_distances;
57-
size_t n_clusters;
5857
};
5958

6059
typedef struct cuvsNNDescentIndexParams* cuvsNNDescentIndexParams_t;

cpp/include/cuvs/neighbors/nn_descent.hpp

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
2+
* Copyright (c) 2023-2025, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,26 +37,24 @@ namespace cuvs::neighbors::nn_descent {
3737

3838
/**
3939
* @brief Parameters used to build an nn-descent index
40-
*
41-
* `graph_degree`: For an input dataset of dimensions (N, D),
40+
* - `graph_degree`: For an input dataset of dimensions (N, D),
4241
* determines the final dimensions of the all-neighbors knn graph
4342
* which turns out to be of dimensions (N, graph_degree)
44-
* `intermediate_graph_degree`: Internally, nn-descent builds an
43+
* - `intermediate_graph_degree`: Internally, nn-descent builds an
4544
* all-neighbors knn graph of dimensions (N, intermediate_graph_degree)
4645
* before selecting the final `graph_degree` neighbors. It's recommended
4746
* that `intermediate_graph_degree` >= 1.5 * graph_degree
48-
* `max_iterations`: The number of iterations that nn-descent will refine
47+
* - `max_iterations`: The number of iterations that nn-descent will refine
4948
* the graph for. More iterations produce a better quality graph at cost of performance
50-
* `termination_threshold`: The delta at which nn-descent will terminate its iterations
51-
*
49+
* - `termination_threshold`: The delta at which nn-descent will terminate its iterations
50+
* - `return_distances`: Boolean to decide whether to return distances array
5251
*/
5352
struct index_params : cuvs::neighbors::index_params {
54-
size_t graph_degree = 64; // Degree of output graph.
55-
size_t intermediate_graph_degree = 128; // Degree of input graph for pruning.
56-
size_t max_iterations = 20; // Number of nn-descent iterations.
57-
float termination_threshold = 0.0001; // Termination threshold of nn-descent.
58-
bool return_distances = true; // return distances if true
59-
size_t n_clusters = 1; // defaults to not using any batching
53+
size_t graph_degree = 64;
54+
size_t intermediate_graph_degree = 128;
55+
size_t max_iterations = 20;
56+
float termination_threshold = 0.0001;
57+
bool return_distances = true;
6058

6159
/** @brief Construct NN descent parameters for a specific kNN graph degree
6260
*
@@ -211,7 +209,10 @@ struct index : cuvs::neighbors::index {
211209
* @brief Build nn-descent Index with dataset in device memory
212210
*
213211
* The following distance metrics are supported:
214-
* - L2
212+
* - L2Expanded
213+
* - L2SqrtExpanded
214+
* - CosineExpanded
215+
* - InnerProduct
215216
*
216217
* Usage example:
217218
* @code{.cpp}
@@ -244,7 +245,10 @@ auto build(raft::resources const& res,
244245
* @brief Build nn-descent Index with dataset in host memory
245246
*
246247
* The following distance metrics are supported:
247-
* - L2
248+
* - L2Expanded
249+
* - L2SqrtExpanded
250+
* - CosineExpanded
251+
* - InnerProduct
248252
*
249253
* Usage example:
250254
* @code{.cpp}
@@ -279,7 +283,10 @@ auto build(raft::resources const& res,
279283
* @brief Build nn-descent Index with dataset in device memory
280284
*
281285
* The following distance metrics are supported:
282-
* - L2
286+
* - L2Expanded
287+
* - L2SqrtExpanded
288+
* - CosineExpanded
289+
* - InnerProduct
283290
*
284291
* Usage example:
285292
* @code{.cpp}
@@ -312,7 +319,10 @@ auto build(raft::resources const& res,
312319
* @brief Build nn-descent Index with dataset in host memory
313320
*
314321
* The following distance metrics are supported:
315-
* - L2
322+
* - L2Expanded
323+
* - L2SqrtExpanded
324+
* - CosineExpanded
325+
* - InnerProduct
316326
*
317327
* Usage example:
318328
* @code{.cpp}
@@ -347,7 +357,11 @@ auto build(raft::resources const& res,
347357
* @brief Build nn-descent Index with dataset in device memory
348358
*
349359
* The following distance metrics are supported:
350-
* - L2
360+
* - L2Expanded
361+
* - L2SqrtExpanded
362+
* - CosineExpanded
363+
* - InnerProduct
364+
* - BitwiseHamming
351365
*
352366
* Usage example:
353367
* @code{.cpp}
@@ -380,7 +394,11 @@ auto build(raft::resources const& res,
380394
* @brief Build nn-descent Index with dataset in host memory
381395
*
382396
* The following distance metrics are supported:
383-
* - L2
397+
* - L2Expanded
398+
* - L2SqrtExpanded
399+
* - CosineExpanded
400+
* - InnerProduct
401+
* - BitwiseHamming
384402
*
385403
* Usage example:
386404
* @code{.cpp}
@@ -415,7 +433,11 @@ auto build(raft::resources const& res,
415433
* @brief Build nn-descent Index with dataset in device memory
416434
*
417435
* The following distance metrics are supported:
418-
* - L2
436+
* - L2Expanded
437+
* - L2SqrtExpanded
438+
* - CosineExpanded
439+
* - InnerProduct
440+
* - BitwiseHamming
419441
*
420442
* Usage example:
421443
* @code{.cpp}
@@ -448,7 +470,11 @@ auto build(raft::resources const& res,
448470
* @brief Build nn-descent Index with dataset in host memory
449471
*
450472
* The following distance metrics are supported:
451-
* - L2
473+
* - L2Expanded
474+
* - L2SqrtExpanded
475+
* - CosineExpanded
476+
* - InnerProduct
477+
* - BitwiseHamming
452478
*
453479
* Usage example:
454480
* @code{.cpp}
@@ -479,6 +505,7 @@ auto build(raft::resources const& res,
479505
std::optional<raft::host_matrix_view<uint32_t, int64_t, raft::row_major>> graph =
480506
std::nullopt) -> cuvs::neighbors::nn_descent::index<uint32_t>;
481507

508+
/** @} */
482509
/**
483510
* @brief Test if we have enough GPU memory to run NN descent algorithm.
484511
*

cpp/include/cuvs/neighbors/tiered_index.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,30 @@ cuvsError_t cuvsTieredIndexSearch(cuvsResources_t res,
246246
cuvsError_t cuvsTieredIndexExtend(cuvsResources_t res,
247247
DLManagedTensor* new_vectors,
248248
cuvsTieredIndex_t index);
249+
/**
250+
* @}
251+
*/
252+
253+
/**
254+
* @defgroup tiered_c_index_merge Tiered index merge
255+
* @{
256+
*/
257+
/**
258+
* @brief Merge multiple indices together into a single index
259+
*
260+
* @param[in] res cuvsResources_t opaque C handle
261+
* @param[in] index_params Index parameters to use when merging
262+
* @param[in] indices pointers to indices to merge together
263+
* @param[in] num_indices the number of indices to merge
264+
* @param[out] output_index the merged index
265+
* @return cuvsError_t
266+
*/
267+
cuvsError_t cuvsTieredIndexMerge(cuvsResources_t res,
268+
cuvsTieredIndexParams_t index_params,
269+
cuvsTieredIndex_t* indices,
270+
size_t num_indices,
271+
cuvsTieredIndex_t output_index);
272+
249273
/**
250274
* @}
251275
*/

cpp/include/cuvs/neighbors/tiered_index.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,34 @@ void search(raft::resources const& res,
197197
raft::device_matrix_view<float, int64_t, raft::row_major> distances,
198198
const cuvs::neighbors::filtering::base_filter& sample_filter =
199199
cuvs::neighbors::filtering::none_sample_filter{});
200+
201+
/** @brief Merge multiple tiered indices into a single index.
202+
*
203+
* This function merges multiple tiered indices into one, combining both the datasets and graph
204+
* structures.
205+
*
206+
* @param[in] res
207+
* @param[in] index_params configure the index building
208+
* @param[in] indices A vector of pointers to the indices to merge. All indices should
209+
* be of the same type, and have datasets with the same dimensionality
210+
*
211+
* @return A new tiered index containing the merged indices
212+
*/
213+
auto merge(raft::resources const& res,
214+
const index_params<cagra::index_params>& index_params,
215+
const std::vector<tiered_index::index<cagra::index<float, uint32_t>>*>& indices)
216+
-> tiered_index::index<cagra::index<float, uint32_t>>;
217+
218+
/** @copydoc merge */
219+
auto merge(raft::resources const& res,
220+
const index_params<ivf_flat::index_params>& index_params,
221+
const std::vector<tiered_index::index<ivf_flat::index<float, int64_t>>*>& indices)
222+
-> tiered_index::index<ivf_flat::index<float, int64_t>>;
223+
224+
/** @copydoc merge */
225+
auto merge(raft::resources const& res,
226+
const index_params<ivf_pq::index_params>& index_params,
227+
const std::vector<tiered_index::index<ivf_pq::typed_index<float, int64_t>>*>& indices)
228+
-> tiered_index::index<ivf_pq::typed_index<float, int64_t>>;
229+
200230
} // namespace cuvs::neighbors::tiered_index

0 commit comments

Comments
 (0)