Cagra
Source header: cuvs/neighbors/cagra.h
C API for CUDA ANN Graph-based nearest neighbor search
cuvsCagraGraphBuildAlgo
Enum to denote which ANN algorithm is used to build CAGRA graph
Values
cuvsCagraHnswHeuristicType
A strategy for selecting the graph build parameters based on similar HNSW index
parameters.
Define how cuvsCagraIndexParamsFromHnswParams should construct a graph to construct a graph that is to be converted to (used by) a CPU HNSW index.
cuvsCagraCompressionParams
Parameters for VPQ compression.
Fields
cuvsAceParams
Parameters for ACE (Augmented Core Extraction) graph build.
ACE enables building indexes for datasets too large to fit in GPU memory by:
- Partitioning the dataset in core (closest) and augmented (second-closest) partitions using balanced k-means.
- Building sub-indexes for each partition independently
- Concatenating sub-graphs into a final unified index
Fields
cuvsCagraIndexParams
Supplemental parameters to build CAGRA Index
Fields
cuvsCagraIndexParamsCreate
Allocate CAGRA Index params, and populate with default values
Parameters
Returns
cuvsCagraIndexParamsDestroy
De-allocate CAGRA Index params
Parameters
Returns
cuvsCagraCompressionParamsCreate
Allocate CAGRA Compression params, and populate with default values
Parameters
Returns
cuvsCagraCompressionParamsDestroy
De-allocate CAGRA Compression params
Parameters
Returns
cuvsAceParamsCreate
Allocate ACE params, and populate with default values
Parameters
Returns
cuvsAceParamsDestroy
De-allocate ACE params
Parameters
Returns
cuvsCagraIndexParamsFromHnswParams
Create CAGRA index parameters similar to an HNSW index
This factory function creates CAGRA parameters that yield a graph compatible with an HNSW graph with the given parameters.
Parameters
Returns
C API for CUDA ANN Graph-based nearest neighbor search
cuvsCagraExtendParams
Supplemental parameters to extend CAGRA Index
Fields
cuvsCagraExtendParamsCreate
Allocate CAGRA Extend params, and populate with default values
Parameters
Returns
cuvsCagraExtendParamsDestroy
De-allocate CAGRA Extend params
Parameters
Returns
cuvsCagraExtend
Extend a CAGRA index with a DLManagedTensor which has underlying
DLDeviceType equal to kDLCUDA, kDLCUDAHost, kDLCUDAManaged, or kDLCPU. Also, acceptable underlying types are:
kDLDataType.code == kDLFloatandkDLDataType.bits = 32kDLDataType.code == kDLFloatandkDLDataType.bits = 16kDLDataType.code == kDLIntandkDLDataType.bits = 8kDLDataType.code == kDLUIntandkDLDataType.bits = 8
Parameters
Returns
C API for CUDA ANN Graph-based nearest neighbor search
cuvsCagraSearchAlgo
Enum to denote algorithm used to search CAGRA Index
Values
cuvsCagraHashMode
Enum to denote Hash Mode used while searching CAGRA index
Values
cuvsCagraSearchParams
Supplemental parameters to search CAGRA index
Fields
cuvsCagraSearchParamsCreate
Allocate CAGRA search params, and populate with default values
Parameters
Returns
cuvsCagraSearchParamsDestroy
De-allocate CAGRA search params
Parameters
Returns
C API for CUDA ANN Graph-based nearest neighbor search
cuvsCagraIndex
Struct to hold address of cuvs::neighbors::cagra::index and its active trained dtype
Fields
cuvsCagraIndexCreate
Allocate CAGRA index
Parameters
Returns
cuvsCagraIndexDestroy
De-allocate CAGRA index
Parameters
Returns
cuvsCagraIndexGetDims
Get dimension of the CAGRA index
Parameters
Returns
cuvsCagraIndexGetSize
Get size of the CAGRA index
Parameters
Returns
cuvsCagraIndexGetGraphDegree
Get graph degree of the CAGRA index
Parameters
Returns
cuvsCagraIndexGetDataset
Returns a view of the CAGRA dataset
This function returns a non-owning view of the CAGRA dataset. The output will be referencing device memory that is directly used in CAGRA, without copying the dataset at all. This means that the output is only valid as long as the CAGRA index is alive, and once cuvsCagraIndexDestroy is called on the cagra index - the returned dataset view will be invalid.
Note that the DLManagedTensor dataset returned will have an associated ‘deleter’ function that must be called when the dataset is no longer needed. This will free up host memory that stores the shape of the dataset view.
Parameters
Returns
cuvsCagraIndexGetGraph
Returns a view of the CAGRA graph
This function returns a non-owning view of the CAGRA graph. The output will be referencing device memory that is directly used in CAGRA, without copying the graph at all. This means that the output is only valid as long as the CAGRA index is alive, and once cuvsCagraIndexDestroy is called on the cagra index - the returned graph view will be invalid.
Note that the DLManagedTensor graph returned will have an associated ‘deleter’ function that must be called when the graph is no longer needed. This will free up host memory that stores the metadata for the graph view.
Parameters
Returns
C API for CUDA ANN Graph-based nearest neighbor search
cuvsCagraBuild
Build a CAGRA index with a DLManagedTensor which has underlying
DLDeviceType equal to kDLCUDA, kDLCUDAHost, kDLCUDAManaged, or kDLCPU. Also, acceptable underlying types are:
kDLDataType.code == kDLFloatandkDLDataType.bits = 32kDLDataType.code == kDLFloatandkDLDataType.bits = 16kDLDataType.code == kDLIntandkDLDataType.bits = 8kDLDataType.code == kDLUIntandkDLDataType.bits = 8
Parameters
Returns
C API for CUDA ANN Graph-based nearest neighbor search
cuvsCagraSearch
Search a CAGRA index with a DLManagedTensor which has underlying
DLDeviceType equal to kDLCUDA, kDLCUDAHost, kDLCUDAManaged. It is also important to note that the CAGRA Index must have been built with the same type of queries, such that index.dtype.code == queries.dl_tensor.dtype.code Types for input are:
queries: a.kDLDataType.code == kDLFloatandkDLDataType.bits = 32b.kDLDataType.code == kDLFloatandkDLDataType.bits = 16c.kDLDataType.code == kDLIntandkDLDataType.bits = 8d.kDLDataType.code == kDLUIntandkDLDataType.bits = 8neighbors:kDLDataType.code == kDLUIntandkDLDataType.bits = 32orkDLDataType.code == kDLIntandkDLDataType.bits = 64distances:kDLDataType.code == kDLFloatandkDLDataType.bits = 32
Parameters
Returns
CAGRA C-API serialize functions
cuvsCagraSerialize
Save the index to file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
cuvsCagraSerializeToHnswlib
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.
Parameters
Returns
cuvsCagraDeserialize
Load index from file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
cuvsCagraIndexFromArgs
Load index from a dataset and graph
Parameters
Returns
CAGRA C-API merge functions
cuvsCagraMerge
Merge multiple CAGRA indices into a single CAGRA index.
All input indices must have been built with the same data type (index.dtype) and have the same dimensionality (index.dims). The merged index uses the output parameters specified in cuvsCagraIndexParams.
Input indices must have:
index.dtype.codeandindex.dtype.bitsmatching across all indices.- Supported data types for indices: a.
kDLFloatwithbits = 32b.kDLFloatwithbits = 16c.kDLIntwithbits = 8d.kDLUIntwithbits = 8
The resulting output index will have the same data type as the input indices.
Example:
Parameters
Returns