[codex] feat: add RankQuant eval scorer#97
Conversation
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request introduces rankquant_eval_search, a standalone, eval-only symmetric RankQuant-style search function supporting arbitrary bit widths (1 to 7) without altering the packed storage format. This is implemented in Rust and exposed to Python via PyO3, accompanied by comprehensive unit and integration tests. The review feedback suggests two valuable performance and safety improvements in src/quant.rs: adding an early return when there are no queries (nq == 0) to prevent redundant corpus processing, and replacing manual slicing with chunks_exact(dim) to make the code more idiomatic and potentially allow better compiler optimizations.
Review Summary by QodoAdd RankQuant eval scorer for arbitrary bit widths
WalkthroughsDescription• Add standalone rankquant_eval_search function supporting arbitrary bit widths (1-7) • Enable eval-only symmetric RankQuant scoring without persistent storage changes • Support non-byte-aligned widths like bits=3 for research and evaluation sweeps • Maintain backward compatibility with existing RankQuant storage and .tvrq format Diagramflowchart LR
corpus["corpus vectors"] --> rankquant_eval_search["rankquant_eval_search<br/>bits in 1..=7"]
queries["query vectors"] --> rankquant_eval_search
rankquant_eval_search --> rank_transform["rank_transform"]
rank_transform --> bucket_centre["bucket_centre<br/>& normalize"]
bucket_centre --> topk["top-k scoring"]
topk --> scores["scores array"]
topk --> indices["indices array"]
File Changes1. src/quant.rs
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
Adds an eval-only RankQuant scorer for arbitrary bit widths, enabling symmetric RankQuant-style top-k search for research sweeps including non-packed widths like bits=3 while preserving the existing packed RankQuant storage contract.
Changes:
- Adds Rust
rankquant_eval_searchwith arbitrarybits in 1..=7. - Exposes the scorer through the Python package API.
- Adds Rust and Python parity tests against packed
RankQuant.searchand scalar/NumPy references.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/quant.rs |
Implements eval-only symmetric RankQuant scoring. |
src/lib.rs |
Re-exports the new Rust scorer. |
ordvec-python/src/lib.rs |
Adds Python binding and validation for the scorer. |
ordvec-python/python/ordvec/__init__.py |
Exposes rankquant_eval_search in the Python public API. |
tests/index/quant.rs |
Adds Rust parity and b=3 reference tests. |
ordvec-python/tests/test_rank_quant.py |
Adds Python API, parity, invalid-bits, and empty-corpus tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
|
Bot review disposition after follow-up fixes:
Validation run locally:
|
Summary
rankquant_eval_search(corpus, queries, dim, bits, k)in Rust for symmetric RankQuant-style top-k scoring at arbitrary eval widthsbits in 1..=7rankquant_eval_search(corpus, queries, bits, k)returning(scores, indices)arrays likeRankQuant.searchRankQuant::new, packed storage, and.tvrqload/write contracts unchanged; b=3 remains unsupported for persistent packed indexesRankQuant.search, and b=3 parity against scalar/NumPy referencesCloses #71.
Validation
cargo fmt --all --checkcargo test -p ordvec rankquant_eval_searchcargo clippy --all-targets --all-features -- -D warningscargo test --all-featuresmaturin develop./.venv/bin/python -m pytest tests/test_rank_quant.py -q./.venv/bin/python -m pytest tests -q