Skip to content

Delete old pq4_accumulate_loop files (replaced by dispatching.h)#4905

Closed
algoriddle wants to merge 4 commits into
facebookresearch:mainfrom
algoriddle:export-D96131176
Closed

Delete old pq4_accumulate_loop files (replaced by dispatching.h)#4905
algoriddle wants to merge 4 commits into
facebookresearch:mainfrom
algoriddle:export-D96131176

Conversation

@algoriddle
Copy link
Copy Markdown
Contributor

Summary:
Now that all search paths use FastScanCodeScanner (via dispatching.h),
the old pq4_accumulate_loop and pq4_accumulate_loop_qbs free functions
have no callers. Delete pq4_fast_scan_search_1.cpp and
pq4_fast_scan_search_qbs.cpp entirely. Relocate the remaining utility
functions (pq4_qbs_to_nq, pq4_preferred_qbs, accumulate_to_mem) to
pq4_fast_scan.cpp. Remove dead declarations from pq4_fast_scan.h.

This completes the code deduplication: dispatching.h uses shared helpers
from accumulate_loops.h and decompose_qbs.h, and no duplicate
implementations remain.

Differential Revision: D96131176

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Mar 11, 2026

@algoriddle has exported this pull request. If you are a Meta employee, you can view the originating Diff in D96131176.

algoriddle added a commit to algoriddle/faiss that referenced this pull request Mar 11, 2026
…ebookresearch#4905)

Summary:
Pull Request resolved: facebookresearch#4905

Now that all search paths use FastScanCodeScanner (via dispatching.h),
the old pq4_accumulate_loop and pq4_accumulate_loop_qbs free functions
have no callers. Delete pq4_fast_scan_search_1.cpp and
pq4_fast_scan_search_qbs.cpp entirely. Relocate the remaining utility
functions (pq4_qbs_to_nq, pq4_preferred_qbs, accumulate_to_mem) to
pq4_fast_scan.cpp. Remove dead declarations from pq4_fast_scan.h.

This completes the code deduplication: dispatching.h uses shared helpers
from accumulate_loops.h and decompose_qbs.h, and no duplicate
implementations remain.

Reviewed By: mdouze

Differential Revision: D96131176
algoriddle added a commit to algoriddle/faiss that referenced this pull request Mar 11, 2026
…ebookresearch#4905)

Summary:
Pull Request resolved: facebookresearch#4905

Now that all search paths use FastScanCodeScanner (via dispatching.h),
the old pq4_accumulate_loop and pq4_accumulate_loop_qbs free functions
have no callers. Delete pq4_fast_scan_search_1.cpp and
pq4_fast_scan_search_qbs.cpp entirely. Relocate the remaining utility
functions (pq4_qbs_to_nq, pq4_preferred_qbs, accumulate_to_mem) to
pq4_fast_scan.cpp. Remove dead declarations from pq4_fast_scan.h.

This completes the code deduplication: dispatching.h uses shared helpers
from accumulate_loops.h and decompose_qbs.h, and no duplicate
implementations remain.

Reviewed By: mdouze

Differential Revision: D96131176
algoriddle added a commit to algoriddle/faiss that referenced this pull request Mar 11, 2026
…ebookresearch#4905)

Summary:
Pull Request resolved: facebookresearch#4905

Now that all search paths use FastScanCodeScanner (via dispatching.h),
the old pq4_accumulate_loop and pq4_accumulate_loop_qbs free functions
have no callers. Delete pq4_fast_scan_search_1.cpp and
pq4_fast_scan_search_qbs.cpp entirely. Relocate the remaining utility
functions (pq4_qbs_to_nq, pq4_preferred_qbs, accumulate_to_mem) to
pq4_fast_scan.cpp. Remove dead declarations from pq4_fast_scan.h.

This completes the code deduplication: dispatching.h uses shared helpers
from accumulate_loops.h and decompose_qbs.h, and no duplicate
implementations remain.

Reviewed By: mdouze

Differential Revision: D96131176
algoriddle added a commit to algoriddle/faiss that referenced this pull request Mar 11, 2026
…ebookresearch#4905)

Summary:
Pull Request resolved: facebookresearch#4905

Now that all search paths use FastScanCodeScanner (via dispatching.h),
the old pq4_accumulate_loop and pq4_accumulate_loop_qbs free functions
have no callers. Delete pq4_fast_scan_search_1.cpp and
pq4_fast_scan_search_qbs.cpp entirely. Relocate the remaining utility
functions (pq4_qbs_to_nq, pq4_preferred_qbs, accumulate_to_mem) to
pq4_fast_scan.cpp. Remove dead declarations from pq4_fast_scan.h.

This completes the code deduplication: dispatching.h uses shared helpers
from accumulate_loops.h and decompose_qbs.h, and no duplicate
implementations remain.

Reviewed By: mdouze

Differential Revision: D96131176
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

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
algoriddle added a commit to algoriddle/faiss that referenced this pull request Mar 11, 2026
…ebookresearch#4905)

Summary:
Pull Request resolved: facebookresearch#4905

Now that all search paths use FastScanCodeScanner (via dispatching.h),
the old pq4_accumulate_loop and pq4_accumulate_loop_qbs free functions
have no callers. Delete pq4_fast_scan_search_1.cpp and
pq4_fast_scan_search_qbs.cpp entirely. Relocate the remaining utility
functions (pq4_qbs_to_nq, pq4_preferred_qbs, accumulate_to_mem) to
pq4_fast_scan.cpp. Remove dead declarations from pq4_fast_scan.h.

This completes the code deduplication: dispatching.h uses shared helpers
from accumulate_loops.h and decompose_qbs.h, and no duplicate
implementations remain.

Reviewed By: mdouze

Differential Revision: D96131176
…ebookresearch#4905)

Summary:
Pull Request resolved: facebookresearch#4905

Now that all search paths use FastScanCodeScanner (via dispatching.h),
the old pq4_accumulate_loop and pq4_accumulate_loop_qbs free functions
have no callers. Delete pq4_fast_scan_search_1.cpp and
pq4_fast_scan_search_qbs.cpp entirely. Relocate the remaining utility
functions (pq4_qbs_to_nq, pq4_preferred_qbs, accumulate_to_mem) to
pq4_fast_scan.cpp. Remove dead declarations from pq4_fast_scan.h.

This completes the code deduplication: dispatching.h uses shared helpers
from accumulate_loops.h and decompose_qbs.h, and no duplicate
implementations remain.

Reviewed By: mdouze

Differential Revision: D96131176
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Mar 12, 2026

This pull request has been merged in 000eec2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants