Add Asymmetric Scalar Hashing (ASH) quantization #796
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 #796"
general
weight: 0.35
r-devulap
Summary
Adds ASH (Asymmetric Scalar Hashing) quantization, introduced in ASH: Asymmetric Scalar Hashing With Learned Dimensionality Reduction for High-Fidelity Vector Quantization (Tepper and Willke, CIKM 2026). ASH reduces the dimension of database vectors with a learned orthonormal projection, then quantizes each projected dimension to a few bits, while keeping queries in their original form. At the same code size it is more accurate than additive and scalar quantizers, trains and encodes quickly, and scores with SIMD lookups. This PR brings ASH to a graph index for the first time.
Quantizer
AsymmetricHashingtrains an ITQ or random projection;encodeAllproducesASHVectors, aCompressedVectorswith codes in compact shared pages. Graph indexes use one landmark.AsymmetricHashing.initializetakesDOT_PRODUCT,EUCLIDEANorCOSINEas a required argument, with no default; the model saves it, every scorer of its codes uses it, and a request for any other similarity fails withIllegalArgumentException.CompressedVectors.similarityFunction()andScoreFunction.similarityFunction()report it (null for PQ, whose caller chooses). Vectors need not be normalized:EUCLIDEANfollows the paper's Euclidean decomposition, storing a scale with each code's offset, andCOSINEnormalizes vectors and queries, then scores dot products.ASHVectorsscore construction and search.BuildScoreProvider.ashBuildScoreProviderbuilds by comparing stored codes (symmetric scoring).On-disk indexes
FusedASH(FeatureId.FUSED_ASH) stores neighbors' codes with each adjacency list and the model in the index header, at 1 to 9 bits per dimension, with NVQ or full-precision reranking.ASHVectorsheld in memory, as with PQ.ramBytesUsed()includes its ASH model, withnativeBytesUsed()for the native part.withPageAlignment(pageBytes)on graph writer builders places base-layer records so none crosses a page boundary, so an index served from storage reads the fewest pages per node. Pages are counted from the file's start, so an index written after other data in a file lines up too. Opt-in; format version 7.Streamed construction
StreamingASHIndexindexes vectors as they arrive. Until its first model is trained from a reservoir sample, it records the vectors and answers searches by scoring them exactly. It then inserts the recorded vectors into a graph of ASH codes inMutableASHVectors(thread-safe encode, set and snapshot) while new inserts continue; inserts do not wait for training.AsymmetricHashing.vectorsBuilder(capacity)encodes batches from any number of threads into an immutableASHVectors, and its live view lets a graph be built over the codes as they fill in.Queries
autoprojects queries in INT8 on x86 processors with VNNI or AMX, then FP16 where the CPU supports it, falling back to FP32. INT8 uses a Highway kernel inlibjvectoron CPUs with AVX-512 VNNI and the oneDNN add-on on the rest.AsymmetricHashing.setQueryOptionssets precision and batch size in code; the system properties remain the defaults.QueryPreparer/PreparedQueryseparate projection from search, andBatchingExecutorqueues concurrent searches with bounded admission so that waiting queries share one batched projection.Operations and benchmarking
run-ash-pq-study.pyreproduces the ASH versus PQ comparison on public 1M datasets, building in one JVM and measuring each query budget in a fresh JVM with only that CPU budget.Experimental, off by default
GraphSearcher.useAdaptiveTermination(true)stops a top-K search by distance instead of beam width, for dot-product, cosine and Euclidean similarity on vectors of any length. Raising the overquery has so far given more recall at the same throughput, so searches keep the standard rule; graph construction with ASH still uses it.-Djvector.ash.gatheredScoring=truescores a node's neighbors from in-memory ASH codes as one gathered block, as fused ASH scores its stored neighborhoods. It lowers single-query latency, but with every core busy it has measured 1–6% lower throughput than scoring one node at a time.Release notes:
796.feature.md,796.enhancement.md. Documentation starts at ASH configuration and defaults and Integrating ASH queries into a database.Compatibility
EUCLIDEAN, a scale unit. JVector 4.0.x rejects version 7 files.CURRENT_VERSIONand the writer defaults are now 7.withVersion(6)andwrite(out, 6)keeps writing files 4.0.x reads, and a version 6 writer rejects fused ASH and page alignment. A host that passes an explicit version to every write keeps its current format until it chooses version 7. See UPGRADING.md.OnDiskGraphIndexCompactor(from #798) writes version 7 by default;withVersion(6)keeps a rollback to 4.0.x possible, and its compressed sidecar is written at the same version. It does not yet compact fused ASH or page-aligned indexes.(1 + dot) / 2without a lower bound for dot product, the scale exact dot-product scoring uses,1 / (1 + d²)for Euclidean and(1 + cos) / 2for cosine.@Experimental.Dependencies
dev.ludovic.netlib:blasanddev.ludovic.netlib:lapack3.0.3 (MIT), which bringnet.sourceforge.f2j:arpack_combined_all0.1 (BSD). They are used only for ASH training, and the publishedjvectorartifact declares them. netlib calls the system BLAS and LAPACK, such as MKL or OpenBLAS, and falls back to Java implementations when none is installed, at a cost in training time.libjvector_ash_fp16-<arch>.so(19 MB on x86-64), shipped in the native JAR with its license and third-party notices. Building it needs CMake 3.13 or later, so it is opt-in: Maven builds it only with-Dnative.onednn=true, which CI and thereleaseprofile set, and default native builds take seconds.subprojects/highway.wrap), pinned at the revision of the former git submodule; the native build no longer needsgit submodule update.Native interface
libjvector(query projection in FP32 and INT8, symmetric construction scoring, neighborhood and single-vector scoring) are compatible additions under the existing handshake. Java looks each one up separately, so an older native library keeps the Java implementations; an explicitly native ASH benchmark fails instead of measuring a fallback.JVECTOR_MAX_ISA=avx3_vnniselects it, andJVECTOR_MAX_ISA=avx3now excludes VNNI kernels.jvector_ash_fp16_abi, currently 1) and status codes, and no C++ exception crosses it. It loads only if present and compatible; otherwise FP16 and INT8 projection are unavailable and queries use the Highway FP32 path. Its Java bindings (NativeAshOneDnn) are generated with jextract, and each entry point is checked before its first call, so an add-on that lacks a newer entry point falls back instead of failing. Its INT8 functions use an AVX2 target and are reached only after oneDNN confirms a VNNI or AMX backend. See Native ABI compatibility.Validation
mainthrough #781: JDK 11, 20 and 22 on Linux and Windows; JDK 20 and 24 on x86 with SSE4.2, AVX2 and AVX-512; JDK 24 on ARM with NEON, SVE and SVE2; and the AVX-512 test and compaction jobs.Benchmarking
Fused ASH versus fused PQ at the same stored bytes per vector, including ASH's 5-byte header, on three large datasets. ASH builds 2.55 times faster overall and has lower construction time in 6 of 6 configurations, higher recall in 12 of 12 cases and higher QPS in 24 of 24.
Construction
Total construction seconds (training, encoding, NVQ, graph build and write); lower is better.
| Dataset | Compression | PQ | ASH | ASH change |
|---|---|---:|---:|---:|
| MPNet 10M | 32x (b=2) | 237.4 | 145.8 | -38.6% |
| MPNet 10M | 16x (b=4) | 436.8 | 173.2 | -60.3% |
| Cohere 10M | 32x (b=2) | 380.3 | 154.7 | -59.3% |
| Cohere 10M | 16x (b=4) | 609.0 | 197.5 | -67.6% |
| CAP 6M | 32x (b=2) | 216.7 | 109.2 | -49.6% |
| CAP 6M | 16x (b=4) | 519.0 | 160.5 | -69.1% |
| Sum | | 2,399.2 | 940.9 | -60.8% |
Recall and throughput
Values: PQ → ASH. Rerank 1x and 2x rescore 10 and 20 candidates with NVQ.
| Dataset | Compression | Rerank | Recall@10 | QPS, 1 core | QPS, 8 cores |
|---|---|---|---:|---:|---:|
| MPNet 10M | 32x (b=2) | 1x | 0.5397 → 0.7568 | 8,048 → 9,122 | 58,864 → 74,639 |
| MPNet 10M | 32x (b=2) | 2x | 0.7122 → 0.8908 | 7,049 → 7,637 | 50,322 → 56,018 |
| MPNet 10M | 16x (b=4) | 1x | 0.7270 → 0.8124 | 7,682 → 9,422 | 49,934 → 71,735 |
| MPNet 10M | 16x (b=4) | 2x | 0.8645 → 0.9009 | 6,003 → 7,386 | 40,194 → 55,348 |
| Cohere 10M | 32x (b=2) | 1x | 0.5333 → 0.5931 | 7,734 → 9,342 | 50,563 → 69,266 |
| Cohere 10M | 32x (b=2) | 2x | 0.7144 → 0.7665 | 6,175 → 7,296 | 45,679 → 50,390 |
| Cohere 10M | 16x (b=4) | 1x | 0.6013 → 0.6550 | 6,318 → 8,585 | 45,298 → 61,948 |
| Cohere 10M | 16x (b=4) | 2x | 0.7605 → 0.7910 | 4,904 → 6,363 | 37,202 → 47,507 |
| CAP 6M | 32x (b=2) | 1x | 0.4118 → 0.7224 | 5,287 → 7,311 | 42,230 → 57,197 |
| CAP 6M | 32x (b=2) | 2x | 0.6001 → 0.8858 | 4,951 → 5,713 | 36,763 → 46,288 |
| CAP 6M | 16x (b=4) | 1x | 0.6624 → 0.8012 | 4,043 → 6,581 | 30,878 → 46,394 |
| CAP 6M | 16x (b=4) | 2x | 0.8404 → 0.9066 | 3,425 → 4,911 | 26,420 → 38,293 |
Eight-core QPS varies by up to about 15% between runs of the same index, so small differences are within noise.
Method
One Intel Xeon 6985P-C socket (Google Cloud c4-standard-96-lssd: 48 physical cores, two threads per core, two NUMA nodes), JDK 22.0.2, native provider with the oneDNN add-on, ash-dev 25b6d845. On-disk format 7, fused graph, degree 32, efConstruction 100, overflow 1.2, hierarchy and refinement on, NVQ reranking, search pruning off, top 10. ASH: ITQ, one landmark, D/2 projected dimensions, symmetric construction scoring; queries use the default
autoprojection (INT8 on this CPU), queued execution with batches of up to 8, adaptive termination. PQ: 8-bit subspaces sized to the same bytes, no centering, anisotropic weighting off; direct execution with four caller threads per core, standard termination. Each index was built once, using both threads of all 48 cores with memory interleaved across both nodes. Queries ran against a warm index with held-out queries never seen before, in a separate JVM per rerank depth and core count, on 1 core or 8 cores of one node. One-core QPS is one run; eight-core QPS is the mean of three. PQ and ASH were measured in the same campaign with the same build. Full details: ASH performance. The study can be rerun with Reproducing ASH versus PQ.