The additive quantizers need to carry around the norms of the vectors to compute L2 distances, or they can be computed.
The storage options work but the ST_norm_from_LUT is not implemented (it is described in eq (16) of the Faiss paper).
the symptom is a crash because the interpreter does not propagate the exception correctly.
import faiss
from faiss.contrib.datasets import SyntheticDataset
ds = SyntheticDataset(20, 1000, 100, 100)
index = faiss.index_factory(ds.d, "RQ2x4")
index.rq.search_type = faiss.AdditiveQuantizer.ST_norm_from_LUT
index.train(ds.get_train())
index.add(ds.get_database())
faiss.omp_set_num_threads(1) # otherwise crashes the interpreter
index.search(ds.get_queries(), 10)
result:
RuntimeError: Error in virtual void faiss::IndexAdditiveQuantizer::search(faiss::idx_t, const float*, faiss::idx_t, float*, faiss::idx_t*, const faiss::SearchParameters*) const at [/home/circleci/miniconda/conda-bld/faiss-pkg_1709244517602/work/faiss/IndexAdditiveQuantizer.cpp:284](http://localhost:8921/home/circleci/miniconda/conda-bld/faiss-pkg_1709244517602/work/faiss/IndexAdditiveQuantizer.cpp#line=283): search type 2 not supported
Summary
The additive quantizers need to carry around the norms of the vectors to compute L2 distances, or they can be computed. The storage options work but the
ST_norm_from_LUT
is not implemented (it is described in eq (16) of the Faiss paper). the symptom is a crash because the interpreter does not propagate the exception correctly.result: