7 Commits
Author SHA1 Message Date
Matthijs Douze 8d1b964c11 Enable dynamic dispatch build on Windows (#5127)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5127

Attempt to enable FAISS dynamic dispatch (DD) mode on Windows/MSVC.

Changes:
- CMakeLists.txt: Remove if(NOT WIN32) guard from DD section, add MSVC per-file
  SIMD flags (/arch:AVX2, /arch:AVX512, /bigobj) alongside existing GCC/Clang flags
- build-pull-request.yml: Add windows-x86_64-DD-cmake job that runs immediately
  (no dependency on linux-x86_64-cmake), builds with MSVC and FAISS_OPT_LEVEL=dd,
  runs C++ tests and Python tests

This diff is expected to fail on Windows due to MSVC requiring explicit template
specialization declarations (C++ §17.8.3) which GCC/Clang don't enforce. The CI
failure will surface the exact errors to guide the fix.

UPDATE: in fact, MSVC does not seem to require this. After fixing build scripts and a few classical Windows error, the C++ and python tests pass.

Reviewed By: algoriddle

Differential Revision: D101649751

fbshipit-source-id: 765ef8483d02652ce58625cd22baab8870acf718
2026-04-23 13:31:11 -07:00
Fabrizio (Misto) Milo b068fd985a Support IO_FLAG_MMAP_IFC on Darwin (#5058)
Summary:
Extend the POSIX mmap reader to Apple platforms and use MAP_FAILED for mmap error checks while keeping madvise best-effort.

Update the C++ and Python mmap tests to exercise Darwin, and stop linking faiss_test against the Python example extension so Python-enabled test builds can run on macOS.

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

Reviewed By: junjieqi

Differential Revision: D100351635

Pulled By: alibeklfc

fbshipit-source-id: f384251a634c7d3154103dbc763293b52b093ee8
2026-04-10 15:31:51 -07:00
Justin Gibbs 2e56328b80 Update callers to use read_index_up API (#4818)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4818

Update call sites that were wrapping read_index/read_index_binary in
unique_ptr to use the new read_index_up/read_index_binary_up functions
directly.

Reviewed By: junjieqi

Differential Revision: D93151783

fbshipit-source-id: a71f0060a5ecea28f7aaf53b9867efc53cb06f54
2026-02-20 10:01:09 -08:00
Aditya Vidyadhar Kamath a3cd63fb6a Skip mmap test case in AIX. (#4275)
Summary:
In AIX, the recent mmap feature is not implemented. So we can skip these test case.

In our internal CI's when we run the test cases, we have two failures.
 21/132 Test  https://github.com/facebookresearch/faiss/issues/21: TestMmap.mmap_flatcodes ...........................................***Failed    0.03 sec
        Start  22: TestMmap.mmap_binary_flatcodes
 22/132 Test  https://github.com/facebookresearch/faiss/issues/22: TestMmap.mmap_binary_flatcodes ....................................***Failed    0.04 sec

Currently these two test cases run since it is written in C. We want to block them like the PR [here](https://github.com/facebookresearch/faiss/commit/df9e2c48d6504fbc6052743aee6bf0b3e4b1f486#diff-26824e205001fe146a1634cf74c1dda1cdb8a07b6216545990b773a12da705d4R15-R489) does.

Kindly let me know what you think.

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

Reviewed By: junjieqi

Differential Revision: D72483472

Pulled By: bshethmeta

fbshipit-source-id: ad13b2dc2797ee51e670e01800d1f8ba0f6632c1
2025-04-16 22:50:42 -07:00
Matthijs Douze 1debb7d812 re-land mmap diff (#4250)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4250

This is an attempt to re-land the diff stack D69972250  D70982449

It was reverted because the bottom of the stack did not pass the tests.

The original code comes from Alexandr Guzhva's  https://github.com/facebookresearch/faiss/pull/4199

To the adsmarket steward: the diff was already accepted by your team (see D70982449), but reverted for an independent reason. So should be easy to accept now.

Reviewed By: mengdilin

Differential Revision: D71614511

fbshipit-source-id: 94139b4a4d457afe0d37ac95342537414aa81e7a
2025-03-24 09:56:45 -07:00
Saumya Agarwal 15491a1e4f Revert D69972250: Memory-mapping and Zero-copy deserializers
Differential Revision:
D69972250

Original commit changeset: 98a3f94d6884

Original Phabricator Diff: D69972250

fbshipit-source-id: 1bea8b8a26c14061a01f8b26b66f0c4e6a75f550
2025-03-11 11:43:17 -07:00
Alexandr Guzhva 55a3c2aff4 Memory-mapping and Zero-copy deserializers (#4199)
Summary:
This PR introduces a backport of a combination of https://github.com/zilliztech/knowhere/pull/996 and https://github.com/zilliztech/knowhere/pull/1032 that allow to have memory-mapped and zerocopy indces.

The root underlying idea is that we replace certain `std::vector<>` containers with a custom `faiss::MaybeOwnedVector<>` container, which may behave either as `std::vector<>`, or as a view of a certain pointer / descriptor. We don't replace all the instances of `std::vector<>`, but the largest ones.

This change affects `IndexFlatCodes`-based and `IndexHNSW` CPU indices.

(done) alter IVF lists as well.
(done) alter binary indices as well.

Memory-mapped index works like this:
```C++
std::unique_ptr<faiss::Index> index_mm(
            faiss::read_index(filenamename.c_str(), faiss::IO_FLAG_MMAP_IFC));
```
In theory, it should be ready to be used from Python. All the descriptor management should be working.

Zero-copy index works like this:
```C++
#include <faiss/impl/zerocopy_io.h>

faiss::ZeroCopyIOReader reader(buffer.data(), buffer.size());
std::unique_ptr<faiss::Index> index_zc(faiss::read_index(&reader));
```
All the pointer management for `faiss::ZeroCopyIOReader` should be handled manually.
I'm not sure how to plug this into Python yet, maybe, some ref-counting is required.

(done) some refactoring

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

Reviewed By: mengdilin

Differential Revision: D69972250

Pulled By: mdouze

fbshipit-source-id: 98a3f94d6884814873d3534ee25f960892ef1076
2025-03-11 11:11:14 -07:00