Cagra

View as Markdown

Source header: cuvs/neighbors/cagra.hpp

Types

neighbors::graph_build_params::ace_params

Specialized parameters for ACE (Augmented Core Extraction) graph build

1struct ace_params { ... };

Fields

NameTypeDescription
npartitionssize_tNumber of partitions for ACE (Augmented Core Extraction) partitioned build. When set to 0 (default), the number of partitions is automatically derived based on available host and GPU memory to maximize partition size while ensuring the build fits in memory. Small values might improve recall but potentially degrade performance and increase memory usage. Partitions should not be too small to prevent issues in KNN graph construction. The partition size is on average 2 * (n_rows / npartitions) * dim * sizeof(T). 2 is because of the core and augmented vectors. Please account for imbalance in the partition sizes (up to 3x in our tests). If the specified number of partitions results in partitions that exceed available memory, the value will be automatically increased to fit memory constraints and a warning will be issued.
ef_constructionsize_tThe index quality for the ACE build. Bigger values increase the index quality. At some point, increasing this will no longer improve the quality.
build_dirstd::stringDirectory to store ACE build artifacts (e.g., KNN graph, optimized graph). Used when use_disk is true or when the graph does not fit in host and GPU memory. This should be the fastest disk in the system and hold enough space for twice the dataset, final graph, and label mapping.
use_diskboolWhether to use disk-based storage for ACE build. When true, enables disk-based operations for memory-efficient graph construction.
max_host_memory_gbdoubleMaximum host memory to use for ACE build in GiB. When set to 0 (default), uses available host memory. When set to a positive value, limits host memory usage to the specified amount. Useful for testing or when running alongside other memory-intensive processes.
max_gpu_memory_gbdoubleMaximum GPU memory to use for ACE build in GiB. When set to 0 (default), uses available GPU memory. When set to a positive value, limits GPU memory usage to the specified amount. Useful for testing or when running alongside other memory-intensive processes.

CAGRA index build parameters

neighbors::vpq_params

Parameters for VPQ compression.

1struct vpq_params { ... };

Fields

NameTypeDescription
pq_bitsuint32_tThe bit length of the vector element after compression by PQ. Possible values: [4, 5, 6, 7, 8]. Hint: the smaller the ‘pq_bits’, the smaller the index size and the better the search performance, but the lower the recall.
pq_dimuint32_tThe dimensionality of the vector after compression by PQ. When zero, an optimal value is selected using a heuristic. TODO: at the moment dim must be a multiple pq_dim.
vq_n_centersuint32_tVector Quantization (VQ) codebook size - number of “coarse cluster centers”. When zero, an optimal value is selected using a heuristic.
kmeans_n_itersuint32_tThe number of iterations searching for kmeans centers (both VQ & PQ phases).
vq_kmeans_trainset_fractiondoubleThe fraction of data to use during iterative kmeans building (VQ phase). When zero, an optimal value is selected using a heuristic.
pq_kmeans_trainset_fractiondoubleThe fraction of data to use during iterative kmeans building (PQ phase). When zero, an optimal value is selected using a heuristic.
pq_kmeans_typecuvs::cluster::kmeans::kmeans_typeType of k-means algorithm for PQ training. Balanced k-means tends to be faster than regular k-means for PQ training, for problem sets where the number of points per cluster are approximately equal. Regular k-means may be better for skewed cluster distributions.
max_train_points_per_pq_codeuint32_tThe max number of data points to use per PQ code during PQ codebook training. Using more data points per PQ code may increase the quality of PQ codebook but may also increase the build time. We will use pq_n_centers * max_train_points_per_pq_code training points to train each PQ codebook.
max_train_points_per_vq_clusteruint32_tThe max number of data points to use per VQ cluster during training.

neighbors::cagra::hnsw_heuristic_type

A strategy for selecting the graph build parameters based on similar HNSW index

parameters.

Define how cagra::index_params::from_hnsw_params should construct a graph to construct a graph that is to be converted to (used by) a CPU HNSW index.

1enum class hnsw_heuristic_type : uint32_t { ... };

neighbors::cagra::index_params::from_hnsw_params

Create a CAGRA index parameters compatible with HNSW index

1static cagra::index_params from_hnsw_params(
2raft::matrix_extent<int64_t> dataset,
3int M,
4int ef_construction,
5hnsw_heuristic_type heuristic = hnsw_heuristic_type::SIMILAR_SEARCH_PERFORMANCE,
6cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Expanded);
  • IMPORTANT NOTE *

The reference HNSW index and the corresponding from-CAGRA generated HNSW index will NOT produce exactly the same recalls and QPS for the same parameter ef. The graphs are different internally. Depending on the selected heuristics, the CAGRA-produced graph’s QPS-Recall curve may be shifted along the curve right or left. See the heuristics descriptions for more details.

Usage example:

Parameters

NameDirectionTypeDescription
datasetraft::matrix_extent<int64_t>The shape of the input dataset
MintHNSW index parameter M
ef_constructionintHNSW index parameter ef_construction
heuristichnsw_heuristic_typeThe heuristic to use for selecting the graph build parameters Default: hnsw_heuristic_type::SIMILAR_SEARCH_PERFORMANCE.
metriccuvs::distance::DistanceTypeThe distance metric to search Default: cuvs::distance::DistanceType::L2Expanded.

Returns

static cagra::index_params

CAGRA index search parameters

neighbors::cagra::search_algo

CAGRA index search parameters

1enum class search_algo { ... };

Values

NameValue
SINGLE_CTA0
MULTI_CTA1
MULTI_KERNEL2
AUTO100

CAGRA index extend parameters

neighbors::cagra::extend_params

CAGRA index extend parameters

1struct extend_params { ... };

Fields

NameTypeDescription
max_chunk_sizeuint32_tThe additional dataset is divided into chunks and added to the graph. This is the knob to adjust the tradeoff between the recall and operation throughput. Large chunk sizes can result in high throughput, but use more working memory (O(max_chunk_size*degree^2)). This can also degrade recall because no edges are added between the nodes in the same chunk. Auto select when 0.

CAGRA index type

neighbors::cagra::index

CAGRA index.

The index stores the dataset and a kNN graph in device memory.

1template <typename T, typename IdxT>
2struct index : cuvs::neighbors::index { ... };

neighbors::cagra::index::metric

Distance metric used for clustering.

1[[nodiscard]] constexpr inline auto metric() const noexcept -> cuvs::distance::DistanceType;

Returns

cuvs::distance::DistanceType

neighbors::cagra::index::size

Total length of the index (number of vectors).

1[[nodiscard]] constexpr inline auto size() const noexcept -> IdxT;

Returns

IdxT

neighbors::cagra::index::dim

Dimensionality of the data.

1[[nodiscard]] constexpr inline auto dim() const noexcept -> uint32_t;

Returns

uint32_t

neighbors::cagra::index::graph_degree

Graph degree

1[[nodiscard]] constexpr inline auto graph_degree() const noexcept -> uint32_t;

Returns

uint32_t

neighbors::cagra::index::data

Dataset [size, dim]

1[[nodiscard]] inline auto data() const noexcept -> const cuvs::neighbors::dataset<int64_t>&;

Returns

const cuvs::neighbors::dataset<int64_t>&

neighbors::cagra::index::graph

neighborhood graph [size, graph-degree]

1[[nodiscard]] inline auto graph() const noexcept
2-> raft::device_matrix_view<const graph_index_type, int64_t, raft::row_major>;

Returns

raft::device_matrix_view<const graph_index_type, int64_t, raft::row_major>

neighbors::cagra::index::source_indices

Mapping from internal graph node indices to the original user-provided indices.

1[[nodiscard]] inline auto source_indices() const noexcept
2-> std::optional<raft::device_vector_view<const index_type, int64_t>>;

Returns

std::optional<raft::device_vector_view<const index_type, int64_t>>

neighbors::cagra::index::dataset_fd

Get the dataset file descriptor (for disk-backed index)

1[[nodiscard]] inline auto dataset_fd() const noexcept
2-> const std::optional<cuvs::util::file_descriptor>&;

Returns

const std::optional<cuvs::util::file_descriptor>&

neighbors::cagra::index::graph_fd

Get the graph file descriptor (for disk-backed index)

1[[nodiscard]] inline auto graph_fd() const noexcept
2-> const std::optional<cuvs::util::file_descriptor>&;

Returns

const std::optional<cuvs::util::file_descriptor>&

neighbors::cagra::index::mapping_fd

Get the mapping file descriptor (for disk-backed index)

1[[nodiscard]] inline auto mapping_fd() const noexcept
2-> const std::optional<cuvs::util::file_descriptor>&;

Returns

const std::optional<cuvs::util::file_descriptor>&

neighbors::cagra::index::dataset_norms

Dataset norms for cosine distance [size]

1[[nodiscard]] inline auto dataset_norms() const noexcept
2-> std::optional<raft::device_vector_view<const float, int64_t>>;

Returns

std::optional<raft::device_vector_view<const float, int64_t>>

neighbors::cagra::index::index

1index(const index&) = delete;

Parameters

NameDirectionTypeDescription
arg1const index&

Returns

void

Additional overload: neighbors::cagra::index::index

Construct an empty index.

1index(raft::resources const& res,
2cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Expanded)
3: cuvs::neighbors::index(),

Parameters

NameDirectionTypeDescription
resraft::resources const&
metriccuvs::distance::DistanceTypeDefault: cuvs::distance::DistanceType::L2Expanded.

Returns

void

Additional overload: neighbors::cagra::index::index

Construct an index from dataset and knn_graph arrays

1template <typename data_accessor, typename graph_accessor>
2index(raft::resources const& res,
3cuvs::distance::DistanceType metric,
4raft::mdspan<const T, raft::matrix_extent<int64_t>, raft::row_major, data_accessor> dataset,
5raft::mdspan<const graph_index_type,
6raft::matrix_extent<int64_t>,
7raft::row_major,
8graph_accessor> knn_graph)
9: cuvs::neighbors::index(),

If the dataset and graph is already in GPU memory, then the index is just a thin wrapper around these that stores a non-owning a reference to the arrays.

The constructor also accepts host arrays. In that case they are copied to the device, and the device arrays will be owned by the index.

In case the dasates rows are not 16 bytes aligned, then we create a padded copy in device memory to ensure alignment for vectorized load.

Usage examples:

  • Cagra index is normally created by the cagra::build In the above example, we have passed a host dataset to build. The returned index will own a device copy of the dataset and the knn_graph. In contrast, if we pass the dataset as a device_mdspan to build, then it will only store a reference to it.

  • Constructing index using existing knn-graph

Parameters

NameDirectionTypeDescription
resraft::resources const&
metriccuvs::distance::DistanceType
datasetraft::mdspan<const T, raft::matrix_extent<int64_t>, raft::row_major, data_accessor>
knn_graphraft::mdspan<const graph_index_type, raft::matrix_extent<int64_t>, raft::row_major, graph_accessor>

Returns

void

neighbors::cagra::index::update_dataset

Replace the dataset with a new dataset.

1void update_dataset(raft::resources const& res,
2raft::device_matrix_view<const T, int64_t, raft::row_major> dataset);

If the new dataset rows are aligned on 16 bytes, then only a reference is stored to the dataset. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. It is expected that the same set of vectors are used for update_dataset and index build.

Note: This will clear any precomputed dataset norms.

Parameters

NameDirectionTypeDescription
resraft::resources const&
datasetraft::device_matrix_view<const T, int64_t, raft::row_major>

Returns

void

Additional overload: neighbors::cagra::index::update_dataset

Set the dataset reference explicitly to a device matrix view with padding.

1void update_dataset(raft::resources const& res,
2raft::device_matrix_view<const T, int64_t, raft::layout_stride> dataset);

Parameters

NameDirectionTypeDescription
resraft::resources const&
datasetraft::device_matrix_view<const T, int64_t, raft::layout_stride>

Returns

void

Additional overload: neighbors::cagra::index::update_dataset

Replace the dataset with a new dataset.

1void update_dataset(raft::resources const& res,
2raft::host_matrix_view<const T, int64_t, raft::row_major> dataset);

We create a copy of the dataset on the device. The index manages the lifetime of this copy. It is expected that the same set of vectors are used for update_dataset and index build.

Note: This will clear any precomputed dataset norms.

Parameters

NameDirectionTypeDescription
resraft::resources const&
datasetraft::host_matrix_view<const T, int64_t, raft::row_major>

Returns

void

Additional overload: neighbors::cagra::index::update_dataset

Replace the dataset with a new dataset. It is expected that the same set of vectors are used

1template <typename DatasetT>
2auto update_dataset(raft::resources const& res, DatasetT&& dataset)
3-> std::enable_if_t<std::is_base_of_v<cuvs::neighbors::dataset<dataset_index_type>, DatasetT>>;

for update_dataset and index build.

Note: This will clear any precomputed dataset norms.

Parameters

NameDirectionTypeDescription
resraft::resources const&
datasetDatasetT&&

Returns

std::enable_if_t<std::is_base_of_v<cuvs::neighbors::dataset<dataset_index_type>, DatasetT>>

neighbors::cagra::index::update_graph

Replace the graph with a new graph.

1void update_graph(
2raft::resources const& res,
3raft::device_matrix_view<const graph_index_type, int64_t, raft::row_major> knn_graph);

Since the new graph is a device array, we store a reference to that, and it is the caller’s responsibility to ensure that knn_graph stays alive as long as the index.

Parameters

NameDirectionTypeDescription
resraft::resources const&
knn_graphraft::device_matrix_view<const graph_index_type, int64_t, raft::row_major>

Returns

void

Additional overload: neighbors::cagra::index::update_graph

Replace the graph with a new graph.

1void update_graph(
2raft::resources const& res,
3raft::host_matrix_view<const graph_index_type, int64_t, raft::row_major> knn_graph);

We create a copy of the graph on the device. The index manages the lifetime of this copy.

Parameters

NameDirectionTypeDescription
resraft::resources const&
knn_graphraft::host_matrix_view<const graph_index_type, int64_t, raft::row_major>

Returns

void

neighbors::cagra::index::update_source_indices

Replace the source indices with a new source indices taking the ownership of the passed vector.

1void update_source_indices(raft::device_vector<index_type, int64_t>&& source_indices);

Parameters

NameDirectionTypeDescription
source_indicesraft::device_vector<index_type, int64_t>&&

Returns

void

Additional overload: neighbors::cagra::index::update_source_indices

Copy the provided source indices into the index.

1template <typename Accessor>
2void update_source_indices(
3raft::resources const& res,
4raft::mdspan<const index_type, raft::vector_extent<int64_t>, raft::row_major, Accessor>
5source_indices);

Parameters

NameDirectionTypeDescription
resraft::resources const&
source_indicesraft::mdspan<const index_type, raft::vector_extent<int64_t>, raft::row_major, Accessor>

Returns

void

Additional overload: neighbors::cagra::index::update_dataset

Update the dataset from a disk file using a file descriptor.

1void update_dataset(raft::resources const& res, cuvs::util::file_descriptor&& fd);

This method configures the index to use a disk-based dataset. The dataset file should contain a numpy header followed by vectors in row-major format. The number of rows and dimensionality are read from the numpy header.

Parameters

NameDirectionTypeDescription
resinraft::resources const&raft resources
fdincuvs::util::file_descriptor&&File descriptor (will be moved into the index for lifetime management)

Returns

void

Additional overload: neighbors::cagra::index::update_graph

Update the graph from a disk file using a file descriptor.

1void update_graph(raft::resources const& res, cuvs::util::file_descriptor&& fd);

This method configures the index to use a disk-based graph. The graph file should contain a numpy header followed by neighbor indices in row-major format. The number of rows and graph degree are read from the numpy header.

Parameters

NameDirectionTypeDescription
resinraft::resources const&raft resources
fdincuvs::util::file_descriptor&&File descriptor (will be moved into the index for lifetime management)

Returns

void

neighbors::cagra::index::update_mapping

Update the dataset mapping from a disk file using a file descriptor.

1void update_mapping(raft::resources const& res, cuvs::util::file_descriptor&& fd);

This method configures the index to use a disk-based dataset mapping. The mapping file should contain a numpy header followed by index mappings.

Parameters

NameDirectionTypeDescription
resinraft::resources const&raft resources
fdincuvs::util::file_descriptor&&File descriptor (will be moved into the index for lifetime management)

Returns

void

CAGRA index build functions

neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::device_matrix_view<const float, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<float, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • InnerProduct (currently only supported with IVF-PQ as the build algorithm)
  • CosineExpanded
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::device_matrix_view<const float, int64_t, raft::row_major>a matrix view (device) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<float, uint32_t>

Additional overload: neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::host_matrix_view<const float, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<float, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • InnerProduct (currently only supported with IVF-PQ as the build algorithm)
  • CosineExpanded
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::host_matrix_view<const float, int64_t, raft::row_major>a matrix view (host) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<float, uint32_t>

Additional overload: neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::device_matrix_view<const half, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<half, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • InnerProduct (currently only supported with IVF-PQ as the build algorithm)
  • CosineExpanded (dataset norms are computed as float regardless of input data type)
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::device_matrix_view<const half, int64_t, raft::row_major>a matrix view (device) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<half, uint32_t>

Additional overload: neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::host_matrix_view<const half, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<half, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • CosineExpanded (dataset norms are computed as float regardless of input data type)
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::host_matrix_view<const half, int64_t, raft::row_major>a matrix view (host) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<half, uint32_t>

Additional overload: neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::device_matrix_view<const int8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<int8_t, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • CosineExpanded (dataset norms are computed as float regardless of input data type)
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)
  • BitwiseHamming (currently only supported with NN-Descent and Iterative Search as the build algorithm, and only for int8_t and uint8_t data types)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::device_matrix_view<const int8_t, int64_t, raft::row_major>a matrix view (device) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<int8_t, uint32_t>

Additional overload: neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::host_matrix_view<const int8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<int8_t, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • InnerProduct (currently only supported with IVF-PQ as the build algorithm)
  • CosineExpanded (dataset norms are computed as float regardless of input data type)
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)
  • BitwiseHamming (currently only supported with NN-Descent and Iterative Search as the build algorithm, and only for int8_t and uint8_t data types)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::host_matrix_view<const int8_t, int64_t, raft::row_major>a matrix view (host) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<int8_t, uint32_t>

Additional overload: neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<uint8_t, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • InnerProduct (currently only supported with IVF-PQ as the build algorithm)
  • CosineExpanded (dataset norms are computed as float regardless of input data type)
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)
  • BitwiseHamming (currently only supported with NN-Descent and Iterative Search as the build algorithm, and only for int8_t and uint8_t data types)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::device_matrix_view<const uint8_t, int64_t, raft::row_major>a matrix view (device) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<uint8_t, uint32_t>

Additional overload: neighbors::cagra::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& res,
2const cuvs::neighbors::cagra::index_params& params,
3raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::cagra::index<uint8_t, uint32_t>;

The build consist of two steps: build an intermediate knn-graph, and optimize it to create the final graph. The index_params struct controls the node degree of these graphs.

The following distance metrics are supported:

  • L2
  • InnerProduct (currently only supported with IVF-PQ as the build algorithm)
  • CosineExpanded (dataset norms are computed as float regardless of input data type)
  • L1 (currently only supported with NN-Descent and Iterative Search as the build algorithm)
  • BitwiseHamming (currently only supported with NN-Descent and Iterative Search as the build algorithm, and only for int8_t and uint8_t data types)

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
paramsinconst cuvs::neighbors::cagra::index_params&parameters for building the index
datasetinraft::host_matrix_view<const uint8_t, int64_t, raft::row_major>a matrix view (host) to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::cagra::index<uint8_t, uint32_t>

CAGRA extend functions

neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::device_matrix_view<const float, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<float, uint32_t>& idx,
6std::optional<raft::device_matrix_view<float, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::device_matrix_view<const float, int64_t, raft::row_major>additional dataset on device memory
idxin,outcuvs::neighbors::cagra::index<float, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<float, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::host_matrix_view<const float, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<float, uint32_t>& idx,
6std::optional<raft::device_matrix_view<float, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::host_matrix_view<const float, int64_t, raft::row_major>additional dataset on host memory
idxin,outcuvs::neighbors::cagra::index<float, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<float, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::device_matrix_view<const half, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<half, uint32_t>& idx,
6std::optional<raft::device_matrix_view<half, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::device_matrix_view<const half, int64_t, raft::row_major>additional dataset on device memory
idxin,outcuvs::neighbors::cagra::index<half, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<half, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::host_matrix_view<const half, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<half, uint32_t>& idx,
6std::optional<raft::device_matrix_view<half, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::host_matrix_view<const half, int64_t, raft::row_major>additional dataset on host memory
idxin,outcuvs::neighbors::cagra::index<half, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<half, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::device_matrix_view<const int8_t, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<int8_t, uint32_t>& idx,
6std::optional<raft::device_matrix_view<int8_t, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::device_matrix_view<const int8_t, int64_t, raft::row_major>additional dataset on device memory
idxin,outcuvs::neighbors::cagra::index<int8_t, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<int8_t, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::host_matrix_view<const int8_t, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<int8_t, uint32_t>& idx,
6std::optional<raft::device_matrix_view<int8_t, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::host_matrix_view<const int8_t, int64_t, raft::row_major>additional dataset on host memory
idxin,outcuvs::neighbors::cagra::index<int8_t, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<int8_t, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<uint8_t, uint32_t>& idx,
6std::optional<raft::device_matrix_view<uint8_t, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::device_matrix_view<const uint8_t, int64_t, raft::row_major>additional dataset on host memory
idxin,outcuvs::neighbors::cagra::index<uint8_t, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<uint8_t, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::extend

Add new vectors to a CAGRA index

1void extend(
2raft::resources const& handle,
3const cagra::extend_params& params,
4raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> additional_dataset,
5cuvs::neighbors::cagra::index<uint8_t, uint32_t>& idx,
6std::optional<raft::device_matrix_view<uint8_t, int64_t, raft::layout_stride>>
7new_dataset_buffer_view = std::nullopt,
8std::optional<raft::device_matrix_view<uint32_t, int64_t>> new_graph_buffer_view = std::nullopt);

Usage example:

part. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets, cols must be the dimension of the dataset, and the stride must be the same as the original index dataset. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the dataset themselves. The data will be copied from the current index in this function. The num rows must be the sum of the original and additional datasets and cols must be the graph degree. This view will be stored in the output index. It is the caller’s responsibility to ensure that dataset stays alive as long as the index. This option is useful when users want to manage the memory space for the graph themselves.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft resources
paramsinconst cagra::extend_params&extend params
additional_datasetinraft::host_matrix_view<const uint8_t, int64_t, raft::row_major>additional dataset on host memory
idxin,outcuvs::neighbors::cagra::index<uint8_t, uint32_t>&CAGRA index
new_dataset_buffer_viewoutstd::optional<raft::device_matrix_view<uint8_t, int64_t, raft::layout_stride>>memory buffer view for the dataset including the additional Default: std::nullopt.
new_graph_buffer_viewoutstd::optional<raft::device_matrix_view<uint32_t, int64_t>>memory buffer view for the graph including the additional part. Default: std::nullopt.

Returns

void

CAGRA search functions

none_sample_filter

Search ANN using the constructed index.

1void search(raft::resources const& res,
2cuvs::neighbors::cagra::search_params const& params,
3const cuvs::neighbors::cagra::index<float, uint32_t>& index,
4raft::device_matrix_view<const float, int64_t, raft::row_major> queries,
5raft::device_matrix_view<uint32_t, int64_t, raft::row_major> neighbors,
6raft::device_matrix_view<float, int64_t, raft::row_major> distances,
7const cuvs::neighbors::filtering::base_filter& sample_filter =
8cuvs::neighbors::filtering::none_sample_filter{}

CAGRA serialize functions

neighbors::cagra::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::cagra::index<float, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<float, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

neighbors::cagra::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::cagra::index<float, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexoutcuvs::neighbors::cagra::index<float, uint32_t>*the cagra index

Returns

void

Additional overload: neighbors::cagra::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::cagra::index<float, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<float, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

Additional overload: neighbors::cagra::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::cagra::index<float, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexoutcuvs::neighbors::cagra::index<float, uint32_t>*the cagra index

Returns

void

Additional overload: neighbors::cagra::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::cagra::index<half, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<half, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

Additional overload: neighbors::cagra::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::cagra::index<half, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexoutcuvs::neighbors::cagra::index<half, uint32_t>*the cagra index

Returns

void

Additional overload: neighbors::cagra::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::cagra::index<half, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<half, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

Additional overload: neighbors::cagra::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::cagra::index<half, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexoutcuvs::neighbors::cagra::index<half, uint32_t>*the cagra index

Returns

void

Additional overload: neighbors::cagra::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::cagra::index<int8_t, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<int8_t, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

Additional overload: neighbors::cagra::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::cagra::index<int8_t, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexoutcuvs::neighbors::cagra::index<int8_t, uint32_t>*the cagra index

Returns

void

Additional overload: neighbors::cagra::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::cagra::index<int8_t, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<int8_t, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

Additional overload: neighbors::cagra::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::cagra::index<int8_t, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexoutcuvs::neighbors::cagra::index<int8_t, uint32_t>*the cagra index

Returns

void

Additional overload: neighbors::cagra::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::cagra::index<uint8_t, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<uint8_t, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

Additional overload: neighbors::cagra::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::cagra::index<uint8_t, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexoutcuvs::neighbors::cagra::index<uint8_t, uint32_t>*the cagra index

Returns

void

Additional overload: neighbors::cagra::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::cagra::index<uint8_t, uint32_t>& index,
4bool include_dataset = true);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<uint8_t, uint32_t>&CAGRA index
include_datasetinboolWhether or not to write out the dataset to the file. Default: true.

Returns

void

Additional overload: neighbors::cagra::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::cagra::index<uint8_t, uint32_t>* index);

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

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexoutcuvs::neighbors::cagra::index<uint8_t, uint32_t>*the cagra index

Returns

void

neighbors::cagra::serialize_to_hnswlib

Write the CAGRA built index as a base layer HNSW index to an output stream

1void serialize_to_hnswlib(
2raft::resources const& handle,
3std::ostream& os,
4const cuvs::neighbors::cagra::index<float, uint32_t>& index,
5std::optional<raft::host_matrix_view<const float, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<float, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const float, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::serialize_to_hnswlib

Save a CAGRA build index in hnswlib base-layer-only serialized format

1void serialize_to_hnswlib(
2raft::resources const& handle,
3const std::string& filename,
4const cuvs::neighbors::cagra::index<float, uint32_t>& index,
5std::optional<raft::host_matrix_view<const float, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<float, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const float, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::serialize_to_hnswlib

Write the CAGRA built index as a base layer HNSW index to an output stream

1void serialize_to_hnswlib(
2raft::resources const& handle,
3std::ostream& os,
4const cuvs::neighbors::cagra::index<half, uint32_t>& index,
5std::optional<raft::host_matrix_view<const half, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<half, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const half, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::serialize_to_hnswlib

Save a CAGRA build index in hnswlib base-layer-only serialized format

1void serialize_to_hnswlib(
2raft::resources const& handle,
3const std::string& filename,
4const cuvs::neighbors::cagra::index<half, uint32_t>& index,
5std::optional<raft::host_matrix_view<const half, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<half, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const half, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::serialize_to_hnswlib

Write the CAGRA built index as a base layer HNSW index to an output stream

1void serialize_to_hnswlib(
2raft::resources const& handle,
3std::ostream& os,
4const cuvs::neighbors::cagra::index<int8_t, uint32_t>& index,
5std::optional<raft::host_matrix_view<const int8_t, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<int8_t, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const int8_t, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::serialize_to_hnswlib

Save a CAGRA build index in hnswlib base-layer-only serialized format

1void serialize_to_hnswlib(
2raft::resources const& handle,
3const std::string& filename,
4const cuvs::neighbors::cagra::index<int8_t, uint32_t>& index,
5std::optional<raft::host_matrix_view<const int8_t, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<int8_t, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const int8_t, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::serialize_to_hnswlib

Write the CAGRA built index as a base layer HNSW index to an output stream

1void serialize_to_hnswlib(
2raft::resources const& handle,
3std::ostream& os,
4const cuvs::neighbors::cagra::index<uint8_t, uint32_t>& index,
5std::optional<raft::host_matrix_view<const uint8_t, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::cagra::index<uint8_t, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const uint8_t, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void

Additional overload: neighbors::cagra::serialize_to_hnswlib

Save a CAGRA build index in hnswlib base-layer-only serialized format

1void serialize_to_hnswlib(
2raft::resources const& handle,
3const std::string& filename,
4const cuvs::neighbors::cagra::index<uint8_t, uint32_t>& index,
5std::optional<raft::host_matrix_view<const uint8_t, int64_t, raft::row_major>> dataset =
6std::nullopt);

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.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::cagra::index<uint8_t, uint32_t>&CAGRA index
datasetinstd::optional<raft::host_matrix_view<const uint8_t, int64_t, raft::row_major>>[optional] host array that stores the dataset, required if the index does not contain the dataset. Default: std::nullopt.

Returns

void