Skip to content

Use PQ API in CAGRA-Q + SCANN#1746

Merged
rapids-bot[bot] merged 21 commits intorapidsai:mainfrom
lowener:26.04-use-pq
Mar 13, 2026
Merged

Use PQ API in CAGRA-Q + SCANN#1746
rapids-bot[bot] merged 21 commits intorapidsai:mainfrom
lowener:26.04-use-pq

Conversation

@lowener
Copy link
Copy Markdown
Contributor

@lowener lowener commented Jan 27, 2026

Follow-up to the PQ PR #1278 .
Closes #1575
Closes #1747
This PR removes the need to compile multiple times the same code for PQ in CAGRA-Q and SCANN, removing code duplication and improving build time.
CAGRA-Q can't use the new public API since it is using half for its math type so an private API function is used.

A small test is added to SCANN to make sure that the returned index is not complete garbage but more testing should be done there. (Created issue #1747 to track this)

This PR saves ~2-3 Mb on libcuvs.so compiled on a single architecture (141 Mb -> 138Mb)

Signed-off-by: Mickael Ide <mide@nvidia.com>
Signed-off-by: Mickael Ide <mide@nvidia.com>
Signed-off-by: Mickael Ide <mide@nvidia.com>
@lowener lowener added improvement Improves an existing functionality non-breaking Introduces a non-breaking change C++ labels Jan 27, 2026
Comment thread cpp/src/neighbors/detail/cagra/factory.cuh
Comment thread cpp/src/preprocessing/quantize/detail/pq.cuh Outdated
Comment thread cpp/src/preprocessing/quantize/detail/pq.cuh
Comment thread cpp/src/neighbors/scann/detail/scann_build.cuh
Comment thread cpp/src/neighbors/scann/detail/scann_build.cuh Outdated
Comment thread cpp/src/neighbors/scann/detail/scann_build.cuh
@rmaschal
Copy link
Copy Markdown
Contributor

rmaschal commented Jan 28, 2026

I know it's hard to test the recall of a ScaNN index, I apologize for that. I pulled this PR to test. Compared to main, recall looks overall the same, so no concern there, but there is a build time regression due to the two issues I mentioned in the comments.

Your prior PR #1278 improved PQ training quite a lot for ScaNN, thank you for that :) For larger dim datasets like LAION and OpenAI, it shaves 2-4s from the overall build time.

@cjnolet cjnolet moved this from Todo to In Progress in Unstructured Data Processing Jan 29, 2026
Comment thread cpp/tests/neighbors/ann_scann.cuh Outdated
Signed-off-by: Mickael Ide <mide@nvidia.com>
@lowener
Copy link
Copy Markdown
Contributor Author

lowener commented Mar 13, 2026

/merge

@rapids-bot rapids-bot Bot merged commit 51fb88e into rapidsai:main Mar 13, 2026
294 of 301 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Unstructured Data Processing Mar 13, 2026
@lowener lowener deleted the 26.04-use-pq branch March 13, 2026 16:27
lowener added a commit to lowener/cuvs that referenced this pull request Mar 30, 2026
Follow-up to the PQ PR rapidsai#1278 .
Closes rapidsai#1575 
Closes rapidsai#1747
This PR removes the need to compile multiple times the same code for PQ in CAGRA-Q and SCANN, removing code duplication and improving build time.
CAGRA-Q can't use the new public API since it is using half for its math type so an private API function is used.

A small test is added to SCANN to make sure that the returned index is not complete garbage but more testing should be done there. (Created issue rapidsai#1747 to track this)

This PR saves ~2-3 Mb on libcuvs.so compiled on a single architecture (141 Mb -> 138Mb)

Authors:
  - Micka (https://github.com/lowener)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: rapidsai#1746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEA] Improve tests for SCANN [FEA] Use PQ public API in Vamana and SCANN

5 participants