HNSW
Source header: cuvs/neighbors/hnsw.h
C API for HNSW index params
cuvsHnswHierarchy
Hierarchy for HNSW index when converting from CAGRA index
NOTE: When the value is NONE, the HNSW index is built as a base-layer-only index.
Values
cuvsHnswAceParams
Parameters for ACE (Augmented Core Extraction) graph build for HNSW.
ACE enables building indexes for datasets too large to fit in GPU memory by:
- Partitioning the dataset in core and augmented partitions using balanced k-means
- Building sub-indexes for each partition independently
- Concatenating sub-graphs into a final unified index
Fields
cuvsHnswAceParamsCreate
Allocate HNSW ACE params, and populate with default values
Parameters
Returns
cuvsHnswAceParamsDestroy
De-allocate HNSW ACE params
Parameters
Returns
cuvsHnswIndexParamsCreate
Allocate HNSW Index params, and populate with default values
Parameters
Returns
cuvsHnswIndexParamsDestroy
De-allocate HNSW Index params
Parameters
Returns
C API for hnswlib wrapper index
cuvsHnswIndex
Struct to hold address of cuvs::neighbors::Hnsw::index and its active trained dtype
Fields
cuvsHnswIndexCreate
Allocate HNSW index
Parameters
Returns
cuvsHnswIndexDestroy
De-allocate HNSW index
Parameters
Returns
Parameters for extending HNSW index
cuvsHnswExtendParams
Parameters for extending HNSW index
Fields
cuvsHnswExtendParamsCreate
Allocate HNSW extend params, and populate with default values
Parameters
Returns
cuvsHnswExtendParamsDestroy
De-allocate HNSW extend params
Parameters
Returns
Load CAGRA index as hnswlib index
cuvsHnswFromCagra
Convert a CAGRA Index to an HNSW index.
NOTE: When 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.
Parameters
Returns
Build HNSW index using ACE algorithm
cuvsHnswBuild
Build an HNSW index using ACE (Augmented Core Extraction) algorithm.
ACE enables building HNSW indexes for datasets too large to fit in GPU memory by:
- Partitioning the dataset using balanced k-means into core and augmented partitions
- Building sub-indexes for each partition independently
- Concatenating sub-graphs into a final unified index
NOTE: This function requires CUDA to be available at runtime.
Parameters
Returns
Extend HNSW index with additional vectors
cuvsHnswExtend
Add new vectors to an HNSW index
NOTE: The HNSW index can only be extended when the hierarchy is CPU when converting from a CAGRA index.
Parameters
Returns
C API for hnswlib wrapper search params
cuvsHnswSearchParams
C API for hnswlib wrapper search params
Fields
cuvsHnswSearchParamsCreate
Allocate HNSW search params, and populate with default values
Parameters
Returns
cuvsHnswSearchParamsDestroy
De-allocate HNSW search params
Parameters
Returns
C API for CUDA ANN Graph-based nearest neighbor search
cuvsHnswSearch
Search a HNSW index with a DLManagedTensor which has underlying
DLDeviceType equal to kDLCPU, kDLCUDAHost, or kDLCUDAManaged. It is also important to note that the HNSW Index must have been built with the same type of queries, such that index.dtype.code == queries.dl_tensor.dtype.code Supported types for input are:
queries: a.kDLDataType.code == kDLFloatandkDLDataType.bits = 32b.kDLDataType.code == kDLIntandkDLDataType.bits = 8c.kDLDataType.code == kDLUIntandkDLDataType.bits = 8neighbors:kDLDataType.code == kDLUIntandkDLDataType.bits = 64distances:kDLDataType.code == kDLFloatandkDLDataType.bits = 32NOTE: When hierarchy isNONE, the HNSW index can only be searched by the hnswlib wrapper in cuVS, as the format is not compatible with the original hnswlib.
Parameters
Returns
HNSW C-API serialize functions
cuvsHnswSerialize
Serialize a CAGRA index to a file as an hnswlib index
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Parameters
Returns
cuvsHnswDeserialize
Load hnswlib index from file which was serialized from a HNSW index.
NOTE: When hierarchy is NONE, the loaded hnswlib index is immutable, and 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
Returns