1065 Commits

Author SHA1 Message Date
Jeff Palm
0d7bd780a6 faiss/utils/simdlib_avx2.h: avoid C++20 ambiguous overloaded operator (#2772)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2772

Resolves errors from overloaded ambiguous operators:
```
faiss/utils/partitioning.cpp:283:34: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'faiss::simd16uint16' and 'faiss::simd16uint16') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
```

Reviewed By: alexanderguzhva, meyering

Differential Revision: D44186458

fbshipit-source-id: 0257fa0aaa4fe74c056bef751591f5f7e5357c9d
2023-03-22 14:34:42 -07:00
Matthijs Douze
0200d131fc fix windows test (#2775)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2775

Reviewed By: algoriddle

Differential Revision: D44210010

fbshipit-source-id: b9b620a4b0a874e09ee2f6082ff0f9463716fdf4
2023-03-21 05:34:50 -07:00
Matthijs Douze
2d7dd5b0a6 support checkpointing in big batch search
Summary: Big batch search can be running for hours so it's useful to have a checkpointing mechanism in case it's run on a best-effort cluster queue.

Reviewed By: algoriddle

Differential Revision: D44059758

fbshipit-source-id: 5cb5e80800c6d2bf76d9f6cb40736009cd5d4b8e
2023-03-14 11:11:50 -07:00
Matthijs Douze
371d9c2f3b Fix decoding of large fast_scan blocks (#2746)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2746

There was a bug in the decoding code for large blocks, see
https://github.com/facebookresearch/faiss/issues/2739

this diff adds a test that exposes the bug, and fixes it.

Reviewed By: alexanderguzhva

Differential Revision: D43872441

fbshipit-source-id: 2fb64bf850ab76acc2af0fec3179858cc7d4cac8
2023-03-10 03:51:46 -08:00
Kaelen Haag
24758fb27d Search params c_api implementation (#2732)
Summary:
https://github.com/facebookresearch/faiss/issues/2727

Implements search_with_params function on c_api for index.

Implemented c_api equivalents of SearchParameters and SearchParametersIVF.

My C/C++ is pretty rusty so I imagine my arguments to the new functions for each search parameters could be refined. Happy to take suggestions :)

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

Reviewed By: alexanderguzhva

Differential Revision: D43917264

Pulled By: mdouze

fbshipit-source-id: c9eaf0d96ec0fad4862528aac9b5946294f5e444
2023-03-09 15:30:19 -08:00
Alexandr Guzhva
52dee5c307 Fix platform pragmas for GCC (#2750)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2750

Enables optimizations using FAISS_PRAGMA_IMPRECISE_* pragmas for GCC, which were not properly enabled beforehand

Reviewed By: DenisYaroshevskiy, mdouze

Differential Revision: D43916065

fbshipit-source-id: 943339544b30cad28e094559e2545319f24a8ce9
2023-03-08 16:24:37 -08:00
Kaelen Haag
1ee15ef3c3 Proposal IDSelectorCombination (#2742)
Summary:
Adds support for an IDSelector that takes in two IDSelectors and can perform a boolean operation on their is_member outcomes.

Current implementation is pretty naive and doesn't try to do any optimizations on the types of IDSelectors combined.

Also test cases are definitely lacking but can add more once approach is agreed upon.

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

Reviewed By: algoriddle

Differential Revision: D43904855

Pulled By: mdouze

fbshipit-source-id: bbe687800a19b418ca30c9257fb0334c64ab5f52
2023-03-08 08:48:54 -08:00
Alexandr Guzhva
6d0294ba6c Support of 12-bit vector codecs for SaDecodeKernels (#2745)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2745

Reviewed By: mdouze

Differential Revision: D43838494

fbshipit-source-id: a45d20b0f23b60a08d815f630615538e6ab7787e
2023-03-06 09:27:42 -08:00
Alexandr Guzhva
da09d22d5d Add comments for vector decode kernels about IVF+PQ with PQ bits > 8 (#2737)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2737

IVFPQ with more than 8 bits per subquantizer seem to be acceptable in Faiss. So, comments were altered, additional unit tests were added.

Reviewed By: mdouze

Differential Revision: D43706459

fbshipit-source-id: 45d0cc6f43ec0198aa95d025f07b75a9c33e4db7
2023-03-06 09:27:42 -08:00
Matthijs Douze
0815970581 Remove exclusion from Doxyfile (#2741)
Summary:
The Doxyfile is used to generate the Faiss documentation in faiss.ai. In its current config it skips over important classes like ProductQuantizer. Hence this diff that forces it to pass over the impl/ subdirectories.

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

Reviewed By: mlomeli1

Differential Revision: D43732475

Pulled By: mdouze

fbshipit-source-id: cf968238838051000fa31b4388e1f2beb7f451db
2023-03-02 04:48:50 -08:00
Iurii Makarov
8ccd800986 Implemented Jaccard distance (#2684)
Summary:
**Summary**
Implemented Jaccard distance requested in this issue: https://github.com/facebookresearch/faiss/issues/1299
**Test plan**
Run: make -C build test
Output: 100% tests passed, 0 tests failed out of 174

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

Reviewed By: mdouze

Differential Revision: D43398833

Pulled By: lvoursl

fbshipit-source-id: b38cf27a7858842efe967bcb1033977863716a76
2023-02-27 07:49:42 -08:00
Alexandr Guzhva
521e271cb8 modify FAISS_PRAGMA_IMPRECISE_FUNCTION_* flags to make old clang versions to generate FMAs on x64 (#2726)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2726

Old versions of clang (prior to 14) do not generate FMAs on x86 unless this option is used. On the other hand, ARM does not support the needed pragma flag.

Reviewed By: DenisYaroshevskiy

Differential Revision: D43503265

fbshipit-source-id: a024dd221288e44d4e2ade2f5db2c4402e26ff3d
2023-02-22 12:19:32 -08:00
Alexandr Guzhva
8ef0985c11 auto-vectorization for fvec_L2sqr() (#2716)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2716

enable fast-math computations for fvec_L2sqr() and let compiler autovectorize it

Reviewed By: algoriddle

Differential Revision: D43369467

fbshipit-source-id: e84985bfbe0385436bcbc829427f479003093ba7
2023-02-22 06:55:01 -08:00
Alexandr Guzhva
f12fe8f300 remove unused fvec_inner_product_ref() and fvec_norm_L2sqr_ref() (#2725)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2725

fvec_inner_product_ref() is no longer needed, using fvec_inner_product() instead in all the cases

fvec_norm_L2sqr_ref() is no longer needed, using fvec_norm_L2sqr() instead in all the cases

Reviewed By: algoriddle

Differential Revision: D43472582

fbshipit-source-id: 2d99a022d420092aed2adfd57e12be5b3e652944
2023-02-22 06:55:01 -08:00
Alexandr Guzhva
67d2a779ea Replace distance_to_code() in IVFPQScanner and PQDistanceComputer (#2717)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2717

Use avx2-optimized distance_to_code(), if appropriate

Reviewed By: mlomeli1

Differential Revision: D43369478

fbshipit-source-id: 0a68c07057710644342e0993a47f26e77a397636
2023-02-21 14:19:13 -08:00
Alexandr Guzhva
55b2d54ee1 move files from impl/ivfpq to impl/code_distance (#2715)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2715

Reviewed By: mlomeli1

Differential Revision: D43369479

fbshipit-source-id: 3de25f4313a20eb4d249316133822b3a31a55893
2023-02-21 14:19:13 -08:00
Denis Yaroshevskiy
cf40d3a73d Fixing FAISS_PRAGMA_IMPRECISE_* for clang arm and gcc (#2721)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2721

FAISS_PRAGMA_IMPRECISE_* macros were modified:

* Disabled ones on clang on arm, because it does not support `_Pragma("float_control(precise, off)")`

* Added missing pragma for the GCC compiler.

Reviewed By: alexanderguzhva

Differential Revision: D43437450

fbshipit-source-id: cec8042c3c8c7147ae7e2ffa1ac9e2232c8f1a92
2023-02-21 07:26:40 -08:00
Rujin Cao
6edd23d1b4 Fix typo 'ownerhsip'
Summary: ownerhsip -> ownership

Reviewed By: stanley-shi, sonamghosh, xuwenzhi

Differential Revision: D43398548

fbshipit-source-id: 60bd51a0d10995686ad5d6f9cc6da4101444bce9
2023-02-17 16:27:15 -08:00
Denis Yaroshevskiy
37f1f67870 Fix msvc pragmas issue (#2718)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2718

Missed msvc failure.

Also updated a failing test somewhere.

Reviewed By: alexanderguzhva

Differential Revision: D43401794

fbshipit-source-id: 029102b969cbe6ab6c2420da21454f61fd28e094
2023-02-17 15:45:06 -08:00
Denis Yaroshevskiy
a5203ff017 Follow up fixes to faiss vectorization change
Summary:
Pragmas:
turns out GCC does not support pragma float_control
I have no way to test it locally but I tried on godbolt: https://godbolt.org/z/zTzf7jd7c

I will put these pragmas in folly later but for now - let's just solve the problem.

Test:
The diff: D43353199 that produced slightly different floating point results broke this test.

After looking into it I don't believe that the original test data had any meaning and was just a dump of the output.

Accoding to mdouze the previous test data was questionable and using random numbers would be preferrable, so I did.

Reviewed By: alexanderguzhva

Differential Revision: D43393684

fbshipit-source-id: 691397302b58a98e1ccbe32feffa7aaeee96accd
2023-02-17 08:53:50 -08:00
Denis Yaroshevskiy
45b16d23a1 faiss: use autovectorization for inner product (#2712)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2712

Using autovectorization to get the proper urnolling.

Previous version timings are:

Before
```
faiss_ip_10000                        2.10us   475.62K
faiss_n2_10000                        4.23us   236.30K
```

After
```
faiss_ip_10000                         1.21us   827.16K
faiss_n2_10000                       640.68ns     1.56M
```

Reviewed By: alexanderguzhva

Differential Revision: D43353199

fbshipit-source-id: 8f73a34acd4b0368be6cdb05ba7a99a566c9ed83
2023-02-16 10:24:25 -08:00
generatedunixname89002005325676
fb88ea3976 Daily arc lint --take CLANGFORMAT
Reviewed By: 0x1eaf

Differential Revision: D43344501

fbshipit-source-id: 0adb4b573057a751057821af645b7802e29c06cd
2023-02-16 03:06:35 -08:00
Alexandr Guzhva
0519c048c2 implemented fvec_L2sqr_ny_y_transposed() plus an AVX2 code for it (#2696)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2696

Add fvec_L2sqr_ny_y_transposed() call which is used by ProductQuantizer in case of pq.sync_transposed_centroids() is enabled.

Reviewed By: mdouze

Differential Revision: D43057940

fbshipit-source-id: b82a0153fb10f1558c7db04e32d690b2ee7b9144
2023-02-15 13:00:05 -08:00
Alexandr Guzhva
f937cef502 Improve fvec_op_ny_D4 for x64 (#2693)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2693

A new kernel for fvec_op_ny_D4 for x64 that reorganizes read ops.

This diff also introduces transpose microkernels for D2 and D8 for AVX2 for future needs.

Reviewed By: mdouze

Differential Revision: D43057318

fbshipit-source-id: 37b2e18139905fcdac69e4603038a15725a730dd
2023-02-15 13:00:05 -08:00
Alexandr Guzhva
875a5d4ac8 Improve IndexIVFPQ::scan_list_with_table and IndexIVFPQ::scan_list_polysemous_hc for x64 (#2694)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2694

Improves the performance of IVFPQ::scan_list_with_table() and IVFPQ::scan_list_polysemous_hc() by manually unrolling loops.

Reviewed By: mdouze

Differential Revision: D43056462

fbshipit-source-id: 326a394b7d9de4f576d165e0245852acc1fec310
2023-02-15 13:00:05 -08:00
Matthijs Douze
a80c96c0de Evaluation script for hybrid CPU / GPU search
Summary:
Implementation of various combinations of coarse quantization / scaning code on CPU and GPU.

Used to generate the results of

https://github.com/facebookresearch/faiss/wiki/Hybrid-CPU-GPU-search-and-multiple-GPUs

Reviewed By: alexanderguzhva

Differential Revision: D43041802

fbshipit-source-id: 12608812ab351d60d4a6dc45be1ca493f76d4375
2023-02-15 12:55:06 -08:00
Matthijs Douze
1dc992bf26 IndexShards with common quantizer (#2682)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2682

IndexShards normally sees the indexes as opaque, so there is no way to factrorize the coarse quantizer.
This diff introduces IndexIVFShards that handles IVF indexes with a common quantizer so that the quantization is computed only once.

Reviewed By: alexanderguzhva

Differential Revision: D42781513

fbshipit-source-id: 441316eff4c1ba0468501c456af9194ea5f042d6
2023-02-15 06:48:47 -08:00
Alexandr Guzhva
868e17f294 OSS legal requirements (#2698)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2698

Add headers about copyright.

Reviewed By: algoriddle

Differential Revision: D43085637

fbshipit-source-id: 5a57876b7047097ffe01cd79322674625d9bca34
2023-02-07 14:32:56 -08:00
Alexandr Guzhva
e7d5577dd0 Fix CircleCI format warnings (#2699)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2699

Remove a couple of blank lines

Reviewed By: algoriddle

Differential Revision: D43092258

fbshipit-source-id: 97a0e0a359562e93052d121ce4b5128b4f73524a
2023-02-07 12:17:42 -08:00
Matthijs Douze
ab058456df Crop a ResidualCoarseQuantizer (#2683)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2683

Adds a small function and a test to demonstrate how to crop a RCQ to its first quantizers.
Also adds a SearchParameters to set the beam_factor of a RCQ.

Reviewed By: alexanderguzhva

Differential Revision: D42842378

fbshipit-source-id: b522269ce983cddc50c3d0e18b541954c5d7001d
2023-02-06 12:52:28 -08:00
Jeff Johnson
9f372ce7f8 Complete Faiss OSS legal requirements
Summary: Added the required terms of use, privacy policy and copyright statement for Meta OSS projects.

Reviewed By: algoriddle

Differential Revision: D43056233

fbshipit-source-id: 8541edd587107bf3129ff7f8b29ec26c016f779f
2023-02-06 12:39:57 -08:00
Jeff Johnson
43d3dcf061 Faiss GPU: Use 64-bit indexing arithmetic everywhere (#2685)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2685

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

This diff is an attempt at dealing with limitations when I originally wrote the Faiss GPU code back in 2016. Namely, 64 bit integer arithmetic was really slow on the GPU (this was also the impetus for me adding the 32 vs 64 bit indexing logic to PyTorch GPU), and GPUs at the time were very memory limited.

However, there have been enough cases where people are attempting to use Faiss GPU to handle larger datasets, especially including > 2 GB flat indexes, which sometimes worked (total number of elements in a tensor being < 2^31 - 1 but the byte size could be larger) or sometimes didn't work (when considering byte offsets not word sizes). This needed fixing.

This diff changes the `Tensor`, `HostTensor` and `DeviceTensor` classes to default to using `faiss::idx_t` as the index type (64 bit), and also changes many other places in the GPU code to follow the same data type. Much of the code being changed follows from the type propagation coming from the `Tensor` class and sub-classes.

`GpuIndexIVF.setNumProbes` and `GpuIndexIVF.getNumProbes` functions have been removed, just set/get `nprobe` on the object as need (like the CPU side).

The net result is that flat indexes can contain > 2 GB of data, and individual IVF lists can similarity contain > 2 GB of data, as well as any tensor dimension can be over 2G (excepting vector dimension; see limitations below).

Notes:

- performance for large `k` (>= 512) or large `nprobe` (>= 512) deteriorates due to low occupancy in the k-selection kernels due to increased register pressure (we now maintain all indices as int64 rather than int32, thus requiring double the registers). However, based on tests this doesn't hurt more than 10-20% or so at these large sizes. Small `k`/`nprobe` has no significant effect, and in some cases is even faster (depending upon if we needed to produce int64 indices but computations were done internally using int32).
- `k`, like with CPU Faiss, is an int parameter everywhere still.
- `d`, like with CPU Faiss, is an int parameter everywhere except for places where dimensionality is inferred from a tensor dimension (in which case it is naturally `idx_`).
- `nprobe`, like `IndexIVF`, is `size_t` at the top level (`GpuIndexIVF` class member) but internally to the code it is either `int` or `idx_t` depending upon the context (e.g., if `nprobe` is extracted from a tensor dimension, it is already `idx_t`).

In the Faiss GPU code however, `k` and `nprobe` are still limited to 2048 maximum at present.

Reviewed By: alexanderguzhva

Differential Revision: D40494090

fbshipit-source-id: 8581aff86ff25091b47e59f749adebebf2d3b160
2023-02-03 12:11:22 -08:00
Jeff Johnson
13ccc683d1 Faiss GPU: change DeviceVector reallocation heuristic (#2691)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2691

`faiss::gpu::DeviceVector<T>` (the GPU analogue of `std::vector`) is used in Faiss GPU to store IVF list data, among other things. `thrust::device_vector` could not be used at the time of the library's authorship due to lack of certain features (stream usage from what I recall).

Like `std::vector`, it involves a heuristic used to determine what the new vector capacity should be in order to allow for a particular number of elements. It previously has always rounded up allocation sizes to the next highest power of 2, thus incremental appending to a DeviceVector amortizes the cost of memory (re-)allocation and only infrequently results in full re-allocation.

However, this doubling behavior was not limited. While at small sizes of individual IVF lists, this doubling is not that much of an issue (and there is a reclaim memory function on indices to reclaim unused memory resulting from this amortization). However, when operating with data sets close to GPU memory limits, this doubling is dangerous, as attempting to allocate, say, a GpuIndexFlat with 4.x GB of vectors on a 8 GB GPU could run out of memory.

Now we introduce a new heuristic:

- below 4 M list sizes, we always double (as before);
- otherwise, below 128 M list sizes, we only increase by 1.25x;
- otherwise, the allocation made by DeviceVector is exactly sized to the size requested by the user.

Reviewed By: mdouze

Differential Revision: D42951571

fbshipit-source-id: 462d8af582725869ab5642b81e27db0e71774c6e
2023-02-02 11:21:05 -08:00
Gergely Szilvasy
72f52af6e4 iterable invlists support range search (#2681)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2681

1. added support for range search
2. refactored iterator to eliminate copying of codes

Reviewed By: mdouze

Differential Revision: D42841542

fbshipit-source-id: 188f950b2ca83b43009e7d7066cacf4221f773b3
2023-01-31 03:40:20 -08:00
Yinze
38593cdbfc fix typo (#2481)
Summary:
`ptointer` to `pointer`

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

Reviewed By: algoriddle

Differential Revision: D42806088

Pulled By: mlomeli1

fbshipit-source-id: 87ef2bbdf4e19d81f6984607ddbfc62012938658
2023-01-30 01:57:56 -08:00
Ikko Eltociear Ashimine
93cc1d7925 Fix typo in Dockerfile (#2648)
Summary:
necesary -> necessary

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

Reviewed By: alexanderguzhva

Differential Revision: D42805978

Pulled By: mlomeli1

fbshipit-source-id: 1d640918dfe85e79856b18ce718fb26bbb0c6a92
2023-01-27 08:56:37 -08:00
Gergely Szilvasy
bff0b156be iterable inverted lists
Summary: Adding support for iterable inverted lists, eg.  key value stores.

Reviewed By: mdouze

Differential Revision: D42778489

fbshipit-source-id: 2236fb37a2c3ae4bc5b384c2e2325f405b673ac9
2023-01-27 07:42:34 -08:00
Matthijs Douze
cf15b89786 indicate default values in class declaration (#2676)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2676

This is a cosmetic diff where default values for scalar fields are moved to the .h file where the object is declared rather than in the object constructor. The advantage is that it is easier to read the default value of a parameter from just the class.

Reviewed By: alexanderguzhva

Differential Revision: D42722205

fbshipit-source-id: 9d9bc4641068f6d6233f60f0a3a16ab793c94bb8
2023-01-26 09:39:47 -08:00
Matthijs Douze
c74cf4f52f Support CPU quantizer parameters in GPU autotune
Summary:
IVF GPU indexes now support CPU quantizers.
In order for the the auto-tuning to support accessing the parameters of the quantizers, GpuAutoTune needs to be adapted.

Reviewed By: algoriddle

Differential Revision: D42633348

fbshipit-source-id: ef472855aa882ccde9d878ae09782204045e38c5
2023-01-24 11:24:47 -08:00
generatedunixname89002005325676
2ae369c276 Daily arc lint --take CLANGFORMAT
Differential Revision: D42496191

fbshipit-source-id: 6adcae2114498ecb0cc80984863e00b8ea36c2f6
2023-01-13 06:46:58 -08:00
Matthijs Douze
8fc3775472 building blocks for hybrid CPU / GPU search (#2638)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2638

This diff is a more streamlined way of searching IVF indexes with precomputed clusters.
This will be used for experiments with hybrid CPU / GPU search.

Reviewed By: algoriddle

Differential Revision: D41301032

fbshipit-source-id: a1d645fd0f2bf806454dfd04971edc0a6200d20d
2023-01-12 13:34:44 -08:00
Rico
1eb4f42639 fix c_api link error: undefined reference (#2660)
Summary:
detail error: undefined reference to `faiss_index_cpu_to_gpu_multiple_with_options'

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

Reviewed By: algoriddle

Differential Revision: D42471891

Pulled By: mdouze

fbshipit-source-id: 3316311ee7a3d856a764f1590372393bf51f11c6
2023-01-12 00:19:18 -08:00
Ji Bin
9c7ad74814 Adaptation for compile c_api with CUDA 12 (#2656)
Summary:
Closes https://github.com/facebookresearch/faiss/issues/2655

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

Reviewed By: algoriddle

Differential Revision: D42471852

Pulled By: mdouze

fbshipit-source-id: 72162acc1590e565cdfcbd78510ae757c396e970
2023-01-12 00:15:36 -08:00
chasingegg
62c7342db1 Enable precomputed table only if L2 quantizer and by_residual is true (#2659)
Summary:
Related issue https://github.com/facebookresearch/faiss/issues/2658

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

Reviewed By: algoriddle

Differential Revision: D42431369

Pulled By: mdouze

fbshipit-source-id: 4beeedd86e8090b499a3cd2931f3d9511bc49c51
2023-01-10 07:29:01 -08:00
pboueri
38bf321885 Missed import module throws unintended error (#2652)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2652

Reviewed By: algoriddle

Differential Revision: D42409264

Pulled By: mdouze

fbshipit-source-id: caf10d97a26a23aca240e67e38d449ca33c298c1
2023-01-09 03:40:36 -08:00
Matthijs Douze
75bd1fcacc Scan exactly max_codes elements (#2647)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2647

The `max_codes` search parameter for IVF indexes limits the number of distance computations that are performed.
Previously, the number of distance computations could exceed max_codes because inverted lists were scanned completely.
This diff changed this to scan the beginning of the last inverted list to reach `max_codes` exactly.

Reviewed By: alexanderguzhva

Differential Revision: D42367593

fbshipit-source-id: 67c88b93a407ab271397e913c5fa17104f4274c3
2023-01-09 00:11:07 -08:00
Alexandr Guzhva
135d3fdf43 about a magnitude faster LSQ/PLSQ training and encoding (#2650)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2650

LocalSearchQuantizer::icm_encode_step was optimized:
* The loop orders were changes
* Memory allocations were optimized
* Different order for accessing 'binaries' tensor, because it is symmetric
* SIMD for the lookup of the best code.

Results are unchanged.

Also, fixes incorrect test in test_local_search_quantizer.py

Reviewed By: mdouze

Differential Revision: D42352124

fbshipit-source-id: bf7e349f2123e6ee99e0776cf15ad5fc1cf2439a
2023-01-06 09:06:34 -08:00
Alexandr Guzhva
bbab020925 Modify approximate heap facility to maintain the correct order as if the input elements were pushed into the heap sequentially (#2651)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2651

Modify approximate heap facility to maintain the correct order as if the input elements were pushed into the heap sequentially

Reviewed By: mdouze

Differential Revision: D42373532

fbshipit-source-id: 477dc8acd2567157e2b99076a566326821021c8c
2023-01-06 09:06:34 -08:00
chasingegg
adc9d1a0cd Refactor prepare cache code in cmp_with_scann benchmark (#2573)
Summary:
In ```cmp_with_scann.py```, we will save npy file for base and query vector file and gt file. However, we will only do this while the lib is faiss, if we directly run this script with scann lib it will complain that file does not exsit.
Therefore, the code should be refactored to save npy file from the beginning so that nothing will go wrong.

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

Reviewed By: mdouze

Differential Revision: D42338435

Pulled By: algoriddle

fbshipit-source-id: 9227f95e1ff79f5329f6206a0cb7ca169185fdb3
2023-01-04 02:35:18 -08:00
chasingegg
af833cd770 Fix some typos (#2645)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2645

Reviewed By: mdouze

Differential Revision: D42338453

Pulled By: algoriddle

fbshipit-source-id: 1ea5c33960a42c9e8624b10eba067e722d712e34
2023-01-04 02:18:09 -08:00