Skip to content

research(nightly): IVF-PQ with HAKES filter-refine (ADR-194)#461

Draft
ruvnet wants to merge 3 commits into
mainfrom
research/nightly/2026-05-13-ivf-pq-hakes
Draft

research(nightly): IVF-PQ with HAKES filter-refine (ADR-194)#461
ruvnet wants to merge 3 commits into
mainfrom
research/nightly/2026-05-13-ivf-pq-hakes

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented May 13, 2026

Summary

  • Adds crates/ruvector-ivfpq — ruvector's first compression-based ANN index (IVF-PQ with HAKES filter-refine architecture), closing the gap noted in ADR-193.
  • Adds docs/adr/ADR-194-ivf-pq-hakes.md recording the design decision.
  • Adds docs/research/nightly/2026-05-13-ivf-pq-hakes/README.md with full SOTA survey and real benchmark results.

What's inside

crates/ruvector-ivfpq — standalone Rust crate (depends only on rand = "0.8"):

  • kmeans.rs — k-means++ (120 lines, includes usize::MAX assignment init fix)
  • pq.rsPqCodebook + LookupTable ADC (130 lines)
  • ivfpq.rsIvfPqIndex with two-phase residual training, 3-stage HAKES search (220 lines)
  • benches/ivfpq_bench.rs — Criterion: search_nprobe × m × train

Search pipeline:

Stage 1: coarse centroid scan → nprobe nearest IVF cells
Stage 2: per-cell ADC filter  → top-rerank_k by PQ-approximate L2
Stage 3: exact-L2 refine      → top-k from raw stored vectors

Benchmark results (Intel Celeron N4020, N=10K, D=128, K=10)

Variant Recall@10 QPS Compressed mem
nprobe=1, rerank_k=50 34.7% 26,429 238 KB
nprobe=4, rerank_k=200 94.7% 9,481 238 KB
nprobe=16, rerank_k=500 100.0% 2,617 238 KB

Compression: 21.0× (238 KB codes vs 5,000 KB raw f32)

Criterion (100-query batches, single-thread):

  • nprobe=1: 2.39 ms → 41,841 QPS
  • nprobe=4: 8.09 ms → 12,361 QPS
  • nprobe=16: 32.66 ms → 3,063 QPS

Test plan

  • cargo build --release -p ruvector-ivfpq — green
  • cargo test -p ruvector-ivfpq — 10/10 pass
  • cargo bench -p ruvector-ivfpq — all criterion benchmarks complete
  • cargo run --release -p ruvector-ivfpq — real recall/QPS numbers captured

Gist

SEO-optimized overview: https://gist.github.com/ruvnet/75a4751ee9ddf463394f277e3cfe8b18

See docs/research/nightly/2026-05-13-ivf-pq-hakes/README.md and docs/adr/ADR-194-ivf-pq-hakes.md for full details.

claude added 3 commits May 13, 2026 07:44
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants