Skip to content

Recover cagra-q path in C API and downstream language wrappers - #2413

Open
HowardHuang1 wants to merge 6 commits into
NVIDIA:mainfrom
HowardHuang1:HH-cagra-q-restore-26.08
Open

Recover cagra-q path in C API and downstream language wrappers#2413
HowardHuang1 wants to merge 6 commits into
NVIDIA:mainfrom
HowardHuang1:HH-cagra-q-restore-26.08

Conversation

@HowardHuang1

Copy link
Copy Markdown
Contributor

Addresses issue #2405.

…ke_vpq_dataset() factory and update_dataset() branches for attaching vpq dataset at C API and downstream language wrappers
@HowardHuang1
HowardHuang1 requested review from a team as code owners August 4, 2026 23:58
@HowardHuang1 HowardHuang1 self-assigned this Aug 4, 2026
@HowardHuang1 HowardHuang1 added feature request New feature or request breaking Introduces a breaking change labels Aug 4, 2026
@HowardHuang1
HowardHuang1 changed the base branch from release/26.08 to main August 5, 2026 00:49
@HowardHuang1
HowardHuang1 force-pushed the HH-cagra-q-restore-26.08 branch from 92cae9c to 6418b95 Compare August 5, 2026 00:53
* @param[out] vpq_dataset newly allocated owning VPQ dataset handle
* @return cuvsError_t
*/
CUVS_EXPORT cuvsError_t cuvsDatasetMakeVpq(cuvsResources_t res,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop the V from this and call it cuvsDatasetMakePq.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to clarify my understanding of make_vpq_dataset() factory. There is a PQ step and a VQ step but the VQ step is optional and run only when the flag bool use_vq = true. Is that why we are renaming the make_vpq_dataset() factory to make_pq_dataset()? So we will have pq dataset, rabitq dataset, bbq dataset, and sq dataset but no standalone vpq dataset? We will treat vpq as a special condition of pq dataset?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VQ is not a proper VQ. It's misnamed. It's coarse centroid assignments. But we don't need to include that in the name.

* @param[in] device_padded_dataset owning or non-owning device-padded dataset handle
* @param[inout] index CAGRA index handle
* @param[in] res cuvsResources_t opaque C handle
* @param[in] dataset device-padded or owning device VPQ_F16 dataset handle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I don't know that i like this naming. VPQ_F16... that's cryptic... and why only F16? Is that really the only data type that's supported?

Let's keep the naming contention here: device-padded or pq`. Also- there's no reason we should need to specify "owning device" here... that should be opaque to the user (they just create a dataset in the c layer and they pass it in and we worry about the view creation under the hood).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VPQ_F32 is not supported right now in the cagra-q search kernels.

Source vectors can be f32/f16/int8/uint8 but the codebook math type stored for search is forced to half.

compute_distance_vpq-impl.cuh has this line:
static_assert(std::is_same_v<CODE_BOOK_T, half>, "Only CODE_BOOK_T = half is supported now");

*/
template <typename T, typename IdxT, typename IndexViewT>
requires cuvs::neighbors::ann_dataset_view<IndexViewT>
auto attach_dataset(raft::resources const& res,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please stop naming this attach_dataset. The only function that should be exposed to the outside world is update_dataset. Since we're not rushing to get this into 26.08, we need to fix this.

[[nodiscard]] auto make_vpq_dataset(raft::resources const& res,
cuvs::neighbors::vpq_params const& params,
SrcT const& src)
[[nodiscard]] auto make_device_vpq_dataset(raft::resources const& res,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename- pq_dataset. We don't need the vpq in the name.

Comment thread go/cagra/cagra.go
}

// Owning VPQ dataset handle for CAGRA-Q search.
type VpqDataset struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a separate struct? Also.. please rename ALL instances of vpq_dataset to pq_dataset.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a mistake that it was ever named vpq to begin with- I understand it does a vector quant on top of the pq, but that's a feature, not a defining name.

@aamijar aamijar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding my review below:

*/
template <typename T, typename IdxT, typename IndexViewT>
requires cuvs::neighbors::ann_dataset_view<IndexViewT>
auto convert_dense_to_vpq_f16_index(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function seems unnecessary. We shouldn't be copying the cagra graph just to change the template type.
I am making the change to update_dataset to do the move instead of copy. We should be able to reuse update_dataset for this.


TEST(CagraC, BuildAttachVpqSearch)
{
// CAGRA-Q smoke test: dense build → MakeVpq → UpdateDataset(VPQ) → Search.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests to C api and language wrappers. I don't see tests in cpp though. We should add that.

CUVS_DATASET_LAYOUT_PADDED = 1
CUVS_DATASET_LAYOUT_PADDED = 1,
/** Device VPQ storage with f16 codebooks (CAGRA-Q search dataset). */
CUVS_DATASET_LAYOUT_VPQ_F16 = 2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CUVS_DATASET_LAYOUT_VPQ_F16 = 2
CUVS_DATASET_LAYOUT_PQ = 2

)
padded = make_device_padded_dataset(dataset_device)
compression = cagra.CompressionParams(pq_bits=8, pq_dim=8)
vpq = cagra.make_vpq_dataset(padded, compression_params=compression)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we saying the user needs to do make_device_padded_dataset before make_vpq_dataset? Can you just call make_vpq_dataset by itself?

@aamijar

aamijar commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This PR is marked a a breaking change, can you clarify what is breaking here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change feature request New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants