Add Jaccard distance support in CAGRA #2997
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 534 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.376
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2997"
general
weight: 0.35
KyleFromNVIDIA
<!--
Thank you for contributing to cuvs :)
Here are some guidelines to help the review process go smoothly.
1. Please write a description in this text box of the changes that are being
made.
2. Please ensure that you have written units tests for the changes made/features
added.
3. If you are closing an issue please use one of the automatic closing words as
noted here: https://help.github.com/articles/closing-issues-using-keywords/
4. If your pull request is not ready for review but you want to make use of the
continuous integration testing facilities please label it with
[WIP].5. If your pull request is ready to be reviewed without requiring additional
work on top of it, then remove the
[WIP]label (if present) and replaceit with
[REVIEW]. If assistance is required to complete the functionality,for example when the C/C++ code of a feature is complete but Python bindings
are still required, then add the label
[HELP-REQ]so that others can triageand assist. The additional changes then can be implemented on top of the
same PR. If the assistance is done by members of the cuVS team, then no
additional actions are required by the creator of the original PR for this,
otherwise the original author of the PR needs to give permission to the
person(s) assisting to commit to their personal fork of the project. If that
doesn't happen then a new PR based on the code of the original PR can be
opened by the person assisting, which then will be the PR that will be
merged.
6. Once all work has been done and review has taken place please do not add
features or make changes out of the scope of those requested by the reviewer
(doing this just add delays as already reviewed code ends up having to be
re-reviewed/it is hard to tell what is new etc!). Further, please do not
rebase your branch on master/force push/rewrite history, doing any of these
causes the context of any comments made by reviewers to be lost. If
conflicts occur against master they should be resolved by merging master
into the branch used for making the pull request.
Many thanks in advance for your cooperation!
-->
Summary
This PR adds
BitwiseJaccardsupport to CAGRA and NN-descent for packed binary vectorsThe distance is calculated directly from packed bytes:
Two empty vectors have distance zero. NN-descent, graph sorting, and CAGRA search use the same calculation.
The JIT implementation adds a defaulted compile-time
IsJaccardtemplate parameter to select a specialized worker incompute_distance_impl.cuh. The worker follows the existing vector-loading and query-layout conventions while accumulating and reducing both counts before division.Closes #1158
Benchmarks
Datasets
Datasets need transformation to binary first. Using MNIST, Fashion-MNIST, and SIFT datasets here. MNIST and Fashion-MNIST use
x > 127.5. SIFT uses per-dimension median thresholds fitted on the base dataset. Ground truth is recomputed using exhaustive binary Jaccard search.A100-PCIE-40GB
Configs:
k=10, batch_size=10000, intermediate_degree=128, graph_degree=[32, 64], max_iteration=20, itopk=[32, 64, 128, 256, 512]Dataset | Build (s) | Search / 10,000 queries (ms) | QPS | Recall@10
-- | -- | -- | -- | --
MNIST · 60K × 784 | 0.720 | 63.477 | 157,536 | 99.571%
Fashion-MNIST · 60K × 784 | 0.733 | 63.120 | 158,429 | 99.461%
SIFT · 1M × 128 | 10.370 | 18.664 | 535,791 | 94.575%
<br class="Apple-interchange-newline">
<img width="1296" height="403" alt="image" src="https://github.com/user-attachments/assets/4bc8d634-284c-4b39-9c86-e3f92f808b12" />
Tests
Added C++ and Python tests covering:
SINGLE_CTA,MULTI_CTA, andMULTI_KERNELsearch.