HNSW
Python module: cuvs.neighbors.hnsw
AceParams
Parameters for ACE (Augmented Core Extraction) graph build for HNSW.
ACE enables building HNSW indices for datasets too large to fit in GPU memory by partitioning the dataset and building sub-indices for each partition independently.
Parameters
Constructor
Members
npartitions
build_dir
use_disk
max_host_memory_gb
max_gpu_memory_gb
IndexParams
Parameters to build index for HNSW nearest neighbor search
Parameters
Constructor
Members
hierarchy
ef_construction
num_threads
m
ace_params
Index
HNSW index object. This object stores the trained HNSW index state which can be used to perform nearest neighbors searches.
Members
trained
ExtendParams
Parameters to extend the HNSW index with new data
Parameters
Constructor
Members
num_threads
build
@auto_sync_resources
Build an HNSW index using the ACE (Augmented Core Extraction) algorithm.
ACE enables building HNSW indices for datasets too large to fit in GPU memory by partitioning the dataset and building sub-indices for each partition independently.
NOTE: This function requires index_params.ace_params to be set with
an instance of AceParams.
Parameters
Returns
Examples
extend
@auto_sync_resources
Extends the HNSW index with new data.
Parameters
Examples
SearchParams
HNSW search parameters
Parameters
Constructor
Members
ef
num_threads
load
@auto_sync_resources
Loads an HNSW index.
If the index was constructed with hnsw.IndexParams(hierarchy="none"),
then the loaded index is immutable and can only be searched by the hnswlib
wrapper in cuVS, as the format is not compatible with the original hnswlib.
However, if the index was constructed with
hnsw.IndexParams(hierarchy="cpu"), then the loaded index is mutable and
compatible with the original hnswlib.
Saving / loading the index is experimental. The serialization format is subject to change, therefore loading an index saved with a previous version of cuVS is not guaranteed to work.
Parameters
Returns
Examples
save
@auto_sync_resources
Saves the CAGRA index to a file as an hnswlib index.
If the index was constructed with hnsw.IndexParams(hierarchy="none"),
then the saved index is immutable and can only be searched by the hnswlib
wrapper in cuVS, as the format is not compatible with the original hnswlib.
However, if the index was constructed with
hnsw.IndexParams(hierarchy="cpu"), then the saved index is mutable and
compatible with the original hnswlib.
Saving / loading the index is experimental. The serialization format is subject to change.
Parameters
Examples
search
@auto_sync_resources
@auto_convert_output
Find the k nearest neighbors for each query.
Parameters
Examples
from_cagra
@auto_sync_resources
Returns an HNSW index from a CAGRA index.
NOTE: When index_params.hierarchy is:
NONE: This method uses the filesystem to write the CAGRA index in/tmp/<random_number>.binbefore reading it as an hnswlib index, then deleting the temporary file. The returned index is immutable and can only be searched by the hnswlib wrapper in cuVS, as the format is not compatible with the original hnswlib.CPU: The returned index is mutable and can be extended with additional vectors. The serialized index is also compatible with the original hnswlib library.
Saving / loading the index is experimental. The serialization format is subject to change.
Parameters
Examples