40 Commits
Author SHA1 Message Date
Tia Lim 0f0f728166 Format faiss Python files with black (line length 80) (#5349)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5349

# this is a no-op change

Ran `black -l 80` over all tracked Python files under `fbcode/faiss/`, using line length 80 to match faiss's documented coding style (`CONTRIBUTING.md`: "80 character line length (both for C++ and Python)"). 172 files were reformatted; 28 were already compliant.

This is a pure-formatting change. `black` runs its AST-equivalence safety check on every file, so no identifiers, string/numeric values, operators, or control flow were altered — only whitespace, indentation, line wrapping, blank lines, trailing commas, and string-quote normalization (single to double quotes).

`fbcode/faiss/` is intentionally excluded from Meta's standard Python autoformatter (`arc f` / `arc lint -a` report no formatter for these paths) because it mirrors to public GitHub, so the Python had drifted out of any consistent style. The C++ is already clang-format-clean (0 of 807 files change), so this effort is Python-only. This diff brings the Python to canonical `black` formatting.

Excluded `demos/index_pq_flat_separate_codes_from_codebook.py`: it contains a Jupyter `!rm` shell-magic line and is not valid Python, so `black` cannot parse it.

This is the base of a 3-diff stack: (1) this black reformat; (2) `.flake8` alignment (max-line-length 80 + black-compatible ignores E203/W503); (3) genuine lint fixes (F401/F403/F841/B011).

Reviewed By: mnorris11

Differential Revision: D109736099

fbshipit-source-id: 9a054635766ed11aa3760a788395babd3d198abf
2026-06-29 17:29:05 -07:00
Saim-naushad 506600962f Add Python HNSW tutorial (#5260)
Summary:
This PR adds a Python HNSW tutorial corresponding to the existing C++ HNSW tutorial.

The example creates synthetic vectors, builds an IndexHNSWFlat index, runs a search, and prints the nearest-neighbor IDs and distances for the final queries.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5260

Reviewed By: mnorris11

Differential Revision: D107272616

Pulled By: alibeklfc

fbshipit-source-id: 721d7a1a95aa79150d6cb9653bd803065c82dcd7
2026-06-03 13:28:20 -07:00
Mihai Capotă 4627695179 Fix SVS Python tutorial (#4720)
Summary:
Update naming and add missing graph degree parameters.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4720

Reviewed By: mnorris11

Differential Revision: D89226673

Pulled By: zoeyeye

fbshipit-source-id: 11df972dcce1e04e19d81f9acf230cc4cee6e345
2025-12-16 11:09:33 -08:00
Aaron Lin a695814f4c Enable Intel ScalableVectorSearch support (#4548)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/issues/4450

This pull request introduces support for [Intel ScalableVectorSearch](https://github.com/intel/ScalableVectorSearch), integrating Intel's proprietary LVQ and LeanVec technologies in binary form. The following index types are now supported: `IndexSVSVamana`, `IndexSVSVamanaLVQ`, `IndexSVSVamanaLeanVec`, and `IndexSVSFlat`. `IndexSVSVamana` and `IndexSVSFlat` utilizes SVS open-source float32/float16/int8 implementation.

Key features and enhancements include:
- Implemented `search`, `add`, and `remove_ids`
- Implemented filter search and `range_search`
- Enabled SVS open-source fp16 and scalar quantization implementation
- Enabled factory methods
- Enabled save/load
- Enabled Python bindings
- Enable fallback mechanism that fallbacks to 8-bit scalar quantization if LVQ/LeanVec is used on non-intel hardware CPUs
- Added examples in both Python and C++ under the `tutorial/` directory
- Added `FAISS_ENABLE_SVS` flag to allows users to optionally enable SVS

TODOs:
- Support more indices such as `IndexSVSIVF` and `IndexSVSFlat` with LVQ and LeanVec
- Documentation

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4548

Reviewed By: subhadeepkaran

Differential Revision: D84713772

Pulled By: mnorris11

fbshipit-source-id: 290365eb3337f685dd46696935b621c57dad3174
2025-12-05 16:03:58 -08:00
Subhadeep Karan 3d4d59fc3b Fix typos in demos, benchs, and other directories (#4709)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4709

Reviewed By: limqiying

Differential Revision: D86571400

fbshipit-source-id: ac60662cf7a1939b900b89830273ee3d40f87e9c
2025-12-05 15:44:35 -08:00
Subhadeep Karan 451ca8429d Fix typos in documentation, tutorials, and C API (#4666)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4666

*   `for OpenMP support support` → `for OpenMP support`
*   `neccesary` → `necessary`
*   `journal= {arXiv:1702.08734},,` → `journal = {arXiv:1702.08734},`
*   `verinsion` → `version`
*   `consistency_check--config` → `consistency_check --config`
*   `etracted` → `extracted` (2 occurrences)
*   `sb` → `xb` (variable reference)
*   `statists` → `statistics`
*   `elemnts` → `elements`

Reviewed By: alibeklfc

Differential Revision: D86474214

fbshipit-source-id: f63272423b0a767f7576cd433004c87d85e2d740
2025-11-07 21:38:52 -08:00
generatedunixname89002005287564 7ba7d29244 Fix CQS signal readability-braces-around-statements in fbcode/faiss/tutorial (#4446)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4446

Differential Revision: D78796179

fbshipit-source-id: 58ef6eff22cc67385eca917e585ca244748d1a89
2025-07-23 11:06:33 -07:00
Tarang Jain cd3699ea73 Faiss + Cuvs Example Notebook (#4434)
Summary:
Example notebook

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4434

Reviewed By: subhadeepkaran

Differential Revision: D78492311

Pulled By: mnorris11

fbshipit-source-id: a15207af2e6c7b0e9f7c8edcca5e2b504efab8c0
2025-07-17 13:43:01 -07:00
Michael Norris eff0898a13 Enable linting: lint config changes plus arc lint command (#3966)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3966

This actually enables the linting.

Manual changes:
- tools/arcanist/lint/fbsource-licenselint-config.toml
- tools/arcanist/lint/fbsource-lint-engine.toml

Automated changes:
`arc lint --apply-patches --take LICENSELINT --paths-cmd 'hg files faiss'`

Reviewed By: asadoughi

Differential Revision: D64484165

fbshipit-source-id: 4f2f6e953c94ef6ebfea8a5ae035ccfbea65ed04
2024-10-22 09:46:48 -07:00
Xiao Fu a900cfa9f1 Add cpp tutorial for index factory refine index construction (#3494)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3494

This tasks focus on the refine index construction tutorial with different index refinement on fp16/sq8 quantization. The python version was added a while ago.

Reviewed By: junjieqi

Differential Revision: D58161983

fbshipit-source-id: 1c598fe612b5dee3952c5f7398e6802e117f141d
2024-06-04 19:44:27 -07:00
Xiao Fu 6e423cc649 Add python tutorial on different indexs refinement and respect accuracy measurement (#3480)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3480

This tutorial summarize the methods to construct different indexs for PQFastScan refinement. It shows how the choice can impact on accuracy.

Reviewed By: junjieqi

Differential Revision: D57799598

fbshipit-source-id: a75c52c60a5217366f3361676da8f03f0c4a9feb
2024-05-27 11:55:06 -07:00
Xiao Fu 414fd1e3b7 Add tutorial for FastScan with refinement for cpp (#3474)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3474

This commit focus on the cpp version of PQfastscan tutorial with index refinement by defining the k factor.

Reviewed By: junjieqi

Differential Revision: D57680905

fbshipit-source-id: 980c2990172f24ec9a4f870685e706195883408f
2024-05-22 13:01:37 -07:00
Xiao Fu 7d7fef0b58 Add FastScan refinement tutorial for python (#3469)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3469

Reviewed By: junjieqi

Differential Revision: D57650807

fbshipit-source-id: 5e642a8140455e4a3f1f21afe2f06771462e61f4
2024-05-22 09:30:18 -07:00
Xiao Fu f38e52c1e2 Add tutorial on PQFastScan for cpp (#3468)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3468

This commit includes the tutorial for PQFastScan in the cpp environment.

Reviewed By: junjieqi

Differential Revision: D57631441

fbshipit-source-id: f5e17eee2a584ebfc9ff63868d741d0da6b3b413
2024-05-21 16:42:15 -07:00
Saarth Deshpande 59e3ee1e30 Missed printing 'D' (#3433)
Summary:
'I' was printed twice and 'D' (distance vector) was not printed. Fixed.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3433

Reviewed By: fxdawnn

Differential Revision: D57451544

Pulled By: junjieqi

fbshipit-source-id: fc17b3b467f8b2c4ad7d80b44866456d9146e530
2024-05-21 13:02:25 -07:00
Xiao Fu 4489773fd4 Add tutorial for FastScan (#3465)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3465

This commit include python version of tutorial for FastScan. It includes all the parameters enabled within PQFastScan.

Reviewed By: junjieqi

Differential Revision: D57594044

fbshipit-source-id: cb12679b6fc241a654b9545c5bc7bd0517aa1813
2024-05-21 09:50:41 -07:00
Richard Barnes b8e4489b98 Remove unused variables in faiss/IndexIVFFastScan.cpp (#3439)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3439

LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje, junjieqi

Differential Revision: D57344013

fbshipit-source-id: adf410139d2e6ca69a26ccdbff8511c9b7620489
2024-05-15 11:45:48 -07:00
Jayjeet Chakraborty 3121fc6175 Fix #3379: Add tutorial for HNSW index (#3381)
Summary:
Fixes https://github.com/facebookresearch/faiss/issues/3379

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3381

Reviewed By: junjieqi

Differential Revision: D56570120

Pulled By: kuarora

fbshipit-source-id: 758ea4ab866609d6dd5621e6e6ffda583ba52503
2024-04-30 12:23:58 -07:00
Matthijs Douze a996a4a052 Put idx_t in the faiss namespace (#2582)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2582

A few more or less cosmetic improvements
* Index::idx_t was in the Index object, which does not make much sense, this diff moves it to faiss::idx_t
* replace multiprocessing.dummy with multiprocessing.pool
* add Alexandr as a core contributor of Faiss in the README ;-)

```
for i in $( find . -name \*.cu -o -name \*.cuh -o -name \*.h -o -name \*.cpp ) ; do
  sed -i s/Index::idx_t/idx_t/ $i
done
```

For the fbcode deps:
```
for i in $( fbgs Index::idx_t --exclude fbcode/faiss -l ) ; do
   sed -i s/Index::idx_t/idx_t/ $i
done
```

Reviewed By: algoriddle

Differential Revision: D41437507

fbshipit-source-id: 8300f2a3ae97cace6172f3f14a9be3a83999fb89
2022-11-30 08:25:30 -08:00
Lucas Hosseini e86bf8cae1 Enable clang-format + autofix.
Summary: Format whole codebase with clang-format.

Reviewed By: mdouze

Differential Revision: D22891341

fbshipit-source-id: 673032b2444d61026d1e2c3fa2c5659f178cf58b
2021-02-25 04:46:10 -08:00
Matthijs Douze 15ffe976f0 fix tutorial files
Summary:
Added TARGETS files and fixed GPU tutorial code.
Related to issue https://github.com/facebookresearch/faiss/issues/1408

Reviewed By: beauby

Differential Revision: D23728732

fbshipit-source-id: 22bec7d439ffc187c144575e1e984111bfbfcbb2
2020-09-17 07:32:56 -07:00
Lucas Hosseini c37e71456b Get rid of non-portable drand48. (#1349)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1349

Reviewed By: mdouze

Differential Revision: D23289393

Pulled By: beauby

fbshipit-source-id: a626bbf252ced4ae01abbc3dce4be50d9e628728
2020-08-24 00:42:21 -07:00
Lucas Hosseini b539a73e58 Linter auto-fix.
Summary: `arc lint faiss/**/*`

Reviewed By: LowikC

Differential Revision: D22891305

fbshipit-source-id: 45bab7294ccccf70898b4967b03683894b6ae4c4
2020-08-16 19:52:27 -07:00
Lucas Hosseini a8e4c5e2d5 Move build to CMake (#1313)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1313

Reviewed By: mdouze

Differential Revision: D22948267

Pulled By: beauby

fbshipit-source-id: ec16fa0342f37672d46fb7886ecc55c7996011c4
2020-08-14 15:03:10 -07:00
Matthijs Douze 9258a9535e fix datatypes for mac (#1270) 2020-06-28 13:00:44 +02:00
Matthijs Douze 1a332509a3 Update 5-Multiple-GPUs.cpp
Thanks to gameofdimension
https://github.com/facebookresearch/faiss/pull/1060/files
2020-01-16 16:46:11 +01:00
Lucas Hosseini a8118acbc5 Facebook sync (May 2019) + relicense (#838)
Changelog:

- changed license: BSD+Patents -> MIT
- propagates exceptions raised in sub-indexes of IndexShards and IndexReplicas
- support for searching several inverted lists in parallel (parallel_mode != 0)
- better support for PQ codes where nbit != 8 or 16
- IVFSpectralHash implementation: spectral hash codes inside an IVF
- 6-bit per component scalar quantizer (4 and 8 bit were already supported)
- combinations of inverted lists: HStackInvertedLists and VStackInvertedLists
- configurable number of threads for OnDiskInvertedLists prefetching (including 0=no prefetch)
- more test and demo code compatible with Python 3 (print with parentheses)
- refactored benchmark code: data loading is now in a single file
2019-05-28 16:17:22 +02:00
gensmusic 712edb043a tutorial build add CPPFLAGS which contains cuda include pathi when ./configure --with-cuda (#833) 2019-05-24 14:46:53 +02:00
Xuhui Sun 0a8f92d6d6 Update cpp tutorial makefile for GPU part (#774) 2019-04-11 14:20:38 +02:00
Lucas Hosseini ac7005b6ef Remove CMake. (#645) 2018-12-23 18:45:16 +01:00
Lucas Hosseini cf18101f6d Refactor makefiles and add configure script (#466)
* Refactors Makefiles and add configure script.

* Give MKL higher priority in configure script.

* Clean up Linux example makefile.inc.

* Cleanup makefile.inc examples.

* Fix python clean Makefile target.

* Regen swig wrappers.

* Remove useless CUDAFLAGS variable.

* Fix python linking flags.

* Separate compile and link phase in python makefile.

* Add macro to look for swig.

* Add CUDA check in configure script.

* Cleanup make depend targets.

* Cleanup CUDA flags.

* Fix linking flags.

* Fix python GPU linking.

* Remove useless flags from python gpu module linking.

* Add check for cuda libs.

* Cleanup GPU targets.

* Clean up test target.

* Add cpu/gpu targets to python makefile.

* Clean up tutorial Makefile.

* Remove stale OS var from example makefiles.

* Clean up cuda example flags.
2018-06-02 08:35:30 +02:00
Lizz 3bdc5abeaf Fix compile error in cpp tutorial (#380)
Not tested but looks legitimate + better than previous state in any case ;-)
2018-03-28 09:15:18 -04:00
Lucas Hosseini 16aed09c0f Make tutorial examples use dynamic linkage. (#343)
* Add shared lib target for GPU version.

* Dynamically link tutorial examples.

* Add shared lib to clean target in GPU Makefile.

* Add clean target to tutorial examples Makefile.

* Minor modifications to tutorial GPU examples.
2018-02-21 15:36:29 +01:00
Lucas Hosseini 2c9aea24e7 [WIP] Update tutorial examples (#342)
* Remove transitional print import.

* Add example for multiple GPUs in python.

* Add example on GPU in C++.

* Add example on multiple GPUs in C++.

* Add IVFFlat example on GPU in python.

* Add Makefile for C++ tutorial examples.

* Add IVF index on GPU example in C++.
2018-02-20 15:53:56 +01:00
Matthijs Douze 1a9b814873 Update 4-GPU.py 2017-12-18 19:23:30 +01:00
matthijs c4ebee7feb added tuto for GPU 2017-12-07 09:12:19 -08:00
matthijs 8e3dc6f2b0 changed license 2017-07-30 00:18:45 -07:00
matthijs 784e2facd8 Synchronization with FB version 2017-06-21
* moved most FAISS_ASSERT calls to C++ exceptions, and adjusted
  memory allocation to avoid mem leaks

* added an IndexIVFScalarQuantizer type that offers an
  intermediate compression between IVFFlat and IVFPQ

* support removal of indices in IndexIDMap / IndexFlat combination

* various fixes in GPU code
2017-06-21 09:01:06 -07:00
Tianwei Shen 80314d9f07 add initial cmake support (#75)
* add initial cmake support

* update cmake, add cmake instructions to INSTALL

* update findopenmp and INSTALL

* change FindOpenBLAS.cmake to cater for macports

- change cblas.h to openblas_config.h since macports does not ship
cblas.h with openblas.

* revise INSTALL for cmake
2017-05-02 11:04:50 +02:00
Matthijs Douze c670118a4e Initial commit 2017-02-22 23:26:44 +01:00