Commit Graph

17 Commits (261edde5142a93a4e021a5c16ff46688794c7847)

Author SHA1 Message Date
Alexandr Guzhva 6a94c67a2f QT_bf16 for scalar quantizer for bfloat16 (#3444)
Summary:
mdouze Please let me know if any additional unit tests are needed

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

Reviewed By: algoriddle

Differential Revision: D57665641

Pulled By: mdouze

fbshipit-source-id: 9bec91306a1c31ea4f1f1d726c9d60ac6415fdfc
2024-05-23 02:59:15 -07:00
Xiao Fu bf8bd6b689 Delete all remaining print (#3452)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3452

Delete all remaining print within the Tests to improve the readability and effectiveness of the codebase.

Reviewed By: junjieqi

Differential Revision: D57466393

fbshipit-source-id: 6ebd66ae2e769894d810d4ba7a5f69fc865b797d
2024-05-16 19:51:07 -07:00
Matthijs Douze b109d086a2 Search and return codes (#3143)
Summary:
This PR adds a functionality where an IVF index can be searched and the corresponding codes be returned. It also adds a few functions to compress int arrays into a bit-compact representation.

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

Test Plan:
```
buck test //faiss/tests/:test_index_composite -- TestSearchAndReconstruct

buck test //faiss/tests/:test_standalone_codec -- test_arrays
```

Reviewed By: algoriddle

Differential Revision: D51544613

Pulled By: mdouze

fbshipit-source-id: 875f72d0f9140096851592422570efa0f65431fc
2023-11-25 13:57:25 -08:00
Matthijs Douze 1c1d5c808f Make tests a little less verbose
Summary: Useful info on github test runs is burried in spurious logging. Avoid this.

Reviewed By: mlomeli1

Differential Revision: D47209139

fbshipit-source-id: b5111c91e2b94f0c3678d599197f8e7094993df1
2023-07-04 07:02:53 -07:00
Alexandr Guzhva 0b74765cca Speedup exhaustive_L2sqr_blas for AVX2, ARM NEON and AVX512 (#2568)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2568

Add a fused kernel for exhaustive_L2sqr_blas() call that combines a computation of dot product and the search for the nearest centroid. As a result, no temporary dot product values are written and read in RAM.

Speeds up the training of PQx[1] indices for dsub = 1, 2, 4, 8, and the effect is higher for higher values of [1]. AVX512 version provides additional overloads for dsub = 12, 16.

The speedup is also beneficial for higher values of pq.cp.max_points_per_centroid (which is 256 by default).

Speeds up IVFPQ training as well.

AVX512 kernel is not enabled, but I've seen it speeding up the training TWICE versus AVX2 version. So, please feel free to use it by enabling AVX512 manually.

Reviewed By: mdouze

Differential Revision: D41166766

fbshipit-source-id: 443014e2e59396b3a90b9171fec8c8191052bcf4
2022-11-14 17:01:52 -08:00
Alexandr Guzhva fb8193d151 Add sa_decode() to IndexIVFAdditiveQuantizer (#2362)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2362

Reviewed By: mdouze

Differential Revision: D37280450

fbshipit-source-id: 610b553e8219df9a9f52442ffc3942036f47284a
2022-06-20 10:54:11 -07:00
Matthijs Douze bef12cf51b Implement LCC's RCQ + ITQ in Faiss (#2123)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2123

One of the encodings used by LCC is based on a RCQ coarse quantizer and a "payload" of ITQ. The codes are compared with Hamming distances.

The index type `IndexIVFSpectralHash` can be re-purposed to perfrorm this type of index.

This diff contains a small demo demo_rcq_itq script in python to show how:
* the RCQ + ITQ are trained
* the RCQ + ITQ index add and search work (with a very inefficient python implementation)
* they can be transferred to an `IndexIVFSpectralHash`
* the python implementation and `IndexIVFSpectralHash` give the same results

The advantage of using to an `IndexIVFSpectralHash` is that in C++ it offers an `InvertedListScanner` object that can be used to compute query to code distances with its `distance_to_code` method. This is generic and will generalize to  other types of encodings and coarse quantizers.

What is missing is an index_factory to make instanciation easier.

Reviewed By: sc268

Differential Revision: D32642900

fbshipit-source-id: 284f3029d239b7946bbca44a748def4e058489bd
2021-11-25 15:59:18 -08:00
Matthijs Douze c659dd2dc9 Support 2 concatenated codecs (#2117)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2117

This supports 2 concatenated codecs. It is based on IndexRefine, that already does this but did not have a standalone codec interface.
The main use case for now is a residual quantizer + ITQ.
The test below demonstrates how to instantiate that.
The advantage is that the index_factory parser already exists.
The IndexRefine decoder just uses the second index decoder, that is supposed to be more accurate than the first.

Reviewed By: beauby

Differential Revision: D32569997

fbshipit-source-id: 3fe9cd02eaa7d1cfe23b0f1168cc034821f1c362
2021-11-23 09:58:55 -08:00
Matthijs Douze 760cce7f3a Support for additive quantizer search (#1961)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1961

This diff implements LUT-based search for additive quantizers.
It also further merges code for LSQ and the RedisualQuantizer.

The documentation + evaluation is on github:

https://github.com/facebookresearch/faiss/wiki/Additive-quantizers

Reviewed By: wickedfoo

Differential Revision: D29395079

fbshipit-source-id: b8a24a647bbdc4cda2a699e791ffdb2a12bfa9c6
2021-08-20 01:00:10 -07:00
Matthijs Douze 2d380e992b Add manifold check for size 0 (#1867)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1867

Merging code for the 1T photodna index seems to fail at

https://www.internalfb.com/phabricator/paste/view/P412975011?lines=174

with
```
terminate called after throwing an instance of 'facebook::manifold::blobstore::StorageException'
  what():  [400] Begin offset and/or length were invalid -- Begin offset must be positive and length must be non-negative. Received: offset = 2642410612, length = 0
Aborted (core dumped)
```
traces back to

https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/fbcode/manifold/blobstore/BlobstoreThriftHandler.cpp?lines=671%2C700%2C732

There is a single case where we don't check if the read or write size is 0. So let's try this fix.

In the process I realized that the Manifold tests were non functional due to a name collision on common.py. Also fix this in all dependent files.

Differential Revision: D28231710

fbshipit-source-id: 700ffa6ca0c82c49e7d1eae9e76549ec5ff16332
2021-05-09 22:30:31 -07:00
Lucas Hosseini 6d51766607 Fix unused variables in python
Reviewed By: mdouze

Differential Revision: D26633983

fbshipit-source-id: 32b9f95ed9647716f65b93f2713a8d5bad6abe78
2021-02-24 11:52:18 -08:00
Matthijs Douze 3dd7ba8ff9 Add range search accuracy evaluation
Summary:
Added a few functions in contrib to:
- run range searches by batches on the query or the database side
- emulate range search on GPU: search on GPU with k=1024, if the farthest neighbor is still within range, re-perform search on CPU
- as reference implementations for precision-recall on range search datasets
- optimized code to plot precision-recall plots (ie. sweep over thresholds)

The new functions are mainly in a new `evaluation.py`

Reviewed By: wickedfoo

Differential Revision: D25627619

fbshipit-source-id: 58f90654c32c925557d7bbf8083efbb710712e03
2020-12-17 17:17:09 -08:00
Matthijs Douze 6d73c2ff69 Fix int64 for python tests in windows (#1381)
Summary:
`long` is 32 bits on windows and so is the default int type for numpy (eg. the one used for `np.arange`).
This diff explicitly specifies 64-bit ints for all occurrences where it matters.

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

Reviewed By: wickedfoo

Differential Revision: D23371232

Pulled By: mdouze

fbshipit-source-id: 220262cd70ee70379f83de93561a4eae71c94b04
2020-08-27 12:40:55 -07:00
Lucas Hosseini f3727a62f5 Remove python shebangs in tests.
Reviewed By: mdouze

Differential Revision: D23167048

fbshipit-source-id: 98196f489461bc922e6124e88e0bfb32dfe507ca
2020-08-17 11:46:26 -07:00
Lucas Hosseini ac74f576f7 fbshipit-source-id: 4f3cfa59471d548af93fe118d1b73d45bc648edf 2020-08-04 12:00:38 -07:00
Lucas Hosseini cd38e82f0c
Facebook sync 2020-07-31 (#1308) 2020-08-03 22:15:02 +02:00
Lucas Hosseini 36ddba9196
Facebook sync (2019-09-10) (#943)
* Facebook sync (2019-09-10)

* Fix depends Makefile target.

* Add faiss symlink for new include directives.

* Fix missing header.

* Fix tests.

* Fix Makefile.

* Update depend.

* Fix include directives spacing.
2019-09-20 18:59:10 +02:00