← Back to Pull requests

Fix scalar CAGRA graph byte encoding #2715

Closed
unknown closed this pull request without merging on Oct 13, 2026 23:02 UTC
View on GitHub
unknown unknown commented on Oct 01, 2026 19:37 UTC
Author

Summary

Fix the scalar bytes supplied to cuVS when building a CAGRA graph for CPU HNSW search. The previous (byte) (value & 0xff) copy did not change the signed byte bits, while the cuVS BYTE matrix interprets them as unsigned. The quantizer now emits 0–127 directly and initializes per-dimension extrema correctly for all-negative values. The redundant full-vector copy is removed.

Two unit regressions and a live GPU-build/HNSW-search test cover negative and mixed-sign vectors, two segments, force merge, GPU-writer selection, self hits, uniqueness, and recall against exact Euclidean neighbors. The affected generated API pages are updated. This PR contains only the standalone scalar fix; it does not include PR #2476 or PR #2653.

Prewarmed search results

The changes in this PR were benchmarked on Jasper-10M in an integrated tree that also contained PR #2476 and PR #2653. Both codecs used the same integrated tree. These are integrated-stack results, not a measurement of the standalone PR head.

The data were 1536-dimensional Euclidean vectors with one segment and no force merge; graph/intermediate degrees were 32/48, with efSearch=1500 and topK=1500. For each of two fresh-JVM search repeats, index files were evicted, ANN vector and graph files were prewarmed, and 210 warmup plus 1,000 measured queries ran. The scalar original-float .vec file was left cold; indiscriminate index prewarming was disabled.

| Codec | Peak search RSS, repeats (GiB) | Mean latency, repeats (ms/query) | Recall@1500 |
| --- | ---: | ---: | ---: |
| Float CAGRA_HNSW | 58.605 / 58.637 | 12.933 / 12.620 | 98.0034% |
| Scalar CAGRA_HNSW_SCALAR | 15.694 / 15.691 | 8.326 / 8.312 | 97.8883% |

Across those repeats, scalar had 42.93 GiB (73.2%) lower hot-process RSS and 34.9% lower mean latency. Most of the RSS difference was file-backed mmap data, not Java heap. The raw float .vec remains on disk and can become resident with blanket prewarming or exact-vector access. These are repeats on one built index per codec, not a confidence interval. Scalar also had a larger index (72.550 vs 58.207 GiB) and slower single-build indexing (332.236 vs 268.413 s).

This is a scalar-versus-float codec comparison, not an isolated search-speed gain caused by this PR: the search reader is unchanged. A separate clone-only ablation kept the corrected quantizer on both sides and restored only the old bit-preserving clone. Two cold scalar builds per variant measured peak build RSS of 96.976 / 96.893 GiB without the clone and 107.007 / 107.381 GiB with it, a median 10.26 GiB (9.6%) reduction. These Jasper results do not establish quality-equivalent scalar behavior on Deep1B-100M.

Validation and compatibility

On NVIDIA A10G with Java 22, Maven 3.9.16, and matching cuVS 26.12, the functional six-file patch in this PR passed Spotless and generated-page checks. The focused quantizer/GPU command ran 3 tests with no failures, errors, or skips; full Maven clean verify ran 350 tests with no failures/errors and 30 other skips. The live test now uses the same assumeTrue(isSupported()) prerequisite convention as the existing cuvs-lucene GPU tests; the recorded GPU run executed with no skips and verified GPU-writer selection. Follow-up cleanup names the quantization bound and refactors test constants for readability; full Maven was not rerun after that nonfunctional cleanup.

Fern site validation was unavailable locally because Node.js was absent. Existing native initial-dimension warnings were also observed in an unchanged main-branch CAGRA test.

The public quantizer byte values intentionally change. Codec identifiers, on-disk format version, and reader code are unchanged, so older indexes are expected to remain readable, though mixed-version reads were not separately tested. Newly built graph topology may differ. Non-Euclidean quality has not been validated.

Diff: 490 lines (+367 / -123) across 6 files Reviewer: imotov Review duration: 17485m
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 490 lines diff across 6 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.371
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2715"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.4% (MEDIUM) · Higher = larger blast radius
47.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 18.7% · Safe to merge
18.7%
Repository