Skip to content

Commit

Permalink
Nightly failure fix - ignore searched vectors with identical distances (
Browse files Browse the repository at this point in the history
facebookresearch#3809)

Summary:
Pull Request resolved: facebookresearch#3809

test_IndexIVFRQ is failing nightly GPU w/RAFT builds. These are false positive failures for the edge cases when the distance of a query vector to two candidate vectors is identical. In such cases, the search and search_and_reconstruct return these candidate vectors in a different order (on GPU w/Raft).

Current fix is to ignore the order of such ids with identical distances by sorting on distance and use id as tiebreaker. There is negligible performance implication (5ms extra), given the test candidate size is low.

Reviewed By: mengdilin, ramilbakhshyiev

Differential Revision: D61977915

fbshipit-source-id: 5f7a81c51c91a967013fb5e69e2bfee59be341c7
  • Loading branch information
pankajsingh88 authored and facebook-github-bot committed Aug 29, 2024
1 parent 97e6f48 commit 95e0a66
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import warnings

from common_faiss_tests import get_dataset, get_dataset_2
from faiss.contrib.evaluation import check_ref_knn_with_draws

class TestModuleInterface(unittest.TestCase):

Expand Down Expand Up @@ -422,7 +423,7 @@ def run_search_and_reconstruct(self, index, xb, xq, k=10, eps=None):
D, I, R = index.search_and_reconstruct(xq, k)

np.testing.assert_almost_equal(D, D_ref, decimal=5)
self.assertTrue((I == I_ref).all())
check_ref_knn_with_draws(D_ref, I_ref, D, I)
self.assertEqual(R.shape[:2], I.shape)
self.assertEqual(R.shape[2], d)

Expand Down

0 comments on commit 95e0a66

Please sign in to comment.