Migrate disk PQ flat scan to flat API - #1341
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
a802e20 to
4d78a62
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates the disk PQ “flat scan” path onto the shared diskann::flat API, introducing a dedicated disk PQ FlatSearchStrategy + visitor that scans PQ-compressed rows and then reuses the existing full-precision reranking + filtering pipeline. It also factors PQ query preprocessing into a reusable owned query-computer (TransposedQueryComputer) so both graph and flat PQ search can share the same preprocessing approach.
Changes:
- Update
FlatIndex::knn_searchto return a lifetime-boundSendFutureso it can borrow strategy/context/output across.await. - Add
TransposedQueryComputer(+ error type) to build per-query PQ lookup tables for transposed PQ tables. - Route disk flat scan through
FlatIndexusing a new disk-specific flat strategy/visitor, and remove now-unused PQ scratch batching API.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| diskann/src/flat/index.rs | Adjusts knn_search signature/lifetimes to support borrowed-provider flat search entrypoints. |
| diskann-quantization/src/product/tables/transposed/query.rs | Introduces an owned PQ query computer for transposed tables (L2/IP), with unit tests. |
| diskann-quantization/src/product/tables/transposed/mod.rs | Wires the new transposed query module into the transposed table submodule exports. |
| diskann-quantization/src/product/tables/mod.rs | Re-exports the new transposed query computer + error at the tables module boundary. |
| diskann-quantization/src/product/mod.rs | Re-exports the new transposed query types at the product module boundary. |
| diskann-disk/src/search/provider/disk_provider.rs | Implements disk PQ flat scan via diskann::flat (DiskFlatProvider/DiskFlatSearchStrategy/DiskFlatVisitor) while preserving scan-time filtering and rerank behavior. |
| diskann-disk/src/search/pq/pq_scratch.rs | Removes PQScratch::max_vectors and updates tests accordingly (no longer needed after migration). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Aditya Krishnan (@arkrishn94) I ended up making a few design changes beyond the
One related detail: filtering happens in These were the main areas where the migration required broader architectural choices, so feedback on them would be helpful before finalizing the approach. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1341 +/- ##
==========================================
- Coverage 91.56% 91.54% -0.02%
==========================================
Files 521 521
Lines 99527 99872 +345
==========================================
+ Hits 91132 91431 +299
- Misses 8395 8441 +46
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
FlatVisitorwith batchedDistancesUnorderedscanningPQQueryComputerbetween graph and flat PQ search preprocessingValidation
Closes #1104