PQ
Source header: cuvs/preprocessing/quantize/pq.hpp
Product Quantizer utilities
kmeans_params_variant
Alias for the variant holding either balanced or regular k-means parameters.
preprocessing::quantize::pq::params
Product Quantizer parameters.
Fields
preprocessing::quantize::pq::params::params
Simplified constructor that will build an appropriate kmeans params object.
Parameters
Returns
void
preprocessing::quantize::pq::quantizer
Defines and stores VPQ codebooks upon training
Fields
preprocessing::quantize::pq::build
Initializes a product quantizer to be used later for quantizing the dataset.
The use of a pool memory resource is recommended for more consistent training performance.
Usage example:
Parameters
Returns
Additional overload: preprocessing::quantize::pq::build
Parameters
Returns
preprocessing::quantize::pq::transform
Applies quantization transform to given dataset
Usage example:
Parameters
Returns
void
Additional overload: preprocessing::quantize::pq::transform
Parameters
Returns
void
preprocessing::quantize::pq::get_quantized_dim
Get the dimension of the quantized dataset (in bytes)
Parameters
Returns
inline int64_t
the dimension of the quantized dataset
preprocessing::quantize::pq::inverse_transform
Applies inverse quantization transform to given dataset
Parameters
Returns
void
preprocessing::quantize::pq::make_vpq_dataset
Train VPQ storage (codebooks + encoded rows) from a row-major mdspan/mdarray/dataset.
Accepts either a row-major mdspan with value_type, extent, stride, and data_handle (same pattern as cuvs::neighbors::make_device_padded_dataset), or any cuVS dense dataset / dataset view exposing view, dim and stride, in which case the logical dim() is quantized and the row padding is skipped. The rows may be device-accessible or host-resident. Device-accessible rows (device, managed or pinned) with tight row-major storage (logical stride equals dimension) are passed through to training as they are; a wider row pitch triggers a contiguous dense copy first. Host-resident rows are subsampled for training and encoded in bounded batches, so the dense dataset is never staged on the device in full; they must be tightly packed. Empty sources are rejected. The element type must be float, half, int8_t or uint8_t.
Typical CAGRA-Q usage: compress the source rows, then build the graph directly from the VPQ dataset (the metric must be L2Expanded). Keep the device_vpq_dataset alive because the index holds a non-owning view of it.
Parameters
Returns
cuvs::neighbors::device_vpq_dataset<half, int64_t>