Skip to content

[dev][VectorSets] Update diskann-garnet and wire up metric types (#1688)#1692

Merged
vazois merged 1 commit into
devfrom
tiagonapoli/cherry-pick-diskann-update-to-dev
Apr 11, 2026
Merged

[dev][VectorSets] Update diskann-garnet and wire up metric types (#1688)#1692
vazois merged 1 commit into
devfrom
tiagonapoli/cherry-pick-diskann-update-to-dev

Conversation

@tiagonapoli

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings April 10, 2026 21:10

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

Updates Garnet’s DiskANN integration to support distance metric selection end-to-end, along with synthetic recall tests to validate expected nearest-neighbor behavior after updating the diskann-garnet dependency.

Changes:

  • Bump diskann-garnet NuGet to 1.0.26 and add an explicit reference in the test project.
  • Wire VectorDistanceMetricType into the native create_index P/Invoke and managed DiskANNService.CreateIndex call path.
  • Replace the old ignored grid test with new synthetic recall tests (grid for L2, circle for cosine).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Directory.Packages.props Updates central package version for diskann-garnet to 1.0.26.
libs/server/Resp/Vector/DiskANNService.cs Passes the distance metric into create_index; adds external-id validation P/Invoke surface.
test/Garnet.test/Garnet.test.csproj Adds diskann-garnet package reference for test runtime/assets availability.
test/Garnet.test/DiskANN/DiskANNSyntheticRecallTests.cs Adds new synthetic recall tests for grid (L2) and circle (cosine) datasets.
test/Garnet.test/DiskANN/DiskANNServiceTests.cs Updates native create_index callsites to include the new metricType parameter.
test/Garnet.test/DiskANN/DiskANNGridTests.cs Removes the old ignored grid search test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/server/Resp/Vector/DiskANNService.cs
Comment thread test/Garnet.test/DiskANN/DiskANNServiceTests.cs
Comment thread test/Garnet.test/DiskANN/DiskANNServiceTests.cs
Comment thread test/Garnet.test/DiskANN/DiskANNServiceTests.cs
@tiagonapoli tiagonapoli force-pushed the tiagonapoli/cherry-pick-diskann-update-to-dev branch from c280773 to 35c0271 Compare April 10, 2026 23:59
* update diskann garnet

Signed-off-by: Tiago Napoli <tiagonapoli@microsoft.com>

* Unify BruteForceNearestNeighbors and CountPerDistance into generic methods

Replace 4 type-specific methods (BruteForceNearestNeighbors_FP32,
BruteForceNearestNeighbors_XB8, CountPerDistance_FP32, CountPerDistance_XB8)
with 2 generic methods that accept Func delegates for ID extraction and
distance computation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Refactor recall tests: unify entry types and extract generic RunRecallTest

- Replace FP32VectorEntry and XB8VectorEntry with generic VectorEntry<TVec>
- Extract common recall loop into RunRecallTest<TEntry> with lambdas for
  distance, distance-key conversion, and VSIM querying
- RunRecallTest_FP32 and RunRecallTest_XB8 become thin wrappers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix formatting: remove trailing newline

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Merge RunRecallTest_FP32 and RunRecallTest_XB8 into single generic RunRecallTest<TVec>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Simplify CountPerDistance to take targetVector + otherVectors directly

Instead of filtering entries by ID set internally, CountPerDistance now
receives the target vector and an enumerable of neighbor vectors, plus
the distance and bucketing functions. Callers filter with LINQ.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Return vectors instead of IDs from BruteForce and VsimQuery mapping

BruteForceNearestNeighbors now takes targetVector + candidates and
returns List<TVec> directly. VsimQuery IDs are mapped to vectors via
idToVector dictionary. Both flow as vector lists into CountPerDistance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove toDistanceKey parameter; hardcode Round(d*100) bucketing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Signed-off-by: Tiago Napoli <tiagonapoli@microsoft.com>
Co-authored-by: Tiago Napoli <tiagonapoli@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tiagonapoli tiagonapoli force-pushed the tiagonapoli/cherry-pick-diskann-update-to-dev branch from 35c0271 to 9992e27 Compare April 11, 2026 00:11
@vazois vazois merged commit 7b7d6b1 into dev Apr 11, 2026
22 of 23 checks passed
@vazois vazois deleted the tiagonapoli/cherry-pick-diskann-update-to-dev branch April 11, 2026 01:51
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.

3 participants