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
This commit is contained in:
Michelle Ma
2026-04-13 15:57:00 -07:00
committed by meta-codesync[bot]
parent 740d3a3965
commit f83ea51eaa
+21 -5
View File
@@ -591,11 +591,19 @@ struct IVFRaBitQFastScanScanner : InvertedListScanner {
std::unique_ptr<FlatCodesDistanceComputer> dc;
std::vector<float> 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<const IVFRaBitQSearchParameters*>(
search_params_in)) {
used_qb = params->qb;
used_centered = params->centered;
}
return new IVFRaBitQFastScanScanner(
*this, store_pairs, sel, used_qb, used_centered);
}
} // namespace faiss