Clean up range search#1253
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens DiskANN’s range search behavior around the max_results / max_returned parameter by (a) validating it against the initial search list size and (b) enforcing the cap when deciding whether to enter, and while executing, the second-round range expansion. It also adds golden-style tests intended to ensure the cap is respected.
Changes:
- Add validation that
max_returned >= starting_l, plus newRangeSearchErrorvariant. - Prevent entering the second-round range search when
max_returnedis already reached after the initial phase. - Terminate second-round expansion once
max_returnedis reached; add two new generated-range-search test cases.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| diskann/src/graph/search/range_search.rs | Enforces max_returned constraints and early-stops/avoids second-round expansion when the cap is reached. |
| diskann/src/graph/test/cases/range_search.rs | Adds two range-search regression tests intended to validate max_results behavior and second-round triggering. |
| diskann/test/generated/graph/test/cases/range_search/max_results_respected_means_no_second_round.json | New golden output for the “no second round” max-results test. |
| diskann/test/generated/graph/test/cases/range_search/max_results_respected_and_second_round_triggered.json | New golden output for the “second round triggered” max-results test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1253 +/- ##
========================================
Coverage 90.15% 90.16%
========================================
Files 509 509
Lines 97079 97191 +112
========================================
+ Hits 87521 87628 +107
- Misses 9558 9563 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
While working on microsoft#1228, I noticed that there were some issues with our current implementation of range search and its testing. The main issue with testing is that there were no tests ensuring the `max_results` parameter was respected. I have added two tests that ensure this now. The main code had several issues with how `max_results` was handled: 1. The `max_results` parameter was allowed to be less than the initial L_search. This is a conceptual issue because the user expects `max_results` to stop the search from continuing for too long, and the compute used in the initial search will always be controlled by `initial_search_l`. 2. A `max_results` check was not enforced before deciding to continue to the second round search. This meant that if the max results was reached via the initial search, it might not be respected. 3. The second round search was not terminated when `max_results` was reached, meaning it would continue to perform unnecessary work. This PR fixes these issues by adding additional checks of `max_results` at the correct points in the code. --------- Co-authored-by: Magdalen Manohar <mmanohar@microsoft.com>
While working on #1228, I noticed that there were some issues with our current implementation of range search and its testing.
The main issue with testing is that there were no tests ensuring the
max_resultsparameter was respected. I have added two tests that ensure this now.The main code had several issues with how
max_resultswas handled:max_resultsparameter was allowed to be less than the initial L_search. This is a conceptual issue because the user expectsmax_resultsto stop the search from continuing for too long, and the compute used in the initial search will always be controlled byinitial_search_l.max_resultscheck was not enforced before deciding to continue to the second round search. This meant that if the max results was reached via the initial search, it might not be respected.max_resultswas reached, meaning it would continue to perform unnecessary work.This PR fixes these issues by adding additional checks of
max_resultsat the correct points in the code.