From f83ea51eaa60987315fcd2deca153924abd7995d Mon Sep 17 00:00:00 2001 From: Michelle Ma Date: Mon, 13 Apr 2026 15:57:00 -0700 Subject: [PATCH] Support IVFRaBitQSearchParameters in RaBitQFastScan scanner (#5081) Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5081 Pass qb and centered from IVFRaBitQSearchParameters to the IVFRaBitQFastScanScanner, matching the behavior of IndexIVFRaBitQ's get_InvertedListScanner. Previously the scanner always used index.qb/index.centered, ignoring search params. Reviewed By: alibeklfc Differential Revision: D100399519 fbshipit-source-id: 9eaaee4fdd25f4b1a54d2a46a27e71076e182a71 --- faiss/IndexIVFRaBitQFastScan.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/faiss/IndexIVFRaBitQFastScan.cpp b/faiss/IndexIVFRaBitQFastScan.cpp index 676978f2e..113a03467 100644 --- a/faiss/IndexIVFRaBitQFastScan.cpp +++ b/faiss/IndexIVFRaBitQFastScan.cpp @@ -591,11 +591,19 @@ struct IVFRaBitQFastScanScanner : InvertedListScanner { std::unique_ptr dc; std::vector centroid; + uint8_t qb; + bool centered; + IVFRaBitQFastScanScanner( const IndexIVFRaBitQFastScan& index_in, bool store_pairs_in, - const IDSelector* sel_in) - : InvertedListScanner(store_pairs_in, sel_in), index(index_in) { + const IDSelector* sel_in, + uint8_t qb_in, + bool centered_in) + : InvertedListScanner(store_pairs_in, sel_in), + index(index_in), + qb(qb_in), + centered(centered_in) { this->keep_max = is_similarity_metric(index_in.metric_type); } @@ -624,7 +632,7 @@ struct IVFRaBitQFastScanScanner : InvertedListScanner { centroid.resize(index.d); index.quantizer->reconstruct(list_no, centroid.data()); dc.reset(index.rabitq.get_distance_computer( - index.qb, centroid.data(), index.centered)); + qb, centroid.data(), centered)); dc->set_query(xi); } @@ -715,8 +723,16 @@ struct IVFRaBitQFastScanScanner : InvertedListScanner { InvertedListScanner* IndexIVFRaBitQFastScan::get_InvertedListScanner( bool store_pairs, const IDSelector* sel, - const IVFSearchParameters*) const { - return new IVFRaBitQFastScanScanner(*this, store_pairs, sel); + const IVFSearchParameters* search_params_in) const { + uint8_t used_qb = qb; + bool used_centered = centered; + if (auto params = dynamic_cast( + search_params_in)) { + used_qb = params->qb; + used_centered = params->centered; + } + return new IVFRaBitQFastScanScanner( + *this, store_pairs, sel, used_qb, used_centered); } } // namespace faiss