research(nightly): IVF-PQ with HAKES filter-refine (ADR-194)#461
Draft
ruvnet wants to merge 3 commits into
Draft
research(nightly): IVF-PQ with HAKES filter-refine (ADR-194)#461ruvnet wants to merge 3 commits into
ruvnet wants to merge 3 commits into
Conversation
Implements crates/ruvector-ivfpq — ruvector's first compression-based ANN index. Closes the gap noted in ADR-193 (ADR-194 TBD). Architecture: - Two-phase training: IVF k-means++ centroids → residual PQ codebook - Insert: encode (v − centroid[cell]) with PQ, store codes + raw vector - Search: coarse centroid scan → per-cell ADC filter → exact-L2 refine Measured results (N=10K, D=128, 20 clusters, K=10, Celeron N4020): - nprobe=1 rerank_k=50: 34.7% recall@10, 26,429 QPS - nprobe=4 rerank_k=200: 94.7% recall@10, 9,481 QPS - nprobe=16 rerank_k=500: 100.0% recall@10, 2,617 QPS - 21.0x compression (238 KB codes vs 5000 KB raw f32) Criterion search latencies (100 queries): - nprobe=1: 2.39 ms → 41,841 QPS single-thread - nprobe=4: 8.09 ms → 12,361 QPS single-thread - nprobe=16: 32.66 ms → 3,063 QPS single-thread 10/10 unit tests pass. cargo build --release green.
Records the architecture decision to implement ruvector's first compression-based ANN index using the HAKES filter-refine pattern. Documents: context (gap from ADR-193), design rationale for residual PQ vs full-vector PQ, HAKES 3-stage search pipeline, alternatives considered (EnhancedPQ reuse, RVQ, IVF-HNSW routing), and production roadmap (FastScan SIMD P0, mmap refine store P1, streaming inserts P2).
SOTA survey (PQ 2011 → FAISS 2024 → HAKES VLDB 2025), design rationale, implementation notes, real benchmark results with hardware context, how-it-works walkthrough, failure modes, production crate layout proposal, and roadmap to FastScan/OPQ/disk-refine. All benchmark numbers from cargo run --release and cargo bench on Intel Celeron N4020, x86-64 Linux 6.18.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crates/ruvector-ivfpq— ruvector's first compression-based ANN index (IVF-PQ with HAKES filter-refine architecture), closing the gap noted in ADR-193.docs/adr/ADR-194-ivf-pq-hakes.mdrecording the design decision.docs/research/nightly/2026-05-13-ivf-pq-hakes/README.mdwith full SOTA survey and real benchmark results.What's inside
crates/ruvector-ivfpq— standalone Rust crate (depends only onrand = "0.8"):kmeans.rs— k-means++ (120 lines, includesusize::MAXassignment init fix)pq.rs—PqCodebook+LookupTableADC (130 lines)ivfpq.rs—IvfPqIndexwith two-phase residual training, 3-stage HAKES search (220 lines)benches/ivfpq_bench.rs— Criterion: search_nprobe × m × trainSearch pipeline:
Benchmark results (Intel Celeron N4020, N=10K, D=128, K=10)
Compression: 21.0× (238 KB codes vs 5,000 KB raw f32)
Criterion (100-query batches, single-thread):
Test plan
cargo build --release -p ruvector-ivfpq— greencargo test -p ruvector-ivfpq— 10/10 passcargo bench -p ruvector-ivfpq— all criterion benchmarks completecargo run --release -p ruvector-ivfpq— real recall/QPS numbers capturedGist
SEO-optimized overview: https://gist.github.com/ruvnet/75a4751ee9ddf463394f277e3cfe8b18
See
docs/research/nightly/2026-05-13-ivf-pq-hakes/README.mdanddocs/adr/ADR-194-ivf-pq-hakes.mdfor full details.