Skip to content

Commit 95e0a66

Browse files
pankajsingh88facebook-github-bot
authored andcommitted
Nightly failure fix - ignore searched vectors with identical distances (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
1 parent 97e6f48 commit 95e0a66

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/test_index.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import warnings
1717

1818
from common_faiss_tests import get_dataset, get_dataset_2
19+
from faiss.contrib.evaluation import check_ref_knn_with_draws
1920

2021
class TestModuleInterface(unittest.TestCase):
2122

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

424425
np.testing.assert_almost_equal(D, D_ref, decimal=5)
425-
self.assertTrue((I == I_ref).all())
426+
check_ref_knn_with_draws(D_ref, I_ref, D, I)
426427
self.assertEqual(R.shape[:2], I.shape)
427428
self.assertEqual(R.shape[2], d)
428429

0 commit comments

Comments
 (0)