For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
GitHubCUDA-X
    • Home
    • Installation
  • Getting Started
    • Introduction
    • Integrations
    • Use-cases
  • User Guide
    • API Guide
    • Benchmarking Guide
    • Field Guide
    • References
  • Developer Guide
    • Coding Guidelines
    • Contributing
  • API Reference
    • C API Documentation
    • Cpp API Documentation
    • Python API Documentation
    • Java API Documentation
    • Rust API Documentation
      • cuVS Cluster
      • cuVS Cluster Kmeans
      • cuVS Cluster Kmeans Params
      • cuVS
      • cuVS Dlpack
      • cuVS Error
      • cuVS Resources
      • cuVS Distance
      • cuVS Distance Type
      • cuVS Brute Force
      • cuVS Cagra
      • cuVS Cagra Index
      • cuVS Cagra Index Params
      • cuVS Cagra Search Params
      • cuVS IVF Flat
      • cuVS IVF Flat Index
      • cuVS IVF Flat Index Params
      • cuVS IVF Flat Search Params
      • cuVS IVF PQ
      • cuVS IVF PQ Index
      • cuVS IVF PQ Index Params
      • cuVS IVF PQ Search Params
      • cuVS Vamana
      • cuVS Vamana Index
      • cuVS Vamana Index Params
    • Go API Documentation
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogocuVS
GitHubCUDA-X
On this page
  • Index
  • build
  • Arguments
  • new
  • search
  • Arguments
  • search_with_filter
  • Arguments
  • serialize
  • Arguments
  • serialize_to_hnswlib
  • Arguments
  • deserialize
  • Arguments
API ReferenceRust API Documentation

Cagra Index Module

||View as Markdown|
Previous

cuVS Cagra

Next

cuVS Cagra Index Params

Rust module: cuvs::cagra::index

Source: rust/cuvs/src/cagra/index.rs

Index

1#[derive(Debug)]
2pub struct Index(ffi::cuvsCagraIndex_t); {
3 /* private fields */
4}

CAGRA ANN Index

Methods

NameSource
buildrust/cuvs/src/cagra/index.rs:38
newrust/cuvs/src/cagra/index.rs:52
searchrust/cuvs/src/cagra/index.rs:69
search_with_filterrust/cuvs/src/cagra/index.rs:107
serializerust/cuvs/src/cagra/index.rs:143
serialize_to_hnswlibrust/cuvs/src/cagra/index.rs:166
deserializerust/cuvs/src/cagra/index.rs:179

build

1pub fn build<T: Into<ManagedTensor>>(
2res: &Resources,
3params: &IndexParams,
4dataset: T,
5) -> Result<Index>

Builds a new Index from the dataset for efficient search.

Arguments

  • res - Resources to use
  • params - Parameters for building the index
  • dataset - A row-major matrix on either the host or device to index

Source: rust/cuvs/src/cagra/index.rs:38

new

1pub fn new() -> Result<Index>

Creates a new empty index

Source: rust/cuvs/src/cagra/index.rs:52

search

1pub fn search(
2&self,
3res: &Resources,
4params: &SearchParams,
5queries: &ManagedTensor,
6neighbors: &ManagedTensor,
7distances: &ManagedTensor,
8) -> Result<()>

Perform a Approximate Nearest Neighbors search on the Index

Arguments

  • res - Resources to use
  • params - Parameters to use in searching the index
  • queries - A matrix in device memory to query for
  • neighbors - Matrix in device memory that receives the indices of the nearest neighbors
  • distances - Matrix in device memory that receives the distances of the nearest neighbors

Source: rust/cuvs/src/cagra/index.rs:69

search_with_filter

1pub fn search_with_filter(
2&self,
3res: &Resources,
4params: &SearchParams,
5queries: &ManagedTensor,
6neighbors: &ManagedTensor,
7distances: &ManagedTensor,
8bitset: &ManagedTensor,
9) -> Result<()>

Perform a filtered Approximate Nearest Neighbors search on the Index

Like search, but accepts a bitset filter to exclude vectors during graph traversal. Filtered vectors are never visited, giving better recall than post-filtering.

Arguments

  • res - Resources to use
  • params - Parameters to use in searching the index
  • queries - A matrix in device memory to query for
  • neighbors - Matrix in device memory that receives the indices of the nearest neighbors
  • distances - Matrix in device memory that receives the distances of the nearest neighbors
  • bitset - A 1-D uint32 device tensor with ceil(n_rows / 32) elements. Each bit corresponds to a dataset row: bit 1 = include, bit 0 = exclude.

Source: rust/cuvs/src/cagra/index.rs:107

serialize

1pub fn serialize<P: AsRef<Path>>(
2&self,
3res: &Resources,
4filename: P,
5include_dataset: bool,
6) -> Result<()>

Save the CAGRA index to file.

Experimental, both the API and the serialization format are subject to change.

Arguments

  • res - Resources to use
  • filename - The file path for saving the index
  • include_dataset - Whether to write out the dataset to the file

Source: rust/cuvs/src/cagra/index.rs:143

serialize_to_hnswlib

1pub fn serialize_to_hnswlib<P: AsRef<Path>>(&self, res: &Resources, filename: P) -> Result<()>

Save the CAGRA index to file in hnswlib format.

NOTE: The saved index can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib.

Experimental, both the API and the serialization format are subject to change.

Arguments

  • res - Resources to use
  • filename - The file path for saving the index

Source: rust/cuvs/src/cagra/index.rs:166

deserialize

1pub fn deserialize<P: AsRef<Path>>(res: &Resources, filename: P) -> Result<Index>

Load a CAGRA index from file.

Experimental, both the API and the serialization format are subject to change.

Arguments

  • res - Resources to use
  • filename - The path of the file that stores the index

Source: rust/cuvs/src/cagra/index.rs:179

Source: rust/cuvs/src/cagra/index.rs:17