faiss
Guides Researchers through Faiss installation, dense and binary similarity search, index training and composition, persistence and evaluation, and explicitly gated CPU/GPU interoperability workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- faiss
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides Researchers through Faiss installation, dense and binary similarity search, index training and composition, persistence and evaluation, and explicitly gated CPU/GPU interoperability workflows.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/repo-provenance.md2.0 KB
- 参考文档references/repo-routing-metadata.json322 B
- 参考文档references/troubleshooting.md5.3 KB
03 SKILL.md 正文
Faiss
Faiss is a C++ library with Python/NumPy bindings for efficient similarity search and clustering of dense vectors. Use this skill when a task involves nearest-neighbor search, vector indexing, clustering, quantization, binary search, index files, or Faiss CPU/GPU integration.
Start with the environment gate
-
Identify the distribution and backend required by the task. Use
faiss-cpufor the CPU baseline. Use a documented CUDA/ROCm/Metal/cuVS/SVS package or source build only when the requested capability needs it. -
Run the bundled read-only probe before making backend claims. The backend-specific checker is bundled with the accelerated route:
python path/to/faiss/sub-skills/accelerated-and-interoperable/scripts/check_backend.py --jsonIt reports the imported version, compile options, available GPU symbols, device count, optional module status, NumPy availability, and tool/runtime signals. A visible GPU does not turn a CPU build into a GPU build.
-
Normalize float inputs to contiguous
float32arrays of shape(n, d). Binary indexes instead use packeduint8rows with a bit dimension that is divisible by eight. Establish the metric and preprocessing before selecting an index. -
Validate an approximate or compressed index against an exact Flat baseline on a bounded fixture before tuning recall, memory, or latency.
For public installation, prefer the documented Conda packages: faiss-cpu for
CPU, faiss-gpu for CUDA, and faiss-gpu-cuvs for the cuVS variant. A source
build uses CMake and can enable Python, CUDA/ROCm, C API, Metal, cuVS, or SVS
independently; do not enable extras merely because they exist.
Route by task
- Index selection and search
covers Flat, IVF, HNSW/graph search, metrics, factory strings, result
contracts,
nprobe,efSearch, range search, and CPU search tuning. - Training and compression covers train/add/code lifecycles, IVF-PQ, PQ, SQ, residual/additive/RaBitQ, transforms, fast scan, reconstruction, and binary/Hamming indexes.
- Composition and filtering covers ID maps, selectors, per-search parameters, transforms, refinement, child ownership, direct maps, shards, replicas, and advanced IVF inspection.
- Persistence and evaluation covers byte/file serialization, cloning, mmap/on-disk storage, merge, clustering, exact ground truth, recall/precision, and operating points.
- Accelerated and interoperable covers CUDA and multi-GPU transfer, cuVS/ROCm/Metal/SVS gates, C++/C APIs, Torch buffers, FFI, dynamic-library diagnosis, and RPC boundaries.
If a workflow spans branches, keep the core CPU baseline in the first relevant route, then follow its explicit sibling link for composition, persistence, compression, or backend-specific work. Do not treat a benchmark result as validated until its data, metric, exact baseline, and backend are recorded.
Minimal CPU check
import numpy as np
import faiss
xb = np.ascontiguousarray(np.random.default_rng(0).random((100, 16), dtype="float32"))
index = faiss.IndexFlatL2(xb.shape[1])
index.add(xb)
D, I = index.search(xb[:2], 4)
assert D.shape == I.shape == (2, 4)
print(faiss.__version__, index.ntotal, faiss.get_compile_options())
Read cross-cutting troubleshooting for installation/import failures, dtype and shape errors, missing optional backends, unsafe index files, and thread/runtime problems. Read repository provenance before deciding whether this graph is stale for a changed Faiss checkout.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).