Repository navigation
[diskann-disk] Preserve virtual start point out-edges when writing the disk index - #1483
Open
Dongliang Wu (doliawu) wants to merge 4 commits into
Open
Dongliang Wu (doliawu) wants to merge 4 commits into
Dongliang Wu (doliawu) wants to merge 4 commits into
Conversation
Dongliang Wu (doliawu)
requested review from
a team
and
a balanced review from Copilot
October 14, 2026 23:03
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The singleton case needs a regression test that verifies successful layout creation and a serialized zero neighbor count.
1 open finding
What changed in this PR
Corrects disk-index writing’s debug assertion to allow a single-point graph with no neighbors.
Changes:
- Allows zero neighbors when
state.num_pts == 1, preserving the existing maximum-degree check.
| File | Description |
|---|---|
diskann-disk/src/storage/disk_index_writer.rs |
Adds the singleton exception to the neighbor-count assertion. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1483 +/- ##
==========================================
+ Coverage 90.93% 91.04% +0.10%
==========================================
Files 586 586
Lines 118318 120008 +1690
==========================================
+ Hits 107597 109262 +1665
- Misses 10721 10746 +25
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
num_nbrs assertion in DiskIndexWriter::read_neighborsnum_nbrs assertion in DiskIndexWriter::read_neighbors
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2c6b1e3-5f90-48bb-b41d-4123079c371c
The disk format folds the in-memory virtual start point into the medoid, but DiskAdaptor only kept the medoid's own adjacency list and dropped the virtual start point's out-edges. If the medoid only linked to the virtual start point, the serialized start node had no out-edges, so disk search could not reach any other point (and debug builds hit the num_nbrs > 0 assertion). Merge the virtual start point's out-edges into the medoid's list, with the inherited edges first and capped at the longer of the two in-memory lists. Regenerate the R4/L50 build truth fixture (only the medoid's list changes) and give the associated-data search test its own truth results, since the shared truth file belongs to a prebuilt index. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2c6b1e3-5f90-48bb-b41d-4123079c371c
num_nbrs assertion in DiskIndexWriter::read_neighbors
Aditya Krishnan (arkrishn94)
approved these changes
Oct 16, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2c6b1e3-5f90-48bb-b41d-4123079c371c
This branch has not been deployed
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.

Reference Issues/PRs
Follow-up to #1350.
What does this implement/fix? Briefly explain your changes.
The disk build uses the in-memory index, which keeps a virtual start point
V(a copy of the medoid's vector) as its search entry point. When the graph is serialized to the disk format,Vis folded into the medoidM, butDiskAdaptorkept onlyM's own adjacency list and droppedV's out-edges.VandMshare a vector but build their adjacency lists independently, soV's edges (the ones in-memory search expands first) were lost.In the worst case,
M's in-memory list is just[V](e.g. small graphs with concurrent inserts). Before #1350 this became a useless[M]self-loop; since #1350 it becomes empty. Either way, disk search, which starts only at the medoid, cannot reach any other point. Debug builds hitdebug_assert!(num_nbrs > 0)inDiskIndexWriter::read_neighbors.Changes:
DiskAdaptornow mergesV's out-edges intoM's disk adjacency list: inherited edges first, thenM's own, remapped, deduplicated, without self-loops, and capped at the longer of the two in-memory lists so the serialized max degree does not grow.DiskIndexWriter::read_neighborsallowsnum_nbrs == 0for a 1-point graph, where an empty list is valid.[V]-only medoid case and the cap, and a disk layout test for a 1-point graph (fails with the old assertion).truth_sift_learn_R4_L50_disk.index; only the medoid's list changes ([118, 108, 86]->[7, 2, 10, 118]). The associated-data search test now has its own truth results, because the shared truth file belongs to the prebuilt search index, which does not match current builds.Any other comments?
Search quality is unchanged. Recall@10 on the 256-point R4/L50 index, using all 256 data points as queries:
Individual results shift because the medoid's first-hop edges changed (27 of 256 queries at L=20, 3 at L=50), but gains and losses roughly cancel.
Keeping
Vas a real node in the disk index would preserve the in-memory graph exactly, but needs a format and search change; that could be a follow-up.Validation:
cargo test -p diskann-providers -p diskann-disk: passedcargo fmt --all --check: passedcargo clippy --workspace --all-targets -- -D warnings: passed