70 Commits
Author SHA1 Message Date
Fadi Arafeh 39079668a8 Select OpenBLAS OMP build in conda for AArch64 + Linux (#5669)
Summary:
- The current Faiss conda recipe does not specify the OpenBLAS threading variant.
- On Linux AArch64, the dependency solver selects the pthreads build.
- This causes problems when Faiss calls BLAS from within an existing OpenMP parallel region due to nested threading
- As a result, the benchmark below (with an OOB conda install of faiss) only yields 7% of the throughput reachable when an OMP build of OpenBLAS is selected (what this PR does)
- This PR fixes the issue, and as a result accelerates affected workloads by ~ 14x
```
# SPDX-FileCopyrightText: Copyright 2026 Arm Limited and/or its affiliates <[email protected]>
# SPDX-License-Identifier: MIT

import ctypes
import statistics
import time

import faiss
import numpy as np

rng = np.random.default_rng(1234)
d = 128
nlist = 4096
nq = 40_000

quantizer = faiss.IndexFlatL2(d)
quantizer.add(rng.random((nlist, d), dtype=np.float32))
index = faiss.IndexIVFPQFastScan(quantizer, d, nlist, 128, 4)
# index is empty - this only triggeres the course quantizer
index.is_trained = True
index.nprobe = 64
xq = rng.random((nq, d), dtype=np.float32)

openblas = ctypes.CDLL("libopenblas.so.0")
openblas.openblas_get_parallel.restype = ctypes.c_int
openblas.openblas_get_num_threads.restype = ctypes.c_int

print(f"nq={nq:,}, d={d}, nlist={nlist}, nprobe={index.nprobe}")
print(f"OpenMP threads={faiss.omp_get_max_threads()}")
print(
    f"OpenBLAS parallel={openblas.openblas_get_parallel()}, "
    f"threads={openblas.openblas_get_num_threads()}"
)
print(f"BLAS threshold={faiss.cvar.distance_compute_blas_threshold}")

index.search(xq, 10)
times = []
for _ in range(20):
    start = time.perf_counter()
    index.search(xq, 10)
    times.append(time.perf_counter() - start)

elapsed = statistics.median(times)
print(f"median={elapsed:.6f}s, throughput={nq / elapsed:,.0f} QPS")
```

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

Reviewed By: weixianghong

Differential Revision: D124380509

Pulled By: mnorris11

fbshipit-source-id: 16e1521e7aaf7d65c6a4ce8e404a47bdb26c1198
2026-10-09 11:27:04 -07:00
Michael Norris 151452ec94 Fix SIMD level detection in Faiss (#5507)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5507

`SIMDConfig::has_dynamic_dispatch()` was defined inline in `simd_levels.h`, where it resolved `#ifdef FAISS_ENABLE_DD` at include time. That macro is only set while faiss itself is compiled, so any code outside the library that included the header always evaluated it to `false` — reporting that dynamic dispatch was unavailable even when linked against a faiss built with it enabled.

Callers using it to decide whether `SIMDConfig::set_level()` will do anything would therefore skip setting the SIMD level, and silently fall back to the auto-detected one.

Move the definition into `simd_levels.cpp`, which is compiled as part of the library and does see the macro. Callers now get the answer for the faiss they actually link against.

The function is no longer `constexpr` and so cannot be used in constant expressions. It had no such uses.

Also bumps the conda `openblas` pin for non-x86_64 platforms from 0.3.33 to 0.3.34, which is required to get the `Linux arm64 (conda)` build green. conda-forge now serves `libopenblas 0.3.34`, which depends on `openblas >=0.3.34,<0.3.35`, so the old pin left the environment unsolvable:

```
ExplainedDependencyNeedsBuildingError: Unsatisfiable dependencies for platform linux-aarch64
  - package libfaiss-1.15.0-py3.12_h3f4af3b_10_cpu requires openblas 0.3.33.*,
    but none of the providers can be installed
```

The separate `libopenblas` pins for osx are left at 0.3.33, since that package is resolving fine.

Reviewed By: junjieqi

Differential Revision: D115218647

fbshipit-source-id: 7163e18011dc9b82e93cd68fb600d24ef7012732
2026-08-10 12:49:24 -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
Michael Norris 6376bc35e3 Fix CI: (cuVS) conda shards cache lock, (ARM) bump openblas, (SVS) fix LeanVec double-destruction (#5209)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5209

Three fixes for GitHub Actions CI build/test failures:

1. sqlite3 "database is locked" error (cuVS cmake builds)

conda-libmamba-solver 26.4.0 uses a SQLite shards cache for package index
data. When consecutive conda install commands run in the same job step,
the SQLite lock from the first install is not fully released before the
second install begins, causing:
sqlite3.OperationalError: database is locked

Fix: Add conda clean --index-cache between the cuVS and PyTorch conda
installs to flush the shards cache and release the lock.

2. OpenBLAS version pin conflict (ARM64 conda builds)

conda-forge removed openblas 0.3.32, making it unresolvable. The conda
recipes pinned 0.3.32 for non-x86_64 (ARM64) and macOS builds, causing:
package libfaiss requires openblas 0.3.32.*, but none of the providers can be installed

Fix: Bump all openblas/libopenblas pins from 0.3.32 to 0.3.33 in the
conda recipes and from 0.3.29 to 0.3.33 in the cmake CI action.

3. Flaky SVS LeanVec test aborts (SVSLL tests)

IndexSVSVamanaLeanVec::~IndexSVSVamanaLeanVec() explicitly called
IndexSVSVamana::~IndexSVSVamana(), but C++ destructor chaining already
calls the base destructor automatically. This caused double-destruction of
base class members (notably std::vector<float> stored_vectors), resulting
in a double-free and non-deterministic SIGABRT. The IVF variant
(IndexSVSIVFLeanVec) correctly omits this call.

Fix: Remove the explicit base destructor call; let C++ handle it.

Reviewed By: pankajsingh88

Differential Revision: D104902441

fbshipit-source-id: c4ab80a4c1fdeb9976c4e089dfb95814284824a7
2026-05-13 10:12:43 -07:00
Matthijs Douze f750815512 Pin MKL to <2026 to avoid soname mismatch with pytorch (#5192)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5192

conda-forge added MKL 2026.0.0 which uses a new soname (libmkl_intel_lp64.so.3
instead of .so.2). The build env now resolves mkl-devel >=2024.2.2 to 2026.0.0,
but the test env gets mkl 2025.3.1 because pytorch 2.10.0 is pinned to that
version. This soname mismatch causes ImportError at test time.

Adding <2026 upper bound forces both build and test envs to use MKL 2025.x,
keeping sonames consistent until pytorch supports MKL 2026.

🤖 This diff was automatically generated by myclaw_faiss_monitor

Reviewed By: mnorris11

Differential Revision: D104219406

fbshipit-source-id: e4d256eade13fe4e193a8ed8a48bbdb53616898e
2026-05-08 08:06:24 -07:00
Michael Norris 6cef1bb08c Fix cuVS and ROCm CI conda environment failures (#5180)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5180

finally passes: https://github.com/facebookresearch/faiss/actions/runs/25449492630?pr=5180

Two GitHub Actions CI jobs are failing due to conda environment resolution issues.

**cuVS**: The `cuda-toolkit=12.9` metapackage includes visual tools (nsight-compute) that require `krb5 >=1.21.3,<1.22.0a0`, which conflicts with `mamba`/`libcurl` needing `krb5 >=1.22.2,<1.23.0a0`. It also has Windows-only variants requiring `__win`. Removing `cuda-toolkit=12.9` and keeping only `cuda-version=12.9` lets `libcuvs` pull in just the CUDA packages it actually needs.

**ROCm**: The latest miniforge ships `conda 25.7.0` with `conda-libmamba-solver 25.11.0`, which references `RepodataCache.cache_path_shards` — an attribute that does not exist in `conda 25.7.0`. The previous constraint `"conda<=25.07"` (numerically equal to `<=25.7.0`) did not force a downgrade. Pinning to `"conda<25.5"` along with `"conda-libmamba-solver<25.9"` ensures a compatible version pair.

Reviewed By: alibeklfc

Differential Revision: D103892827

fbshipit-source-id: 88c91a4741950cac4fe1f6ab56ae00fcf19c96cd
2026-05-06 15:15:52 -07:00
Gergely Szilvasy 6e64c5d687 Bump GCC pin in faiss-gpu conda recipe to fix AVX2 SIMD miscompilation (#5125)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5125

The faiss-gpu conda recipe pins `{{ compiler('cxx') }} =12.4` (GCC 12.4). GCC 12.4 miscompiles the 16-bin SIMD histogram reduction in `partitioning_simdlib256.h`, producing correct results for bins 0-7 but near-zero for bins 8-15. This causes `test_16bin_bounded_bigrange` in `TestHistograms_AVX2` to fail in the CUDA 12.6 GPU nightly.

The bug is in GCC 12's code generation for the AVX2 cross-lane reduction chain (`_mm256_hadd_epi16` → `_mm256_permute2f128_si256` → `_mm256_permutevar8x32_epi32`). GCC 13 and 14 both compile this correctly. The CPU-only `faiss/meta.yaml` leaves the compiler unpinned (gets GCC 14), which is why only the GPU nightly fails.

The GCC 12.4 pin was introduced in D84193438 as part of a batch nightly fix — not a deliberate CUDA compatibility constraint. CUDA 12.6 supports up to GCC 13.x as host compiler (GCC 14 requires CUDA 12.9+), so we widen the pin to `>=12.4,<14`.

Reproduced locally: GCC 12.4 fails, GCC 13.4 passes, GCC 14.2 passes — all on the same faiss source, same test, same machine.

Reviewed By: mdouze

Differential Revision: D101601476

fbshipit-source-id: 8e36c83a9df67ba66408faa4ca392e1bd46d7c87
2026-04-20 03:51:37 -07:00
ethanglaser aef066ac0e SVS 0.3.0 (#4999)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4999

Reviewed By: subhadeepkaran

Differential Revision: D98740733

Pulled By: mnorris11

fbshipit-source-id: 631a3f9c88a0b7fa456954e38dc9ddfc2f1c5dd2
2026-04-01 22:13:10 -07:00
Matthijs Douze 9af8384f14 Bump openblas from 0.3.30 to 0.3.32 in conda recipes (#4994)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4994

🤖 This diff was automatically generated by myclaw_faiss_monitor

The arm64 nightly build (Linux arm64) started failing on Mar 26 because
conda-forge removed openblas 0.3.30 for linux-aarch64. The solver cannot
satisfy the exact pin `openblas =0.3.30` since only 0.3.32 is available.

Fix: bump `openblas =0.3.30` to `=0.3.32` in all three conda recipes
(faiss, faiss-gpu, faiss-gpu-cuvs) for the `# [not x86_64]` targets
(arm64 Linux). OSX libopenblas pins are unaffected (different package).

Reviewed By: mnorris11

Differential Revision: D98293081

fbshipit-source-id: d2371a6e1bf1c920fb130cc35fb385ec43aa8e56
2026-03-26 14:35:08 -07:00
Michael Norris 645a742b51 Re add cuvs to cmakelists.txt (#4953)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4953

Reviewed By: scsiguy

Differential Revision: D97118209

fbshipit-source-id: f29135b7801664fbbf8cb65c836ad1a92b2193db
2026-03-19 08:06:00 -07:00
Michael Norris 5622e93733 v1.14.1 Fix build-release (#4876)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4876

Reviewed By: alibeklfc

Differential Revision: D95420200

fbshipit-source-id: b30d0c9c0342460187c3b8dcffbbc3df88f4a11d
2026-03-06 09:33:08 -08:00
ethanglaser 6cf2c63bc3 Update SVS to v0.2.0 and install from conda forge (#4860)
Summary:
Installs [SVS v0.2.0](https://github.com/intel/ScalableVectorSearch/releases/tag/v0.2.0) which includes updates for LeanVec OOD and IVF to be integrated in subsequent PRs. Also removes intel conda channel logic as libsvs-runtime is now available on conda-forge.

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

Reviewed By: alibeklfc

Differential Revision: D95164622

Pulled By: mnorris11

fbshipit-source-id: 3b2bbaa8c5283e6aa5ac5ee250e8eac4ccba0e5a
2026-03-06 09:20:55 -08:00
ethanglaser c5ae3d0710 Enable use of svs runtime conda package instead of tarball (#4747)
Summary:
This PR migrates from using SVS via tarball to using a conda package

Currently the package is available at the intel channel. In future releases, it will be available from conda-forge and the channel configuration can be removed

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

Reviewed By: subhadeepkaran

Differential Revision: D91484831

Pulled By: alibeklfc

fbshipit-source-id: b94dba1f03b4083ae8aa35cdd258ad71c421d30b
2026-01-26 12:48:57 -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
Michael Norris 2964a374db Fix nightly by updating mkl version (#4604)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4604

Nightly for GPU builds (cuvs and non-cuvs) is failing again after numpy2 upgrade.
- Fixed it by upgrading CUDA, using the right deps (pytorch-gpu instead of the deprecated pytorch-cuda), pinning pytorch >=2.7 for GPU builds, upgrading MKL
- SVE requires pytorch<2.5 for the testing flow, otherwise it times out for 1 test.

Reviewed By: subhadeepkaran

Differential Revision: D84193438

fbshipit-source-id: 71868d5f9deb973ee431e10ee765a450d4f1f876
2025-10-10 15:11:44 -07:00
Michael Norris 4fab13c9c6 Upgrade Faiss OSS side to numpy2 (#4523)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4523

This upgrades OSS Faiss to numpy 2.3.3. I tried to fix issues based on https://numpy.org/devdocs/numpy_2_0_migration_guide.html.

Overall, numpy2 causes some test issues on various platforms/optimization levels.

Test changes that are OK:
- test_contrib.py: test_float: changing to use item(): this is just the new way of getting the value, like recommended in the migration guide.

Test changes that indicate some problem:
- test_contrib.py: test_ivf_train_2level: This fails on many platforms (avx2, conda installs). I could not find what the issue was. I had to increase the bounds slightly.
- test_index_accuracy.py: test_OIVFPQ: This fails just on AVX512. I had to increase the iterations from 10 to 12.
- test_local_search_quantizer.py and test_standalone_codec.py: Some of these break on Windows. Others needed lighter tolerances.

Debugging attempts: Especially for test_ivf_train_2level, I tried to unsuccessfully track down what might have changed. I suspected the type promotion change from numpy1 to 2.
```
- np.float32(3) + 3. now returns a float32 when it previously returned a float64.
- np.array([3], dtype=np.float32) + np.float64(3) will now return a float64 array. (The higher precision of the scalar is not ignored.)
```
I changed all datasets to be explicitly float64s, and checked for any constants in the code path. No luck.

Devmate was less than useless, it was actively a waste of time (as usual...)

Reviewed By: subhadeepkaran

Differential Revision: D79900113

fbshipit-source-id: 541cfa6f1fa1d60c84d855ce71f0e1de7ea7c7f1
2025-10-02 09:49:05 -07:00
Michael Norris 43736dd8ed try to add nightly conda publish for Faiss classic GPU with CUDA 12.4 (#4442)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4442

Trying to set up conda nightly for 12.4.

It already works in cmake, builds are using 12.4 by default

Reviewed By: ramilbakhshyiev

Differential Revision: D78716765

fbshipit-source-id: 1a7c0d71da40e58df2036647f39aab967cf676ff
2025-07-25 10:08:05 -07:00
Michael Norris b6e6ec61ad Pin openblas 0.3.30 to fix nightly breakage (#4404)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4404

Reviewed By: limqiying

Differential Revision: D77027464

fbshipit-source-id: 5b67764691b2bbde41c2b75c027cda5f6ae86a4f
2025-06-20 13:13:20 -07:00
Kaival Parikh 13255a8bf0 Publish the C API to Conda (#4186)
Summary:
Addresses https://github.com/facebookresearch/faiss/issues/4181

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

Reviewed By: junjieqi

Differential Revision: D70328657

Pulled By: mnorris11

fbshipit-source-id: a8bda4f3342af557369b625e8ace13e9a1d92d65
2025-03-30 20:11:39 -07:00
Michael Norris 20c7ca35bb Upgrade openblas to 0.3.29 for ARM architectures (#4203)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4203

Related to issue: https://github.com/facebookresearch/faiss/issues/4202

Reviewed By: mengdilin

Differential Revision: D69933126

fbshipit-source-id: cafc5f34d0f91450c5067827756b1297684b0ce3
2025-02-21 17:46:25 -08:00
Michael Norris d72d0cab6b Fix nightly by installing earlier version of lief (#4198)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4198

1. pins lief due to `AttributeError: type object 'CLASS' has no attribute 'CLASS64'` (just set it to last passing nightly version)
2. pins mkl in gpu builds due to it trying to pull in 2024.2.2 which conflicts with 2023 in the libfaiss.

Added nightlies to make sure they pass https://github.com/facebookresearch/faiss/actions/runs/13422430425/job/37498020894. Not all passed: I'm not sure the `build-pull-request / Linux x86_64 GPU w/ cuVS nightlies (CUDA 12.4.0)` nightly is actually broken, but this unblocks the PR builds for now.

Reviewed By: junjieqi

Differential Revision: D69860604

fbshipit-source-id: 2da623c71b03c22d581b78655253a863fbafd3ed
2025-02-19 21:44:03 -08:00
Michael Norris 32beb162f2 Migration off defaults to conda-forge channel (#4126)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4126

Good resource on overriding channels to make sure we aren't using `defaults`:https://stackoverflow.com/questions/67695893/how-do-i-completely-purge-and-disable-the-default-channel-in-anaconda-and-switch

Explanation of changes:
-
- changed to miniforge from miniconda: this ensures we only pull in from conda-defaults when creating the environment
- architecture: ARM64 and aarch64 are the same thing. But there is no miniforge package for ARM64, so we need to make it check for aarch64 instead. However, mac breaks this rule, and does have macOS-arm64! So there is a conditional for mac to use arm64. https://github.com/conda-forge/miniforge/releases/
- action.yml mkl 2022.2.1 change: conda-forge and defaults have completely different dependencies. Defaults required intel-openmp, but now on conda-forge, mkl 2023.1 or higher requires llvm-openmp >=14.0.6, but this is incompatible with the pytorch build <2.5 which requires llvm-openmp<14.0. We would need to upgrade Python to 3.12 first, upgrade Pytorch build, then upgrade this mkl. (The meta.yaml changes are the ones that narrow it to 2022.2.1 during `conda build faiss`.) So, this has just been changed to 2022.2.1.
- mkl now requires _openmp_mutex of type "llvm" instead of "gnu": prior non-cuVS builds all used gnu, because intel-openmp from anaconda defaults channel does not require llvm-openmp. Now we need to remove the gnu one which is automatically pulled in during miniconda setup, and only keep the llvm version of _openmp_mutex.
- liblief: The above changes tried to pull in liblief 0.15. This results in an error like `AttributeError: module 'lief._lief.ELF' has no attribute 'ELF_CLASS'`. When I checked passing PR builds on defaults, they use lief 0.12, so I pinned that one for Python 3.9 3.10 3.11. For Python 3.12, we need lief 0.14 or higher.
- gcc_linux-64 =11.2 for faiss-gpu on cudatoolkit-11.2: GPU builds kept trying to reference 11.2 when 14.2 was installed. I couldn't figure out why, or how to point it to the 14.2 installed on the host. Current nightly builds still reference 11.2, so I gave up and pinned 11.2 to keep it the same. Moving to 14.2 will take some more investigation.
- meta.yaml mkl 2023.0 vs 2023.1 with python versions: 3.9, 3.10, and 3.11 pass with 2023.0, but python 3.12 needs mkl 2023.1 or higher. Otherwise we get:
```
INTEL MKL ERROR: $PREFIX/lib/python3.12/site-packages/faiss/../../.././libmkl_def.so.2: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8.
Intel MKL FATAL ERROR: Cannot load libmkl_def.so.2.
```
so the solution was to put a bunch of conditions in in faiss/meta.yaml.
We should be able to use Jinja macros to reduce duplication but it requires some investigation. It was failing: https://github.com/facebookresearch/faiss/actions/runs/12915187334/job/36016477707?pr=4126  (paste of logs here: P1716887936). This can be a future BE task.
Macro example (the `-` signs remove whitespace lines before and after)
```
{% macro inclmkldevel() %}
{%- if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' -%}
        - mkl-devel =2023.0  # [x86_64]
        - liblief =0.12.3  # [not win]
        - python_abi <3.12
{%- elif PY_VER == '3.12' %}
        - mkl-devel >=2023.2.0  # [x86_64]
        - liblief =0.15.1  # [not win]
        - python_abi =3.12
{% endif -%}
{% endmacro %}
```
The python_abi was required to be pinned inside these conditions because otherwise several builds got this error:
```
File "/Users/runner/miniconda3/lib/python3.12/site-packages/conda_build/utils.py", line 1919, in insert_variant_versions
        matches = [regex.match(pkg) for pkg in reqs]
                   ^^^^^^^^^^^^^^^^
    TypeError: expected string or bytes-like object, got 'list'
```

Unit test notes:
-
- test_gpu_basics.py: GPU residual quantizer: Debugged extensively with Matthijs. The problem is in the C++ -> Python conversion. The C++ side prints the right values, but when getting it back to Python, it is filled with junk data. It is only reproducible on CUDA 11.4.4 after switching channels. It is likely a compiler problem. We discussed, and resolved to create a C++ side unit test (so this diff creates TestGpuResidualQuantizer) to verify the functionality and disable the Python unit test, but leave it in the codebase with a comment. Matthijs made extensive notes in https://docs.google.com/document/d/1MjMdOpPgx-MArdrYJZCaQlRqlrhSj5Y1Z9lTyiab8jc/edit?usp=sharing .
- test_contrib.py: this now hangs forever and times out the runner for Windows on Python 3.12. I have it skipping now.
- test_mem_leak.cpp seems flaky. It sometimes fails, then passes with rerun.

Unfixed issues:
-
- I noticed sometimes downloads will fail with the text like below. It passes on re-run.
```
libgomp-14.2.0-h77fa898_1.conda extraction failed
  Warning: error    libmamba Error when extracting package: Could not chdir info/recipe/parent/patches/0005-Hardcode-HAVE_ALIGNED_ALLOC-1-in-libstdc-v3-configur.patch

  error    libmamba Error when extracting package: Could not chdir info/recipe/parent/patches/0005-Hardcode-HAVE_ALIGNED_ALLOC-1-in-libstdc-v3-configur.patch
  Warning: Found incorrect download: libgomp. Aborting

  Found incorrect download: libgomp. Aborting
  Warning:
```

Green build and tests for both build pull request and nightlies: https://github.com/facebookresearch/faiss/actions/runs/12956402963/job/36148818361

Reviewed By: asadoughi

Differential Revision: D68043874

fbshipit-source-id: b105a1e3e6272763ad9daab7fc6f05a79f01c9e2
2025-01-27 14:49:18 -08:00
Junjie Qi 66c989a173 Pin Nightlies with testing on PR (#4088)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4088

Test Plan: https://github.com/facebookresearch/faiss/actions/runs/12325339739

Reviewed By: gtwang01

Differential Revision: D67227820

Pulled By: junjieqi

fbshipit-source-id: c516ea6c26415f521dff90f7de1ab6e65d173e44
2024-12-16 10:50:44 -08:00
Junjie Qi d997ea0cd6 fix nightily build (#4080)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4080

Reviewed By: mnorris11

Differential Revision: D67002610

Pulled By: junjieqi

fbshipit-source-id: fb561d7bb4b23866daa0b992694fcc393e595312
2024-12-09 21:15:42 -08:00
Junjie Qi 1ac6f3746b Pin conda build (#4062)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4062

Reviewed By: mengdilin

Differential Revision: D66802452

Pulled By: junjieqi

fbshipit-source-id: c4b59a17fb2385269bcceb51a81390b65130b5c8
2024-12-05 09:37:19 -08:00
Tarang Jain 134922061c Migrate from RAFT to CUVS (#3549)
Summary:
Remove the dependency on `raft::compiled` and modify GPU implementations to use cuVS backend in place of RAFT.

A deeper insight into the dependency:
FAISS gets the ANN algorithm implementations such as IVF-Flat and IVF-PQ from cuVS. RAFT is meant to be a lightweight C++ header-only template library that cuVS relies on for the more fundamental / low-level utilities. Some examples of these are RAFT's device mdarray and mdspan objects; the RAFT resource object (`raft::resource`) that takes care of the stream ordering of device functions; linear algebra functions such as mapping, reduction, BLAS routines etc. A lot of the cuVS functions take the RAFT mdspan objects as arguments (for example `raft::device_matrix_view`). Therefore FAISS relies on both cuVS and RAFT. FAISS gets RAFT headers through cuVS and uses them to create the function arguments that can be consumed by cuVS. Note that we are not explicitly linking FAISS against `raft::raft` or `raft::compiled`. Only the required headers are included and compiled rather than compiling the whole RAFT shared library. This is the reason we still see mentions of `raft` in FAISS.

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

Reviewed By: ramilbakhshyiev

Differential Revision: D62041013

Pulled By: asadoughi

fbshipit-source-id: 7230dcc06cf47baf95873adc1dec2adca4a8f82a
2024-11-14 11:30:16 -08: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
Michael Norris cb1a512fb3 Back out "Add example of how to build, link, and test an external SWIG module" (#3954)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3954

Original commit changeset: 0c1cd25eabbf

Original Phabricator Diff: D63991471

Reviewed By: mengdilin, asadoughi

Differential Revision: D64439886

fbshipit-source-id: cc90958f6d90a429a4eece8e1cd1322b20d9aceb
2024-10-15 19:01:46 -07:00
Michael Norris 847cde8652 Add example of how to build, link, and test an external SWIG module (#3922)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3922

We need to be able to build external modules into FAISS, but don't have an example yet. This diff shows what CMakeLists.txt changes need to happen to incorporate an external module.

Reference: https://github.com/facebookresearch/faiss/pull/3699/

Reviewed By: mdouze

Differential Revision: D63991471

fbshipit-source-id: 0c1cd25eabbffb01d2a7170d6725a0c4a13c5bf0
2024-10-11 09:32:08 -07:00
Ramil Bakhshyiev a60a9e56c6 Fix CUDA 11.4.4 builds under CircleCI (#3466)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3466

Flattening Conda include directories breaks CUDA 11.4.4 build on Ubuntu 20 / v5 kernel. This change updates the logic to only flatten includes on Ubuntu 22 / v6 kernel (aka as running on GitHub Actions runners).

Reviewed By: algoriddle

Differential Revision: D57602154

fbshipit-source-id: 00c14ca7c64644b8b86483ac6b4d40c6d8f12372
2024-05-21 09:07:47 -07:00
Ramil Bakhshyiev 8c95c6943b Fix linter warnings in faiss-gpu Conda build script (#3463)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3463

Satisfying linter warnings from a previous change

Reviewed By: junjieqi

Differential Revision: D57581364

fbshipit-source-id: 9e9b7f963a27d2da54d0e85390cce2f9f773c502
2024-05-20 14:30:36 -07:00
Ramil Bakhshyiev 0c983f361b Workaround for CUDA 11.4.4 build in Conda on Ubuntu 22 / v6 kernel (#3459)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3459

When building with CUDA 11.4.4, CMake does not properly include files under Conda environment. This workaround flattens the include sub-directories in to the include root. It will unblock us for now while we are looking for a fix through CMakeLists files or figure out if it's a CMake bug and it gets fixed.

Reviewed By: junjieqi

Differential Revision: D57545169

fbshipit-source-id: 9cbdd0866e00e899cc889930a59448da55d873c2
2024-05-20 12:50:08 -07:00
Ramil Bakhshyiev 2050a03090 Add cuda-toolkit package dependency to faiss-gpu and faiss-gpu-raft conda build recipes (#3440)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3440

This change is required to unblock the migration to GitHub Actions. `cuda-toolkit` was only specified in the `libfaiss` package and it was not available in `faiss-gpu` or `faiss-gpu-raft`. This currently works on CircleCI because the runner image has CUDA toolkit of the needed version installed on the system and the build logic falls back to that but breaks on GitHub Actions because their runner images do not come with CUDA toolkit pre-installed.

Reviewed By: junjieqi

Differential Revision: D57371597

fbshipit-source-id: 8bededd53e2528f033fac797b296d74b47f9403e
2024-05-15 13:06:00 -07:00
iotamudelta 0169f29f37 Update required cmake version to 3.24. (#3305)
Summary:
The CMakeLists.txt in faiss/gpu uses the $<LINK_LIBRARY:WHOLE_ARCHIVE expression which requires at least cmake 3.24.

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

Reviewed By: mlomeli1

Differential Revision: D56234500

Pulled By: algoriddle

fbshipit-source-id: dfe7df3379c5250dedec7d1988cffa889fc1c393
2024-04-17 03:43:57 -07:00
Gergely Szilvasy ed3f6e5fdf faiss-gpu to use 11.4.4 and be the only one supporting P100 (#3237)
Summary:
Considering that only GPU classic works on Pascal and only if compiled with cuda 11.4, this sets up the conda builds as follows.

tl;dr: Pascal will only be supported by faiss-gpu on cuda 11.

## faiss-gpu
1. build on cuda 11.4.4, supports Pascal, works with pytorch-cuda=11 (including hosts with cuda 12 drivers)
2. build on cuda 12.1.1, does NOT support Pascal, works with pytorch-cuda=12

## faiss-gpu-raft
1. build on cuda 11.8.0, does NOT support Pascal, works with pytorch-cuda=11.8
2. build on cuda 12.1.1, does NOT support Pascal, works with pytorch-cuda=12

The reason faiss-gpu-raft is built with and supports only 11.8 is due to the risk of clobbering otherwise between libraft and pytorch-cuda dependencies.

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

Reviewed By: mdouze

Differential Revision: D53354121

Pulled By: algoriddle

fbshipit-source-id: 86108e975168759572f84922bf0ccef55ae75ef8
2024-02-02 09:01:10 -08:00
Gergely Szilvasy c1822a81b2 cuda dependencies (#3230)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3230

Reviewed By: mlomeli1

Differential Revision: D53271742

Pulled By: algoriddle

fbshipit-source-id: b0f09e26ab0b4cfcbdb10528b2f57e15c10f4265
2024-01-31 14:25:13 -08:00
Gergely Szilvasy 31bddeb0cf add faiss_gpu lib (#3222)
Summary:
1. Split the GPU code into a separate static library to reduce build times.
2. faiss-gpu now depends on pytorch-cuda to stop clobbering of CUDA libraries when Faiss and Pytorch installed in the same environment
3. Add CUDA 12 (we support both 11.8 and 12.1)
4. Add Python 3.12

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

Reviewed By: mlomeli1

Differential Revision: D53215033

Pulled By: algoriddle

fbshipit-source-id: d48c5707af20b7e5ff72c3aa27b0e677259f22f8
2024-01-30 01:44:50 -08:00
Kota Yamaguchi c540e762ca Use packaging instead of deprecated distutils for version handling (#3191)
Summary:
This PR replaces deprecated `distutils.version.LooseVersion` with [`packaging.version.Version`](https://packaging.pypa.io/en/stable/index.html). This change is needed to support CPython 3.12+.

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

Reviewed By: algoriddle

Differential Revision: D52872218

Pulled By: mlomeli1

fbshipit-source-id: 336b2a618fde0a65d70b53c7d8a27aef3b62ece1
2024-01-18 11:15:03 -08:00
Gergely Szilvasy 0013c702f4 avx512 CI + conda packages (#3197)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3197

Reviewed By: mlomeli1

Differential Revision: D52689379

Pulled By: algoriddle

fbshipit-source-id: 54e27c6d310d6da14777ae10ae62f46e7076cacf
2024-01-11 08:26:33 -08:00
Gergely Szilvasy 6c89c8bd4e fix faiss-gpu nightly
Summary: Forcing cudatoolkit to 11.8 to work around cudatoolkit vs cuda-cudart clobbering: https://app.circleci.com/pipelines/github/facebookresearch/faiss/4845/workflows/baee8356-31c5-44e8-ae98-44f897967557/jobs/26451?invite=true#step-105-335068_80

Reviewed By: mlomeli1

Differential Revision: D50924919

fbshipit-source-id: 590f39d1292ec64af7e179e764b8e7ac26108962
2023-11-02 03:09:40 -07:00
Gergely Szilvasy 0c07a114ad fix raft contbuild and switch to libraft 23.12 (#3116)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3116

Test Plan: https://app.circleci.com/pipelines/github/facebookresearch/faiss/4839/workflows/cfd84a94-ca60-4128-96e6-db0f5afc69c4

Reviewed By: mdouze

Differential Revision: D50897934

Pulled By: algoriddle

fbshipit-source-id: 1422be39d640a2aec3ab6b4c68d3ef54900b5ba2
2023-11-01 14:37:21 -07:00
Gergely Szilvasy c00fe254e4 faiss-gpu-raft, fix dispatch test (#3017)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3017

Somehow this got mixed up with the deleted install-cmake.sh

Reviewed By: mlomeli1

Differential Revision: D48496314

fbshipit-source-id: 851a5f9222d74e7681c8dcddded83dd8f9945591
2023-08-19 10:26:36 -07:00
Gergely Szilvasy 2768fb38b2 faiss-gpu-raft package (#2992)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2992

Reviewed By: mdouze

Differential Revision: D48391366

Pulled By: algoriddle

fbshipit-source-id: 94b7f62afc8a09a9feaea47bf60e5358d89fcde5
2023-08-16 09:30:41 -07:00
Gergely Szilvasy 726143d056 install libraft for cmake build (#2968)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2968

Reviewed By: mlomeli1, mdouze

Differential Revision: D47677660

Pulled By: algoriddle

fbshipit-source-id: 8fad8323ea3c0a264149c76fc9519d9c63346d00
2023-07-31 07:37:27 -07:00
Gergely Szilvasy e153cac419 fix the osx nightly build (#2896)
Summary:
Based on comments in https://github.com/conda/conda-build/issues/4498

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

Reviewed By: mdouze

Differential Revision: D46802512

Pulled By: algoriddle

fbshipit-source-id: 7449b2f0db08fdd793770a44afb659d7ac28e3cd
2023-06-16 13:01:17 -07:00
Gergely Szilvasy f809cf0d51 fix osx openmp (#2857)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2857

Reviewed By: alexanderguzhva

Differential Revision: D45791625

Pulled By: algoriddle

fbshipit-source-id: 52ec30f0ec66812f60a08843947aabe8be876afa
2023-05-12 09:07:50 -07:00
Gergely Szilvasy eea4a48b97 pin mkl to 2023 (#2856)
Summary:
This fixes the build, except for MacOS, where there's a problem with cmake + OpenMP. We can fix it separately.

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

Reviewed By: mlomeli1

Differential Revision: D45704458

Pulled By: algoriddle

fbshipit-source-id: 0c09036ae5fa34ab114b857f407a35603986613a
2023-05-09 12:20:54 -07:00
Gergely Szilvasy a3d6212983 upgrade cmake to 3.23.1 (#2808)
Summary:
RAFT requires cmake 3.23.1, pulling it from conda-forge. We continue to keep the dependency on conda-forge minimal, hence the ordering of the channels and the pinning of sysroot to a specific version.

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

Test Plan:
contbuild

Imported from GitHub, without a `Test Plan:` line.

Reviewed By: mlomeli1

Differential Revision: D44746827

Pulled By: algoriddle

fbshipit-source-id: ad576b11b257203bd0cafd57c2c2e7fd8d10ca98
2023-04-06 06:25:51 -07:00
Gergely Szilvasy 7bf645e344 GPU builds without Docker (#2803)
Summary:
1. GPU builds use CircleCI base image, no docker
2. Switched to CUDA 11.4 (used to be 11.3)
3. Merged all build jobs into two parameterized targets: `build_cmake` and `build_conda`.
4. Cleaned up test execution, fixed bug of Python GPU tests not running on PRs

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

Reviewed By: mlomeli1

Differential Revision: D44541714

Pulled By: algoriddle

fbshipit-source-id: aa09ae638ecb6ef556d42f27a4bfaddad7355e50
2023-03-30 10:45:54 -07:00
Gergely Szilvasy 766f9c8e93 add python 3.10 (#2791)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2791

Removed building for 3.7 (D44373285 - not supported for M1), adding 3.10 with this diff.

The only change that matters is in `conda_build_config.yaml`, the others are about making the configs consistent between CPU and GPU.

Reviewed By: mlomeli1

Differential Revision: D44405573

fbshipit-source-id: ad933e08834593e55a35075c602e5f509a813e73
2023-03-27 04:41:14 -07:00