Skip to content

research: RVQ compressed ANN — nightly study 2026-07-28 - #742

Draft
ruvnet wants to merge 3 commits into
mainfrom
research/nightly/2026-07-28-rvq-compressed-ann
Draft

research: RVQ compressed ANN — nightly study 2026-07-28#742
ruvnet wants to merge 3 commits into
mainfrom
research/nightly/2026-07-28-rvq-compressed-ann

Conversation

@ruvnet

@ruvnet ruvnet commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements ruvector-rvq, a zero-dependency Rust crate providing Residual Vector Quantization (RVQ) and Product Quantization (PQ) as compressed approximate nearest-neighbour indices with ADC (Asymmetric Distance Computation) query-time lookup.
  • Adds ADR-273 documenting the architecture decision to adopt RVQ as a compressed index format, including tradeoffs vs OPQ, AQ/AQLM, RaBitQ+, and SQ8.
  • Adds nightly research README and SEO gist covering SOTA survey, 10–20 year thesis, real benchmark results, memory math, failure modes, and production roadmap.

What Changed

New crate: crates/ruvector-rvq

File Description
src/lib.rs VectorIndex trait, Hit struct, recall_at_k, dot, l2_sq, nearest_centroid, stat helpers
src/dataset.rs LCG PRNG, DatasetConfig, Dataset::generate() (L2-normalised Gaussian unit vectors)
src/kmeans.rs Lloyd's k-means with Fisher-Yates init; sentinel assignment prevents premature convergence
src/exact.rs Brute-force inner-product baseline (ExactSearch)
src/pq.rs PqIndex: M sub-spaces × K codewords, ADC search, memory accounting, unit tests
src/rvq.rs RvqIndex: S stages × K codewords residual encoding, reconstruct, reconstruction error, ADC search, unit tests
src/bin/benchmark.rs Benchmark binary: env-var tuning, 3 variants, acceptance checks, dimensionality sweep

New docs

  • docs/adr/ADR-273-rvq-compressed-ann.md
  • docs/research/nightly/2026-07-28-rvq-compressed-ann/README.md
  • docs/research/nightly/2026-07-28-rvq-compressed-ann/gist.md

Benchmark Results (measured)

N=5K, D=128, 4 sub-spaces/stages × 64 codewords, 8 k-means iters

Variant QPS Recall@10 Memory
Exact-f32 1,363 1.0000 2.44 MB
PQ-4sub-64cw 7,388 0.0490 0.05 MB
RVQ-4stage-64cw 6,311 0.0585 0.14 MB

RVQ recall is consistently ≥ PQ recall across D=32/64/128, with the gap widening at lower D. Reconstruction MSE decreases monotonically with stages (guaranteed by algorithm).

Test Plan

  • cargo build --release -p ruvector-rvq succeeds
  • cargo test -p ruvector-rvq — 13/13 tests pass
  • cargo run --release -p ruvector-rvq --bin benchmark — all acceptance checks [PASS]
  • cargo fmt -p ruvector-rvq applied

Generated by Claude Code

claude and others added 3 commits July 28, 2026 07:47
Implements Residual Vector Quantization (RVQ) and Product Quantization
(PQ) as compressed approximate nearest-neighbour indices in pure Rust
with zero external dependencies. ADC lookup tables give O(S×N) query
time vs O(D×N) for exact search.

Includes:
- VectorIndex trait + Hit struct + recall_at_k utility (lib.rs)
- LCG PRNG + unit-vector dataset generator (dataset.rs)
- Lloyd's k-means with Fisher-Yates init (kmeans.rs)
- ExactSearch brute-force inner-product baseline (exact.rs)
- PqIndex: M sub-spaces × K codewords ADC search (pq.rs)
- RvqIndex: S stages × K codewords residual encoding + ADC (rvq.rs)
- benchmark binary with env-var tuning + acceptance checks (bin/benchmark.rs)

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01KDumUj8CDoyXgvneENUjgu
Captures the architecture decision to adopt Residual Vector Quantization
as the compressed index format in ruvector-rvq. Documents context, tradeoffs,
alternatives considered (OPQ, AQ/AQLM, RaBitQ+, SQ8), and migration path.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01KDumUj8CDoyXgvneENUjgu
Research document covers SOTA survey (RaBitQ, AQLM, FaTRQ, Qinco2),
10-20 year thesis, ecosystem fit, design rationale, real benchmark
results, memory math, failure modes, MCP/edge implications,
8 practical and 8 exotic applications, and production roadmap.

Gist is a full SEO-optimised public technical article with algorithm
walkthrough, benchmark table, competitor comparison, optimization guide,
and deep research notes with paper references.

Real benchmark numbers (cargo run --release):
  Exact-f32  : 1,363 QPS, recall=1.0000, 2.44 MB
  PQ-4sub-64 : 7,388 QPS, recall=0.0490, 0.05 MB (build 237.6ms)
  RVQ-4s-64  : 6,311 QPS, recall=0.0585, 0.14 MB (build 1,370.6ms)

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01KDumUj8CDoyXgvneENUjgu
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