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
This commit is contained in:
Michael Norris
2026-05-06 23:11:37 -07:00
committed by meta-codesync[bot]
parent 2322afd2d8
commit 4eee3d7859
+4 -1
View File
@@ -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):