Wire RaBitQ search through FastScanCodeScanner dispatch#4903
Open
algoriddle wants to merge 2 commits intofacebookresearch:mainfrom
Open
Wire RaBitQ search through FastScanCodeScanner dispatch#4903algoriddle wants to merge 2 commits intofacebookresearch:mainfrom
algoriddle wants to merge 2 commits intofacebookresearch:mainfrom
Conversation
algoriddle
added a commit
to algoriddle/faiss
that referenced
this pull request
Mar 11, 2026
…arch#4903) Summary: Add make_knn_scanner() virtual to IndexFastScan and IndexIVFFastScan that returns a SIMD-dispatched FastScanCodeScanner. Override in RaBitQ classes to produce rabitq-specific scanners via per-SIMD TU factories (rabitq_dispatching.h). Move RaBitQ handler method bodies into headers, add context pointer, and update rabitq_result_handler.h for SL template param. Wire IVFRaBitQFastScanScanner::scan_codes to use the new scanner. Update build files and SWIG ignores. Callers (search_implem_12/14, search_dispatch_implem) are unchanged and still use make_knn_handler. Differential Revision: D96116557
957a351 to
ca6d277
Compare
algoriddle
added a commit
to algoriddle/faiss
that referenced
this pull request
Mar 11, 2026
…arch#4903) Summary: Pull Request resolved: facebookresearch#4903 Add make_knn_scanner() virtual to IndexFastScan and IndexIVFFastScan that returns a SIMD-dispatched FastScanCodeScanner. Override in RaBitQ classes to produce rabitq-specific scanners via per-SIMD TU factories (rabitq_dispatching.h). Move RaBitQ handler method bodies into headers, add context pointer, and update rabitq_result_handler.h for SL template param. Wire IVFRaBitQFastScanScanner::scan_codes to use the new scanner. Update build files and SWIG ignores. Callers (search_implem_12/14, search_dispatch_implem) are unchanged and still use make_knn_handler. Differential Revision: D96116557
ca6d277 to
8c097f1
Compare
Contributor
|
@algoriddle has exported this pull request. If you are a Meta employee, you can view the originating Diff in D96116557. |
algoriddle
added a commit
to algoriddle/faiss
that referenced
this pull request
Mar 11, 2026
…arch#4903) Summary: Add make_knn_scanner() virtual to IndexFastScan and IndexIVFFastScan that returns a SIMD-dispatched FastScanCodeScanner. Override in RaBitQ classes to produce rabitq-specific scanners via per-SIMD TU factories (rabitq_dispatching.h). Move RaBitQ handler method bodies into headers, add context pointer, and update rabitq_result_handler.h for SL template param. Wire IVFRaBitQFastScanScanner::scan_codes to use the new scanner. Update build files and SWIG ignores. Callers (search_implem_12/14, search_dispatch_implem) are unchanged and still use make_knn_handler. Differential Revision: D96116557
8c097f1 to
2d71c52
Compare
Summary: Add `FastScanCodeScanner`, a virtual base that bundles handler + kernel behind the SIMD dispatch boundary. In DD mode, `SINGLE_SIMD_LEVEL = NONE` so the existing fast scan code path uses emulated SIMD types. The new scanner provides per-SIMD translation units (AVX2, AVX512, ARM_NEON) compiled with the correct ISA flags, and a factory function (`make_fast_scan_knn_scanner`) that uses `DISPATCH_SIMDLevel` to select the right TU at runtime. This follows the proven `THE_LEVEL_TO_DISPATCH` pattern from the scalar quantizer per-SIMD TUs (`sq-dispatch.h`). Each per-SIMD TU includes `dispatching.h` which provides: - `ScannerMixIn<Handler>`: wraps a concrete handler and calls accumulation kernels (both search_1 multi-BB and QBS paths) - Factory specialization `make_fast_scan_scanner_impl<SL>()` with combinatorial dispatch over `is_max × with_id_map × handler_type` (SingleResultHandler for k=1, HeapHandler for k≤20, ReservoirHandler for k>20) New files: - `impl/fast_scan/dispatching.h` — dispatch template header - `impl/fast_scan/impl-avx2.cpp` — AVX2 per-SIMD TU - `impl/fast_scan/impl-avx512.cpp` — AVX512 per-SIMD TU - `impl/fast_scan/impl-neon.cpp` — ARM NEON TU (with ARM_SVE forwarding) Modified files: - `impl/fast_scan/pq4_fast_scan.h` — FastScanCodeScanner base + factory decl - `impl/fast_scan/pq4_fast_scan.cpp` — NONE specialization + dispatch wrapper - `xplat.bzl` / `CMakeLists.txt` — register SIMD files and header Note: RaBitQ handler is not wired through FastScanCodeScanner in this diff. That comes in later diffs when callers are switched. Differential Revision: D95950483
…arch#4903) Summary: Pull Request resolved: facebookresearch#4903 Add make_knn_scanner() virtual to IndexFastScan and IndexIVFFastScan that returns a SIMD-dispatched FastScanCodeScanner. Override in RaBitQ classes to produce rabitq-specific scanners via per-SIMD TU factories (rabitq_dispatching.h). Move RaBitQ handler method bodies into headers, add context pointer, and update rabitq_result_handler.h for SL template param. Wire IVFRaBitQFastScanScanner::scan_codes to use the new scanner. Update build files and SWIG ignores. Callers (search_implem_12/14, search_dispatch_implem) are unchanged and still use make_knn_handler. Reviewed By: mdouze Differential Revision: D96116557
2d71c52 to
7f52a2d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add make_knn_scanner() virtual to IndexFastScan and IndexIVFFastScan
that returns a SIMD-dispatched FastScanCodeScanner. Override in
RaBitQ classes to produce rabitq-specific scanners via per-SIMD TU
factories (rabitq_dispatching.h). Move RaBitQ handler method bodies
into headers, add context pointer, and update rabitq_result_handler.h
for SL template param. Wire IVFRaBitQFastScanScanner::scan_codes to
use the new scanner. Update build files and SWIG ignores.
Callers (search_implem_12/14, search_dispatch_implem) are unchanged
and still use make_knn_handler.
Differential Revision: D96116557