ASH: support every similarity at every setting; faster Panama scoring for 2–9 bits #831
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #831"
general
weight: 0.35
MarkWolters
ASH says it supports
DOT_PRODUCT,COSINEandEUCLIDEAN, but the tests covered only 1–4 bits and a few scoring paths. This PR tests every supported setting, fixes what the tests found, and replaces the slow Panama scoring paths.Tests
TestASHMetricMatrixcovers all three similarities at:- 1–9 bits, 1 and 3 landmarks,
ITQandRANDOM- in-memory, symmetric, fused (block sizes 8/16/32), separated and streaming scoring
- every kernel mode (
singleKernel/blockKernelscalar/simd/auto,gatheredScoring)PanamaASHOffsetBinaryDotTestchecks the new kernels against an independent decoder at every width and many lengths, with codes anywhere in an array, and checks they give the same bits before and after the JIT compiles them.Fixes found by the tests
MutableASHVectors: symmetric batch scoring threw a null pointer when its batch kernel was off (for example at 1 bit).ASHVectors.blockScorerFor(query): threw a null pointer with-Djvector.ash.gatheredScoring=true.OnDiskGraphIndex.View: a fused score function made on one view and used to search through another returned wrong neighbors (0 of 10 correct in one case). The searching view now reads its own neighbor list when the score function loaded it elsewhere.TestASHCodeschecks it, and 2/4-bit single scoring is 3–5% faster.-XX:MaxVectorSize=8, also in4.1.0-rc.1), and 8 and 9-bit decoding was wrong at 32 lanes.Faster scoring
Results
ns per vector, d=384, JDK 22, old =
4.1.0-rc.1. One thread, JVM pinned to 4 cores, one width per JVM, median of 3 timed rounds, best of 2 JVMs.| | Ice Lake (32 cores) | Ice Lake (8 cores) | GNR (48 cores) |
|---|---|---|---|
| 3, 5–9 bits, Panama, single | ~740–1,410 → ~55 | ~720–1,380 → ~52 | ~460–920 → ~36–40 |
| 3, 5–9 bits, Panama, fused upper layers | ~610–990 → ~75–81 | ~590–970 → ~71–75 | ~370–670 → ~53–59 |
| 3, 5–9 bits, Panama, fused neighborhoods | ~790–1,000 → ~85–88 | ~750–950 → ~80–82 | ~470–600 → ~54–56 |
| 3, 5–9 bits, native, single | 190–526 → ~58–61 | 92–346 → ~55–56 | 51–249 → ~39–44 |
| 2 bits, Panama, single | 293 → 78 | 134 → 75 | 80 → 55 |
| 4 bits, Panama, single | 287 → 78 | 134 → 74 | 83 → 55 |
| 3, 5–9 bits, symmetric (graph construction) | 1,210–1,550 → 85–95 | — | — |
| 1/2/4 bits otherwise | no change | no change | no change |
The symmetric row is ns per pair at 5 and 8 bits, JDK 22 and 25, native and Panama, 3–6 JVMs each. JDK 25 gives the same 3/5–9-bit gains. JDK 25 Panama keeps its 2/4-bit kernel; its 2-bit single score is faster with the new lane sum (88 → 65 on Ice Lake (32 cores)). Every apparent 1/2/4-bit slowdown was re-run across several JVMs and was run-to-run noise.
End to end, 1M vectors, 5 bits
Ice Lake (32 cores), JDK 22, native provider,
4.1.0-rc.1→ this PR. The repo's ASH vs PQ study setup (run-ash-pq-benchmark.sh) withbitsPerDimension: 5andencodedBitsto match; build on all cores, then one pass of cold queries on 1 core.| | ada002-1M (1536 dims) | dpr-gemma-1m (768 dims) |
|---|---|---|
| Build time | 631 s → 63 s (10×) | 323 s → 39 s (8.3×) |
| QPS, 1 core, overquery 1× | 4,175 → 6,324 (+51%) | 7,005 → 9,689 (+38%) |
| QPS, 1 core, overquery 2× | 3,420 → 4,806 (+41%) | 5,651 → 7,229 (+28%) |
| Recall@10, 1× / 2× | 0.848 / 0.930 → 0.850 / 0.931 | 0.888 / 0.978 → 0.889 / 0.980 |
| p50 latency, 1× | 2.06 → 1.35 ms | 1.22 → 0.87 ms |
Recall differs only by the run-to-run variation of the parallel build; the scores themselves are unchanged.
Testing
-Pjdk11), on Ice Lake (32 cores).TestASHMetricMatrixpasses on JDK 22 and 25, native and Panama.-XX:MaxVectorSize=32(8 lanes, as on AVX2),=16(4 lanes) and=8(2 lanes, the Java fallback), with assertions on, on JDK 22 and 25. At 2 lanes, PQ'sassembleAndSumstill rejects 64-bit vectors, as it does in4.1.0-rc.1.4.1.0-rc.1.NativeASHInt8ProjectionTestfails under forced Panama there too, and so do the intermittent JDK 25 Panama tests that compare floats bit for bit across JIT tiers (TestASHEuclidean,TestASHCosine,TestStreamingASHIndex).TestASHTrainingSetup.unitLengthInputGivesTheSameModelAsTheEarlierUnitLengthTrainingandTestMutableASHVectors.concurrentlyAddedVectorsScoreBitForBitAsAFixedCollectionnow allow exactly the differences that can cause, and pass 10 of 10 on JDK 22 and 25 at 4 lanes and full width. Production code is unchanged by this; making those sums fixed-order cost 1–3% in query projection.TestASHSymmetricScorerhad a stale check that failed with-Djvector.vectorization_provider=native; it is removed, so the test now covers native at every width.Known issues
-XX:MaxInlineLevel(15), 2 of 12 at 14 and 4 of 12 at 13, so a kernel reached through a deeper call chain can still lose its vector intrinsics. Hoisting the kernels' broadcasts out of their loops removed them, but cost 4–19% on other paths, so it is not included.4.1.0-rc.1); not changed here.4.1.0-rc.1when timed alone (29.2 ns in 6 of 6 JVMs on Ice Lake (32 cores)). After fused L0 scoring in the same JVM it is 31.0 ns in 3 of 6 JVMs. 5–9 bits match4.1.0-rc.1either way.Docs
docs/ash-configuration.mdnow says every similarity works at every setting, and describes the per-width kernels, symmetric ones included.Release notes:
docs/release notes/4.1.0-rc.2/831.performance.mdand831.bugfix.md.