Switch all search paths to FastScanCodeScanner and remove make_knn_handler#4904
Open
algoriddle wants to merge 3 commits intofacebookresearch:mainfrom
Open
Switch all search paths to FastScanCodeScanner and remove make_knn_handler#4904algoriddle wants to merge 3 commits intofacebookresearch:mainfrom
algoriddle wants to merge 3 commits intofacebookresearch:mainfrom
Conversation
Contributor
|
@algoriddle has exported this pull request. If you are a Meta employee, you can view the originating Diff in D96116555. |
algoriddle
added a commit
to algoriddle/faiss
that referenced
this pull request
Mar 11, 2026
…ndler (facebookresearch#4904) Summary: Pull Request resolved: facebookresearch#4904 Now that every make_knn_scanner() returns a real scanner (never nullptr), switch all callers to use scanners directly and remove make_knn_handler. Add impl param to make_knn_scanner and its factory so heap vs reservoir selection respects the implem setting. Switch IndexFastScan search_implem_12/14, IndexIVFFastScan search_dispatch_implem/range_search, and IndexIVFPQFastScan scan_codes to scanner-only paths. Add range scanner factories (make_range_scanner, make_partial_range_scanner). Remove make_knn_handler from all classes. Change search_implem_10/12 scanner param from pointer to reference. Differential Revision: D96116555
1d6a807 to
9d18481
Compare
algoriddle
added a commit
to algoriddle/faiss
that referenced
this pull request
Mar 11, 2026
…ndler (facebookresearch#4904) Summary: Pull Request resolved: facebookresearch#4904 Now that every make_knn_scanner() returns a real scanner (never nullptr), switch all callers to use scanners directly and remove make_knn_handler. Add impl param to make_knn_scanner and its factory so heap vs reservoir selection respects the implem setting. Switch IndexFastScan search_implem_12/14, IndexIVFFastScan search_dispatch_implem/range_search, and IndexIVFPQFastScan scan_codes to scanner-only paths. Add range scanner factories (make_range_scanner, make_partial_range_scanner). Remove make_knn_handler from all classes. Change search_implem_10/12 scanner param from pointer to reference. Differential Revision: D96116555
9d18481 to
0efe212
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
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
…ndler (facebookresearch#4904) Summary: Pull Request resolved: facebookresearch#4904 Now that every make_knn_scanner() returns a real scanner (never nullptr), switch all callers to use scanners directly and remove make_knn_handler. Add impl param to make_knn_scanner and its factory so heap vs reservoir selection respects the implem setting. Switch IndexFastScan search_implem_12/14, IndexIVFFastScan search_dispatch_implem/range_search, and IndexIVFPQFastScan scan_codes to scanner-only paths. Add range scanner factories (make_range_scanner, make_partial_range_scanner). Remove make_knn_handler from all classes. Change search_implem_10/12 scanner param from pointer to reference. Reviewed By: mdouze Differential Revision: D96116555
0efe212 to
6c0a67a
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:
Now that every make_knn_scanner() returns a real scanner (never nullptr),
switch all callers to use scanners directly and remove make_knn_handler.
Add impl param to make_knn_scanner and its factory so heap vs reservoir
selection respects the implem setting. Switch IndexFastScan
search_implem_12/14, IndexIVFFastScan search_dispatch_implem/range_search,
and IndexIVFPQFastScan scan_codes to scanner-only paths. Add range scanner
factories (make_range_scanner, make_partial_range_scanner). Remove
make_knn_handler from all classes. Change search_implem_10/12 scanner
param from pointer to reference.
Differential Revision: D96116555