From f2a9324359ac6ee3bdfd4282be0e1cffeeb81c4a Mon Sep 17 00:00:00 2001 From: Matthijs Douze Date: Mon, 25 Jul 2022 06:58:39 -0700 Subject: [PATCH] make tests cheaper Summary: Many of the additive quantizer tests are recognized as flaky because the tests timeout in non-optimized stress mode. This is probably because they don't import https://www.internalfb.com/code/fbsource/fbcode/faiss/tests/common_faiss_tests.py that sets the number of threads to 4. This diff fixes that and in addition declares the tests as "heavyweight" so that not too many of them are spawned in parallel in stress mode. https://www.internalfb.com/intern/wiki/TAE/tpx/Timeouts_and_Sharded_Bundled_mode/#degree-of-parallelism Hopefully it should fix the flaky tests Reviewed By: alexanderguzhva Differential Revision: D38111820 fbshipit-source-id: 7dd7c72e7e92b82384a170743cfd5c4aaf9a6960 --- tests/test_fast_scan.py | 2 ++ tests/test_fast_scan_ivf.py | 2 ++ tests/test_local_search_quantizer.py | 1 + tests/test_residual_quantizer.py | 1 + 4 files changed, 6 insertions(+) diff --git a/tests/test_fast_scan.py b/tests/test_fast_scan.py index 6069c8931..9a58084c1 100644 --- a/tests/test_fast_scan.py +++ b/tests/test_fast_scan.py @@ -14,6 +14,8 @@ import faiss from faiss.contrib import datasets +# the tests tend to timeout in stress modes + dev otherwise +faiss.omp_set_num_threads(4) class TestCompileOptions(unittest.TestCase): diff --git a/tests/test_fast_scan_ivf.py b/tests/test_fast_scan_ivf.py index 81bd01c01..a7cfce28e 100644 --- a/tests/test_fast_scan_ivf.py +++ b/tests/test_fast_scan_ivf.py @@ -14,6 +14,8 @@ import faiss from faiss.contrib import datasets from faiss.contrib.inspect_tools import get_invlist +# the tests tend to timeout in stress modes + dev otherwise +faiss.omp_set_num_threads(4) class TestLUTQuantization(unittest.TestCase): diff --git a/tests/test_local_search_quantizer.py b/tests/test_local_search_quantizer.py index a80abe889..43974ec01 100644 --- a/tests/test_local_search_quantizer.py +++ b/tests/test_local_search_quantizer.py @@ -14,6 +14,7 @@ import unittest from faiss.contrib import datasets +faiss.omp_set_num_threads(4) sp = faiss.swig_ptr diff --git a/tests/test_residual_quantizer.py b/tests/test_residual_quantizer.py index 641cf501b..4702f7993 100644 --- a/tests/test_residual_quantizer.py +++ b/tests/test_residual_quantizer.py @@ -15,6 +15,7 @@ from faiss.contrib.inspect_tools import get_additive_quantizer_codebooks # Reference implementation of encoding with beam search ########################################################### +faiss.omp_set_num_threads(4) def pairwise_distances(a, b): anorms = (a ** 2).sum(1)