research(nightly): Residual Vector Quantization for compact agent memory (5.2× over PQ)#653
Draft
ruvnet wants to merge 3 commits into
Draft
research(nightly): Residual Vector Quantization for compact agent memory (5.2× over PQ)#653ruvnet wants to merge 3 commits into
ruvnet wants to merge 3 commits into
Conversation
2026-07-09 nightly: Residual Vector Quantization for compact agent memory. Survey covers 2026 SOTA (EnCodec, FAISS-RVQ, ScaNN, RaBitQ), 10-20 year thesis on hierarchical RVQ with learned residuals, and RuVector ecosystem fit. Includes real benchmark numbers from cargo run --release. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01AQYp452uYmTnfGVvDwe379
Implements three VectorQuantizer variants in pure Rust: - ScalarQuantizer (8-bit per dim, 4× compression baseline) - ProductQuantizer (M sub-spaces × K centroids, 32× at M=4) - ResidualQuantizer (L sequential full-D stages on residuals, 32× at L=4) Benchmark: clustered semantic data (100 clusters, σ=3.0) at equal 4-byte budget shows RVQ achieves MSQE=0.497 vs PQ MSQE=2.569 — 5.2× improvement. Acceptance test: PASS. 6/6 unit tests pass. No unsafe code. Dependencies: rand + rand_distr (workspace). Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01AQYp452uYmTnfGVvDwe379
Architecture Decision Record proposing ruvector-rvq as the compression primitive for RuVector's agent memory layer. Documents context, decision, measured consequences, and alternatives (AQ, neural VQ-VAE, RaBitQ). Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01AQYp452uYmTnfGVvDwe379
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
Nightly research branch (2026-07-09) implementing Residual Vector Quantization (RVQ) as a compression primitive for RuVector's agent memory layer.
crates/ruvector-rvq— a pure-Rust implementation of threeVectorQuantizervariants:ScalarQuantizer,ProductQuantizer,ResidualQuantizerdocs/research/nightly/2026-07-09-rvq-agent-memory/README.md— full research survey with 2026 SOTA, 10–20 year thesis, ecosystem fit, architecture diagram, and measured numbersdocs/adr/ADR-272-rvq-agent-memory.md— architecture decision record proposing RVQ for the RVM write pathdocs/research/nightly/2026-07-09-rvq-agent-memory/gist.md— SEO-optimized public gistKey Result
On clustered semantic data (100 clusters, σ=3.0, modeling real LLM embeddings) at equal 4 bytes/vector byte budget:
RVQ: 5.2× lower MSQE than PQ at the same 4-byte/vector storage cost. Acceptance test: PASS ✓
On isotropic Gaussian data (Suite 1), RVQ and PQ perform within 5% of each other — no regression on non-clustered data.
Why It Matters
LLM embeddings cluster around semantic concepts. Product Quantization assumes independent sub-dimensions — an assumption that breaks on clustered data. RVQ's sequential residual stages capture cross-dimension cluster structure PQ can't see, at identical storage cost.
At production scale (1M vectors, D=1536): RVQ compresses 6 GB of raw embeddings to 4 MB (1,500×), enabling lifetime-scale persistent agent memory without dedicated hardware.
What Changed
Test Plan
cargo test -p ruvector-rvq— 6 tests passcargo run --release -p ruvector-rvq --bin benchmark— BENCHMARK RESULT: PASSGenerated by Claude Code