[BUG] Brute-force kNN can return nonzero distances for identical vectors

Aperta
#2,883 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp, github

Direzione di ricerca

Read PR #2841 and the existing brute-force kNN tests, including the Go test whose tolerance was adjusted there. Reproduce the float32 self-distance behavior with copied and sliced datasets, then trace the brute-force distance calculation and the existing pairwise-distance diagonal correction. Done means identical finite vectors return zero distance while distinct nearby vectors retain correct nonzero distances; add coverage for the reported input forms and metrics.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

#2841 removed a rule that forced small distances to zero when two vectors had equal squared lengths. This addressed a real problem: distinct nearby vectors could incorrectly receive zero distance, affecting neighbor ordering and clustering.

As discussed in the PR, removing that rule also exposes underlying rounding errors when comparing a vector with itself. Negative errors are still clamped to zero, while positive errors remain. Taking the square root makes these errors more visible with the Euclidean metric. The PR documents this tradeoff and adjusts the Go brute-force test tolerance accordingly.

Observed behavior :
In a float32 test with 800 vectors of 32 dimensions, searching an independently allocated copy of the dataset returned nonzero self-distances for 256 vectors:

  • Maximum squared Euclidean self-distance: approximately 0.000732.
  • Maximum Euclidean self-distance: approximately 0.0271.

This occurred with both k=8 and k=65. The correct self-neighbor IDs were returned. Similar behavior occurs with dataset slices, column-major inputs, and filtered searches.

Expected behavior :
Identical finite vectors should have zero distance, including when queries are copies or slices of the dataset.
Could we preserve this behavior while retaining the improvements from #2841? This would complement the diagonal correction already added for certain pairwise-distance calls, extending support to brute-force kNN.

Lingua principale
Cuda
Stelle
902
Fork
267
Merge medio
2g 21h
PR unite (30g)
57

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/cuvs

Tutte le issue di NVIDIA/cuvs

Issue simili

Altre issue su Machine Learning

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.