1065 Commits

Author SHA1 Message Date
Matthijs Douze
783e044a2d support big-endian machines (#3361)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3361

Fix a few issues in the PR.
Normally all tests should pass on a litlle-endian machine

Reviewed By: junjieqi

Differential Revision: D56003181

fbshipit-source-id: 405dec8c71898494f5ddcd2718c35708a1abf9cb
2024-04-24 05:40:49 -07:00
Aditya Vidyadhar Kamath
67574aabbc Fix the endianness issue in AIX while running the benchmark. (#3345)
Summary:
This pull request is for issue https://github.com/facebookresearch/faiss/issues/3330. This patch makes sure that packed code arrays are in big endian format. Kindly let us know if we need any changes or if we can have a better approach.

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

Reviewed By: junjieqi

Differential Revision: D55957630

Pulled By: mdouze

fbshipit-source-id: f728f9563f6b942af9d8899b54662d7ceb811206
2024-04-24 05:40:49 -07:00
Carl Love
b2e91f685e Unroll loop in lookup_2_lanes (#3364)
Summary:
The current loop goes from 0 to 31.  It has an if statement to do an assignment for j < 16 and a different assignment for j >= 16.  By unrolling the loop to do the j < 16 and the j >= 16 iterations in parallel the if j < 16 is eliminated and the number of loop iterations is reduced in half.

Then unroll the loop for the j < 16 and the j >=16 to a depth of 2.

This change results in approximately a 55% reduction in the execution time for the bench_ivf_fastscan.py workload on Power 10 when compiled with CMAKE_INSTALL_CONFIG_NAME=Release.

The removal of the if (j < 16) statement and the unrolling of the loop removes branch cycle stall and register dependencies on instruction issue. The result is the unrolled code is able issue instructions earlier thus reducing the total number of cycles required to execute the function.

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

Reviewed By: kuarora

Differential Revision: D56455690

Pulled By: mdouze

fbshipit-source-id: 490a17a40d9d4439b1a8ea22e991e706d68fb2fa
2024-04-24 02:05:48 -07:00
Junjie Qi
5893ab77da remove unused code (#3371)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3371

This will never happen because N is fixed at compile time and the buffer is large enough. It is misleading to add error handling code for a case that will never happen.

Reviewed By: kuarora

Differential Revision: D56274458

fbshipit-source-id: ca706f1223dbc97e69d5ac9750b277afa4df80a7
2024-04-22 09:30:05 -07:00
Junjie Qi
3677ab5021 Switch clang-format-11 to clang-format-18 (#3372)
Summary:
In this commit ab2b7f5093, they changed format based on clang-format-18. However, we still use clang-format-11 in our circle ci job which caused the failure. In this PR, we are going to switch to clang-format-18

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

Reviewed By: kuarora

Differential Revision: D56280363

Pulled By: junjieqi

fbshipit-source-id: f832ab2112f762e6000b55a155e3e43fe99071d7
2024-04-19 13:55:15 -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
Andres Suarez
ab2b7f5093 Apply clang-format 18
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
2024-04-14 11:28:32 -07:00
Richard Barnes
a35eb0ac11 Remove unused variables in faiss/IndexIVF.cpp
Summary:
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: dmm-fb

Differential Revision: D56065763

fbshipit-source-id: b0541b8a759c4b6ca0e8753fc24b8c227047bd3d
2024-04-12 13:03:17 -07:00
Junjie Qi
acd06d6211 Switch sprintf to snprintf (#3363)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3363

'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead

{F1484071654}

Reviewed By: kuarora

Differential Revision: D56009251

fbshipit-source-id: ec222cf589ff98b016979058d59fc20cccec8f43
2024-04-12 10:52:31 -07:00
Matthijs Douze
40e8643336 selector parameter for FastScan (#3362)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3362

Add test to Alex' PR

Reviewed By: junjieqi

Differential Revision: D56003946

fbshipit-source-id: 5a8a881d450bc97ae0777d73ce0ce8607ec6b686
2024-04-11 14:23:46 -07:00
Alexandr Guzhva
17fbeb8d7e Improve filtering & search parameters propagation (#3304)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3304

Reviewed By: junjieqi

Differential Revision: D55823369

Pulled By: mdouze

fbshipit-source-id: c0e9f4b85d979758f02e9953f3706b63a846bf22
2024-04-11 14:23:46 -07:00
Kumar Saurabh Arora
252ae16ea3 Support for Remove ids from IVFPQFastScan index (#3354)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3354

**Change was previously reverted because of build failure as change D55577576 removed the definition of FAISS_THROW_IF_MSG**

**Context**
[Issue 3128](https://github.com/facebookresearch/faiss/issues/3128) is an enhancement request to support remove_ids for IVFPQFastScan.

Existing mechanism use direct map and iterate over items in selector and use scopecodes and scopeIds to replace item to be removed. Given that codes are packed, it is hard to return single code how it is packed in CodePackerPQ4. Thus, we need a custom implementation to removed_ids.

**In this diff**,
1. We have added custom implementation of remove_ids from BlockInvertedLists which unpack code as it iterate and repack in new position. DirectMap use this remove_id function in BlockInvertedLists for type NoMap in DirectMap.

2. Also, we are throwing exception for other map type in DirectMap i.e. HashTable

Reviewed By: ramilbakhshyiev

Differential Revision: D55858959

fbshipit-source-id: c8a0631495380b7dead36720e4507f4d1900d39f
2024-04-09 09:36:22 -07:00
Gufan Yin
366a8146aa Revert D55723390: Support for Remove ids from IVFPQFastScan index
Differential Revision:
D55723390

Original commit changeset: 0017b556bd79

Original Phabricator Diff: D55723390

fbshipit-source-id: 58d61467b30dd11d27398f9f825162f598896845
2024-04-05 19:11:34 -07:00
Ramil Bakhshyiev
7657e812c4 Change index_cpu_to_gpu to throw for indices not implemented on GPU (#3336)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3336

Issues:
https://github.com/facebookresearch/faiss/issues/3269
https://github.com/facebookresearch/faiss/issues/3024

List of implemented GPU indices: https://github.com/facebookresearch/faiss/wiki/Faiss-on-the-GPU#implemented-indexes

Reviewed By: mdouze

Differential Revision: D55577576

fbshipit-source-id: 49f490cfba6784661e378acf4de3cce4195bb43b
2024-04-05 18:13:03 -07:00
Kumar Saurabh Arora
f34588aae7 Support for Remove ids from IVFPQFastScan index (#3349)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3349

**Context**
[Issue 3128](https://github.com/facebookresearch/faiss/issues/3128) is an enhancement request to support remove_ids for IVFPQFastScan.

Existing mechanism use direct map and iterate over items in selector and use scopecodes and scopeIds to replace item to be removed. Given that codes are packed, it is hard to return single code how it is packed in CodePackerPQ4. Thus, we need a custom implementation to removed_ids.

**In this diff**,
1. We have added custom implementation of remove_ids from BlockInvertedLists which unpack code as it iterate and repack in new position. DirectMap use this remove_id function in BlockInvertedLists for type NoMap in DirectMap.

2. Also, we are throwing exception for other map type in DirectMap i.e. HashTable

Reviewed By: mdouze

Differential Revision: D55723390

fbshipit-source-id: 0017b556bd790765251e778ac48ed37ff3a29a45
2024-04-05 15:54:23 -07:00
Junjie Qi
cfc7fe513b Implement reconstruct_n for GPU IVFFlat indexes (#3338)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3338

add reconstruct_n for GPU IVFFlat

Reviewed By: mdouze

Differential Revision: D55577561

fbshipit-source-id: 47f8b939611e2df7dbcd087129538145f627293c
2024-04-05 14:08:35 -07:00
Kumar Saurabh Arora
da9f292a4b Support of skip_ids in merge_from_multiple function of OnDiskInvertedLists (#3327)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3327

**Context**
1. [Issue 2621](https://github.com/facebookresearch/faiss/issues/2621) discuss inconsistency between OnDiskInvertedList and InvertedList. OnDiskInvertedList is supposed to handle disk based multiple Index Shards. Thus, we should name it differently when merging invls from index shard.
2. [Issue 2876](https://github.com/facebookresearch/faiss/issues/2876) provides usecase of shifting ids when merging invls from different shards.

**In this diff**,
1. To address #1 above, I renamed the merge_from function to merge_from_multiple without touching merge_from base class.
why so? To continue to allow merge invl from one index to ondiskinvl from other index.

2. To address #2 above, I have added support of shift_ids in merge_from_multiple to shift ids from different shards. This can be used when each shard has same set of ids but different data. This is not recommended if id is already unique across shards.

Reviewed By: mdouze

Differential Revision: D55482518

fbshipit-source-id: 95470c7449160488d2b45b024d134cbc037a2083
2024-04-03 10:36:56 -07:00
Warmchay
c9c86f0daa Fix missing overload variable in Rocksdb ivf demo (#3326)
Summary:
**Bugs:**
When following rocksdb_ivf demo to build executable file, its output as:
```bash
faiss/demos/rocksdb_ivf/RocksDBInvertedLists.h:52:35: error: 'faiss::InvertedListsIterator* faiss_rocksdb::RocksDBInvertedLists::get_iterator(size_t) const' marked 'override', but does not override
   52 |     faiss::InvertedListsIterator* get_iterator(size_t list_no) const override;
      |                                   ^~~~~~~~~~~~
make[2]: *** [CMakeFiles/demo_rocksdb_ivf.dir/build.make:90: CMakeFiles/demo_rocksdb_ivf.dir/RocksDBInvertedLists.cpp.o] Error 1
```

**Solution:**
Add relevant variable `void* inverted_list_contex` corresponding `get_iterator`'s base virtual function.

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

Reviewed By: mlomeli1, mdouze

Differential Revision: D55629580

Pulled By: algoriddle

fbshipit-source-id: a12fcacb483e0dd576411ad91a3dd1e0de94abec
2024-04-02 06:11:53 -07:00
Ramil Bakhshyiev
77e2e79cd0 Throw when attempting to move IndexPQ to GPU (#3328)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3328

Reviewed By: junjieqi

Differential Revision: D55476917

fbshipit-source-id: e7f64adefa07650fda32ad2300a1b933cedc9c79
2024-03-29 11:43:33 -07:00
Aalekh Patel
4e6b6f8a12 Add the ability to clone and read binary indexes to the C API. (#3318)
Summary:
I noticed we have a pretty decent C API for binary indexes and please correct me if I'm wrong but we seem to be missing a couple of functions, like the ability to clone and read binary indexes. This PR provides those functions.

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

Reviewed By: algoriddle

Differential Revision: D55469615

Pulled By: mdouze

fbshipit-source-id: 42e6f827d8b5ad6bc3efe989e47ede3aa06c1810
2024-03-29 02:37:19 -07:00
Alexandr Guzhva
d99f07e91a AVX512 for PQFastScan (#3276)
Summary:
AVX-512 implementation for PQFastScan for QBS.
For local benchmarks on 4th gen Xeon, the QPS is up to 10% higher, mostly for a single query case. But as far as I remember, production cases would show higher performance improvements.

* Baseline `benchs/bench_ivf_fastscan_single_query.py` (sift1M): https://gist.github.com/alexanderguzhva/c9cde2cb5e9c7675f429623e6faa9fbf
* Candidate `benchs/bench_ivf_fastscan_single_query.py` (sift1M): https://gist.github.com/alexanderguzhva/4e8530073a108f73771d38e55bc45b17
* Baseline `benchs/bench_ivf_fastscan.py` (sift1M): https://gist.github.com/alexanderguzhva/9eb03ed60354d7e76cfa25e676f983ac
* Candidate `benchs/bench_ivf_fastscan.py` (sift1M): https://gist.github.com/alexanderguzhva/3cbfeba1364dd445a2bb52455966979e

mdouze should I modify `pq4_fast_scan_search_1.cpp` as well? It is somewhat cumbersome to dig through various possible sub-implementations

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

Reviewed By: junjieqi

Differential Revision: D54943632

Pulled By: mdouze

fbshipit-source-id: 3d70066e9779039559b1734c2be99bf439058246
2024-03-29 01:25:24 -07:00
Junjie Qi
d6854136af Fix faiss swig build with version > 4.2.x (#3315)
Summary:
Currently, faiss can't build with swig version > 4.2.x. As the https://github.com/facebookresearch/faiss/issues/3239 mentioned.  Swig removed the support for 32bit 9fb3a4939e. So SWIGTYPE_p_unsigned_long_long isn't supported any more. In this diff, we are going to remove the unsupported type from Faiss swig.

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

Test Plan:
STEP 1: create a new conda env
```
conda create --name faiss_swig
conda activate faiss_swig
```

STEP 2: install dependecies from conda-forge
```
conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64=2.28 -c conda-forge
```

STEP 3: CMAKE

```
cmake -B build \
      -DBUILD_TESTING=ON \
      -DBUILD_SHARED_LIBS=ON \
      -DFAISS_ENABLE_GPU=OFF \
      -DFAISS_ENABLE_RAFT=OFF \
      -DFAISS_OPT_LEVEL=avx512 \
      -DFAISS_ENABLE_C_API=ON \
      -DPYTHON_EXECUTABLE=$(which python) \
      -DCMAKE_BUILD_TYPE=Release \
      -DBLA_VENDOR=Intel10_64_dyn \
      -DCMAKE_CUDA_FLAGS="-gencode arch=compute_75,code=sm_75" \
      .
```

STEP 4: build
```
make -C build -j faiss && make -C build -j swigfaiss
```
<img width="876" alt="Screenshot 2024-03-25 at 12 24 16 AM" src="https://github.com/facebookresearch/faiss/assets/8333898/918f0caf-398a-4361-989f-93ff547cf2b2">

Reviewed By: algoriddle

Differential Revision: D55304004

Pulled By: junjieqi

fbshipit-source-id: e958009dc637aa33b0e1a574a16a846a4abb1525
2024-03-28 22:54:51 -07:00
Chip-Kerchner
03db694aa7 Fix problems when using 64-bit integers. (#3322)
Summary:
Fixes problem when compiling OpenBLAS with INTERFACE64=1 (64-bit integers).

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

Reviewed By: algoriddle

Differential Revision: D55469397

Pulled By: mdouze

fbshipit-source-id: 14d916fb074f6ea0f591e0324bb7b8674a624473
2024-03-28 03:38:02 -07:00
Junjie Qi
55dc880c2f Change cmake to build googletest from source (#3319)
Summary:
In the https://github.com/facebookresearch/faiss/pull/3278, we to find_package to link to GTest. However, it needs to have googletest to build independently. Not everyone builds their googletest locally first. In this diff, we still try to build googletest from source and combine find_package together.

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

Test Plan:
STEP 1: Install deps
```
conda install -y -q python=3.11 cmake make swig=4.0.2 mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64
```

STEP2: Compile

```
cmake -B build \
      -DBUILD_TESTING=ON \
      -DBUILD_SHARED_LIBS=ON \
      -DFAISS_ENABLE_GPU=OFF \
      -DFAISS_ENABLE_RAFT=OFF \
      -DFAISS_OPT_LEVEL=avx2 \
      -DFAISS_ENABLE_C_API=ON \
      -DPYTHON_EXECUTABLE=$(which python) \
      -DCMAKE_BUILD_TYPE=Release \
      -DBLA_VENDOR=Intel10_64_dyn \
      -DCMAKE_CUDA_FLAGS="-gencode arch=compute_75,code=sm_75" \
      .
```

Reviewed By: algoriddle

Differential Revision: D55358059

Pulled By: junjieqi

fbshipit-source-id: 95ad4a745238b88b438728de64173f99d3d50dbe
2024-03-27 10:53:49 -07:00
Junjie Qi
14b8af6e73 Fix IVFPQFastScan decode function (#3312)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3312

as the [#issue3258](https://github.com/facebookresearch/faiss/issues/3258) mentioned, the IVFPQFastScan should have same decoding result as IVFPQ. However, current result is not as expected.

In this PR/Diff, we are going to fix the decoding function

Reviewed By: mdouze

Differential Revision: D55264781

fbshipit-source-id: dfdae9eabceadfc5a3ebb851930d71ce3c1c654d
2024-03-25 11:19:40 -07:00
Gergely Szilvasy
0c96b0d7e0 enable rapidsai-nightly channel for libraft (#3317)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3317

libraft packages are first published in rapidsai-nightly and moved to rapidsai after release, at which point they're removed from rapidsai-nightly

In this diff we enable both channels with a preference to rapidsai (since it's before rapidsai-nightly on the command line).

Reviewed By: mlomeli1

Differential Revision: D55310143

fbshipit-source-id: b85e0fda86a442f435d985ace1d7eb37209c74e1
2024-03-25 04:02:23 -07:00
Kumar Saurabh Arora
af5793cf12 Adding test for IndexBinaryFlat.reconstruct_n() (#3310)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3310

**Context**
[Issue 2751](https://github.com/facebookresearch/faiss/issues/2751) is already fixed as class wrappers has replacement definition of reconstruct_n in handle_IndexBinary.

**In this diff**,
Writing test test_reconstruct for binary index to validate fix for above issue.

Reviewed By: junjieqi

Differential Revision: D55168600

fbshipit-source-id: b62dc5fa89d65b843c52faa7456f046142e34421
2024-03-22 15:04:01 -07:00
Kumar Saurabh Arora
798427c019 Handling FaissException in few destructors of ResultHandler.h (#3311)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3311

**Context**
[Issue 2948](https://github.com/facebookresearch/faiss/issues/2948) highlights potential issue of calling allocation on result handler which may throw exception but it is not handled.

**In this diff**,
I observed two calls where we may potentially call allocation in ResultHandler.h and handled FaissException.
1/ partial result when finalized in ~SingleResultHandler
2/ partial result when merged in ~RangeSearchBlockResultHandler

Reviewed By: junjieqi

Differential Revision: D55258213

fbshipit-source-id: 259be472e73619b2fcb0ea480d6d3486affeafdf
2024-03-22 14:58:14 -07:00
Matthijs Douze
fa1f39ec9f Fix HNSW stats (#3309)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3309

Make sure that the HNSW search stats work, remove stats for deprecated functionality.
Remove code of the link and code paper that is not supported anymore.

Reviewed By: kuarora, junjieqi

Differential Revision: D55247802

fbshipit-source-id: 03f176be092bff6b2db359cc956905d8646ea702
2024-03-22 12:55:30 -07:00
Gergely Szilvasy
b77061ff5e move to raft 24.04 (#3302)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3302

Reviewed By: junjieqi

Differential Revision: D55173776

fbshipit-source-id: 5de2225638e2d997fbfa4e28b924d5e4633ee27f
2024-03-21 11:18:02 -07:00
Ramil Bakhshyiev
8274c38f27 Remove TypedStorage usage when working with torch_utils (#3301)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3301

In `torch_utils.py`, changed `storage()' references to `untyped_storage()`.

Reviewed By: junjieqi

Differential Revision: D55167842

fbshipit-source-id: 911eda1c22f10595663fb4416ab992903390d457
2024-03-21 10:30:44 -07:00
divyegala
9c79e3d5b1 RAFT 24.04 API changes (#3282)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3282

Reviewed By: junjieqi

Differential Revision: D55153617

Pulled By: algoriddle

fbshipit-source-id: 7b1ab24a6b0fbe002a0d8358078d014b1556044a
2024-03-20 14:28:42 -07:00
Yuri Victorovich
5483f210d2 Use cmake's find_package to link to GTest (#3278)
Summary:
Otherwise the gtest transitive dependency isn't linked properly when GoogleTest is built to have shared libraries.

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

Reviewed By: junjieqi

Differential Revision: D55134304

Pulled By: algoriddle

fbshipit-source-id: 01e7b11f28c27f837afee36350fbf9543e301a31
2024-03-20 09:52:12 -07:00
Junjie Qi
6f3843e14f Back out "Remove swig version and always rely on the latest version" (#3297)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3297

Original commit changeset: 7ca59fb58390

Original Phabricator Diff: D54975271

Differential Revision: D55102226

fbshipit-source-id: 2a2828b4e74b16ee25b090ae4b844dab4f1d72a6
2024-03-19 16:31:48 -07:00
Jason Sylka
0e06a28094 Revert D54973709: Remove unused fallthrough
Differential Revision:
D54973709

Original commit changeset: 545118e30773

Original Phabricator Diff: D54973709

fbshipit-source-id: d975b59d071deda5d8eaa2583a8f7c6f1562b9ba
2024-03-19 13:21:00 -07:00
Junjie Qi
cf364ec606 Remove unused fallthrough (#3296)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3296

same as title

Reviewed By: algoriddle

Differential Revision: D54973709

fbshipit-source-id: 545118e30773c6a4ea3f544a3a20c5ba8c394f69
2024-03-19 11:32:29 -07:00
Junjie Qi
f7fe62e801 Remove swig version and always rely on the latest version (#3295)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3295

In the past, we had build failure due to the latest swig version in conda-forge so we had to specify the version of swig. In this diff, we are going to change it to be the latest version always because the issue has gone.

Reviewed By: algoriddle

Differential Revision: D54975271

fbshipit-source-id: 7ca59fb58390edb0cc5ed52f6fd416f633dd7938
2024-03-19 10:46:30 -07:00
Maria
7d21c92fc1 Dim reduction support in OIVFBBS (#3290)
Summary:
This PR adds support for dimensionality reduction in OIVFBBS. I tested the code with an index `OPQ64_128,IVF4096,PQ64` using the ssnpp embeddings - this index string is added to the config_ssnpp.yaml to showcase this functionality.

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

Reviewed By: junjieqi

Differential Revision: D54878345

Pulled By: mlomeli1

fbshipit-source-id: 98ecdeb2224ce0325e37720cc113d82f9c6c75d6
2024-03-18 11:59:21 -07:00
Maria
d5e4c798f3 Removed index_shard_and_quantize OIVFBBS (#3291)
Summary:
This PR removes the unused method `index_shard_and_quantize` in OIVFBBS.

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

Reviewed By: algoriddle, junjieqi

Differential Revision: D54901824

Pulled By: mlomeli1

fbshipit-source-id: f723aa386b91417f697b24b620618b864329ef6d
2024-03-18 11:16:56 -07:00
ranjitsastra
e99ad124cb AIX compilation fix for io classes (#3275)
Summary:
in AIX OS ,as fileno is defined as C macro,   we get the compilation error during preprocessing step.

In file included from /ranjit/Faiss/faiss/faiss/invlists/InvertedListsIOHook.h:10:
/ranjit/Faiss/faiss/faiss/impl/io.h:35:17: error: expected member name or ';' after declaration specifiers
   35 |     virtual int fileno();
      |     ~~~~~~~~~~~ ^
/usr/include/stdio.h:517:30: note: expanded from macro 'fileno'
  517 | #define fileno(__p)     ((__p)->_file)

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

Reviewed By: algoriddle

Differential Revision: D54944388

Pulled By: mdouze

fbshipit-source-id: 40c4314de93547778ac274281245ff59e3a18b6d
2024-03-15 05:19:05 -07:00
Junjie Qi
dafdff1104 Change intall.md to reflect faiss 1.8.0
Summary: Same as title

Reviewed By: algoriddle

Differential Revision: D54399993

fbshipit-source-id: a0b05aabc2a0b70ae64843ca2ef2f4faaa123cdd
2024-03-04 03:07:49 -08:00
John Mazanec
12b92e9fa5 Skip HNSWPQ sdc init with new io flag (#3250)
Summary:
## Description

Related issue: https://github.com/facebookresearch/faiss/issues/3246

When reading HNSWPQ from disk, if index ~read only~ new `IO_FLAG_PQ_SKIP_SDC_TABLE` flag is set, skip initializing the sdc_table.

In addition, adds cpp test case verifying functionality and build test util header file to share creation of temporary files amongst tests.

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

Test Plan: buck test //faiss/tests/:test_disable_pq_sdc_tables

Reviewed By: junjieqi

Differential Revision: D53844075

Pulled By: mdouze

fbshipit-source-id: e9a83c0e5243867edbca8f80e3b1242b38ef6a42
2024-03-01 04:27:49 -08:00
Junjie Qi
943d08bdad Prepare for v.1.8.0 release (#3265)
Summary:
Prepare for v1.8.0 release

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

Reviewed By: mdouze

Differential Revision: D54232846

Pulled By: junjieqi

fbshipit-source-id: f92efc93e340507262321c5033bab7fede7d7f40
2024-02-29 13:24:50 -08:00
Jeff Johnson
abff75ef07 faiss gpu: fix DeviceVector reallocations (#3256)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3256

Per https://github.com/facebookresearch/faiss/issues/3251 there are two problems with DeviceVector resizing and capacity growth. The first is that if you resize a vector with enough capacity available for the new size, it will go ahead and re-allocate memory anyways.

The second is that the calculation that was supposed to produce x + 0.25 * x was actually producing x + 4 * x for determining the new size of the allocated memory for a vector. This is also fixed.

Reviewed By: mdouze

Differential Revision: D53813207

fbshipit-source-id: 5aa67bc0a87c171a070645bdcc6bc5d22ba6b36b
2024-02-21 11:38:57 -08:00
Gergely Szilvasy
b8d91d8cf8 fixes for D51074065
Summary: to get past CI

Reviewed By: junjieqi

Differential Revision: D53956063

fbshipit-source-id: 260fdabff2aada511d775f54270974f1b629e9eb
2024-02-21 06:41:08 -08:00
Tarang Jain
27b1055cc6 Integrate IVF-PQ from RAFT (#3044)
Summary:
Imports changes from https://github.com/facebookresearch/faiss/issues/3133 and https://github.com/facebookresearch/faiss/issues/3171. So this single PR adds all the changes together.

- [x] Implement RaftIVFPQ class
- [x] Update gtests to test correctness with RAFT enabled
- [x] All googleTests for RAFT enabled IVFPQ pass
- [x] Move some common functions in RaftIVFFlat and RaftIVFPQ to helper: RaftUtils.h
- [x] update Quantizer retroactively after building RAFT index -- both IVFFlat and IVFPQ
- [x] resolve failing LargeBatch (classical GPU)
- [x] add checks for Pascal deprecation
- [x] apply RMM changes from https://github.com/facebookresearch/faiss/issues/3171
- [x] apply robertmaynard's changes from https://github.com/facebookresearch/faiss/issues/3133

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

Reviewed By: junjieqi

Differential Revision: D51074065

Pulled By: algoriddle

fbshipit-source-id: 6871257921bcaff2064a20637e2ed358acbdc363
2024-02-21 06:41:08 -08:00
Jim Borden
87d43b9529 Fix AVX2 build on Windows (#3238)
Summary:
Tested with both MSVC (with /openmp:llvm) and clang-cl (no particular extra flags needed).  This PR is separated into two commits (three after I found out that lines need to be 80 chars or less):

1. Changes needed for clang-cl (and probably stock clang too)
2. Changes needed for MSVC

So FAISS can decide either to require using LLVM for Windows (not a hard thing to do these days since it is fully supported inside Visual Studio) and discarding the second commits, or taking them all and documenting the need to use /openmp:llvm

Closes https://github.com/facebookresearch/faiss/issues/3193

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

Reviewed By: mdouze

Differential Revision: D53479325

Pulled By: algoriddle

fbshipit-source-id: e8628f44626b6f49c5d9d7f259a9e3061cfe5568
2024-02-15 14:05:04 -08:00
Gergely Szilvasy
c577f43be6 fix perf test (#3255)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3255

Reviewed By: mlomeli1

Differential Revision: D53811550

fbshipit-source-id: b103dc2d0cf43cabb9e4e7e74f4e737ff39fbbbc
2024-02-15 10:38:55 -08:00
Richard Barnes
8400ece2b0 Remove unused variables in faiss/utils/partitioning.cpp
Summary:
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

Differential Revision: D53779589

fbshipit-source-id: 2631d7b23f2bc79b0468a8d983f74547c15f9c15
2024-02-15 07:42:30 -08:00
Gergely Szilvasy
873b1bc68c fix perf test (#3253)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3253

relaxing thresholds + allow equal, duh

Reviewed By: mlomeli1

Differential Revision: D53803000

fbshipit-source-id: 7b68386523d9a44a0cd8e099fc1d72b3ed7d5e43
2024-02-15 04:08:09 -08:00