Commit Graph

14 Commits (9f13e4348692631945dbfc4e4d51fe82d504f9f3)

Author SHA1 Message Date
Matthijs Douze a996a4a052 Put idx_t in the faiss namespace (#2582)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2582

A few more or less cosmetic improvements
* Index::idx_t was in the Index object, which does not make much sense, this diff moves it to faiss::idx_t
* replace multiprocessing.dummy with multiprocessing.pool
* add Alexandr as a core contributor of Faiss in the README ;-)

```
for i in $( find . -name \*.cu -o -name \*.cuh -o -name \*.h -o -name \*.cpp ) ; do
  sed -i s/Index::idx_t/idx_t/ $i
done
```

For the fbcode deps:
```
for i in $( fbgs Index::idx_t --exclude fbcode/faiss -l ) ; do
   sed -i s/Index::idx_t/idx_t/ $i
done
```

Reviewed By: algoriddle

Differential Revision: D41437507

fbshipit-source-id: 8300f2a3ae97cace6172f3f14a9be3a83999fb89
2022-11-30 08:25:30 -08:00
Alexandr Guzhva 135203a251 Add faiss.IO_FLAG_SKIP_PRECOMPUTE_TABLE flag for faiss.read_index() (#2489)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2489

Currently, Faiss does not save the precomputed_table for IVFPQ when saving an index, and reconstructs one on the fly upon loading. The introduced flag allows to skip the reconstruction during faiss.read_index()

Reviewed By: mdouze

Differential Revision: D39747978

fbshipit-source-id: 47d3cfc59e791e2e0b986301764ccc5b220292f4
2022-09-23 11:19:46 -07:00
Abdelrahman Elmeniawy c6c7862089 T132029385 support merge for IndexFlatCodes (#2488)
Summary:
support merge for all IndexFlatCodes children
make merge_from and check_compatible_for_merge methods of Index and IndexIVF and IndexFlatCodes(the only supported types) inherit them from Index.

This is part 1 of 2 as merge_into still not updated

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

Test Plan:
cd build
make -j
make test
cd faiss/python && python setup.py build
cd ../../..
PYTHONPATH="$(ls -d ./build/faiss/python/build/lib*/)" pytest tests/test_*.py

# fbcode

 buck test //faiss/tests/:test_index_merge

buck test //faiss/tests/:test_io

Reviewed By: mdouze

Differential Revision: D39726378

Pulled By: AbdelrahmanElmeniawy

fbshipit-source-id: 6739477fddcad3c7a990f3aae9be07c1b2b74fef
2022-09-23 07:19:21 -07:00
Matthijs Douze c0052c1533 IndexFlatCodes: a single parent for all flat codecs (#2132)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2132

This diff adds the class IndexFlatCodes that becomes the parent of all "flat" encodings.
IndexPQ
IndexFlat
IndexAdditiveQuantizer
IndexScalarQuantizer
IndexLSH
Index2Layer

The other changes are:
- for IndexFlat, there is no vector<float> with the data anymore. It is replaced with a `get_xb()` function. This broke quite a few external codes, that this diff also attempts to fix.
- I/O functions needed to be adapted. This is done without changing the I/O format for any index.
- added a small contrib function to get the data from the IndexFlat
- the functionality has been made uniform, for example remove_ids and add are now in the parent class.

Eventually, we may support generic storage for flat indexes, similar to `InvertedLists`, eg to memmap the data, but this will again require a big change.

Reviewed By: wickedfoo

Differential Revision: D32646769

fbshipit-source-id: 04a1659173fd51b130ae45d345176b72183cae40
2021-12-07 01:31:07 -08: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
Matthijs Douze 57e29a5cb7 Implement serialization of indexes
Summary: add getstate / setstate to serialize indexes. Seems to work properly with object ownership etc.

Reviewed By: wickedfoo

Differential Revision: D26521228

fbshipit-source-id: ebbe08cfe2c15af2aa5b7ea1fc1bf87546066c23
2021-02-19 12:08:27 -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
Lucas Hosseini 2434e91ef7 Fix leaking fd in test_io. (#1362)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1362

Test Plan: Imported from OSS

Reviewed By: mdouze

Differential Revision: D23311998

Pulled By: beauby

fbshipit-source-id: 9de47f9650eee2a07d302ac1753d60d0d00c2f0f
2020-08-24 23:53:27 -07:00
Lucas Hosseini 24c4460dd2 Avoid leaking file descriptors in python tests. (#1353)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1353

Test Plan: Imported from OSS

Reviewed By: mdouze

Differential Revision: D23292456

Pulled By: beauby

fbshipit-source-id: 44458eb16d037883ff39827accf5edddb1b1bb89
2020-08-24 06:46:52 -07:00
Lucas Hosseini 10bddff11c Fix unclosed thread pool. (#1351)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1351

Test Plan: Imported from OSS

Reviewed By: mdouze

Differential Revision: D23292458

Pulled By: beauby

fbshipit-source-id: 5f134178d2991d90bb5bbd50414af6febafb141d
2020-08-24 06:46:52 -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 a17a631dc3
Sync 20200323. (#1157)
* Sync 20200323.

* Bump version.

* Remove warning filter.
2020-03-24 14:06:48 +01:00