diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 240f82be68..2f064ebb61 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,11 @@ -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, NVIDIA CORPORATION. repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/README.md b/README.md index aded8813cb..3107f6d0cb 100755 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ cuVS contains state-of-the-art implementations of several algorithms for running Vector search is an information retrieval method that has been growing in popularity over the past few years, partly because of the rising importance of multimedia embeddings created from unstructured data and the need to perform semantic search on the embeddings to find items which are semantically similar to each other. -Vector search is also used in _data mining and machine learning_ tasks and comprises an important step in many _clustering_ and _visualization_ algorithms like [UMAP](https://arxiv.org/abs/2008.00325), [t-SNE](https://lvdmaaten.github.io/tsne/), K-means, and [HDBSCAN](https://hdbscan.readthedocs.io/en/latest/how_hdbscan_works.html). +Vector search is also used in _data mining and machine learning_ tasks and comprises an important step in many _clustering_ and _visualization_ algorithms like [UMAP](https://arxiv.org/abs/2008.00325), [t-SNE](https://lvdmaaten.github.io/tsne/), K-means, and [HDBSCAN](https://hdbscan.readthedocs.io/en/latest/how_hdbscan_works.html). -Finally, faster vector search enables interactions between dense vectors and graphs. Converting a pile of dense vectors into nearest neighbors graphs unlocks the entire world of graph analysis algorithms, such as those found in [GraphBLAS](https://graphblas.org/) and [cuGraph](https://github.com/rapidsai/cugraph). +Finally, faster vector search enables interactions between dense vectors and graphs. Converting a pile of dense vectors into nearest neighbors graphs unlocks the entire world of graph analysis algorithms, such as those found in [GraphBLAS](https://graphblas.org/) and [cuGraph](https://github.com/rapidsai/cugraph). Below are some common use-cases for vector search @@ -45,7 +45,7 @@ Below are some common use-cases for vector search - Audio search - Molecular search - Model training - + - ### Data mining - Clustering algorithms @@ -71,7 +71,7 @@ In addition to the items above, cuVS takes on the burden of keeping non-trivial ## cuVS Technology Stack -cuVS is built on top of the RAPIDS RAFT library of high performance machine learning primitives and provides all the necessary routines for vector search and clustering on the GPU. +cuVS is built on top of the RAPIDS RAFT library of high performance machine learning primitives and provides all the necessary routines for vector search and clustering on the GPU. ![cuVS is built on top of low-level CUDA libraries and provides many important routines that enable vector search and clustering on the GPU](img/tech_stack.png "cuVS Technology Stack") @@ -103,7 +103,7 @@ pip install cuvs-cu11 --extra-index-url=https://pypi.nvidia.com And CUDA 12 packages: ```bash pip install cuvs-cu12 --extra-index-url=https://pypi.nvidia.com -``` +``` ### Nightlies If installing a version that has not yet been released, the `rapidsai` channel can be replaced with `rapidsai-nightly`: @@ -240,7 +240,7 @@ If you are interested in contributing to the cuVS library, please read our [Cont ## References -For the interested reader, many of the accelerated implementations in cuVS are also based on research papers which can provide a lot more background. We also ask you to please cite the corresponding algorithms by referencing them in your own research. +For the interested reader, many of the accelerated implementations in cuVS are also based on research papers which can provide a lot more background. We also ask you to please cite the corresponding algorithms by referencing them in your own research. - [CAGRA: Highly Parallel Graph Construction and Approximate Nearest Neighbor Search](https://arxiv.org/abs/2308.15136) - [Top-K Algorithms on GPU: A Comprehensive Study and New Methods](https://dl.acm.org/doi/10.1145/3581784.3607062) - [Fast K-NN Graph Construction by GPU Based NN-Descent](https://dl.acm.org/doi/abs/10.1145/3459637.3482344?casa_token=O_nan1B1F5cAAAAA:QHWDEhh0wmd6UUTLY9_Gv6c3XI-5DXM9mXVaUXOYeStlpxTPmV3nKvABRfoivZAaQ3n8FWyrkWw>) diff --git a/cpp/.clang-format b/cpp/.clang-format index 18f376d660..26b9a5bf4c 100644 --- a/cpp/.clang-format +++ b/cpp/.clang-format @@ -27,7 +27,7 @@ AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false +BinPackArguments: false BinPackParameters: false BraceWrapping: AfterClass: false diff --git a/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_flat_wrapper.h b/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_flat_wrapper.h index 54a0d2facb..0540edc8f0 100644 --- a/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_flat_wrapper.h +++ b/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_flat_wrapper.h @@ -137,4 +137,4 @@ void cuvs_mg_ivf_flat::search( handle_, *index_, search_params_, queries_view, neighbors_view, distances_view); } -} // namespace cuvs::bench \ No newline at end of file +} // namespace cuvs::bench diff --git a/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_pq_wrapper.h b/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_pq_wrapper.h index 84aea7d4a3..65ca1bb11e 100644 --- a/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_pq_wrapper.h +++ b/cpp/bench/ann/src/cuvs/cuvs_mg_ivf_pq_wrapper.h @@ -136,4 +136,4 @@ void cuvs_mg_ivf_pq::search( handle_, *index_, search_params_, queries_view, neighbors_view, distances_view); } -} // namespace cuvs::bench \ No newline at end of file +} // namespace cuvs::bench diff --git a/cpp/cmake/config.json b/cpp/cmake/config.json index f7cc50e513..3c568d9766 100644 --- a/cpp/cmake/config.json +++ b/cpp/cmake/config.json @@ -9,7 +9,7 @@ "VERSION": "?", "GIT_SHALLOW": "?", "OPTIONS": "*", - "FIND_PACKAGE_ARGUMENTS": "*" + "FIND_PACKAGE_ARGUMENTS": "*" } }, "ConfigureTest": { diff --git a/cpp/cmake/patches/cutlass/build-export.patch b/cpp/cmake/patches/cutlass/build-export.patch index a6423e9c08..31bbd25102 100644 --- a/cpp/cmake/patches/cutlass/build-export.patch +++ b/cpp/cmake/patches/cutlass/build-export.patch @@ -20,8 +20,7 @@ index 7419bdf5e..545384d82 100755 - $ - $ ) - + # Mark CTK headers as system to supress warnings from them --- +-- 2.34.1 - diff --git a/cpp/cmake/patches/faiss_override.json b/cpp/cmake/patches/faiss_override.json index c39abdc2b7..18542fcf5f 100644 --- a/cpp/cmake/patches/faiss_override.json +++ b/cpp/cmake/patches/faiss_override.json @@ -6,4 +6,4 @@ "git_tag": "main" } } - } \ No newline at end of file + } diff --git a/cpp/cmake/patches/ggnn.diff b/cpp/cmake/patches/ggnn.diff index fc45298803..c2413110b6 100644 --- a/cpp/cmake/patches/ggnn.diff +++ b/cpp/cmake/patches/ggnn.diff @@ -3,11 +3,11 @@ @@ -62,7 +62,7 @@ struct SimpleKNNSymCache { const ValueT dist_half) : dist_query(dist_query), dist_half(dist_half) {} - + - __device__ __forceinline__ DistQueryAndHalf() {} + DistQueryAndHalf() = default; }; - + struct DistanceAndNorm { @@ -98,8 +98,7 @@ struct SimpleKNNSymCache { KeyT cache; @@ -17,7 +17,7 @@ - __device__ __forceinline__ SyncTempStorage() {} + SyncTempStorage() = default; }; - + public: diff --git a/include/ggnn/cuda_knn_ggnn_gpu_instance.cuh b/include/ggnn/cuda_knn_ggnn_gpu_instance.cuh index 8cbaf0d..6eb72ac 100644 @@ -28,23 +28,23 @@ index 8cbaf0d..6eb72ac 100644 #include "ggnn/utils/cuda_knn_utils.cuh" #include "ggnn/utils/cuda_knn_constants.cuh" -#include "ggnn/utils/cuda_knn_dataset.cuh" - + template __global__ void divide(ValueT* res, ValueT* input, ValueT N) { @@ -98,9 +97,7 @@ struct GGNNGPUInstance { typedef GGNNGraphDevice GGNNGraphDevice; typedef GGNNGraphHost GGNNGraphHost; - + - const Dataset* dataset; GGNNGraphBuffer* ggnn_buffer {nullptr}; - GGNNQuery ggnn_query; - + // Graph Shards resident on the GPU std::vector ggnn_shards; @@ -117,13 +114,12 @@ struct GGNNGPUInstance { // number of shards that need to be processed by this instance const int num_parts; - + - GGNNGPUInstance(const int gpu_id, const Dataset* dataset, + GGNNGPUInstance(const int gpu_id, const int N_shard, const int L, @@ -60,14 +60,14 @@ index 8cbaf0d..6eb72ac 100644 @@ -135,7 +131,6 @@ struct GGNNGPUInstance { CHECK_EQ(current_gpu_id, gpu_id) << "cudaSetDevice() needs to be called in advance!"; } - + - ggnn_query.loadQueriesAsync(dataset->h_query, 0); - + computeGraphParameters(); - + @@ -186,7 +181,7 @@ struct GGNNGPUInstance { } - + GGNNGPUInstance(const GGNNGPUInstance& other) - : dataset{nullptr}, ggnn_query{0, D, KQuery}, + : @@ -75,9 +75,9 @@ index 8cbaf0d..6eb72ac 100644 // this exists to allow using vector::emplace_back // when it triggers a reallocation, this code will be called. @@ -305,6 +300,7 @@ struct GGNNGPUInstance { - + // io - + + /* void waitForDiskIO(const int shard_id) { auto& cpu_buffer = ggnn_cpu_buffers[shard_id%ggnn_cpu_buffers.size()]; @@ -87,41 +87,41 @@ index 8cbaf0d..6eb72ac 100644 CHECK_CUDA(cudaPeekAtLastError()); } + */ - + // graph operations - + template - void queryLayer(const int shard_id = 0) const { + void queryLayer(const BaseT* d_query, int batch_size, KeyT* d_query_result_ids, ValueT* d_query_result_dists, const int shard_id = 0) const { CHECK_CUDA(cudaSetDevice(gpu_id)); const auto& shard = ggnn_shards.at(shard_id%ggnn_shards.size()); - + @@ -482,21 +479,21 @@ struct GGNNGPUInstance { - + int* m_dist_statistics = nullptr; if (DIST_STATS) - cudaMallocManaged(&m_dist_statistics, dataset->N_query * sizeof(int)); + cudaMallocManaged(&m_dist_statistics, batch_size * sizeof(int)); - + QueryKernel query_kernel; query_kernel.d_base = shard.d_base; - query_kernel.d_query = ggnn_query.d_query; + query_kernel.d_query = d_query; - + query_kernel.d_graph = shard.d_graph; - query_kernel.d_query_results = ggnn_query.d_query_result_ids; - query_kernel.d_query_results_dists = ggnn_query.d_query_result_dists; + query_kernel.d_query_results = d_query_result_ids; + query_kernel.d_query_results_dists = d_query_result_dists; - + query_kernel.d_translation = shard.d_translation; - + query_kernel.d_nn1_stats = shard.d_nn1_stats; - + - query_kernel.N = dataset->N_query; + query_kernel.N = batch_size; query_kernel.N_offset = 0; - + query_kernel.d_dist_stats = m_dist_statistics; @@ -771,6 +768,16 @@ struct GGNNGPUInstance { sym(layer, shard_id); @@ -138,7 +138,7 @@ index 8cbaf0d..6eb72ac 100644 + ggnn_shards.at(0).d_base = dataset; + } }; - + #endif // INCLUDE_GGNN_CUDA_KNN_GGNN_GPU_INSTANCE_CUH_ diff --git a/include/ggnn/graph/cuda_knn_ggnn_graph_device.cuh b/include/ggnn/graph/cuda_knn_ggnn_graph_device.cuh index c94a8f1..781226d 100644 @@ -146,11 +146,11 @@ index c94a8f1..781226d 100644 +++ b/include/ggnn/graph/cuda_knn_ggnn_graph_device.cuh @@ -50,7 +50,7 @@ struct GGNNGraphDevice { ValueT* d_nn1_stats; - + /// base data pointer for the shard. - BaseT* d_base; + const BaseT* d_base; - + /// combined memory pool char* d_memory; @@ -69,7 +69,9 @@ struct GGNNGraphDevice { @@ -161,12 +161,12 @@ index c94a8f1..781226d 100644 + // base_size = align8(static_cast(N) * D * sizeof(BaseT)); + (void) N; + (void) D; - + const size_t total_size = base_size+total_graph_size; - + @@ -86,8 +88,7 @@ struct GGNNGraphDevice { CHECK_CUDA(cudaMalloc(&d_memory, total_size)); - + size_t pos = 0; - d_base = reinterpret_cast(d_memory+pos); - pos += base_size; @@ -175,17 +175,17 @@ index c94a8f1..781226d 100644 pos += graph_size; d_translation = reinterpret_cast(d_memory+pos); @@ -99,14 +100,14 @@ struct GGNNGraphDevice { - + CHECK_EQ(pos, total_size); - + - CHECK_CUDA(cudaStreamCreate(&stream)); + // CHECK_CUDA(cudaStreamCreate(&stream)); - + CHECK_CUDA(cudaPeekAtLastError()); CHECK_CUDA(cudaDeviceSynchronize()); CHECK_CUDA(cudaPeekAtLastError()); } - + - GGNNGraphDevice(const GGNNGraphDevice& other) { + GGNNGraphDevice(const GGNNGraphDevice&) { // this exists to allow using vector::emplace_back @@ -194,12 +194,12 @@ index c94a8f1..781226d 100644 @@ -116,7 +117,7 @@ struct GGNNGraphDevice { ~GGNNGraphDevice() { cudaFree(d_memory); - + - CHECK_CUDA(cudaStreamDestroy(stream)); + // CHECK_CUDA(cudaStreamDestroy(stream)); } }; - + diff --git a/include/ggnn/graph/cuda_knn_ggnn_graph_host.cuh b/include/ggnn/graph/cuda_knn_ggnn_graph_host.cuh index 2055f9e..ef5843a 100644 --- a/include/ggnn/graph/cuda_knn_ggnn_graph_host.cuh @@ -207,7 +207,7 @@ index 2055f9e..ef5843a 100644 @@ -92,7 +92,7 @@ struct GGNNGraphHost { CHECK_CUDA(cudaPeekAtLastError()); } - + - GGNNGraphHost(const GGNNGraphHost& other) { + GGNNGraphHost(const GGNNGraphHost&) { // this exists to allow using vector::emplace_back @@ -220,11 +220,10 @@ index 49d76a1..eef69e6 100644 @@ -22,7 +22,6 @@ limitations under the License. #include #include - + -#include #include - + #include "ggnn/utils/cuda_knn_constants.cuh" --- +-- 2.43.0 - diff --git a/cpp/cmake/patches/ggnn_override.json b/cpp/cmake/patches/ggnn_override.json index c9a1b69782..f1bd8c8a4b 100644 --- a/cpp/cmake/patches/ggnn_override.json +++ b/cpp/cmake/patches/ggnn_override.json @@ -13,4 +13,4 @@ ] } } - } \ No newline at end of file + } diff --git a/cpp/cmake/patches/hnswlib.diff b/cpp/cmake/patches/hnswlib.diff index f20c27d919..96be2b2380 100644 --- a/cpp/cmake/patches/hnswlib.diff +++ b/cpp/cmake/patches/hnswlib.diff @@ -11,20 +11,20 @@ index bef0017..0ee7931 100644 + bool base_layer_init = true; static const tableint MAX_LABEL_OPERATION_LOCKS = 65536; static const unsigned char DELETE_MARK = 0x01; - + @@ -1098,7 +1101,7 @@ class HierarchicalNSW : public AlgorithmInterface { - + std::unique_lock lock_el(link_list_locks_[cur_c]); int curlevel = getRandomLevel(mult_); - if (level > 0) + if (level > -1) curlevel = level; - + element_levels_[cur_c] = curlevel; @@ -1116,6 +1119,9 @@ class HierarchicalNSW : public AlgorithmInterface { memcpy(getExternalLabeLp(cur_c), &label, sizeof(labeltype)); memcpy(getDataByInternalId(cur_c), data_point, data_size_); - + + if (!base_layer_init && curlevel == 0) + return cur_c; + @@ -43,7 +43,7 @@ index bef0017..0ee7931 100644 @@ -1188,28 +1194,41 @@ class HierarchicalNSW : public AlgorithmInterface { tableint currObj = enterpoint_node_; dist_t curdist = fstdistfunc_(query_data, getDataByInternalId(enterpoint_node_), dist_func_param_); - + - for (int level = maxlevel_; level > 0; level--) { - bool changed = true; - while (changed) { @@ -66,7 +66,7 @@ index bef0017..0ee7931 100644 + while (changed) { + changed = false; + unsigned int *data; - + - data = (unsigned int *) get_linklist(currObj, level); - int size = getListCount(data); - metric_hops++; @@ -82,7 +82,7 @@ index bef0017..0ee7931 100644 + if (static_cast(cand) < 0 || cand > max_elements_) + throw std::runtime_error("cand error"); + dist_t d = fstdistfunc_(query_data, getDataByInternalId(cand), dist_func_param_); - + - tableint *datal = (tableint *) (data + 1); - for (int i = 0; i < size; i++) { - tableint cand = datal[i]; @@ -109,7 +109,7 @@ index 834d19f..0c0af26 100644 @@ -252,12 +252,13 @@ class L2Space : public SpaceInterface { ~L2Space() {} }; - + +template static int L2SqrI4x(const void *__restrict pVect1, const void *__restrict pVect2, const void *__restrict qty_ptr) { @@ -119,13 +119,13 @@ index 834d19f..0c0af26 100644 - unsigned char *b = (unsigned char *) pVect2; + T *a = (T *) pVect1; + T *b = (T *) pVect2; - + qty = qty >> 2; for (size_t i = 0; i < qty; i++) { @@ -277,11 +278,12 @@ L2SqrI4x(const void *__restrict pVect1, const void *__restrict pVect2, const voi return (res); } - + +template static int L2SqrI(const void* __restrict pVect1, const void* __restrict pVect2, const void* __restrict qty_ptr) { size_t qty = *((size_t*)qty_ptr); @@ -134,13 +134,13 @@ index 834d19f..0c0af26 100644 - unsigned char* b = (unsigned char*)pVect2; + T* a = (T*)pVect1; + T* b = (T*)pVect2; - + for (size_t i = 0; i < qty; i++) { res += ((*a) - (*b)) * ((*a) - (*b)); @@ -291,6 +293,7 @@ static int L2SqrI(const void* __restrict pVect1, const void* __restrict pVect2, return (res); } - + +template class L2SpaceI : public SpaceInterface { DISTFUNC fstdistfunc_; diff --git a/cpp/cmake/patches/hnswlib_override.json b/cpp/cmake/patches/hnswlib_override.json index c50220e248..812af74bc1 100644 --- a/cpp/cmake/patches/hnswlib_override.json +++ b/cpp/cmake/patches/hnswlib_override.json @@ -13,4 +13,4 @@ ] } } -} \ No newline at end of file +} diff --git a/cpp/cmake/thirdparty/get_faiss.cmake b/cpp/cmake/thirdparty/get_faiss.cmake index d6261d2484..90d53a4d8b 100644 --- a/cpp/cmake/thirdparty/get_faiss.cmake +++ b/cpp/cmake/thirdparty/get_faiss.cmake @@ -23,7 +23,7 @@ function(find_and_configure_faiss) HEADER_NAMES faiss/IndexFlat.h LIBRARY_NAMES faiss ) - + set(patch_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../patches") rapids_cpm_package_override("${patch_dir}/faiss_override.json") @@ -62,7 +62,7 @@ function(find_and_configure_faiss) "CMAKE_MESSAGE_LOG_LEVEL VERBOSE" ) - + include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake") rapids_cpm_display_patch_status(faiss) diff --git a/cpp/cmake/thirdparty/get_ggnn.cmake b/cpp/cmake/thirdparty/get_ggnn.cmake index 2ccfbc64df..8ee5bfd1d3 100644 --- a/cpp/cmake/thirdparty/get_ggnn.cmake +++ b/cpp/cmake/thirdparty/get_ggnn.cmake @@ -38,7 +38,7 @@ function(find_and_configure_ggnn) include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake") rapids_cpm_display_patch_status(ggnn) - + if(NOT TARGET ggnn::ggnn) add_library(ggnn INTERFACE) target_include_directories(ggnn INTERFACE "$") diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 845c7a8337..3c352b6936 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -44,7 +44,7 @@ function(find_and_configure_raft) INSTALL_EXPORT_SET cuvs-exports COMPONENTS ${RAFT_COMPONENTS} CPM_ARGS - EXCLUDE_FROM_ALL TRUE + EXCLUDE_FROM_ALL TRUE GIT_REPOSITORY https://github.com/${PKG_FORK}/raft.git GIT_TAG ${PKG_PINNED_TAG} SOURCE_SUBDIR cpp diff --git a/cpp/doxygen/Doxyfile b/cpp/doxygen/Doxyfile index e28572457b..ce6741c1f2 100644 --- a/cpp/doxygen/Doxyfile +++ b/cpp/doxygen/Doxyfile @@ -880,7 +880,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = ../include/cuvs/sparse/selection +EXCLUDE = ../include/cuvs/sparse/selection # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/cpp/doxygen/main_page.md b/cpp/doxygen/main_page.md index d002df0017..81757f5dbd 100644 --- a/cpp/doxygen/main_page.md +++ b/cpp/doxygen/main_page.md @@ -1,3 +1,3 @@ # libcuvs -cuVS is a library for vector search on the GPU \ No newline at end of file +cuVS is a library for vector search on the GPU diff --git a/cpp/include/cuvs/neighbors/hnsw.hpp b/cpp/include/cuvs/neighbors/hnsw.hpp index f0b433d8e2..81a823493c 100644 --- a/cpp/include/cuvs/neighbors/hnsw.hpp +++ b/cpp/include/cuvs/neighbors/hnsw.hpp @@ -724,4 +724,4 @@ void deserialize(raft::resources const& res, #else #error "This header is only available if cuVS CMake option `BUILD_CAGRA_HNSWLIB=ON" -#endif \ No newline at end of file +#endif diff --git a/cpp/include/cuvs/neighbors/refine.hpp b/cpp/include/cuvs/neighbors/refine.hpp index 5e60ff5379..e03ffb5632 100644 --- a/cpp/include/cuvs/neighbors/refine.hpp +++ b/cpp/include/cuvs/neighbors/refine.hpp @@ -481,4 +481,4 @@ void refine(raft::resources const& handle, raft::host_matrix_view distances, cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Unexpanded); -} // namespace cuvs::neighbors \ No newline at end of file +} // namespace cuvs::neighbors diff --git a/cpp/scripts/run-clang-compile.py b/cpp/scripts/run-clang-compile.py index eae52f7310..71b5db568b 100644 --- a/cpp/scripts/run-clang-compile.py +++ b/cpp/scripts/run-clang-compile.py @@ -253,12 +253,12 @@ def run_clang_command(clang_cmd, cwd): class LockContext(object): def __init__(self, lock=None) -> None: self._lock = lock - + def __enter__(self): if self._lock: self._lock.acquire() return self - + def __exit__(self, _, __, ___): if self._lock: self._lock.release() diff --git a/cpp/scripts/run-clang-tidy.py b/cpp/scripts/run-clang-tidy.py index 3d8bbcec4a..cad08ca551 100644 --- a/cpp/scripts/run-clang-tidy.py +++ b/cpp/scripts/run-clang-tidy.py @@ -296,12 +296,12 @@ def run_clang_tidy_command(tidy_cmd, cwd): class LockContext(object): def __init__(self, lock=None) -> None: self._lock = lock - + def __enter__(self): if self._lock: self._lock.acquire() return self - + def __exit__(self, _, __, ___): if self._lock: self._lock.release() diff --git a/cpp/scripts/run-cmake-format.sh b/cpp/scripts/run-cmake-format.sh index 1f7ae359f1..7e30258fcb 100755 --- a/cpp/scripts/run-cmake-format.sh +++ b/cpp/scripts/run-cmake-format.sh @@ -17,7 +17,7 @@ # and exits gracefully if the file is not found. If a user wishes to specify a # config file at a nonstandard location, they may do so by setting the # environment variable RAPIDS_CMAKE_FORMAT_FILE. -# +# # This script can be invoked directly anywhere within the project repository. # Alternatively, it may be invoked as a pre-commit hook via # `pre-commit run (cmake-format)|(cmake-lint)`. diff --git a/cpp/src/cluster/detail/mst.cuh b/cpp/src/cluster/detail/mst.cuh index 5804b8b5d9..2929262d21 100644 --- a/cpp/src/cluster/detail/mst.cuh +++ b/cpp/src/cluster/detail/mst.cuh @@ -204,4 +204,4 @@ void build_sorted_mst( raft::copy_async(mst_weight, mst_coo.weights.data(), mst_coo.n_edges, stream); } -}; // namespace cuvs::cluster::agglomerative::detail \ No newline at end of file +}; // namespace cuvs::cluster::agglomerative::detail diff --git a/cpp/src/cluster/detail/single_linkage.cuh b/cpp/src/cluster/detail/single_linkage.cuh index 8b90336b71..d1660f9ff3 100644 --- a/cpp/src/cluster/detail/single_linkage.cuh +++ b/cpp/src/cluster/detail/single_linkage.cuh @@ -122,4 +122,4 @@ void single_linkage(raft::resources const& handle, out->n_leaves = m; out->n_connected_components = 1; } -}; // namespace cuvs::cluster::agglomerative::detail \ No newline at end of file +}; // namespace cuvs::cluster::agglomerative::detail diff --git a/cpp/src/distance/detail/fused_distance_nn/gemm.h b/cpp/src/distance/detail/fused_distance_nn/gemm.h index 6c8d718d0e..789878a736 100644 --- a/cpp/src/distance/detail/fused_distance_nn/gemm.h +++ b/cpp/src/distance/detail/fused_distance_nn/gemm.h @@ -409,4 +409,4 @@ struct FusedDistanceNNGemm>(handle, knn_graph, new_graph); } -} // namespace cuvs::neighbors::cagra \ No newline at end of file +} // namespace cuvs::neighbors::cagra diff --git a/cpp/src/neighbors/detail/cagra/cagra_build.cpp b/cpp/src/neighbors/detail/cagra/cagra_build.cpp index 574a020977..490dc0f304 100644 --- a/cpp/src/neighbors/detail/cagra/cagra_build.cpp +++ b/cpp/src/neighbors/detail/cagra/cagra_build.cpp @@ -32,4 +32,4 @@ ivf_pq_params::ivf_pq_params(raft::matrix_extent dataset_extents, refinement_rate = 2; } -} // namespace cuvs::neighbors::cagra::graph_build_params \ No newline at end of file +} // namespace cuvs::neighbors::cagra::graph_build_params diff --git a/cpp/src/neighbors/ivf_flat/generate_ivf_flat.py b/cpp/src/neighbors/ivf_flat/generate_ivf_flat.py index c435cc6d95..39baeeafae 100644 --- a/cpp/src/neighbors/ivf_flat/generate_ivf_flat.py +++ b/cpp/src/neighbors/ivf_flat/generate_ivf_flat.py @@ -136,7 +136,7 @@ { \\ cuvs::neighbors::ivf_flat::detail::extend( \\ handle, new_vectors, new_indices, idx); \\ - } + } """ search_macro = """ diff --git a/cpp/src/neighbors/ivf_list.cuh b/cpp/src/neighbors/ivf_list.cuh index c6335b1142..9d8aef5033 100644 --- a/cpp/src/neighbors/ivf_list.cuh +++ b/cpp/src/neighbors/ivf_list.cuh @@ -192,4 +192,4 @@ enable_if_valid_list_t deserialize_list(const raft::resources& handle, // Make sure the data is copied from host to device before the host arrays get out of the scope. raft::resource::sync_stream(handle); } -} // namespace cuvs::neighbors::ivf \ No newline at end of file +} // namespace cuvs::neighbors::ivf diff --git a/cpp/src/neighbors/nn_descent_index.cpp b/cpp/src/neighbors/nn_descent_index.cpp index 25d5b6af84..3fe69e7754 100644 --- a/cpp/src/neighbors/nn_descent_index.cpp +++ b/cpp/src/neighbors/nn_descent_index.cpp @@ -26,4 +26,4 @@ index_params::index_params(size_t graph_degree, cuvs::distance::DistanceType met this->intermediate_graph_degree = 1.5 * graph_degree; this->metric = metric; } -} // namespace cuvs::neighbors::nn_descent \ No newline at end of file +} // namespace cuvs::neighbors::nn_descent diff --git a/cpp/src/neighbors/refine/detail/refine_host_half_float.cpp b/cpp/src/neighbors/refine/detail/refine_host_half_float.cpp index ed9c412089..4c9378dfc1 100644 --- a/cpp/src/neighbors/refine/detail/refine_host_half_float.cpp +++ b/cpp/src/neighbors/refine/detail/refine_host_half_float.cpp @@ -34,4 +34,4 @@ instantiate_cuvs_neighbors_refine(int64_t, half, float, int64_t); -#undef instantiate_cuvs_neighbors_refine \ No newline at end of file +#undef instantiate_cuvs_neighbors_refine diff --git a/cpp/src/neighbors/refine/refine_device.cuh b/cpp/src/neighbors/refine/refine_device.cuh index a5491be0da..606ba58e39 100644 --- a/cpp/src/neighbors/refine/refine_device.cuh +++ b/cpp/src/neighbors/refine/refine_device.cuh @@ -159,4 +159,4 @@ void refine_impl( { detail::refine_device(handle, dataset, queries, neighbor_candidates, indices, distances, metric); } -} // namespace cuvs::neighbors \ No newline at end of file +} // namespace cuvs::neighbors diff --git a/cpp/src/neighbors/refine/refine_host.hpp b/cpp/src/neighbors/refine/refine_host.hpp index dcaccd5a87..105023d590 100644 --- a/cpp/src/neighbors/refine/refine_host.hpp +++ b/cpp/src/neighbors/refine/refine_host.hpp @@ -211,4 +211,4 @@ void refine_impl( detail::refine_host(dataset, queries, neighbor_candidates, indices, distances, metric); } -} // namespace cuvs::neighbors \ No newline at end of file +} // namespace cuvs::neighbors diff --git a/cpp/src/preprocessing/quantize/scalar.cu b/cpp/src/preprocessing/quantize/scalar.cu index 9624ad4fe8..68cba4cc8d 100644 --- a/cpp/src/preprocessing/quantize/scalar.cu +++ b/cpp/src/preprocessing/quantize/scalar.cu @@ -71,4 +71,4 @@ CUVS_INST_QUANTIZATION(half, int8_t); #undef CUVS_INST_QUANTIZATION -} // namespace cuvs::preprocessing::quantize::scalar \ No newline at end of file +} // namespace cuvs::preprocessing::quantize::scalar diff --git a/cpp/src/sparse/cluster/cluster_solvers.cuh b/cpp/src/sparse/cluster/cluster_solvers.cuh index 7b4cf6ab34..737dfa5f8a 100644 --- a/cpp/src/sparse/cluster/cluster_solvers.cuh +++ b/cpp/src/sparse/cluster/cluster_solvers.cuh @@ -97,4 +97,4 @@ struct kmeans_solver_t { } // namespace spectral } // namespace cuvs -#endif \ No newline at end of file +#endif diff --git a/cpp/src/sparse/cluster/detail/spectral.cuh b/cpp/src/sparse/cluster/detail/spectral.cuh index 571d92bf56..3d44bd4a20 100644 --- a/cpp/src/sparse/cluster/detail/spectral.cuh +++ b/cpp/src/sparse/cluster/detail/spectral.cuh @@ -108,4 +108,4 @@ void fit_embedding(raft::resources const& handle, RAFT_CUDA_TRY(cudaGetLastError()); } -}; // namespace cuvs::sparse::cluster::spectral::detail \ No newline at end of file +}; // namespace cuvs::sparse::cluster::spectral::detail diff --git a/cpp/src/sparse/cluster/modularity_maximization.cuh b/cpp/src/sparse/cluster/modularity_maximization.cuh index 71cba69272..ce60116d13 100644 --- a/cpp/src/sparse/cluster/modularity_maximization.cuh +++ b/cpp/src/sparse/cluster/modularity_maximization.cuh @@ -83,4 +83,4 @@ void analyzeModularity(raft::resources const& handle, } // namespace spectral } // namespace cuvs -#endif \ No newline at end of file +#endif diff --git a/cpp/src/sparse/cluster/partition.cuh b/cpp/src/sparse/cluster/partition.cuh index df78a8a2d9..111decadf3 100644 --- a/cpp/src/sparse/cluster/partition.cuh +++ b/cpp/src/sparse/cluster/partition.cuh @@ -92,4 +92,4 @@ void analyzePartition(raft::resources const& handle, } // namespace spectral } // namespace cuvs -#endif \ No newline at end of file +#endif diff --git a/cpp/src/sparse/neighbors/cross_component_nn.cuh b/cpp/src/sparse/neighbors/cross_component_nn.cuh index 36a0c79f59..02ce240c4a 100644 --- a/cpp/src/sparse/neighbors/cross_component_nn.cuh +++ b/cpp/src/sparse/neighbors/cross_component_nn.cuh @@ -96,4 +96,4 @@ void cross_component_nn( metric); } -}; // end namespace cuvs::sparse::neighbors \ No newline at end of file +}; // end namespace cuvs::sparse::neighbors diff --git a/cpp/test/distance/gram.cu b/cpp/test/distance/gram.cu index 89b1525ea8..3d14da84da 100644 --- a/cpp/test/distance/gram.cu +++ b/cpp/test/distance/gram.cu @@ -171,4 +171,4 @@ typedef GramMatrixTest GramMatrixTestDouble; TEST_P(GramMatrixTestFloat, Gram) { runTest(); } INSTANTIATE_TEST_SUITE_P(GramMatrixTests, GramMatrixTestFloat, ::testing::ValuesIn(inputs)); -}; // namespace cuvs::distance::kernels \ No newline at end of file +}; // namespace cuvs::distance::kernels diff --git a/cpp/test/distance/gram_base.cuh b/cpp/test/distance/gram_base.cuh index 326cdb4f86..6cfb1807b0 100644 --- a/cpp/test/distance/gram_base.cuh +++ b/cpp/test/distance/gram_base.cuh @@ -88,4 +88,4 @@ void naiveGramMatrixKernel(int n1, } // namespace kernels } // namespace distance -} // namespace cuvs \ No newline at end of file +} // namespace cuvs diff --git a/cpp/test/sparse/cluster/spectral.cu b/cpp/test/sparse/cluster/spectral.cu index 7d0cdef9db..98b963451f 100644 --- a/cpp/test/sparse/cluster/spectral.cu +++ b/cpp/test/sparse/cluster/spectral.cu @@ -106,4 +106,4 @@ TEST(Raft, Spectral) } } // namespace cluster -} // namespace cuvs \ No newline at end of file +} // namespace cuvs diff --git a/cpp/test/sparse/gram.cu b/cpp/test/sparse/gram.cu index d7af30a1cb..c3ce99817e 100644 --- a/cpp/test/sparse/gram.cu +++ b/cpp/test/sparse/gram.cu @@ -327,4 +327,4 @@ INSTANTIATE_TEST_SUITE_P(GramMatrixTests, GramMatrixTestFloatLd, ::testing::Valu INSTANTIATE_TEST_SUITE_P(GramMatrixTests, GramMatrixTestFloatLdCsr, ::testing::ValuesIn(inputs_ld_csr)); -}; // namespace cuvs::distance::kernels::sparse \ No newline at end of file +}; // namespace cuvs::distance::kernels::sparse diff --git a/cpp/test/test_utils.cuh b/cpp/test/test_utils.cuh index d0b2d6bdac..022202ffb2 100644 --- a/cpp/test/test_utils.cuh +++ b/cpp/test/test_utils.cuh @@ -327,4 +327,4 @@ inline std::vector read_csv(std::string filename, bool skip_first_n_colum return result; } -}; // end namespace cuvs \ No newline at end of file +}; // end namespace cuvs diff --git a/docs/README.md b/docs/README.md index cd0fe0a149..639961ea37 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,4 +11,4 @@ bash build.sh docs #### Once the process finishes, documentation can be found in build/html ```shell script xdg-open build/html/index.html` -``` \ No newline at end of file +``` diff --git a/docs/source/_static/references.css b/docs/source/_static/references.css index 225cf13ba9..d1f647233a 100644 --- a/docs/source/_static/references.css +++ b/docs/source/_static/references.css @@ -20,4 +20,4 @@ dl.citation > dt.label > span::before { /* Add closing bracket */ dl.citation > dt.label > span::after { content: "]"; -} \ No newline at end of file +} diff --git a/docs/source/api_basics.rst b/docs/source/api_basics.rst index 4842e27889..d3e2c8a6ff 100644 --- a/docs/source/api_basics.rst +++ b/docs/source/api_basics.rst @@ -87,4 +87,4 @@ Rust .. code-block:: rust - let res = cuvs::Resources::new()?; \ No newline at end of file + let res = cuvs::Resources::new()?; diff --git a/docs/source/api_docs.rst b/docs/source/api_docs.rst index f4deef5064..68d184c72c 100644 --- a/docs/source/api_docs.rst +++ b/docs/source/api_docs.rst @@ -10,4 +10,4 @@ API Reference rust_api/index.rst * :ref:`genindex` -* :ref:`search` \ No newline at end of file +* :ref:`search` diff --git a/docs/source/api_interoperability.rst b/docs/source/api_interoperability.rst index 4dfe1e09af..519660036f 100644 --- a/docs/source/api_interoperability.rst +++ b/docs/source/api_interoperability.rst @@ -48,10 +48,10 @@ The `mdarray` is an owning object that forms a convenience layer over RMM and ca .. code-block:: c++ #include - + int n_rows = 10; int n_cols = 10; - + auto scalar = raft::make_device_scalar(handle, 1.0); auto vector = raft::make_device_vector(handle, n_cols); auto matrix = raft::make_device_matrix(handle, n_rows, n_cols); diff --git a/docs/source/comparing_indexes.rst b/docs/source/comparing_indexes.rst index 221aab6d75..167aa2e072 100644 --- a/docs/source/comparing_indexes.rst +++ b/docs/source/comparing_indexes.rst @@ -57,4 +57,4 @@ It turns out that most vector databases, like Milvus for example, make many smal Please note, however, that there are often caps on the size of each of these smaller indexes, and that needs to be taken into consideration when choosing the size of the sub sample to tune. -Please see :doc:`this guide ` for more information on the steps one would take to do this subsampling and tuning process. \ No newline at end of file +Please see :doc:`this guide ` for more information on the steps one would take to do this subsampling and tuning process. diff --git a/docs/source/contributing.md b/docs/source/contributing.md index c426ce5340..1a58da4d75 100755 --- a/docs/source/contributing.md +++ b/docs/source/contributing.md @@ -89,5 +89,3 @@ implementation of the issue, ask them in the issue instead of the PR. ## Attribution Portions adopted from https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md - - diff --git a/docs/source/cpp_api/cluster.rst b/docs/source/cpp_api/cluster.rst index 3e3e627f75..3de663a21b 100644 --- a/docs/source/cpp_api/cluster.rst +++ b/docs/source/cpp_api/cluster.rst @@ -11,4 +11,3 @@ Cluster cluster_kmeans.rst cluster_agglomerative.rst - diff --git a/docs/source/cpp_api/cluster_kmeans.rst b/docs/source/cpp_api/cluster_kmeans.rst index 3ff8a03e5a..6c342baabd 100644 --- a/docs/source/cpp_api/cluster_kmeans.rst +++ b/docs/source/cpp_api/cluster_kmeans.rst @@ -41,4 +41,4 @@ namespace *cuvs::cluster::kmeans::helpers* .. doxygengroup:: kmeans_helpers :project: cuvs :members: - :content-only: \ No newline at end of file + :content-only: diff --git a/docs/source/cpp_api/neighbors_nn_descent.rst b/docs/source/cpp_api/neighbors_nn_descent.rst index edecdfa8df..c21a1003db 100644 --- a/docs/source/cpp_api/neighbors_nn_descent.rst +++ b/docs/source/cpp_api/neighbors_nn_descent.rst @@ -34,4 +34,4 @@ Index build .. doxygengroup:: nn_descent_cpp_index_build :project: cuvs :members: - :content-only: \ No newline at end of file + :content-only: diff --git a/docs/source/cpp_api/neighbors_refine.rst b/docs/source/cpp_api/neighbors_refine.rst index d53c8087cc..4a90ee9959 100644 --- a/docs/source/cpp_api/neighbors_refine.rst +++ b/docs/source/cpp_api/neighbors_refine.rst @@ -17,4 +17,4 @@ Index .. doxygengroup:: ann_refine :project: cuvs :members: - :content-only: \ No newline at end of file + :content-only: diff --git a/docs/source/cpp_api/preprocessing_quantize.rst b/docs/source/cpp_api/preprocessing_quantize.rst index b660c61c51..8a08fb98ba 100644 --- a/docs/source/cpp_api/preprocessing_quantize.rst +++ b/docs/source/cpp_api/preprocessing_quantize.rst @@ -2,7 +2,7 @@ Quantize ======== This page provides C++ class references for the publicly-exposed elements of the -`cuvs/preprocessing/quantize` package. +`cuvs/preprocessing/quantize` package. .. role:: py(code) :language: c++ @@ -17,4 +17,3 @@ namespace *cuvs::preprocessing::quantize::scalar* .. doxygengroup:: scalar :project: cuvs - diff --git a/docs/source/cpp_api/stats.rst b/docs/source/cpp_api/stats.rst index 80d6c65fc9..988ba05dfc 100644 --- a/docs/source/cpp_api/stats.rst +++ b/docs/source/cpp_api/stats.rst @@ -32,4 +32,3 @@ namespace *cuvs::stats* :project: cuvs :members: :content-only: - diff --git a/docs/source/cuvs_bench/build.rst b/docs/source/cuvs_bench/build.rst index de84326915..0c2dc98b8c 100644 --- a/docs/source/cuvs_bench/build.rst +++ b/docs/source/cuvs_bench/build.rst @@ -56,4 +56,4 @@ Available targets to use with `--limit-bench-ann` are: - CUVS_IVF_PQ_ANN_BENCH - CUVS_IVF_FLAT_ANN_BENCH -By default, the `*_ANN_BENCH` executables program infer the dataset's datatype from the filename's extension. For example, an extension of `fbin` uses a `float` datatype, `f16bin` uses a `float16` datatype, extension of `i8bin` uses `int8_t` datatype, and `u8bin` uses `uint8_t` type. Currently, only `float`, `float16`, int8_t`, and `unit8_t` are supported. \ No newline at end of file +By default, the `*_ANN_BENCH` executables program infer the dataset's datatype from the filename's extension. For example, an extension of `fbin` uses a `float` datatype, `f16bin` uses a `float16` datatype, extension of `i8bin` uses `int8_t` datatype, and `u8bin` uses `uint8_t` type. Currently, only `float`, `float16`, int8_t`, and `unit8_t` are supported. diff --git a/docs/source/cuvs_bench/datasets.rst b/docs/source/cuvs_bench/datasets.rst index 0f6539e560..e6a53ca82b 100644 --- a/docs/source/cuvs_bench/datasets.rst +++ b/docs/source/cuvs_bench/datasets.rst @@ -59,4 +59,4 @@ If you have a dataset, but no corresponding ground truth file, then you can gene # Using only a subset of the dataset. Define queries by randomly # selecting vectors from the (subset of the) dataset. - python -m cuvs_bench.generate_groundtruth --dataset /dataset/base.fbin --nrows=2000000 --output=groundtruth_dir --queries=random-choice --n_queries=10000 \ No newline at end of file + python -m cuvs_bench.generate_groundtruth --dataset /dataset/base.fbin --nrows=2000000 --output=groundtruth_dir --queries=random-choice --n_queries=10000 diff --git a/docs/source/cuvs_bench/param_tuning.rst b/docs/source/cuvs_bench/param_tuning.rst index faffa9daff..c85504e967 100644 --- a/docs/source/cuvs_bench/param_tuning.rst +++ b/docs/source/cuvs_bench/param_tuning.rst @@ -671,4 +671,4 @@ hnswlib - 1 - Number of threads to use for queries. -Please refer to `HNSW algorithm parameters guide `_ from `hnswlib` to learn more about these arguments. \ No newline at end of file +Please refer to `HNSW algorithm parameters guide `_ from `hnswlib` to learn more about these arguments. diff --git a/docs/source/cuvs_bench/wiki_all_dataset.rst b/docs/source/cuvs_bench/wiki_all_dataset.rst index 04ac7d9a4b..cedeeb93f5 100644 --- a/docs/source/cuvs_bench/wiki_all_dataset.rst +++ b/docs/source/cuvs_bench/wiki_all_dataset.rst @@ -52,4 +52,4 @@ After the dataset is downloaded and extracted to the `wiki_all_88M` directory (o License info ============ -The English wiki texts available on Kaggle come with the `CC BY-NCSA 4.0 `_ license and the Cohere wikipedia data set comes with the `Apache 2.0 `_ license. \ No newline at end of file +The English wiki texts available on Kaggle come with the `CC BY-NCSA 4.0 `_ license and the Cohere wikipedia data set comes with the `Apache 2.0 `_ license. diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index fa38c45ee0..b9cfdaca2e 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -117,4 +117,4 @@ We always welcome patches for new features and bug fixes. Please read our `contr comparing_indexes.rst indexes/indexes.rst api_basics.rst - api_interoperability.rst \ No newline at end of file + api_interoperability.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 286836c186..4dcf59112d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -88,4 +88,3 @@ Contents cuvs_bench/index.rst api_docs.rst contributing.md - diff --git a/docs/source/indexes/cagra.rst b/docs/source/indexes/cagra.rst index de8821e745..551eca8f72 100644 --- a/docs/source/indexes/cagra.rst +++ b/docs/source/indexes/cagra.rst @@ -145,5 +145,3 @@ IVF-PQ Search (max batch size 1024 vectors on device at a time): [n_vectors * (pq_dim * pq_bits / 8 + sizeof(int64_t)) + O(n_clusters)] + [batch_size * n_dim * sizeof(float)] + [batch_size * intermediate_degree * sizeof(uint32_t)] + [batch_size * intermediate_degree * sizeof(float)] - - diff --git a/docs/source/indexes/indexes.rst b/docs/source/indexes/indexes.rst index a2fb1434a5..4a18f793a7 100644 --- a/docs/source/indexes/indexes.rst +++ b/docs/source/indexes/indexes.rst @@ -16,4 +16,4 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` -* :ref:`search` \ No newline at end of file +* :ref:`search` diff --git a/docs/source/indexes/ivfflat.rst b/docs/source/indexes/ivfflat.rst index 14dd1798c5..89a9fb6e64 100644 --- a/docs/source/indexes/ivfflat.rst +++ b/docs/source/indexes/ivfflat.rst @@ -113,4 +113,3 @@ Peak device memory usage for index build: :math:`workspace = min(1GB, n\_queries * [(n\_lists + 1 + n\_probes * (k + 1)) * sizeof_{float}) + n\_probes * k * sizeof_{idx}])` :math:`index\_size + workspace` - diff --git a/docs/source/indexes/ivfpq.rst b/docs/source/indexes/ivfpq.rst index e4bd81395b..0474452a01 100644 --- a/docs/source/indexes/ivfpq.rst +++ b/docs/source/indexes/ivfpq.rst @@ -133,8 +133,3 @@ Build peak memory usage (device): + n\_clusters * dim * sizeof_{float} Note, if there’s not enough space left in the workspace memory resource, IVF-PQ build automatically switches to the managed memory for the training set and labels. - - - - - diff --git a/docs/source/python_api.rst b/docs/source/python_api.rst index 69bcd300b6..9d7a583fea 100644 --- a/docs/source/python_api.rst +++ b/docs/source/python_api.rst @@ -8,4 +8,4 @@ Python API Documentation :maxdepth: 4 python_api/distance.rst - python_api/neighbors.rst \ No newline at end of file + python_api/neighbors.rst diff --git a/docs/source/vector_databases_vs_vector_search.rst b/docs/source/vector_databases_vs_vector_search.rst index 446737c11c..5c43ee5508 100644 --- a/docs/source/vector_databases_vs_vector_search.rst +++ b/docs/source/vector_databases_vs_vector_search.rst @@ -54,4 +54,4 @@ Unfortunately, for large datasets, doing a hyper-parameter optimization on the w Full hyper-parameter optimization may also not always be necessary- for example, once you have built a ground truth dataset on a subset, many times you can start by building an index with the default build parameters and then playing around with different search parameters until you get the desired quality and search performance. For massive indexes that might be multiple terabytes, you could also take this subsampling of, say, 10M vectors, train an index and then tune the search parameters from there. While there might be a small margin of error, the chosen build/search parameters should generalize fairly well for the databases that build locally partitioned indexes. -Refer to our :doc:`tuning guide ` for more information and examples on how to efficiently and automatically tune your vector search indexes based on your needs. \ No newline at end of file +Refer to our :doc:`tuning guide ` for more information and examples on how to efficiently and automatically tune your vector search indexes based on your needs. diff --git a/examples/README.md b/examples/README.md index 701fd0deee..f5a606ee35 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,17 +1,17 @@ # cuVS C and C++ Examples -This template project provides a drop-in sample to either start building a new application with, or using CUVS in an existing CMake project. +This template project provides a drop-in sample to either start building a new application with, or using CUVS in an existing CMake project. First, please refer to our [installation docs](https://docs.rapids.ai/api/cuvs/stable/build.html#cuda-gpu-requirements) for the minimum requirements to use cuVS. -Once the minimum requirements are satisfied, this example template application can be built with the provided `build.sh` script. This is a bash script that calls the appropriate CMake commands, so you can look into it to see the typical CMake based build workflow. +Once the minimum requirements are satisfied, this example template application can be built with the provided `build.sh` script. This is a bash script that calls the appropriate CMake commands, so you can look into it to see the typical CMake based build workflow. The directories (`CUVS_SOURCE/examples/c`) or (`CUVS_SOURCE/examples/cpp`) can be copied directly in order to build a new application with cuVS. -cuVS can be integrated into an existing CMake project by copying the contents in the `configure rapids-cmake` and `configure cuvs` sections of the provided `CMakeLists.txt` into your project, along with `cmake/thirdparty/get_cuvs.cmake`. +cuVS can be integrated into an existing CMake project by copying the contents in the `configure rapids-cmake` and `configure cuvs` sections of the provided `CMakeLists.txt` into your project, along with `cmake/thirdparty/get_cuvs.cmake`. Make sure to link against the appropriate CMake targets. Use `cuvs::c_api` and `cuvs::cuvs` to use the C and C++ shared libraries respectively. ```cmake target_link_libraries(your_app_target PRIVATE cuvs::cuvs) -``` \ No newline at end of file +``` diff --git a/examples/c/src/L2_c_example.c b/examples/c/src/L2_c_example.c index 73ddf61039..0b621798e3 100644 --- a/examples/c/src/L2_c_example.c +++ b/examples/c/src/L2_c_example.c @@ -84,7 +84,7 @@ void l2_distance_calc(int64_t n_cols,float x[], float y[], float *ret) { DLManagedTensor y_tensor; int64_t y_shape[2] = {N_ROWS, n_cols}; tensor_initialize(y_d, y_shape, &y_tensor); - + DLManagedTensor dist_tensor; int64_t distances_shape[2] = {N_ROWS, N_ROWS}; tensor_initialize(distance_d, distances_shape, &dist_tensor); @@ -93,7 +93,7 @@ void l2_distance_calc(int64_t n_cols,float x[], float y[], float *ret) { cuvsPairwiseDistance(res, &x_tensor, &y_tensor, &dist_tensor, L2SqrtUnexpanded, 2.0); cudaMemcpy(ret, distance_d, sizeof(float) * N_ROWS * N_ROWS, cudaMemcpyDefault); - + cuvsRMMFree(res, distance_d, sizeof(float) * N_ROWS * N_ROWS); cuvsRMMFree(res, x_d, sizeof(float) * N_ROWS * n_cols); cuvsRMMFree(res, y_d, sizeof(float) * N_ROWS * n_cols); @@ -106,12 +106,12 @@ int euclidean_distance_calculation_example() { outputVector((float *)PointA); outputVector((float *)PointB); - + float ret; - + l2_distance_calc(DIM, (float *)PointA, (float *)PointB, &ret); printf("L2 distance is %f.\n", ret); - + cuvsResourcesDestroy(res); return 0; diff --git a/examples/c/src/common.h b/examples/c/src/common.h index 60b9b73cf6..e5b8d01768 100644 --- a/examples/c/src/common.h +++ b/examples/c/src/common.h @@ -106,4 +106,3 @@ void print_results(int64_t * neighbor, float* distances,int n_rows, int n_cols) printf("]\n"); } } - diff --git a/examples/c/src/ivf_flat_c_example.c b/examples/c/src/ivf_flat_c_example.c index c068d04f82..2121ca35e5 100644 --- a/examples/c/src/ivf_flat_c_example.c +++ b/examples/c/src/ivf_flat_c_example.c @@ -56,7 +56,7 @@ void ivf_flat_build_search_simple(cuvsResources_t *res, DLManagedTensor * datase DLManagedTensor neighbors_tensor; int64_t neighbors_shape[2] = {n_queries, topk}; int_tensor_initialize(neighbors_d, neighbors_shape, &neighbors_tensor); - + DLManagedTensor distances_tensor; int64_t distances_shape[2] = {n_queries, topk}; float_tensor_initialize(distances_d, distances_shape, &distances_tensor); @@ -91,7 +91,7 @@ void ivf_flat_build_search_simple(cuvsResources_t *res, DLManagedTensor * datase cuvsIvfFlatSearchParamsDestroy(search_params); cuvsIvfFlatIndexDestroy(index); - cuvsIvfFlatIndexParamsDestroy(index_params); + cuvsIvfFlatIndexParamsDestroy(index_params); } void ivf_flat_build_extend_search(cuvsResources_t *res, DLManagedTensor * trainset_tensor, DLManagedTensor * dataset_tensor, DLManagedTensor * queries_tensor) { @@ -102,7 +102,7 @@ void ivf_flat_build_extend_search(cuvsResources_t *res, DLManagedTensor * trains int64_t data_indices_shape[1] = {n_dataset}; int_tensor_initialize(data_indices_d, data_indices_shape, &data_indices_tensor); data_indices_tensor.dl_tensor.ndim = 1; - + printf("\nRun k-means clustering using the training set\n"); int64_t *data_indices = (int64_t *)malloc(n_dataset * sizeof(int64_t)); @@ -154,11 +154,11 @@ void ivf_flat_build_extend_search(cuvsResources_t *res, DLManagedTensor * trains DLManagedTensor neighbors_tensor; int64_t neighbors_shape[2] = {n_queries, topk}; int_tensor_initialize(neighbors_d, neighbors_shape, &neighbors_tensor); - + DLManagedTensor distances_tensor; int64_t distances_shape[2] = {n_queries, topk}; float_tensor_initialize(distances_d, distances_shape, &distances_tensor); - + // Create default search params cuvsIvfFlatSearchParams_t search_params; cuvsIvfFlatSearchParamsCreate(&search_params); @@ -203,7 +203,7 @@ int main() { float *queries = (float *)malloc(n_queries * n_dim * sizeof(float)); generate_dataset(dataset, n_samples, n_dim, -10.0, 10.0); generate_dataset(queries, n_queries, n_dim, -1.0, 1.0); - + // Create a cuvsResources_t object cuvsResources_t res; cuvsResourcesCreate(&res); @@ -245,7 +245,7 @@ int main() { DLManagedTensor trainset_tensor; int64_t trainset_shape[2] = {n_trainset, n_dim}; float_tensor_initialize(trainset_d, trainset_shape, &trainset_tensor); - + // Build and extend example. ivf_flat_build_extend_search(&res, &trainset_tensor, &dataset_tensor, &queries_tensor); diff --git a/examples/c/src/ivf_pq_c_example.c b/examples/c/src/ivf_pq_c_example.c index b6d6b485b2..c3235f2d45 100644 --- a/examples/c/src/ivf_pq_c_example.c +++ b/examples/c/src/ivf_pq_c_example.c @@ -45,7 +45,7 @@ void ivf_pq_build_search(cuvsResources_t *res, DLManagedTensor * dataset_tensor, cuvsIvfPqIndexParamsDestroy(index_params); return; } - + // Create output arrays. int64_t topk = 10; int64_t n_queries = queries_tensor->dl_tensor.shape[0]; @@ -89,7 +89,7 @@ void ivf_pq_build_search(cuvsResources_t *res, DLManagedTensor * dataset_tensor, printf("\nOriginal results:\n"); print_results(neighbors, distances, 2, topk); - + // Re-ranking operation: refine the initial search results by computing exact distances int64_t topk_refined = 7; int64_t *neighbors_refined_d; @@ -100,11 +100,11 @@ void ivf_pq_build_search(cuvsResources_t *res, DLManagedTensor * dataset_tensor, DLManagedTensor neighbors_refined_tensor; int64_t neighbors_refined_shape[2] = {n_queries, topk_refined}; int_tensor_initialize(neighbors_refined_d, neighbors_refined_shape, &neighbors_refined_tensor); - + DLManagedTensor distances_refined_tensor; int64_t distances_refined_shape[2] = {n_queries, topk_refined}; float_tensor_initialize(distances_refined_d, distances_refined_shape, &distances_refined_tensor); - + // Note, refinement requires the original dataset and the queries. // Don't forget to specify the same distance metric as used by the index. cuvsError_t refine_status = cuvsRefine(*res, dataset_tensor, queries_tensor, @@ -140,7 +140,7 @@ void ivf_pq_build_search(cuvsResources_t *res, DLManagedTensor * dataset_tensor, cuvsIvfPqSearchParamsDestroy(search_params); cuvsIvfPqIndexDestroy(index); - cuvsIvfPqIndexParamsDestroy(index_params); + cuvsIvfPqIndexParamsDestroy(index_params); } int main() { @@ -152,7 +152,7 @@ int main() { float *queries = (float *)malloc(n_queries * n_dim * sizeof(float)); generate_dataset(dataset, n_samples, n_dim, -10.0, 10.0); generate_dataset(queries, n_queries, n_dim, -1.0, 1.0); - + // Create a cuvsResources_t object cuvsResources_t res; cuvsResourcesCreate(&res); @@ -166,7 +166,7 @@ int main() { DLManagedTensor dataset_tensor; int64_t dataset_shape[2] = {n_samples,n_dim}; float_tensor_initialize(dataset_d, dataset_shape, &dataset_tensor); - + // Allocate memory for `queries` float *queries_d; cuvsRMMAlloc(res, (void**) &queries_d, sizeof(float) * n_queries * n_dim); @@ -177,7 +177,7 @@ int main() { DLManagedTensor queries_tensor; int64_t queries_shape[2] = {n_queries, n_dim}; float_tensor_initialize(queries_d, queries_shape, &queries_tensor); - + // Simple build and search example. ivf_pq_build_search(&res, &dataset_tensor, &queries_tensor); diff --git a/examples/cpp/src/common.cuh b/examples/cpp/src/common.cuh index 8e109a7644..a743ff802d 100644 --- a/examples/cpp/src/common.cuh +++ b/examples/cpp/src/common.cuh @@ -124,7 +124,6 @@ raft::device_matrix read_bin_dataset(raft::device_resources const &dev_r auto dataset = raft::make_device_matrix(dev_resources, N, dim); raft::copy(dataset.data_handle(), data.data(), data.size(), raft::resource::get_cuda_stream(dev_resources)); - + return dataset; } - diff --git a/python/cuvs/.coveragerc b/python/cuvs/.coveragerc index fc087fb9c5..3269e10b8a 100644 --- a/python/cuvs/.coveragerc +++ b/python/cuvs/.coveragerc @@ -1,3 +1,3 @@ # Configuration file for Python coverage tests [run] -source = pylibraft \ No newline at end of file +source = pylibraft diff --git a/python/cuvs_bench/cuvs_bench/config/algos/faiss_cpu_ivf_flat.yaml b/python/cuvs_bench/cuvs_bench/config/algos/faiss_cpu_ivf_flat.yaml index 29c145f86d..aa7409dce8 100644 --- a/python/cuvs_bench/cuvs_bench/config/algos/faiss_cpu_ivf_flat.yaml +++ b/python/cuvs_bench/cuvs_bench/config/algos/faiss_cpu_ivf_flat.yaml @@ -7,4 +7,4 @@ groups: useFloat16: [False] search: nprobe: [1, 5, 10, 50, 100, 200] - refine_ratio: [1] \ No newline at end of file + refine_ratio: [1] diff --git a/python/cuvs_bench/cuvs_bench/config/algos/faiss_gpu_ivf_flat.yaml b/python/cuvs_bench/cuvs_bench/config/algos/faiss_gpu_ivf_flat.yaml index e4abc35f5c..ba1dcbab9b 100644 --- a/python/cuvs_bench/cuvs_bench/config/algos/faiss_gpu_ivf_flat.yaml +++ b/python/cuvs_bench/cuvs_bench/config/algos/faiss_gpu_ivf_flat.yaml @@ -18,4 +18,4 @@ groups: use_raft: [True] search: nprobe: [1, 5, 10, 50, 100, 200] - refine_ratio: [1] \ No newline at end of file + refine_ratio: [1] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index ddb8b32cd8..37aa837f60 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -13,4 +13,3 @@ homepage = "https://github.com/rapidsai/cuvs" description = "RAPIDS vector search library" authors = ["NVIDIA Corporation"] license = "Apache-2.0" - diff --git a/rust/cuvs/src/distance/mod.rs b/rust/cuvs/src/distance/mod.rs index 566bf0129e..f6911c6836 100644 --- a/rust/cuvs/src/distance/mod.rs +++ b/rust/cuvs/src/distance/mod.rs @@ -71,7 +71,7 @@ mod tests { let distances = ManagedTensor::from(&distances_host) .to_device(&res) .unwrap(); - + pairwise_distance(&res, &dataset_device, &dataset_device, &distances, DistanceType::L2Expanded, None).unwrap(); diff --git a/rust/cuvs/src/ivf_flat/mod.rs b/rust/cuvs/src/ivf_flat/mod.rs index 32aa707845..cee4e9454c 100644 --- a/rust/cuvs/src/ivf_flat/mod.rs +++ b/rust/cuvs/src/ivf_flat/mod.rs @@ -14,8 +14,8 @@ * limitations under the License. */ -//! The IVF-Flat method is an ANN algorithm. It uses an inverted file index (IVF) with -//! unmodified (that is, flat) vectors. This algorithm provides simple knobs to reduce +//! The IVF-Flat method is an ANN algorithm. It uses an inverted file index (IVF) with +//! unmodified (that is, flat) vectors. This algorithm provides simple knobs to reduce //! the overall search space and to trade-off accuracy for speed. //! //! Example: diff --git a/thirdparty/LICENSES/LICENSE.ann-benchmark b/thirdparty/LICENSES/LICENSE.ann-benchmark index 9f8e4222f6..4d04745ab4 100644 --- a/thirdparty/LICENSES/LICENSE.ann-benchmark +++ b/thirdparty/LICENSES/LICENSE.ann-benchmark @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/thirdparty/LICENSES/LICENSE.faiss b/thirdparty/LICENSES/LICENSE.faiss index 87cbf536c6..b96dcb0480 100644 --- a/thirdparty/LICENSES/LICENSE.faiss +++ b/thirdparty/LICENSES/LICENSE.faiss @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/thirdparty/LICENSES/LICENSE.pytorch b/thirdparty/LICENSES/LICENSE.pytorch index 7ad3d737a5..04f9ad1105 100644 --- a/thirdparty/LICENSES/LICENSE.pytorch +++ b/thirdparty/LICENSES/LICENSE.pytorch @@ -74,4 +74,4 @@ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +POSSIBILITY OF SUCH DAMAGE.