Skip to content

Strengthen arguments to robust_prune. - #1358

Merged
Mark Hildebrand (hildebrandmw) merged 5 commits into
mainfrom
mhildebr/sorted-neighbors
Aug 31, 2026
Merged

Mark Hildebrand (hildebrandmw) merged 5 commits into
mainfrom
mhildebr/sorted-neighbors

Conversation

@hildebrandmw

Copy link
Copy Markdown
Contributor

Make the sorted_cache argument a SortedNeighbors instead to structurally require sortedness. This removes the Eq bound from SortedNeighbors, which is left over from #1273, and provides a helper map_in for projecting SortedNeighbors.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the graph::internal::prune::robust_prune API by requiring its candidate input to be a SortedNeighbors, making the sorted-by-distance invariant structural rather than a debug assertion. It also removes the lingering Eq bound from SortedNeighbors (left over from #1273) and introduces a SortedNeighbors::map_in helper to project a sorted neighbor list into another storage buffer while preserving sortedness.

Changes:

  • Change robust_prune to accept SortedNeighbors<'_, Option<V>> instead of a raw &[(f32, Option<V>)], removing the runtime sortedness assertion.
  • Refactor SortedNeighbors to drop the Eq bound and add map_in to project IDs into a separate, linearly accessible cache while preserving order.
  • Extend VerboseEq support in tests (notably for str and references).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
diskann/src/test/cmp.rs Adds VerboseEq impl for references and expands leaf VerboseEq coverage (incl. str).
diskann/src/graph/internal/sorted_neighbors.rs Drops Eq constraint, makes SortedNeighbors Copy/Clone, adds map_in, and adds tests for mapping behavior.
diskann/src/graph/internal/prune.rs Updates robust_prune to accept SortedNeighbors candidates and adapts indexing/lookup logic accordingly.
diskann/src/graph/index.rs Uses SortedNeighbors::map_in to build the prune candidate cache and updates the robust_prune call site.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread diskann/src/test/cmp.rs
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.55%. Comparing base (158126e) to head (cb09c2d).

Files with missing lines Patch % Lines
diskann/src/graph/internal/sorted_neighbors.rs 93.02% 3 Missing ⚠️
diskann/src/graph/internal/prune.rs 85.71% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1358      +/-   ##
==========================================
- Coverage   91.55%   91.55%   -0.01%     
==========================================
  Files         521      521              
  Lines      100371   100410      +39     
==========================================
+ Hits        91898    91927      +29     
- Misses       8473     8483      +10     
Flag Coverage Δ
miri 91.55% <93.33%> (-0.01%) ⬇️
unittests 91.23% <93.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann/src/graph/index.rs 96.47% <100.00%> (-0.02%) ⬇️
diskann/src/test/cmp.rs 98.37% <100.00%> (+0.02%) ⬆️
diskann/src/graph/internal/prune.rs 84.90% <85.71%> (-0.15%) ⬇️
diskann/src/graph/internal/sorted_neighbors.rs 96.47% <93.02%> (-3.53%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hildebrandmw
Mark Hildebrand (hildebrandmw) merged commit b25a8b6 into main Aug 31, 2026
31 checks passed
@hildebrandmw
Mark Hildebrand (hildebrandmw) deleted the mhildebr/sorted-neighbors branch August 31, 2026 21:17
MustafaIdrisArm pushed a commit to MustafaIdrisArm/DiskANN that referenced this pull request Sep 11, 2026
# Breaking Changes

Flat search visitors are now query-aware (microsoft#1359)
* `flat::FlatIndex`  has been removed. The search entry point is now the
free function `flat::knn_search`, and the `DistancesUnordered` visitor
is constructed per-query rather than reused. The `ElementRef`,
`QueryComputer`, and `QueryComputerError` associated types and the
visitor GAT have also been removed. `DistancesUnordered` now yields
`(id, distance)` pairs directly.

Migration: Callers of the old `FlatIndex`/visitor API should:

1. Drop `FlatIndex` and construct your `DistancesUnordered` visitor
directly for the query being searched.
2. Replace calls into the removed wrapper with `flat::knn_search(&mut
visitor, k, processor, query, &mut output)`.
3. Remove any `ElementRef`/`QueryComputer` implementation, fuse scanning
and distance computation directly in your
`DistancesUnordered::distances_unordered` implementation.

# All Changes

* Make `UnalignedSlice` Send and Sync. by @hildebrandmw in
microsoft#1348
* Bump actions/checkout from 4.4.0 to 7.0.1 in the github-actions group
by @dependabot[bot] in microsoft#1344
* Deduplicate virtual start point edges during disk serialization by
@partychen in microsoft#1350
* Fix alpha pruning documentation by @xinyuwen2 in
microsoft#1351
* Bump the github-actions group with 4 updates by @dependabot[bot] in
microsoft#1356
* Add Neon Inner product u4*u4 kernel by @pfoxARM in
microsoft#1353
* Strengthen arguments to `robust_prune`. by @hildebrandmw in
microsoft#1358
* Allow inspection of the paged search accessor. by @hildebrandmw in
microsoft#1364
* Make flat search visitors query-aware by @partychen in
microsoft#1359
* Add Neon inner-product kernel for USlice<2> with spherical wiring by
@pfoxARM in microsoft#1363

## New Contributors
* @pfoxARM made their first contribution in
microsoft#1353

**Full Changelog**:
microsoft/DiskANN@v0.56.0...v0.57.0

Co-authored-by: Mark Hildebrand <mhildebrand@microsoft.com>
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.

5 participants