IVF PQ
Source header: cuvs/neighbors/ivf_pq.h
IVF-PQ index build parameters
cuvsIvfPqCodebookGen
A type for specifying how PQ codebooks are created
Values
cuvsIvfPqListLayout
A type for specifying the memory layout of IVF-PQ list data
Values
cuvsIvfPqIndexParams
Supplemental parameters to build IVF-PQ Index
Fields
cuvsIvfPqIndexParamsCreate
Allocate IVF-PQ Index params, and populate with default values
Parameters
Returns
cuvsIvfPqIndexParamsDestroy
De-allocate IVF-PQ Index params
Parameters
Returns
IVF-PQ index search parameters
cuvsIvfPqSearchParams
Supplemental parameters to search IVF-PQ index
Fields
cuvsIvfPqSearchParamsCreate
Allocate IVF-PQ search params, and populate with default values
Parameters
Returns
cuvsIvfPqSearchParamsDestroy
De-allocate IVF-PQ search params
Parameters
Returns
IVF-PQ index
cuvsIvfPqIndex
Struct to hold address of cuvs::neighbors::ivf_pq::index and its active trained dtype
Fields
cuvsIvfPqIndexCreate
Allocate IVF-PQ index
Parameters
Returns
cuvsIvfPqIndexDestroy
De-allocate IVF-PQ index
Parameters
Returns
cuvsIvfPqIndexGetNLists
Get the number of clusters/inverted lists
Parameters
Returns
cuvsIvfPqIndexGetDim
Get the dimensionality
Parameters
Returns
cuvsIvfPqIndexGetSize
Get the size of the index
Parameters
Returns
cuvsIvfPqIndexGetPqDim
Get the dimensionality of an encoded vector after compression by PQ.
Parameters
Returns
cuvsIvfPqIndexGetPqBits
Get the bit length of an encoded vector element after compression by PQ.
Parameters
Returns
cuvsIvfPqIndexGetPqLen
Get the Dimensionality of a subspace, i.e. the number of vector
components mapped to a subspace
Parameters
Returns
cuvsIvfPqIndexGetCenters
Get the cluster centers corresponding to the lists in the original space
Parameters
Returns
cuvsIvfPqIndexGetCentersPadded
Get the padded cluster centers [n_lists, dim_ext]
where dim_ext = round_up(dim + 1, 8)
This returns the full padded centers as a contiguous array, suitable for use with cuvsIvfPqBuildPrecomputed.
Parameters
Returns
cuvsIvfPqIndexGetPqCenters
Get the PQ cluster centers
- CUVS_IVF_PQ_CODEBOOK_GEN_PER_SUBSPACE: [pq_dim , pq_len, pq_book_size]
- CUVS_IVF_PQ_CODEBOOK_GEN_PER_CLUSTER: [n_lists, pq_len, pq_book_size]
Parameters
Returns
cuvsIvfPqIndexGetCentersRot
Get the rotated cluster centers [n_lists, rot_dim]
where rot_dim = pq_len * pq_dim
Parameters
Returns
cuvsIvfPqIndexGetRotationMatrix
Get the rotation matrix [rot_dim, dim]
Transform matrix (original space -> rotated padded space)
data
Parameters
Returns
cuvsIvfPqIndexGetListSizes
Get the sizes of each list
Parameters
Returns
cuvsIvfPqIndexUnpackContiguousListData
Unpack n_rows consecutive PQ encoded vectors of a single list (cluster) in the
compressed index starting at given offset, not expanded to one code per byte. Each code in the output buffer occupies ceildiv(index.pq_dim() * index.pq_bits(), 8) bytes.
Parameters
Returns
cuvsIvfPqIndexGetListIndices
Get the indices of each vector in a ivf-pq list
Parameters
Returns
IVF-PQ index build
cuvsIvfPqBuild
Build a IVF-PQ 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
cuvsIvfPqBuildPrecomputed
Build a view-type IVF-PQ index from device memory precomputed centroids and codebook.
This function creates a non-owning index that stores a reference to the provided device data. All parameters must be provided with correct extents. The caller is responsible for ensuring the lifetime of the input data exceeds the lifetime of the returned index.
The index_params must be consistent with the provided matrices. Specifically:
- index_params.codebook_kind determines the expected shape of pq_centers
- index_params.metric will be stored in the index
- index_params.conservative_memory_allocation will be stored in the index The function will verify consistency between index_params, dim, and the matrix extents.
matrices) dim]
Parameters
Returns
IVF-PQ index search
cuvsIvfPqSearch
Search a IVF-PQ index with a DLManagedTensor which has underlying
DLDeviceType equal to kDLCUDA, kDLCUDAHost, kDLCUDAManaged. It is also important to note that the IVF-PQ 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:kDLDataType.code == kDLFloatandkDLDataType.bits = 32orkDLDataType.bits = 16neighbors:kDLDataType.code == kDLUIntandkDLDataType.bits = 32distances:kDLDataType.code == kDLFloatandkDLDataType.bits = 32
Parameters
Returns
IVF-PQ C-API serialize functions
cuvsIvfPqSerialize
Save the index to file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
cuvsIvfPqDeserialize
Load index from file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
IVF-PQ index extend
cuvsIvfPqExtend
Extend the index with the new data.
Parameters
Returns
IVF-PQ index transform
cuvsIvfPqTransform
Transform the input data by applying pq-encoding
Parameters
Returns