From 4eee3d7859d4872dc30172092e3ff2a7b919df99 Mon Sep 17 00:00:00 2001 From: Michael Norris Date: Wed, 6 May 2026 23:11:37 -0700 Subject: [PATCH] Add tolerance and assertion log to test_OIVFPQ (#5188) Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5188 It breaks on unrelated tests, see https://github.com/facebookresearch/faiss/actions/runs/25464950049/job/74717916355?pr=5167 I tried it locally and differences usually favor OPQ by 0.007 at nq=100. So it could easily cross to favor non-OPQ. This adds threshold so now it has to win by additional 0.005. Should be enough to catch OPQ regressions and still prevent flakiness. Reviewed By: junjieqi Differential Revision: D104144105 fbshipit-source-id: 3223022f9c3a0c2dbeb67445b6083769e9f73e60 --- tests/test_index_accuracy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_index_accuracy.py b/tests/test_index_accuracy.py index 21ce3d447..6507457f5 100644 --- a/tests/test_index_accuracy.py +++ b/tests/test_index_accuracy.py @@ -655,7 +655,10 @@ class OPQRelativeAccuracy(unittest.TestCase): # verify same on OIVFPQ for r in 1, 10, 100: - assert e_oivfpq[r] >= e_ivfpq[r] + assert e_oivfpq[r] >= e_ivfpq[r] - 0.005, ( + f"recall@{r}: OPQ+IVFPQ ({e_oivfpq[r]:.4f}) " + f"< IVFPQ ({e_ivfpq[r]:.4f})" + ) class TestRoundoff(unittest.TestCase):