Skip to content

Commit e0f8a4e

Browse files
authored
Merge pull request #2652 from NVIDIA/release/26.10
Forward-merge release/26.10 into main
2 parents cf0f429 + 436c932 commit e0f8a4e

40 files changed

Lines changed: 1822 additions & 548 deletions

c/include/cuvs/core/dataset.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ extern "C" {
2020
*/
2121
typedef enum {
2222
CUVS_DATASET_LAYOUT_STANDARD = 0,
23-
CUVS_DATASET_LAYOUT_PADDED = 1
23+
CUVS_DATASET_LAYOUT_PADDED = 1,
24+
CUVS_DATASET_LAYOUT_PQ = 2
2425
} cuvsDatasetLayout_t;
2526

2627
/**
@@ -48,6 +49,23 @@ typedef struct {
4849
} cuvsDataset;
4950
typedef cuvsDataset* cuvsDataset_t;
5051

52+
struct cuvsCagraCompressionParams;
53+
typedef struct cuvsCagraCompressionParams cuvsPqParams;
54+
typedef cuvsPqParams* cuvsPqParams_t;
55+
56+
/**
57+
* @brief Compatibility name for PQ dataset parameters; planned for removal in the 27.02 ABI-breaking release.
58+
*
59+
* Use `cuvsPqParams_t` in new code.
60+
*/
61+
typedef struct cuvsCagraCompressionParams* cuvsCagraCompressionParams_t;
62+
63+
/** Allocate generic PQ dataset parameters with default values. */
64+
CUVS_EXPORT cuvsError_t cuvsPqParamsCreate(cuvsPqParams_t* params);
65+
66+
/** De-allocate generic PQ dataset parameters. */
67+
CUVS_EXPORT cuvsError_t cuvsPqParamsDestroy(cuvsPqParams_t params);
68+
5169
/**
5270
* @brief Create an empty owning dataset handle.
5371
*
@@ -72,6 +90,17 @@ CUVS_EXPORT cuvsError_t cuvsDatasetMakePadded(cuvsResources_t res,
7290
cuvsDatasetMemType_t target_mem_type,
7391
cuvsDataset_t* padded_dataset);
7492

93+
/**
94+
* @brief Compress a dense dataset into a device PQ dataset.
95+
*
96+
* Only device output is currently supported.
97+
*/
98+
CUVS_EXPORT cuvsError_t cuvsDatasetMakePQ(cuvsResources_t res,
99+
cuvsPqParams_t params,
100+
cuvsDataset_t dataset,
101+
cuvsDatasetMemType_t target_mem_type,
102+
cuvsDataset_t* pq_dataset);
103+
75104
/**
76105
* @brief Create a non-owning padded dataset view from a host- or device-resident tensor.
77106
*

c/include/cuvs/neighbors/cagra.h

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,19 @@ enum cuvsCagraHnswHeuristicType {
8181
CUVS_CAGRA_HEURISTIC_SAME_GRAPH_FOOTPRINT = 1
8282
};
8383

84-
/** Parameters for VPQ compression. */
84+
/**
85+
* Parameters for PQ dataset compression.
86+
*
87+
* The `cuvsCagraCompressionParams` name is retained for ABI compatibility and is planned for
88+
* removal in the 27.02 ABI-breaking release. Use `cuvsPqParams` in new code.
89+
*/
8590
struct cuvsCagraCompressionParams {
8691
/**
8792
* The bit length of the vector element after compression by PQ.
8893
*
8994
* Possible values: [4, 5, 6, 7, 8].
9095
*
91-
* Hint: the smaller the 'pq_bits', the smaller the index size and the better the search
96+
* Hint: the smaller the `pq_bits`, the smaller the index size and the better the search
9297
* performance, but the lower the recall.
9398
*/
9499
uint32_t pq_bits;
@@ -118,8 +123,6 @@ struct cuvsCagraCompressionParams {
118123
double pq_kmeans_trainset_fraction;
119124
};
120125

121-
typedef struct cuvsCagraCompressionParams* cuvsCagraCompressionParams_t;
122-
123126
struct cuvsIvfPqParams {
124127
cuvsIvfPqIndexParams_t ivf_pq_build_params;
125128
cuvsIvfPqSearchParams_t ivf_pq_search_params;
@@ -270,15 +273,21 @@ CUVS_EXPORT cuvsError_t cuvsCagraMergeParamsCreate(cuvsCagraMergeParams_t* param
270273
CUVS_EXPORT cuvsError_t cuvsCagraMergeParamsDestroy(cuvsCagraMergeParams_t params);
271274

272275
/**
273-
* @brief Allocate CAGRA Compression params, and populate with default values
276+
* @brief Allocate CAGRA Compression params, and populate with default values.
277+
*
278+
* Deprecated: Use `cuvsPqParamsCreate`. This compatibility API is planned for removal in
279+
* the 27.02 ABI-breaking release.
274280
*
275281
* @param[in] params cuvsCagraCompressionParams_t to allocate
276282
* @return cuvsError_t
277283
*/
278284
CUVS_EXPORT cuvsError_t cuvsCagraCompressionParamsCreate(cuvsCagraCompressionParams_t* params);
279285

280286
/**
281-
* @brief De-allocate CAGRA Compression params
287+
* @brief De-allocate CAGRA Compression params.
288+
*
289+
* Deprecated: Use `cuvsPqParamsDestroy`. This compatibility API is planned for removal in
290+
* the 27.02 ABI-breaking release.
282291
*
283292
* @param[in] params
284293
* @return cuvsError_t
@@ -610,21 +619,20 @@ CUVS_EXPORT cuvsError_t cuvsCagraIndexGetDataset(cuvsCagraIndex_t index, DLManag
610619
CUVS_EXPORT cuvsError_t cuvsCagraIndexGetGraph(cuvsCagraIndex_t index, DLManagedTensor* graph);
611620

612621
/**
613-
* @brief Update a CAGRA index with a device-padded dataset.
622+
* @brief Update a CAGRA index with a device-padded or device-PQ dataset.
614623
*
615-
* This is the centralized dataset update operation for C callers. If \p index
616-
* is already device-padded, its dataset view is replaced in place. Otherwise,
617-
* the index is converted and its opaque handle is rebound to a search-ready
618-
* device-padded index. Caller retains ownership of
619-
* \p device_padded_dataset and must keep it alive while \p index uses it.
624+
* This is the centralized dataset update operation for C callers. The index's opaque handle is
625+
* rebound to an index over the supplied dataset layout. Device-padded and device-PQ datasets can
626+
* be attached to any supported index layout. The caller retains ownership of \p dataset and must
627+
* keep it alive while \p index uses it.
620628
*
621-
* @param[in] res cuvsResources_t opaque C handle
622-
* @param[in] device_padded_dataset owning or non-owning device-padded dataset handle
623-
* @param[inout] index CAGRA index handle
629+
* @param[in] res cuvsResources_t opaque C handle
630+
* @param[in] dataset owning or non-owning device-padded or device-PQ dataset handle
631+
* @param[inout] index CAGRA index handle
624632
* @return cuvsError_t
625633
*/
626634
CUVS_EXPORT cuvsError_t cuvsCagraUpdateDataset(cuvsResources_t res,
627-
cuvsDataset_t device_padded_dataset,
635+
cuvsDataset_t dataset,
628636
cuvsCagraIndex_t index);
629637

630638
/**
@@ -685,6 +693,10 @@ CUVS_EXPORT cuvsError_t cuvsCagraUpdateDataset(cuvsResources_t res,
685693
* cuvsError_t res_destroy_status = cuvsResourcesDestroy(res);
686694
* @endcode
687695
*
696+
* A `CUVS_DATASET_LAYOUT_PQ` dataset created by `cuvsDatasetMakePQ` builds an iterative CAGRA-Q
697+
* index. VPQ input requires `L2Expanded` and `ITERATIVE_CAGRA_SEARCH` (or `AUTO_SELECT`), and the
698+
* VPQ dataset must outlive the index because the index stores a non-owning view.
699+
*
688700
* @param[in] res cuvsResources_t opaque C handle
689701
* @param[in] params cuvsCagraIndexParams_t used to build CAGRA index
690702
* @param[in] dataset cuvsDataset_t training dataset or dataset view
@@ -848,6 +860,9 @@ CUVS_EXPORT cuvsError_t cuvsCagraSearchMultiPartition(cuvsResources_t res,
848860
/**
849861
* Save the CAGRA graph to file without its dataset.
850862
*
863+
* This supports dense and PQ-backed indexes. The dataset must be attached separately after loading
864+
* the graph.
865+
*
851866
* Experimental, both the API and the serialization format are subject to change.
852867
*
853868
* @param[in] res cuvsResources_t opaque C handle
@@ -863,7 +878,7 @@ CUVS_EXPORT cuvsError_t cuvsCagraSerializeGraph(cuvsResources_t res,
863878
*
864879
* The index stores a non-owning dataset view. The caller must keep the dataset backing that view
865880
* alive while this function runs. Returns CUVS_ERROR without modifying the destination file if
866-
* the index has no attached dataset.
881+
* the index has no attached dataset. PQ datasets are not serialized by this function.
867882
*
868883
* Experimental, both the API and the serialization format are subject to change.
869884
*
@@ -907,7 +922,7 @@ CUVS_EXPORT cuvsError_t cuvsCagraSerializeToHnswlib(cuvsResources_t res,
907922
* Load the CAGRA graph from file without retaining a serialized dataset.
908923
*
909924
* This succeeds whether or not the file contains a dataset. Use cuvsCagraUpdateDataset to attach a
910-
* caller-owned device-padded dataset view before searching the graph-only index.
925+
* caller-owned device-padded or device-PQ dataset before searching the graph-only index.
911926
*
912927
* Experimental, both the API and the serialization format are subject to change.
913928
*

0 commit comments

Comments
 (0)