需按官方 Build and Install Guide 选择对应语言与 CUDA 版本的包;CUDA 13 与 CUDA 12 的二进制体积差异较大,体积敏感时可选静态链接的 libcuvs-static;示例中的 load_data 等函数需自行提供数据加载。
conda install -c conda-forge cuvs
pip install cuvsREADME 未说明具体显存要求与支持的 GPU 型号,仅说明在 GPU 上运行并依赖 NVIDIA CUDA 与 RAFT。
NVIDIA 的 GPU 向量检索与聚类库,用 GPU 加速近似最近邻搜索和聚类
基于 GPU 的向量检索与聚类库,为近似最近邻搜索和相似度计算提供 CUDA 加速,适合大规模向量数据和 LLM 检索场景。
核心能力
- 在 GPU 上实现近似最近邻搜索与聚类算法
- 提供 CAGRA 等高性能图索引的构建与搜索
- 支持 Python、C++、C、Rust 多语言 API
- 可在 GPU 上构建索引、在 CPU 上部署
- 基于 RAFT 高性能机器学习原语构建
容易踩的坑
- v26.10.00最新正式版2026-10-08 · 2026-10-08 01:23 UTC
What's Changed
🚨 Breaking Changes
- Apply ABI Breaking Changes for KMeans by @tarang-jain in https://github.com/NVIDIA/cuvs/pull/2147
- Containerize standalone tarball build by @jameslamb in https://github.com/NVIDIA/cuvs/pull/2595
- Migrate stream APIs from rmm::cuda_stream_view to cuda::stream_ref by @bdice in https://github.com/NVIDIA/cuvs/pull/2521
- Iterative CAGRA-Q by @irina-resh-nvda in https://github.com/NVIDIA/cuvs/pull/1810
- FIX IVF-RabitQ: allow searching after building without serialize round-trip by @achirkin in https://github.com/NVIDIA/cuvs/pull/2664
🐛 Bug Fixes
- Fix missing trailing barrier in ivf_rabitq blockReduceSum by @hhy3 in https://github.com/NVIDIA/cuvs/pull/2322
- Use
mainbranch for C ABI baseline by @jrbourbeau in https://github.com/NVIDIA/cuvs/pull/2388 - Improve C ABI struct change error handling by @jrbourbeau in https://github.com/NVIDIA/cuvs/pull/2386
- [WIP] Preload cudart before cuvs native library load to prevent downstream class load errors by @rahulgoswami in https://github.com/NVIDIA/cuvs/pull/2376
- Fix benchmark regressions from #1846 by @achirkin in https://github.com/NVIDIA/cuvs/pull/2384
- fix knn_merge_parts for inner product by @qwertyforce in https://github.com/NVIDIA/cuvs/pull/2426
- Fix
cuvs-benchopensearch recall and save results by @jrbourbeau in https://github.com/NVIDIA/cuvs/pull/2369 - Fix CAGRA-ACE regressions from #1846 by @julianmi in https://github.com/NVIDIA/cuvs/pull/2416
- Remove unused extend code in cagra by @aamijar in https://github.com/NVIDIA/cuvs/pull/2436
- Fix batched silhouette score reduction aliasing by @csadorf in https://github.com/NVIDIA/cuvs/pull/2422
- Align views with partial batch extents for SNMG ANN direct merge by @viclafargue in https://github.com/NVIDIA/cuvs/pull/2441
- Fix devcontainer cache version updates by @bdice in https://github.com/NVIDIA/cuvs/pull/2479
- Fix silent brute force fallback at aligned vector dimensions by @imotov in https://github.com/NVIDIA/cuvs/pull/2483
- Fix intermittent ThreadLeak failures in the concurrent IT tests by @imotov in https://github.com/NVIDIA/cuvs/pull/2499
- Fix
cuvsbuild due tormmandcuCollectionsapi changes by @jcrist in https://github.com/NVIDIA/cuvs/pull/2504 - [CI] Update Convergence Criteria to Fix Flaky KMeans Test by @tarang-jain in https://github.com/NVIDIA/cuvs/pull/2256
- Keep cufile.log out of the Java source tree by @imotov in https://github.com/NVIDIA/cuvs/pull/2553
- Match merged vectors by document id, not by ordinal position by @imotov in https://github.com/NVIDIA/cuvs/pull/2556
- Fix hnswlib cmake download only by @aamijar in https://github.com/NVIDIA/cuvs/pull/2638
- Fix creation of
hnswlibtarget by @KyleFromNVIDIA in https://github.com/NVIDIA/cuvs/pull/2643 - Lucene: add exact search fallback for very selective filters by @imotov in https://github.com/NVIDIA/cuvs/pull/2612
- Lucene: Fix GPU search failing on segments with no live vectors by @imotov in https://github.com/NVIDIA/cuvs/pull/2637
- Disable AnnNNDescentTestUI8_U32 until release/26.10 is complete by @aamijar in https://github.com/NVIDIA/cuvs/pull/2656
📖 Documentation
- Fix the build_knn_graph sample code by @enp1s0 in https://github.com/NVIDIA/cuvs/pull/2339
- Adding new docs link(s) to readme. Adding landing page for API refs by @cjnolet in https://github.com/NVIDIA/cuvs/pull/2228
- Keep the Fern API reference in sync with the sources by @imotov in https://github.com/NVIDIA/cuvs/pull/2547
- Sync up API docs with code by @imotov in https://github.com/NVIDIA/cuvs/pull/2561
- Adds a Lucene API section to the Fern docs, generated from java/cuvs-… by @imotov in https://github.com/NVIDIA/cuvs/pull/2580
- Move Lucene getting-started guide to Fern, expand install and examples by @imotov in https://github.com/NVIDIA/cuvs/pull/2640
🚀 New Features
- rust: expose cuvsVersionGet via safe Rust by @yan-za
- v26.08.012026-08-06 · 2026-08-06 17:52 UTC
查看更新说明
Full Changelog: https://github.com/NVIDIA/cuvs/compare/v26.08.00...v26.08.01
- v26.08.002026-08-05 · 2026-08-05 19:38 UTC
查看更新说明
What's Changed
🚨 Breaking Changes
- Auto select CAGRA build algorithm for hnsw::build by @tfeher in https://github.com/NVIDIA/cuvs/pull/1719
- Track tensor and index lifetimes in the Rust DLPack bindings by @yan-zaretskiy in https://github.com/NVIDIA/cuvs/pull/2245
- wheels: build CUDA 13 wheels with latest CTK (13.3.0) by @jameslamb in https://github.com/NVIDIA/cuvs/pull/2305
- [FEA] Multi-node Out of Core Streaming KMeans API by @tarang-jain in https://github.com/NVIDIA/cuvs/pull/2066
- Rust: builder-based params, per-module errors by @yan-zaretskiy in https://github.com/NVIDIA/cuvs/pull/2284
- [KMeans] Rename streaming_batch_size param by @tarang-jain in https://github.com/NVIDIA/cuvs/pull/2328
- Update DLPack to 1.0 by @divyegala in https://github.com/NVIDIA/cuvs/pull/2354
- Apply ABI Breaking Changes to KMeans Params (release branch) by @tarang-jain in https://github.com/NVIDIA/cuvs/pull/2329
- Revert "Update DLPack to 1.0 (#2354)" by @bdice in https://github.com/NVIDIA/cuvs/pull/2366
- [REVIEW] New Dataset API Clarifying Ownership by @HowardHuang1 in https://github.com/NVIDIA/cuvs/pull/1846
🐛 Bug Fixes
- [CI nightly] Temporarily disable conda-python-tests codecov reporting by @aamijar in https://github.com/NVIDIA/cuvs/pull/2274
- Exclude SPDX copyright lines from .clang-format by @achirkin in https://github.com/NVIDIA/cuvs/pull/2275
- Fix
FastIntDivtparam by @aamijar in https://github.com/NVIDIA/cuvs/pull/2278 - CAGRA: fix concurrent initialization and usage of dataset descriptor by @achirkin in https://github.com/NVIDIA/cuvs/pull/2237
- Revert "FIX: disable warpspeed scan (#2062)" by @bdice in https://github.com/NVIDIA/cuvs/pull/2074
- Predict IVF-PQ FP16 overflow and auto-switch to FP32 by @huuanhhuyn in https://github.com/NVIDIA/cuvs/pull/2246
- Update .clang-format to fix copyright and style check by @HowardHuang1 in https://github.com/NVIDIA/cuvs/pull/2304
- Fix batched silhouette score stream ordering by @csadorf in https://github.com/NVIDIA/cuvs/pull/2316
- fix(pre-commit): normalize SPDX handling by @bdice in https://github.com/NVIDIA/cuvs/pull/2318
- Remove fragile explicit import that breaks with jextract/CUDA changes by @imotov in https://github.com/NVIDIA/cuvs/pull/2124
- Remove trailing new lines from GTest names by @robertmaynard in https://github.com/NVIDIA/cuvs/pull/2312
- Update Comparison Branch for ABI Stability Git Workflow by @tarang-jain in https://github.com/NVIDIA/cuvs/pull/2331
- CAGRA ACE build: avoid rounding down graph degree during sub-index build by @achirkin in https://github.com/NVIDIA/cuvs/pull/2335
- [BUG] Fix CAGRA search recall with a graph built by NN Descent by @enp1s0 in https://github.com/NVIDIA/cuvs/pull/819
- Fix IVF extend list resize bug by @qwertyforce in https://github.com/NVIDIA/cuvs/pull/2297
- Use batched unfused 1-NN for KMeans on Blackwell by @viclafargue in https://github.com/NVIDIA/cuvs/pull/2346
- Fix prefilter bitmap host buffer under-allocation in Java bindings by @imotov in https://github.com/NVIDIA/cuvs/pull/2375
- Fix incorrect distances tensor type in cuvsCagraSearch by @imotov in https://github.com/NVIDIA/cuvs/pull/2372
📖 Documentation
- Update cuvs-bench docs to show both CLI and Python API usage by @jnke2016 in https://github.com/NVIDIA/cuvs/pull/2084
- doc: fix better the python api example by @yihong0618 in https://github.com/NVIDIA/cuvs/pull/2080
- docs: RAFT->cuVS in issue templates by @jameslamb in https://github.com/NVIDIA/cuvs/pull/2097
- Updating Fern and fixing a couple small links by @cjnolet in https://github.com/NVIDIA/cuvs/pull/2210
- Adding nvidia as the "global-theme" by @cjnolet in https://github.com/NVIDIA/cuvs/pull/2216
- remove pypi.nvidia.com from install docs by @jameslamb in https://github.com/NVIDIA/cuvs/pull/2223
- Add code of conduct by @aamijar in https://github.com/NVIDIA/cuvs/pull/2272
- Readme: ivf-rabitq paper in refer
- v26.06.002026-06-04 · 2026-06-04 00:21 UTC
查看更新说明
What's Changed
🚨 Breaking Changes
- Default to static linking of libcudart by @bdice in https://github.com/rapidsai/cuvs/pull/1627
- Remove JIT+LTO fragment database by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1927
- Use static cudart by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1931
- Always build with JIT+LTO by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1923
- Migrate RMM usage to CCCL MR design by @bdice in https://github.com/rapidsai/cuvs/pull/1990
- Exposition of KMeans param object for PQ in C++ by @lowener in https://github.com/rapidsai/cuvs/pull/2005
- [Cleanup] Combine Batched and Regular KMeans Impl by @tarang-jain in https://github.com/rapidsai/cuvs/pull/2015
- Preserve input memory location for NN Descent by @jinsolp in https://github.com/rapidsai/cuvs/pull/1928
🐛 Bug Fixes
- Fix CCCL compilation error by @viclafargue in https://github.com/rapidsai/cuvs/pull/1963
- Forward-merge release/26.04 into main by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1971
- Forward-merge release/26.04 into main by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1980
- Remove dangling pointers in JIT Fragments by @divyegala in https://github.com/rapidsai/cuvs/pull/1988
- Add
head_revto cuvs recipe by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1993 - Fix potential OOB access in CAGRA search when graph size < dataset size by @irina-resh-nvda in https://github.com/rapidsai/cuvs/pull/1780
- Fix MG kmeans intertia_check n_iters by @aamijar in https://github.com/rapidsai/cuvs/pull/2020
- Fix cuvs_bench pytest pareto assert by @aamijar in https://github.com/rapidsai/cuvs/pull/2027
- Fix nightly build matrix by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/2054
- Fix vulnerable index deserialization by @lowener in https://github.com/rapidsai/cuvs/pull/2068
- Fix symbol export kmeans by @aamijar in https://github.com/rapidsai/cuvs/pull/2070
- Fix argmin/argmax based on the distance type by @achirkin in https://github.com/rapidsai/cuvs/pull/2016
- Remove unneeded request for CUDA device link phase by @robertmaynard in https://github.com/rapidsai/cuvs/pull/2077
- Update Faiss and DiskANN Patch to Use C++20 by @tarang-jain in https://github.com/rapidsai/cuvs/pull/1796
- Fix brute force Rust index dataset lifetime by @yan-zaretskiy in https://github.com/rapidsai/cuvs/pull/2083
- Fix segfault cuvs bench by @aamijar in https://github.com/rapidsai/cuvs/pull/2088
- Fix cagra::optimize modifying the state of raft::resources by @achirkin in https://github.com/rapidsai/cuvs/pull/2103
- Add direct target dependency when embedding fatbins by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/2106
- Fix check for PQ vectorized load by @lowener in https://github.com/rapidsai/cuvs/pull/2107
- Fix workspace usage by @mfoerste4 in https://github.com/rapidsai/cuvs/pull/2135
- Add missing visibility controls in IVF SQ by @divyegala in https://github.com/rapidsai/cuvs/pull/2141
📖 Documentation
- Elaborate on fragment architecture in JIT+LTO documentation by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1991
- Add Cluster and Distance sections to C documentation by @lowener in https://github.com/rapidsai/cuvs/pull/1955
- Adding CAGRA merge to the documentation by @viclafargue in https://github.com/rapidsai/cuvs/pull/1942
- [Doc Update] CAGRA Memory Footprint by @singhmanas1 in https://github.com/rapidsai/cuvs/pull/1300
- Align docs with pluggable benchmark API by @jnke2016 in https://github.com/rapidsai/cuvs/pull/1891
- Add docs for cagra mem usage with NN Descent build algo by @jinsolp in https://github.com/rapidsai/cuvs/pull/2000
- Fix minor typos in
cuvs-benchsource build docs by @jrbourbeau in https://github.com/rapidsai/cuvs/pull/2006 - Fix
cuvs-benchdocker images in docs by @jrbourbeau in https://github.com/rapidsai/cuvs/pull/2003 - U
- v26.04.002026-04-08 · 2026-04-08 19:23 UTC
查看更新说明
What's Changed
🚨 Breaking Changes
- Use HNSW GPU Hierarchy by Default by @julianmi in https://github.com/rapidsai/cuvs/pull/1617
- Backport "Default to static linking of libcudart" by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1918
- enforce a floor on libnvjitlink, build wheels with CUDA 13.0.x, test wheels against mix of CTK versions by @jameslamb in https://github.com/rapidsai/cuvs/pull/1862
🐛 Bug Fixes
- Add float16 support for CAGRA extend by @lowener in https://github.com/rapidsai/cuvs/pull/1620
- Fix C examples CUDAToolkit dependency by @tfeher in https://github.com/rapidsai/cuvs/pull/1626
- clang-tidy: remove AnalyzeTemporaryDtors key by @achirkin in https://github.com/rapidsai/cuvs/pull/1778
- Fix build.sh: build cuvs_c for examples and fix --gpu-arch parsing by @achirkin in https://github.com/rapidsai/cuvs/pull/1779
- Better handling of batching of search in MG replicated mode by @viclafargue in https://github.com/rapidsai/cuvs/pull/1718
- Add nvjitlink to cuda-toolkit pip extras for cusparse compatibility by @bdice in https://github.com/rapidsai/cuvs/pull/1794
- [REVIEW] Fix: for balanced kmeans use grid.x for adjust_centers to avoid grid.y overflow for >262K centroids by @Nischal1729 in https://github.com/rapidsai/cuvs/pull/1805
- Fix thrust header by @aamijar in https://github.com/rapidsai/cuvs/pull/1817
- Fix persistent CAGRA regressions by @achirkin in https://github.com/rapidsai/cuvs/pull/1800
- Fix thrust header by @aamijar in https://github.com/rapidsai/cuvs/pull/1825
- Set
cudaFuncAttributeMaxDynamicSharedMemorySizewith thread-safety by @mythrocks in https://github.com/rapidsai/cuvs/pull/1771 - [REVIEW] Move from
thrust::make_counting_iteratortocuda::make_counting_iteratorby @mythrocks in https://github.com/rapidsai/cuvs/pull/1826 - Fixed cuvs benchmark debug build issue (linker step fail) by @irina-resh-nvda in https://github.com/rapidsai/cuvs/pull/1599
- Graph degree equals intermediate graph degree bug fix by @irina-resh-nvda in https://github.com/rapidsai/cuvs/pull/1834
- FAISS patch for
thrust_counting_iterator.hby @aamijar in https://github.com/rapidsai/cuvs/pull/1844 - Use 1D grid calculations in
epsilon_neighborhoodby @divyegala in https://github.com/rapidsai/cuvs/pull/1847 - Fix setting CAGRA graph build algo to iterative search by default by @achirkin in https://github.com/rapidsai/cuvs/pull/1864
- Faiss suppress warning 611 by @aamijar in https://github.com/rapidsai/cuvs/pull/1879
- Pin faiss to 1.14.0 by @aamijar in https://github.com/rapidsai/cuvs/pull/1885
- Make some minor fixes to JIT+LTO functionality by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1896
- Revert "Default to static linking of libcudart" by @KyleFromNVIDIA in https://github.com/rapidsai/cuvs/pull/1925
- Fix hanging pytests by @aamijar in https://github.com/rapidsai/cuvs/pull/1924
- Disallow programmatic stream serialization in JIT kernel launches by @divyegala in https://github.com/rapidsai/cuvs/pull/1932
- IVF-Flat: fix irrelevant assert in the fused kernel mode by @achirkin in https://github.com/rapidsai/cuvs/pull/1941
- [REVIEW] cuVS bench: Fix cudaFuncSetAttribute not being called when CAGRA search switches kernel variants by @irina-resh-nvda in https://github.com/rapidsai/cuvs/pull/1851
- Pin openblas for aarch64 by @tarang-jain in https://github.com/rapidsai/cuvs/pull/1965
- Null JIT kernel launch config by @divyegala in https://github.com/rapidsai/cuvs/pull/1974
- [BUG] Fix Vamana Serialization by @tarang-jain in https://github.com/rapidsai/cuvs/pull/1966
📖 Documentation
- remove docs references to cuvs-bench-datasets, install a C compiler in pre-commit env by @jameslamb in https://github.com/rapidsai/cuvs/pull/1736
- Adding simple tarball install to build and install docs by @cjnolet in https://github.com/rapidsai/cuvs/pull/1868
- Fixing nccl link in tarball install instr
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
cuVS: Vector Search and Clustering on the GPU
Contents
Useful Resources
- Documentation: Library documentation.
- Build and Install Guide: Instructions for installing and building cuVS.
- Getting Started Guide: Guide to getting started with cuVS.
- Code Examples: Self-contained Code Examples.
- API Reference Documentation: API Documentation.
- GitHub repository: Download the cuVS source code.
- Issue tracker: Report issues or request features.
What is cuVS?
cuVS contains state-of-the-art implementations of several algorithms for running approximate nearest neighbors and clustering on the GPU. It can be used directly or through the various databases and other libraries that have integrated it. The primary goal of cuVS is to simplify the use of GPUs for vector similarity search and clustering.
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, t-SNE, K-means, and HDBSCAN.
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 and cuGraph.
Below are some common use-cases for vector search
-
Semantic search
- Generative AI & Retrieval augmented generation (RAG)
- Recommender systems
- Computer vision
- Image search
- Text search
- Audio search
- Molecular search
- Model training
-
Data mining
- Clustering algorithms
- Visualization algorithms
- Sampling algorithms
- Class balancing
- Ensemble methods
- k-NN graph construction
Why cuVS?
There are several benefits to using cuVS and GPUs for vector search, including
- Fast index build
- Latency critical and high throughput search
- Parameter tuning
- Cost savings
- Interoperability (build on GPU, deploy on CPU)
- Multiple language support
- Building blocks for composing new or accelerating existing algorithms
In addition to the items above, cuVS shoulders the burden of keeping non-trivial accelerated code up to date as new NVIDIA architectures and CUDA versions are released. This provides a delightful development experience, guaranteeing that any libraries, databases, or applications built on top of it will always be getting the best performance and scale.
cuVS Technology Stack
cuVS is built on top of the NVIDIA RAFT library of high performance machine learning primitives and provides all the necessary routines for vector search and clustering on the GPU.

Installing cuVS
cuVS comes with pre-built packages that can be installed through conda and pip or tarball. Different packages are available for the different languages supported by cuVS.
[!NOTE] If compiled binary size is a concern, please note that the cuVS builds for CUDA 13 are roughly half the size of CUDA 12 builds. This is a result of improved compression rates in the newer supported CUDA drivers. We will be adopting the newer drivers for CUDA 12 builds in Spring of 2026, which will ultimately bring them down to roughly the size of the CUDA 13 builds. In the meantime, the NVIDIA cuVS team is continuing to shave down the binary sizes for all supported CUDA versions. If binary size is an issue for you, please consider linking to cuVS statically either by building from source or using pre-built
libcuvs-staticconda package.
Please see the Build and Install Guide for more information on installing the available cuVS packages and building from source.
Standalone C library (Docker)
To build the standalone C library tarball (libcuvs_c.tar.gz) for use in your own C/C++ projects, see Building the standalone C library with Docker.
Getting Started
The following code snippets train an approximate nearest neighbors index for the CAGRA algorithm in the various different languages supported by cuVS.
Python API
from cuvs.neighbors import cagra
dataset = load_data()
index_params = cagra.IndexParams()
index = cagra.build(index_params, dataset)
C++ API
#include <cuvs/neighbors/cagra.hpp>
using namespace cuvs::neighbors;
raft::device_matrix_view<float> dataset = load_dataset();
raft::device_resources res;
cagra::index_params index_params;
auto index = cagra::build(res, index_params, dataset);
For more code examples of the C++ APIs, including drop-in Cmake project templates, please refer to the C++ examples directory in the codebase.
C API
#include <cuvs/neighbors/cagra.h>
cuvsResources_t res;
cuvsCagraIndexParams_t index_params;
cuvsCagraIndex_t index;
DLManagedTensor *dataset;
load_dataset(dataset);
cuvsResourcesCreate(&res);
cuvsCagraIndexParamsCreate(&index_params);
cuvsCagraIndexCreate(&index);
cuvsDataset_t dataset_view;
cuvsDatasetMakeStandardView(res, dataset, &dataset_view);
cuvsCagraBuild(res, index_params, dataset_view, index);
cuvsDatasetDestroy(dataset_view);
cuvsCagraIndexDestroy(index);
cuvsCagraIndexParamsDestroy(index_params);
cuvsResourcesDestroy(res);
For more code examples of the C APIs, including drop-in Cmake project templates, please refer to the C examples
Rust API
use cuvs::distance::DistanceType;
use cuvs::neighbors::cagra::{Index, IndexParams, SearchParams};
use cuvs::{AsDlTensor, AsDlTensorMut, DLPackError, DLTensorView, DLTensorViewMut, Resources};
// cuVS is agnostic about where your vectors live: `build` and `search` accept
// any type implementing `AsDlTensor` (inputs) / `AsDlTensorMut` (outputs). Wrap
// your own GPU buffer by implementing these traits. See `rust/cuvs/examples`
// for a complete, runnable CUDA-backed implementation.
struct GpuTensor;
impl AsDlTensor for GpuTensor {
fn as_dl_tensor(&self) -> Result<DLTensorView<'_>, DLPackError> {
unimplemented!("wrap your device buffer; see rust/cuvs/examples")
}
}
impl AsDlTensorMut for GpuTensor {
fn as_dl_tensor_mut(&mut self) -> Result<DLTensorViewMut<'_>, DLPackError> {
unimplemented!("wrap your device buffer; see rust/cuvs/examples")
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let res = Resources::new()?;
// Build a CAGRA index over your dataset.
let dataset = GpuTensor;
let index_params = IndexParams::builder()
.metric(DistanceType::L2Expanded)
.graph_degree(64)
.build()?;
let index = Index::build(&res, &index_params, &dataset)?;
// Search for the k nearest neighbors of each query, writing the results into
// the neighbor and distance device buffers.
let queries = GpuTensor;
let (mut neighbors, mut distances) = (GpuTensor, GpuTensor);
let search_params = SearchParams::builder().itopk_size(64).build()?;
index.search(&res, &search_params, &queries, &mut neighbors, &mut distances)?;
Ok(())
}
For more code examples of the Rust APIs, including a drop-in project templates, please refer to the Rust examples.
Contributing
If you are interested in contributing to the cuVS library, please read our Contributing guidelines. Refer to the Developer Guide for details on the developer guidelines, workflows, and principles.
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.
- CAGRA: Highly Parallel Graph Construction and Approximate Nearest Neighbor Search
- Top-K Algorithms on GPU: A Comprehensive Study and New Methods
- Fast K-NN Graph Construction by GPU Based NN-Descent
- cuSLINK: Single-linkage Agglomerative Clustering on the GPU
- GPU Semiring Primitives for Sparse Neighborhood Methods
- VecFlow: A High-Performance Vector Data Management System for Filtered-Search on GPUs
- GPU-Native Approximate Nearest Neighbor Search with IVF-RaBitQ: Fast Index Build and Search