1164 Commits

Author SHA1 Message Date
Mengdi Lin
96d0781942 turn on SVE opt mode in CI (#3703)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3703

Now that SVE PR has been merged, we can turn on SVE opt mode in CI

Reviewed By: ramilbakhshyiev

Differential Revision: D60457456

fbshipit-source-id: 053b1f8ac805afba9035095c5df811da05675a81
2024-07-30 14:48:12 -07:00
Ramil Bakhshyiev
28f7d3a153 Merge cmake command in the cmake build action (#3702)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3702

Simplify the cmake command in the cmake build action

Reviewed By: mengdilin

Differential Revision: D60427830

fbshipit-source-id: 0e89068649a61e2df3889de69e4d3fa13de0442f
2024-07-30 10:50:13 -07:00
Ramil Bakhshyiev
fecabc268e Gate ARM SVE build behind base Linux build (#3701)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3701

Gating ARM SVE behind the plain vanilla linux x64 build like all the other builds.

Reviewed By: mengdilin

Differential Revision: D60425535

fbshipit-source-id: f2e082fbaa6ea1e314ffe0e2e7260c8634cab989
2024-07-30 10:50:13 -07:00
vorj
4eeaa42b93 Add sve targets (#2886)
Summary:
related: https://github.com/facebookresearch/faiss/issues/2884

This PR contains below changes:

- Add new optlevel `sve`
    - ARM SVE is _extension_ of ARMv8, so it should be treated similar to AVX2 IMO
- Add targets for ARM SVE, `faiss_sve` and `swigfaiss_sve`
    - These targets will be built when you give `-DFAISS_OPT_LEVEL=sve` at build time
    - Design decision: Don't fix SVE register length.
        - The python package of faiss is "fat binary" (for example, the package for avx2 contains `_swigfaiss_avx2.so` and `_swigfaiss.so`)
        - SVE is scalable instruction set (= doesn't fix vector length), but actually we can specify the vector length at compile time.
            - [with `-msve-vector-length=` option](https://developer.arm.com/documentation/101726/4-0/Coding-for-Scalable-Vector-Extension--SVE-/SVE-Vector-Length-Specific--VLS--programming)
            - When this option is specified, the binary can't work correctly on the CPU which has other vector length rather than specified at compile time
        - When we use fixed vector length, SVE-supported faiss python package will contain 7 shared libraries like `_swigfaiss.so` , `_swigfaiss_sve.so` , `_swigfaiss_sve128.so` , `_swigfaiss_sve256.so` , `_swigfaiss_sve512.so` , `_swigfaiss_sve1024.so` , and `_swigfaiss_sve2048.so` . The package size will be exploded.
        - For these reason, I don't specify the vector length at compile time and `faiss_sve` detects the vector length at run time.
- Add a mechanism of detecting ARM SVE on runtime environment and importing `swigfaiss_sve` dynamically
    - Currently it only supports Linux, but there is no SVE environment with non-Linux OS now, as far as I know

NOTE: I plan to make one more PR about add some SVE implementation after this PR merged. This PR only contains adding sve target.

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

Reviewed By: ramilbakhshyiev

Differential Revision: D60386983

Pulled By: mengdilin

fbshipit-source-id: 7e66162ee53ce88fbfb6636e7bf705b44e6c3282
2024-07-29 15:05:17 -07:00
Matthijs Douze
7178bf8a1d Fix radius search with HSNW and IP (#3698)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3698

Addressed issue

https://github.com/facebookresearch/faiss/issues/3684

I forgot to negate the threshold of the radius search.
This diff adds a test and fixes the issue.

Reviewed By: mengdilin

Differential Revision: D60373054

fbshipit-source-id: 70f3daa8292177a4038846a94aff6221f88077e8
2024-07-29 09:52:52 -07:00
mengdilin
34bbe5e540 Add ARM64 build to build_cmake actions for SVE (#3653)
Summary:
Add instructions to download arm64 specific conda dependencies and cmake command and run it on CI. This should prepare us to turn on CI with SVE optimization

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

Reviewed By: ramilbakhshyiev

Differential Revision: D60043435

Pulled By: mengdilin

fbshipit-source-id: d81bb1c1022681c3da8f98bbf080d5e1d65d6b80
2024-07-26 17:27:39 -07:00
Bhavik Sheth
4cfa63865f add get_version() for c_api. (#3688)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3688
Looks like our previous changes only modified the cpp API. Not the c_api like the request wanted. This attempts to add faiss_get_version to c_api

Reviewed By: ramilbakhshyiev

Differential Revision: D60207739

fbshipit-source-id: 07184aeae92a154bb3f440279595077f002851f3
2024-07-25 23:38:46 -07:00
Amir Sadoughi
6e1f23f354 Moved statements to faiss.ai (#3694)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3694

depends on https://github.com/facebookresearch/faiss/pull/3693

Reviewed By: ramilbakhshyiev

Differential Revision: D60255937

fbshipit-source-id: 9d56812a9d94d8d81ed855aa97232cd400fdeac4
2024-07-25 18:12:23 -07:00
Bhavik Sheth
f2361a4124 Back out "Add warning on adding nbits to LSH index factory" (#3690)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3690

Seems like this may not be necessary because it is the the expected behavior.

See: https://github.com/facebookresearch/faiss/pull/3687#issuecomment-2249397476

Reviewed By: asadoughi

Differential Revision: D60241747

fbshipit-source-id: 7b8780fc4922a58c1975ae1b4343dc87e0eda0e1
2024-07-25 11:38:13 -07:00
Bhavik Sheth
0363934529 Add warning on adding nbits to LSH index factory (#3687)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3687

We will write a warning if nbits is not specified while using index factory with LSH. The warning lets users know we will be using default d as nbits.

Reviewed By: ramilbakhshyiev

Differential Revision: D60187935

fbshipit-source-id: 0fa960eeed615d857add77fa131a4cfa1989809d
2024-07-24 21:16:47 -07:00
Bhavik Sheth
aed7b0e678 First attempt at LSH matching with nbits (#3679)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3679

T195237796 Claims we should be able to incldue nbits in the LSH factory string.

Their example is:

```
index = faiss.index_factory(128, 'LSH16rt')
Returns the following error.
faiss/index_factory.cpp:880: could not parse index string LSHrt_16
```

This is my first attempt at modifying the regex to accept an integer for nbits. Can an expert help me understand what the domain of accepted strings should be so I can modify the regex as necessary?

Reviewed By: ramilbakhshyiev

Differential Revision: D60054776

fbshipit-source-id: e47074eb9986b7c1c702832fc0bf758f60f45290
2024-07-24 10:28:51 -07:00
Bhavik Sheth
8b5895ff79 1720 - expose FAISS version field to c_api (#3635)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3635

Add a util function to return the version in the c api.

Reviewed By: ramilbakhshyiev, fxdawnn

Differential Revision: D59817407

fbshipit-source-id: ca805f8e04f554d0294ba9da8ec6dc7c31e91fe3
2024-07-22 16:01:35 -07:00
mengdilin
749163e1d0 Fix CI for AVX512 (#3649)
Summary:
With the refactoring diff landed in [D59650573](https://www.internalfb.com/diff/D59650573), we take in the instance type string for aws and register it as the label for the runner. There was a typo in the previous registration (`m7i.xlarge` instead of `m7i.large`). The refactoring diff fixed the typo from the runner registration side but we need to fix it on the CI side as well so CI can find the runners

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

Test Plan: CI's AVX512 run on Github Action should succeed instead of stuck in pending

Reviewed By: ramilbakhshyiev

Differential Revision: D59916841

Pulled By: mengdilin

fbshipit-source-id: 5403e1a449ed765f0bf1a00e4a0d81d6c97463b9
2024-07-18 09:25:19 -07:00
Matthijs Douze
dd72e4121d QINCo implementation in CPU Faiss (#3608)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3608

This is a straightforward implementation of QINCo in CPU Faiss, with encoding and decoding capabilities (not training).

For this, we translate a simplified version of some torch classes:

- tensors, restricted to 2D and int32 + float32

- Linear and Embedding layer

Then the QINCoStep and QINCo can just be defined as C++ objects that are copy-constructable.

There is some plumbing required in the wrapping layers to support the integration. Pytroch tensors are converted to numpy for getting / setting them in C++.

Reviewed By: asadoughi

Differential Revision: D59132952

fbshipit-source-id: eea4856507a5b7c5f219efcf8d19fe56944df088
2024-07-11 02:40:38 -07:00
Matthijs Douze
ab109c28d5 Add search functionality to FlatCodes (#3611)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3611

Using the new dispatcher functions, add search func to flat codes. To test it, make IndexLattice a subclass of FlatCodes and check the resonstruction there.

Reviewed By: asadoughi

Differential Revision: D59367989

fbshipit-source-id: 405dab4358fe34b2e38ac8bcc222b19f58643229
2024-07-11 02:40:38 -07:00
Matthijs Douze
261edde514 add dispatcher for VectorDistance and ResultHandlers
Summary: Add dispatcher function to avoid repeating dispatching code for distance computation and result handlers.

Reviewed By: asadoughi

Differential Revision: D59318865

fbshipit-source-id: 59046ede02f71a0da3b8061289fc70306bf875cb
2024-07-11 02:40:38 -07:00
Michael Norris
444614b076 Set verbosoe before train (#3619)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3619

Resolves issue https://github.com/facebookresearch/faiss/issues/3293

This just means that we wouldn't get verbose prints in train() before, and after we do.

Reviewed By: junjieqi

Differential Revision: D59474995

fbshipit-source-id: 72537643b661c553353e5f701cfcaf76d21f40d2
2024-07-09 14:56:31 -07:00
Amir Sadoughi
036a7e3cf1 Rename autoclose to autoclose.yml (#3618)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3618

Reviewed By: junjieqi

Differential Revision: D59467510

Pulled By: asadoughi

fbshipit-source-id: 52c4cc42e7a9362d78596a695ec4a1121bf455a2
2024-07-08 10:40:52 -07:00
Amir Sadoughi
e5ab7013bf Create autoclose GHA workflow (#3614)
Summary:
After a reviewer labels the issue as "autoclose", issues will be labeled as "stale" after 7 days of no update and close after an additional 7 days.

See https://docs.github.com/en/actions/managing-issues-and-pull-requests/closing-inactive-issues and https://github.com/marketplace/actions/close-stale-issues

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

Reviewed By: junjieqi

Differential Revision: D59411424

Pulled By: asadoughi

fbshipit-source-id: d79f173de900d5aec53d01c77e8ddc9a8312c12c
2024-07-05 23:39:48 -07:00
Michael Norris
3fe0b934f3 Fix typo in matrix mult (#3607)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3607

Github issue: https://github.com/facebookresearch/faiss/issues/3026

Reviewed By: mengdilin, junjieqi

Differential Revision: D59284732

fbshipit-source-id: a1100c05e7eab40ae90e910364f9ee1db8b1bc55
2024-07-03 13:27:05 -07:00
Junjie Qi
db251e2778 Adding missing includes which are necessary for building (#3609)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3609

The current version of Faiss cannot be built due to missing #includes on a test file tests/test_ivf_index.cpp. This is better described in issue #3532.

https://github.com/facebookresearch/faiss/pull/3533

Reviewed By: ramilbakhshyiev

Differential Revision: D59314273

fbshipit-source-id: 6ec8bfa973760d0a44bc94ae751b4fc55c4784ef
2024-07-03 10:58:40 -07:00
mengdilin
f8217045dc Non-Blocking AVX512 Build on self-hosted github runner (#3602)
Summary:
Start beta-testing AVX512 Build on self-hosted github runner with label faiss-aws-m7i.xlarge. This build is non-blocking on the PRs right now (via the parameter `continue-on-error`)

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

Reviewed By: ramilbakhshyiev

Differential Revision: D59290555

Pulled By: mengdilin

fbshipit-source-id: 6a82538bd44fecf4913885ac3b1999eb0fa52047
2024-07-02 12:48:42 -07:00
divyegala
079fd5559c Fix seg faults in CAGRA C++ unit tests (#3552)
Summary:
The issue was that `uniform_int_distribution` generates numbers in the range `[0, ntotal]` and not `[0, ntotal)`, which was an oversight on my part. This PR also attempts to reduce the tolerance for `copyTo` tests as we have seen those fail intermittently.

cc ramilbakhshyiev mdouze cjnolet

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

Reviewed By: junjieqi

Differential Revision: D59097786

Pulled By: ramilbakhshyiev

fbshipit-source-id: 9dac4367e25c6c219b116ed172089a2fa2a39c4f
2024-06-27 00:50:02 -07:00
Naveen Tatikonda
33c0ba5d00 Add SQ8bit signed quantization (#3501)
Summary:
### Description
Add new signed 8 bit scalar quantizer, `QT_8bit_direct_signed` to ingest signed 8 bit vectors ([-128 to 127]).

### Issues Resolved
https://github.com/facebookresearch/faiss/issues/3488

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

Reviewed By: mengdilin

Differential Revision: D58639363

Pulled By: mdouze

fbshipit-source-id: cf7f244fdbb7a34051d2b20c6f8086cd5628b4e0
2024-06-24 05:11:53 -07:00
Kumar Saurabh Arora
da75d03442 Refactor bench_fw to support train, build & search in parallel (#3527)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3527

**Context**
Design Doc: [Faiss Benchmarking](https://docs.google.com/document/d/1c7zziITa4RD6jZsbG9_yOgyRjWdyueldSPH6QdZzL98/edit)

**In this diff**
1. Be able to reference codec and index from blobstore (bucket & path) outside the experiment
2. To support #1, naming is moved to descriptors.
3. Build index can be written as well.
4. You can run benchmark with train and then refer it in index built and then refer index built in knn search. Index serialization is optional. Although not yet exposed through index descriptor.
5. Benchmark can support index with different datasets sizes
6. Working with varying dataset now support multiple ground truth. There may be small fixes before we could use this.
7. Added targets for bench_fw_range, ivf, codecs and optimize.

**Analysis of ivf result**: D58823037

Reviewed By: algoriddle

Differential Revision: D57236543

fbshipit-source-id: ad03b28bae937a35f8c20f12e0a5b0a27c34ff3b
2024-06-21 13:04:09 -07:00
Kumar Saurabh Arora
3a7c718ace Adding faiss bench_fw to bento faiss kernel (#3531)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3531

**In this diff**
1. I have add bench_fw to bento faiss kernel target
2. First part of notebook is changed to analyze sift1M results

Reviewed By: algoriddle

Differential Revision: D58823037

fbshipit-source-id: a67d4638af4368f0575bd289ce7aff8cf1fcd38b
2024-06-21 09:18:42 -07:00
Matthijs Douze
e758973fa0 Add ABS_INNER_PRODUCT metric (#3524)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3524

Searches with the metric abs(dot(query, database))
This makes it possible to search vectors that are closest to a hyperplane

* adds support for alternative metrics in faiss.knn in python

* checks that it works with HNSW

* simplifies the extra distances interface by removing the template on

Reviewed By: asadoughi

Differential Revision: D58695971

fbshipit-source-id: 2a0ff49c7f7ac2c005d85f141cc5de148081c9c4
2024-06-18 03:13:51 -07:00
Ramil Bakhshyiev
e188eb3810 Bump libraft to 24.06 to unblock nightly RAFT builds (#3522)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3522

Quick fix to unblock nightly

Reviewed By: mlomeli1

Differential Revision: D58694193

fbshipit-source-id: ea323991cc2e2b958fc11ab614dcd6e09d4c072c
2024-06-17 17:59:13 -07:00
Ramil Bakhshyiev
849557a38a Unbreak RAFT conda builds (#3519)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3519

Fixing the conda conflicts because of `_openmp_mutex` build versions. This change pins that version for RAFT conda package builds.

Reviewed By: algoriddle

Differential Revision: D58646659

fbshipit-source-id: 4c1eaa9f08bd354da016b9399a36698007a497d8
2024-06-17 01:40:32 -07:00
Gergely Szilvasy
e65a910eb4 fix Windows build - signed int OMP for MSVC (#3517)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3517

MSVC doesn't support unsigned int for OMP

Reviewed By: kuarora, junjieqi, ramilbakhshyiev

Differential Revision: D58591594

fbshipit-source-id: ac7d6b37a82f9543be3e0fe418f0f6b439751475
2024-06-14 13:00:05 -07:00
Ramil Bakhshyiev
44d21eedb6 Consolidate build environment configuration steps in cmake builds (#3516)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3516

This diff seeks to simplify the steps that install conda packages and environment configuration into a single step at the start of the cmake build action.

Reviewed By: mnorris11

Differential Revision: D58560454

fbshipit-source-id: ee2c6b36865809f31eb335cfb3c2fffdccaa318d
2024-06-13 22:30:28 -07:00
Gergely Szilvasy
34feae48d4 typo in test_io_no_storage (#3515)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3515

Fix typo `test_io_no_storage`

Reviewed By: kuarora, asadoughi

Differential Revision: D58540190

fbshipit-source-id: b8b9cacd7ea6005c0edb94014de74188450318c1
2024-06-13 13:31:34 -07:00
Ramil Bakhshyiev
d45f78b1e1 Add conda bin to path early in the cmake GitHub action (#3512)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3512

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

GitHub hosted runners some with the build-essentials package pre-installed, self-hosted runners on AWS do not have this package. This made it all steps other than the `all targets` one fall back to the system executables which unintentially worked on GitHub hosted runners but not on the self-hosted ones. This diff fixes it by pulling the line that adds conda bin to path early in the cmake build action.

Reviewed By: asadoughi

Differential Revision: D58513853

fbshipit-source-id: 23e95459e0031c96bd142515db07d1b700d713cf
2024-06-13 08:14:38 -07:00
Gergely Szilvasy
3d32330e3d add use_raft to knn_gpu (torch) (#3509)
Summary:
Add support for `use_raft` in the torch version of `knn_gpu`. The numpy version already has this support, see https://github.com/facebookresearch/faiss/blob/main/faiss/python/gpu_wrappers.py#L59

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

Reviewed By: mlomeli1, junjieqi

Differential Revision: D58489851

Pulled By: algoriddle

fbshipit-source-id: cfad722fefd4809b135b765d0d43587cfd782d0e
2024-06-12 19:19:23 -07:00
Matthijs Douze
f71d5b9aa2 fix spurious include to land the cagra diff (#3502)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3502

include probably added by vscode

Reviewed By: mengdilin

Differential Revision: D58411537

fbshipit-source-id: 3035f690d26decc937fb492c54ffa2f974ee2db8
2024-06-11 08:14:48 -07:00
divyegala
df0dea6c6d Interop between CAGRA and HNSW (#3252)
Summary:
Depends on https://github.com/facebookresearch/faiss/pull/3084

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

Reviewed By: junjieqi

Differential Revision: D57971948

Pulled By: mdouze

fbshipit-source-id: 4371f4d136eeceb59568593f98a6ae9163a768ba
2024-06-11 08:14:48 -07:00
Abhiram Vadlapatla
ec67ac1594 Update .gitignore (#3492)
Summary:
Adding build folder to gitignore, so that they don't show up in the commit tree while building from source

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

Reviewed By: junjieqi

Differential Revision: D58171359

Pulled By: asadoughi

fbshipit-source-id: b0efed348769328a3bdbcc13098dcb84cadb6c4f
2024-06-04 21:59:57 -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
Matthijs Douze
bf73e38d10 add skip_storage flag to HNSW (#3487)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3487

Sometimes it is not useful to serialize the storage index along with a HNSW index. This diff adds a flag that supports skipping the storage of the index.

Searchign and adding to the index is not possible until a storage index is added back in.

Reviewed By: junjieqi

Differential Revision: D57911060

fbshipit-source-id: 5a4ceee4a8f53f6f746df59af3942b813a99c14f
2024-05-31 14:48:13 -07:00
Kumar Saurabh Arora
22304340d2 Adding buck target for experiment bench_fw_ivf (#3423)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3423

Adding small fixes to run experiments from fbcode.
1. Added buck target
2. Full import path of faiss bench_fw modules
3. new dataset path to run tests locally as we can't use  an existing directory ./data in fbcode.

Reviewed By: algoriddle, junjieqi

Differential Revision: D57235092

fbshipit-source-id: f78a23199e619b640a19ca37f8b52ff0abdd8298
2024-05-31 14:30:39 -07:00
Kumar Saurabh Arora
0beecb4c85 sys.big_endian to sys.byteorder (#3422)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3422

Found vec_io failing when running some benchmarking.
There is no such field named big_endian in sys. So, reverting it to original field byteorder

Reviewed By: algoriddle

Differential Revision: D56718607

fbshipit-source-id: 553f1d2d6bc967581142a92282e534f3f164e8f9
2024-05-30 09:27:55 -07:00
simshi
6e7d9e040f fix algorithm of spreading vectors over shards (#3374)
Summary:
simple math:
| **input n** | **input nshards** |  shard_size | idx | i0 | ni |
| -- |-- |-- |-- |-- |-- |
| 19 | 6 | 4 | 5 | 20 | **-1** |
| 1000 | 37 | 28 | 36 | 1008 | -8 |
| 1000 | 64 | 16 | 63 | 1008 | -8 |

root cause:
integer cause precision loss, `idx * shard_size` overflows, because `(n + nshards - 1) / nshards` is roundup

my solution:
each shard takes at least  `base_shard_size = n / nshards`, then `remain = n % nshards`, we know `0 <= remain < nshards`, next, assign those remain vectors to first `remain` shards, i.e. first `remain` shards take one more vector each.
```c++
auto i0 = idx * base_shard_size;
if (i0 < remain) {
  // if current idx is one of the first `remain` shards
  i0 += idx;
} else {
  i0 += remain;
}
```
simplify above code: `i0 = idx * base_shard_size + std::min(size_t(idx), n % nshards);`

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

Reviewed By: fxdawnn

Differential Revision: D57867910

Pulled By: junjieqi

fbshipit-source-id: 7e72ea5cd197af4f3446fb7a3fd34ad08901dbb2
2024-05-28 11:47:04 -07:00
Jim Borden
db6ff2e095 Workaround for missing intrinsic on gcc < 9 (#3481)
Summary:
Rebased branch for https://github.com/facebookresearch/faiss/issues/3420

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

Reviewed By: mdouze

Differential Revision: D57830230

Pulled By: junjieqi

fbshipit-source-id: a93fb3cc53f11245faec891a9590b5e849dbf3b9
2024-05-27 17:44:09 -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
Tarang Jain
6580156e96 Delete Raft Handle (#3435)
Summary:
Small Raft related modification to StandardGpuResources:
if the stream for a particular device is modified by a user, delete the Raft handle for that device. On any subsequent call to `getRaftHandle(device)`, a new raft handle with the updated stream will be created.
Closes https://github.com/facebookresearch/faiss/issues/3424

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

Reviewed By: ramilbakhshyiev

Differential Revision: D57640976

Pulled By: junjieqi

fbshipit-source-id: 41e2898a39250b7e52e920b71e819fc21ca9fc85
2024-05-23 15:33:23 -07:00
Alexandr Guzhva
eb284811e0 Remove duplicate NegativeDistanceComputer instances (#3450)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3450

Reviewed By: mdouze

Differential Revision: D57708412

Pulled By: junjieqi

fbshipit-source-id: 9540b7e60d8b2b39e0ca92423d2a305fab2a17e6
2024-05-23 09:19:24 -07:00
Richard Barnes
729a66f004 Remove extra semi colon from deprecated/libmccpp/ThreadSafeClientPool.h (#3479)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3479

`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: palmje

Differential Revision: D57632759

fbshipit-source-id: 48bc23e87b3f518182085124c4c8e68ddbb3ca8f
2024-05-23 07:47:33 -07:00
Ramil Bakhshyiev
eec4cba025 Disable CircleCI builds (#3477)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3477

AVX-512 must remain on CircleCI until GitHub provides runners with AVX-512 support (ETA: Q1 2025).

Reviewed By: algoriddle

Differential Revision: D57707621

fbshipit-source-id: e8a0885f8363cf8f20854cccca3ec0adc946362b
2024-05-23 06:42:48 -07:00
Ramil Bakhshyiev
93bc9b6470 Gate all PR builds behind linux-x86_64-cmake in GitHub Actions (#3476)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3476

The long tail will still be the RAFT build but we can save on cost if the build has errors by incurring ~10m penalty added by waiting for the basic cmake build to complete. Both GPU and RAFT builds will start together so this will take less time overall to complete.

Reviewed By: algoriddle

Differential Revision: D57707298

fbshipit-source-id: 3589842e9bda9ebca9b25e089e6177fe96b6a0f5
2024-05-23 06:42:48 -07:00
Ramil Bakhshyiev
ee7ce21acd Add display names to all PR build jobs on GitHub Actions (#3475)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3475

Migration to GitHub

Reviewed By: algoriddle

Differential Revision: D57707064

fbshipit-source-id: 17f0a97028007f3664faa5b6b2c269f50bcdf39e
2024-05-23 06:42:48 -07:00