mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Add IVFSQTurboQSearchParameters to __init__.pyi stub (#5304)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5304 Add IVFSQTurboQSearchParameters to the authoritative __init__.pyi type stub. TurboQuant was added to ScalarQuantizer in D102408184, which introduced IVFSQTurboQSearchParameters in IndexScalarQuantizer.h. The struct controls two new per-search parameters: - qb: query quantization bits for MSE pre-screening (0 = float path, 1-8 = integer popcount path) - int_qjl: use integer popcount for the QJL sign-bit stage (requires qb > 0) IndexScalarQuantizer.h is `%include`d in swigfaiss.swig so SWIG wraps the struct at runtime. However, __init__.pyi (the authoritative Pyre type source since D107274305) was not updated when the struct was added. Any Pyre-checked code that uses IVFSQTurboQSearchParameters receives [missing-attribute] errors. Pattern matches the approach used in D107508282, which added SearchParametersHNSW and SearchParametersPQ for the same gap. Reviewed By: limqiying, mnorris11 Differential Revision: D108001955 fbshipit-source-id: 6cfbb0dddea1e09562b8185888c571aea229b747
This commit is contained in:
committed by
meta-codesync[bot]
parent
262fc3c7a2
commit
261d8f25aa
@@ -2290,6 +2290,12 @@ class IVFSearchParameters(SearchParameters):
|
||||
sel: IDSelector | None
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class IVFSQTurboQSearchParameters(IVFSearchParameters):
|
||||
qb: int
|
||||
int_qjl: bool
|
||||
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
# IVF Statistics tracking
|
||||
class IndexIVFStats:
|
||||
nq: int # number of queries run
|
||||
|
||||
@@ -146,6 +146,14 @@ class TestSWIGWrap(unittest.TestCase):
|
||||
with self.assertRaises(AttributeError):
|
||||
index.centered2 = False
|
||||
|
||||
def test_ivfsq_turboq_search_parameters(self):
|
||||
params = faiss.IVFSQTurboQSearchParameters()
|
||||
self.assertEqual(params.qb, 0)
|
||||
self.assertFalse(params.int_qjl)
|
||||
params.qb = 4
|
||||
params.int_qjl = True
|
||||
self.assertEqual(params.qb, 4)
|
||||
self.assertTrue(params.int_qjl)
|
||||
|
||||
|
||||
class TestRevSwigPtr(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user