Skip to content

Commit 80a1656

Browse files
Michael Norrismeta-codesync[bot]
authored andcommitted
Enable Faiss dynamic dispatch for OVIS and VeST fbpkgs (facebookresearch#5515)
Summary: Pull Request resolved: facebookresearch#5515 Enable `faiss.dynamic_dispatch=true` on the three `vector_search` fbpkgs that link Faiss, and add a probe that logs which SIMD kernels each process actually dispatched to. Also adds some logs in VeST. **fbpkgs covered** - `ovis_cli` (`cli/BUCK`) - `vector_search_offline_knn` (`offline_knn/BUCK`) - `vector_search_index_trainer` (`training/BUCK`) — the VeST trainer Without the flag, Faiss is compiled with static AVX2 SIMD selection. With it, all compiled-in SIMD variants (AVX2, AVX512, AVX512-SPR) are built and the best supported one is selected at runtime via CPUID. **This is not a speedup, and is not intended as one.** These workloads *build* indexes rather than search them, and the AVX-512 win for SQ4 lives on the scan path, not the encode path. Measured end-to-end as perf-neutral — see the test plan. The reasons to land it are consistency across the `vector_search` fbpkgs, unlocking AVX-512 for any future search-side work in these binaries, and the observability below. **SIMD probe.** `log_faiss_simd_level()` in `training/utils.py` logs `level`, `dispatched_level`, `has_dynamic_dispatch` and `compile_options`. It is called from `assignment_worker.py` (datasink worker) and from `datasinks/common.py::_build_merged_file_blocking` (the spawned leaf-build children are separate processes and do not inherit parent Faiss state, so each reports its own; guarded to log once per process rather than once per cluster). This probe is load-bearing: Faiss logs nothing about its own dispatch state, so the earlier VeST DD A/B could not distinguish "DD did not help" from "DD never engaged". With the probe, that ambiguity is resolved — DD demonstrably engages, and the null result is real. Reviewed By: bshethmeta Differential Revision: D107286701 fbshipit-source-id: 48cada6220c2b379f9774514edd48f2f5858f39a
1 parent e2f9cca commit 80a1656

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

faiss/python/__init__.pyi

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,6 +3057,36 @@ class CodePacker:
30573057
class CodePackerFlat(CodePacker):
30583058
def __init__(self, code_size: int) -> None: ...
30593059

3060+
# SIMD dispatch (faiss/utils/simd_levels.h). SWIG exposes the scoped enum
3061+
# SIMDLevel as module-level int constants (EnumName_Value convention).
3062+
SIMDLevel_NONE: int
3063+
SIMDLevel_AVX2: int
3064+
SIMDLevel_AVX512: int
3065+
SIMDLevel_AVX512_SPR: int
3066+
SIMDLevel_ARM_NEON: int
3067+
SIMDLevel_ARM_SVE: int
3068+
SIMDLevel_RISCV_RVV: int
3069+
SIMDLevel_COUNT: int
3070+
3071+
class SIMDConfig:
3072+
level: int
3073+
supported_simd_levels: int
3074+
avx512_split: bool
3075+
@staticmethod
3076+
def auto_detect_simd_level() -> int: ...
3077+
@staticmethod
3078+
def has_dynamic_dispatch() -> bool: ...
3079+
@staticmethod
3080+
def set_level(level: int) -> None: ...
3081+
@staticmethod
3082+
def get_level() -> int: ...
3083+
@staticmethod
3084+
def get_level_name() -> str: ...
3085+
@staticmethod
3086+
def is_simd_level_available(level: int) -> bool: ...
3087+
@staticmethod
3088+
def get_dispatched_level() -> int: ...
3089+
30603090
# Utility functions
30613091
def get_mem_usage_kb() -> int: ...
30623092
def get_compile_options() -> str: ...

0 commit comments

Comments
 (0)