15 Commits
Author SHA1 Message Date
Mihai Capotă 4864f4d420 SVS: Add ParameterSpace.set_index_parameter support for Vamana (#5644)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5644

Reviewed By: alibeklfc

Differential Revision: D120290334

Pulled By: mnorris11

fbshipit-source-id: c947484d0704789553a7d4d80a0ef7185e59962a
2026-09-18 10:15:10 -07:00
ethanglaser cfbf4ec5ff SVS: allow option to disable vector storing (#5525)
Summary:
Allow avoiding storing original vectors, which may not necessarily be used, in which case they would be wasting memory

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

Reviewed By: alibeklfc

Differential Revision: D118722620

Pulled By: mnorris11

fbshipit-source-id: 9757fa3d272187308c750fb6c6d0e3a6e8ab2bb3
2026-09-04 10:02:36 -07:00
Rafik Saliev 42dc2862c2 Implement memory-mapped I/O for Flat and static Vamana SVS indices (#5271)
Summary:
This pull request adds support for memory-mapped I/O (mmap) loading of static SVS (Scalable Vector Search) indices in Faiss, enabling faster and more memory-efficient index loading. The main changes include implementing mmap-based deserialization for static Vamana and Flat indices, updating the index loading logic to use mmap when requested, and adding comprehensive tests for the new functionality.

**Memory-mapped index loading support:**

* Added `map_to` methods to `IndexSVSVamana` and `IndexSVSFlat` for loading static indices directly from memory-mapped files, including logic to manage memory mapping ownership and adjust file positions after mapping.

**Index and file structure updates:**

* Extended `IndexSVSVamana` and `IndexSVSFlat` classes to hold a reference to the mmap owner, ensuring the mapped memory remains valid for the lifetime of the index. Also added forward declarations and includes for mmap-related types.
* Modified `reset` methods to release memory mappings when the index is reset, preventing resource leaks.

**Testing and interface improvements:**

* Enhanced test utilities and added new tests to verify correct mmap loading for various static Vamana index types, including FP32, FP16, SQI8, LVQ4x4, and LeanVec4x4 in `tests/test_svs.cpp`

These changes collectively provide robust and efficient support for memory-mapped loading of static SVS indices, improving both performance and usability for large-scale vector search applications.

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

Reviewed By: alibeklfc

Differential Revision: D108313487

Pulled By: mnorris11

fbshipit-source-id: 4ae6dc3e69363b0c792cd56ad26b01bf6a853d28
2026-07-01 21:53:26 -07:00
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
Michael Norris 9223d62e81 Rename SQI8 to SQ8 to be consistent with the rest of Faiss (#5337)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5337

We will use SQ8 more frequently in Vamana in particular, so this will reduce friction

Reviewed By: junjieqi

Differential Revision: D109480499

fbshipit-source-id: 8d8a3982f459eb75b1d63e7032b8abacf7f3a41a
2026-06-24 10:50:39 -07:00
ethanglaser 215740ecc3 SVS static vamana support (#5224)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5224

Reviewed By: alibeklfc

Differential Revision: D106684059

Pulled By: mnorris11

fbshipit-source-id: b0430f17798ef8737835892a505d19be21e06630
2026-06-01 10:47:38 -07:00
Trang Nguyen ffd3727d48 Update pattern for index factory string with SVSVamana (#5201)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5201

Currently SVSVamana failed with error:
Mitigation: Error in std::unique_ptr<Index> faiss::(anonymous namespace)::index_factory_sub(int, std::string, MetricType, bool) at fbcode/faiss/index_factory.cpp:1176: could not parse index string IVF524288_SVSVamana64_SQI8,SQ4

In this diff we will fix the issue
f1078497787

Reviewed By: mnorris11

Differential Revision: D104326684

fbshipit-source-id: 974723c880d235cfee4ec36b3f4c91d251f408b4
2026-05-08 10:19:00 -07:00
generatedunixname2012458493028417 bb2ce7137d Fix 7 broken tests (#5197)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5197

Reviewed By: limqiying

Differential Revision: D103977518

fbshipit-source-id: 208a028413ee6ce74d0f8fc227a32049da754b7e
2026-05-07 18:28:05 -07:00
Ishwar Bhati 46def46902 Enable SVS IVF Index in FAISS (#4801)
Summary:
This PR introduces SVS IVF (Inverted File) index support in FAISS, complementing the existing SVS Vamana graph‑based index. The implementation integrates Intel's Scalable Vector Search (SVS) runtime to provide a high‑performance, partition‑based ANN index with strong scalability on modern hardware.

## Key Advantages of SVS IVF

- **AMX‑accelerated builds** for significantly faster index training on supported Intel platforms
- **Hierarchical clustering** (default ON) enabling much faster k‑means on large datasets
- **LVQ and LeanVec compression** applied at search time to boost throughput while preserving recall
- **Intra-query parallelism** to reduce latency for small‑batch or single‑query workloads
- **Static index mode** for read‑only workloads with optimized memory layout and search performance

## New Factory Strings

| Factory String | IndexClass | Storage |
|---|---|---|
| `SVSIVF{nlist}` | IndexSVSIVF | FP32 (default) |
| `SVSIVF{nlist},FP16` | IndexSVSIVF | Float16 |
| `SVSIVF{nlist},SQI8` | IndexSVSIVF | Scalar quantized int8 |
| `SVSIVF{nlist},LVQ4x0` | IndexSVSIVFLVQ | LVQ primary=4, no residual |
| `SVSIVF{nlist},LVQ4x4` | IndexSVSIVFLVQ | LVQ primary=4, residual=4 |
| `SVSIVF{nlist},LVQ4x8` | IndexSVSIVFLVQ | LVQ primary=4, residual=8 |
| `SVSIVF{nlist},LVQ8x0` | IndexSVSIVFLVQ | LVQ primary=8, no residual |
| `SVSIVF{nlist},LeanVec4x4_{dims}` | IndexSVSIVFLeanVec | LeanVec 4x4 |
| `SVSIVF{nlist},LeanVec4x8_{dims}` | IndexSVSIVFLeanVec | LeanVec 4x8 |
| `SVSIVF{nlist},LeanVec8x8_{dims}` | IndexSVSIVFLeanVec | LeanVec 8x8 |

## Static vs Dynamic IVF Index

SVS IVF supports two modes controlled by the `is_static` constructor parameter:

### Dynamic IVF (default, `is_static = false`)
- Supports `train()`, `add()`, `remove_ids()`, and `search()`
- Vectors can be added or removed after index creation
- Suitable for workloads where the dataset changes over time

### Static IVF (`is_static = true`)
- **All data must be provided during `train()`** — the index is built and populated in a single step
- `add()` and `remove_ids()` will throw an exception after creation
- Optimized for **read‑only workloads** where the dataset is fixed at build time
- Uses `svs_runtime::IVFIndex` (static) instead of `svs_runtime::DynamicIVFIndex`
- Serialization and deserialization are fully supported

**Usage Examples(C++):**

```cpp
// Dynamic IVF with intra-query parallelism
faiss::IndexSVSIVF index(d, nlist);

// intra_query_threads must be set BEFORE train() — changes after
// train() are not propagated to the SVS backend (current SVS runtime
// API limitation, will be fixed in a future SVS version).
index.intra_query_threads = 4;
index.n_probes = 20;

index.train(n, train_data);
index.add(n, base_data);
index.search(nq, queries, k, distances, labels);

// num_threads CAN be changed between searches (synced at search time).
index.num_threads = 8;
index.search(nq, queries, k, distances, labels);

// Static IVF (read-only, all data at build time)
faiss::IndexSVSIVF index(d, nlist, faiss::METRIC_L2,
                         faiss::SVSStorageKind::SVS_FP32, /*is_static=*/true);
index.intra_query_threads = 4;  // set before train()
index.train(n, data);           // builds and populates the index
index.search(nq, queries, k, distances, labels);
// index.add(...)        // throws — not supported on static index
// index.remove_ids(...) // throws — not supported on static index

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

Reviewed By: limqiying

Differential Revision: D102536698

Pulled By: mnorris11

fbshipit-source-id: cbc2b882c1f7728ed54a0bd25ceacb225d5a6c74
2026-05-01 19:03:51 -07:00
Trang Nguyen 71448c07d3 Fix issue with svs tests (#5162)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5162

T225351715 Fixing failed unit test as part of oncall duty. test_svs_py are failing due to timeout.

In this diff, we are fixing 2 issues with the tests:
1. setUp runs before every test method — with 11 tests per class × 8 classes = ~57 times, each regenerating the same numpy arrays. setUpClass runs once per class, so data is generated ~8 times instead of ~57. The data is deterministic (fixed np.random.seed(1234)) and no test mutates xb/xq — tests only read them. So regenerating identical arrays per-method is pure waste.
2. Reduce test size

Reviewed By: mnorris11

Differential Revision: D103043664

fbshipit-source-id: ac79b23910c2d936168dc7021b06f57c47a32782
2026-04-29 14:18:12 -07:00
Akshay Mahesh 748e4d47ad Revert D97138228: Generated from a GitHub Pull Request. Run 'jf sync' on this diff to load the correct commit data.
Differential Revision:
D97138228

Original commit changeset: 311eafd5186a

Original Phabricator Diff: D97138228

fbshipit-source-id: c0aead65b62bdf6a3ccf0009ee5c3d57e5707304
2026-04-25 22:30:04 -07:00
Michael Norris bdc882c4d3 Generated from a GitHub Pull Request. Run 'jf sync' on this diff to load the correct commit data.
Reviewed By: limqiying

Differential Revision: D97138228

fbshipit-source-id: 311eafd5186a77e1ba32805a4723662e75815593
2026-04-25 16:46:57 -07:00
Andreas Huber 1cb3d4653f feat(svs): LeanVec OOD support (#4773)
Summary:
This PR will add LeanVec OOD (out-of-distribution) support.

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

Reviewed By: alibeklfc

Differential Revision: D94607022

Pulled By: mnorris11

fbshipit-source-id: df1b023919b6a2753fdddcd7d5490475f8630d36
2026-03-04 13:12:16 -08:00
Junjie Qi 07549baa00 Fix lint errors in SVS integration code (#4774)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4774

Fix FLAKE8 and CLANGTIDY lint errors in the SVS integration test file and index_factory to resolve CI failures from D88785138.

Reviewed By: mnorris11

Differential Revision: D91659701

fbshipit-source-id: 7bc3d47fdb76a620056295fcde9ac1b09769e2bb
2026-01-28 10:45:00 -08:00
Junjie Qi 79ec020cbe Enable Faiss for internal use (#4737)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4737

Add SVS as dependency of Faiss in BUCK files so we can use SVS internally. Also makes minor changes to index_read and index_factory to fix compiler warnings generated internally.

Reviewed By: mdouze

Differential Revision: D88785138

fbshipit-source-id: 975ade365cd6775582526aa2c852644ef4676610
2026-01-27 13:22:08 -08:00