Commit Graph

35 Commits (7e8f65ee224259fd089b5e1eafee053138aefafe)

Author SHA1 Message Date
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
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
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
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
Gergely Szilvasy 51b6083187 faiss on rocksdb demo (#3216)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3216

Reviewed By: mdouze

Differential Revision: D53051090

Pulled By: algoriddle

fbshipit-source-id: 13a027db36207af9be11a2f181116994b2aff2cb
2024-01-25 07:39:53 -08:00
Maria Lomeli 0fc8456e1d Offline IVF powered by faiss big batch search (#3202)
Summary:
This PR introduces the offline IVF (OIVF) framework which contains some tooling to run search using IVFPQ indexes (plus OPQ pretransforms) for large batches of queries using [big_batch_search](https://github.com/mlomeli1/faiss/blob/main/contrib/big_batch_search.py) and GPU faiss. See the [README](36226f5fe8/demos/offline_ivf/README.md) for details about using this framework.

This PR includes the following unit tests, which can be run with the unittest library as so:
````
~/faiss/demos/offline_ivf$ python3 -m unittest tests/test_iterate_input.py -k test_iterate_back
````
In test_offline_ivf:
````
test_consistency_check
test_train_index
test_index_shard_equal_file_sizes
test_index_shard_unequal_file_sizes
test_search
test_evaluate_without_margin
test_evaluate_without_margin_OPQ
````
In test_iterate_input:
````
test_iterate_input_file_larger_than_batch
test_get_vs_iterate
test_iterate_back

````

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

Reviewed By: algoriddle

Differential Revision: D52734222

Pulled By: mlomeli1

fbshipit-source-id: 61fd0084277c1b14bdae1189db8ae43340611e16
2024-01-16 05:05:15 -08:00
Gergely Szilvasy 77c28f8ba4 Back out "Offline IVF powered by faiss big batch search"
Summary: Revert so that the test data can be replaced with synthetic

Reviewed By: mdouze

Differential Revision: D52388604

fbshipit-source-id: c0037635a4e66c54d42400294d13d9a80610b845
2023-12-22 03:43:05 -08:00
Maria 9a8b34e295 Offline IVF powered by faiss big batch search (#3175)
Summary:
This PR introduces the offline IVF (OIVF) framework  which contains some tooling to run search using IVFPQ indexes (plus OPQ pretransforms) for large batches of queries using [big_batch_search](https://github.com/mlomeli1/faiss/blob/main/contrib/big_batch_search.py) and GPU faiss. See the [README](https://github.com/mlomeli1/faiss/blob/oivf/demos/offline_ivf/README.md) for details about using this framework.

This PR includes the following unit tests, which can be run with the unittest library as so:
````
~/faiss/demos/offline_ivf$ python3 -m unittest tests/test_iterate_input.py -k test_iterate_back
````

In test_offline_ivf:
````
test_consistency_check
test_train_index
test_index_shard_equal_file_sizes
test_index_shard_unequal_file_sizes
 test_search
test_evaluate_without_margin
test_evaluate_without_margin_OPQ
test_evaluate_with_margin
test_split_batch_size_bigger_than_file_sizes
test_split_batch_size_smaller_than_file_sizes
test_split_files_with_corrupted_input_file
````

In test_iterate_input:
````
test_iterate_input_file_larger_than_batch
test_get_vs_iterate
test_iterate_back
````

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

Reviewed By: algoriddle

Differential Revision: D52218447

Pulled By: mlomeli1

fbshipit-source-id: 78b12457c79b02eb2c9ae993560f2e295798e7e5
2023-12-18 15:09:31 -08:00
chasingegg 6218111233 Fix some typos (#3056)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3056

Reviewed By: pemazare

Differential Revision: D49617607

Pulled By: mlomeli1

fbshipit-source-id: b2d5df67e88e029882e697597af9f3fc8fe1e64c
2023-09-27 03:17:41 -07:00
generatedunixname89002005287564 d85601d972 fairring, faiss, fairness (4401366386162573988)
Reviewed By: r-barnes

Differential Revision: D49181434

fbshipit-source-id: 0554ec62155b422e4abe9cec709b69587f71dea0
2023-09-14 00:50:50 -07: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
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
Matthijs Douze bb4c987b5c Demo of residual quantizer distance computer for LaserKNN (#2283)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2283

This is a demonstration for:

- how to use a distance computer to compute query-to-code distances with a residual quantizer

- how to construct a ResidualCoarseQuantizer that uses a prefix of residalquantizer codes

See related doc https://docs.google.com/document/d/1g97lrMXVYh5FcQzw23v_sUE22ybHfCFxtbHyFJwxKKE/edit?usp=sharing

Reviewed By: alexanderguzhva

Differential Revision: D34958088

fbshipit-source-id: edb06ee350de67f855e96ae57a3862fbf14f6e54
2022-04-06 12:42:24 -07:00
Check Deng d6535a3d87 Add NNDescent to faiss (#1654)
Summary:
As discussed in https://github.com/facebookresearch/faiss/issues/685, I'm going to add an NSG index to faiss. This PR which adds an NNDescent index is the first step as I commented [here ](https://github.com/facebookresearch/faiss/issues/685#issuecomment-760608431).

**Changes:**
1. Add an `IndexNNDescent` and an `IndexNNDescentFlat` which allow users to construct a KNN graph on a million scale dataset using CPU and search NN on it. The implementation part is put under `faiss/impl`.
2. Add compilation entries to `CMakeLists.txt` for C++ and `swigfaiss.swig` for Python. `IndexNNDescentFlat` could be directly called by users in C++ and Python.
3. `VisitedTable` struct in `HNSW.h` is moved into `AuxIndexStructures.h`.
3. Add a demo `demo_nndescent.cpp` to demonstrate the effectiveness.

**TODO**
1. Support index factor.
2. Implement `IndexNNDescentPQ` and `IndexNNDescentSQ`
3. More comments in the code.

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

Test Plan:
buck test //faiss/tests/:test_index_accuracy -- TestNNDescent

buck test //faiss/tests/:test_build_blocks -- TestNNDescentKNNG

Reviewed By: wickedfoo

Differential Revision: D26309716

Pulled By: mdouze

fbshipit-source-id: 2abade9708d29023f8bccbf77143e8eea14f66c4
2021-02-25 16:48:28 -08:00
Lucas Hosseini e86bf8cae1 Enable clang-format + autofix.
Summary: Format whole codebase with clang-format.

Reviewed By: mdouze

Differential Revision: D22891341

fbshipit-source-id: 673032b2444d61026d1e2c3fa2c5659f178cf58b
2021-02-25 04:46:10 -08:00
Matthijs Douze f351a83ef6 Update demo_imi_pq.cpp (#1636)
Summary:
remove long.
This is to close PR https://github.com/facebookresearch/faiss/issues/1050

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

Reviewed By: beauby

Differential Revision: D25994690

Pulled By: mdouze

fbshipit-source-id: 35dfa4295602f64053883594b5a7d0b9b7293545
2021-01-22 00:04:19 -08:00
Matthijs Douze 0b55f10f7e Fix ASAN bugs in demo_sift1M
Summary: Fixes 2 bugs spotted by ASAN in the demo.

Reviewed By: wenjieX

Differential Revision: D25897053

fbshipit-source-id: fd2bed13faded42426cefc5ebe9d027adec78015
2021-01-13 08:28:25 -08:00
Matthijs Douze 9c51bbb977 Fix faiss_contrib (#1478)
Summary:
Fixes the path issue mentioned in https://github.com/facebookresearch/faiss/issues/1472

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

Reviewed By: LowikC

Differential Revision: D24394529

Pulled By: mdouze

fbshipit-source-id: 5e4261a0f271751c736c562514f2ee8604c50702
2020-10-20 04:35:19 -07:00
Lucas Hosseini 70eaa9b1a3 Add missing copyright headers. (#1460)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1460

Reviewed By: wickedfoo

Differential Revision: D24278804

Pulled By: beauby

fbshipit-source-id: 5ea96ceb63be76a34f1eb4da03972159342cd5b6
2020-10-13 11:15:59 -07:00
Lucas Hosseini c37e71456b Get rid of non-portable drand48. (#1349)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1349

Reviewed By: mdouze

Differential Revision: D23289393

Pulled By: beauby

fbshipit-source-id: a626bbf252ced4ae01abbc3dce4be50d9e628728
2020-08-24 00:42:21 -07:00
Lucas Hosseini a8e4c5e2d5 Move build to CMake (#1313)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1313

Reviewed By: mdouze

Differential Revision: D22948267

Pulled By: beauby

fbshipit-source-id: ec16fa0342f37672d46fb7886ecc55c7996011c4
2020-08-14 15:03:10 -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
Lucas Hosseini 22b7876ef5
Facebook sync (2020-03-10) (#1136) 2020-03-10 14:24:07 +01:00
Matthijs Douze 4c32fa4d14
Update demo_sift1M.cpp 2019-11-19 11:18:47 +01: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
Lucas Hosseini a8118acbc5
Facebook sync (May 2019) + relicense (#838)
Changelog:

- changed license: BSD+Patents -> MIT
- propagates exceptions raised in sub-indexes of IndexShards and IndexReplicas
- support for searching several inverted lists in parallel (parallel_mode != 0)
- better support for PQ codes where nbit != 8 or 16
- IVFSpectralHash implementation: spectral hash codes inside an IVF
- 6-bit per component scalar quantizer (4 and 8 bit were already supported)
- combinations of inverted lists: HStackInvertedLists and VStackInvertedLists
- configurable number of threads for OnDiskInvertedLists prefetching (including 0=no prefetch)
- more test and demo code compatible with Python 3 (print with parentheses)
- refactored benchmark code: data loading is now in a single file
2019-05-28 16:17:22 +02:00
Lucas Hosseini 7f5b22b0ff
Add conda packages metadata + tests. (#769)
+ Add conda packages metadata (now building Faiss using conda's toolchain);
+ add Dockerfile for building conda packages (for all CUDA versions);
+ add working Dockerfile building faiss on Centos7;
+ simplify GPU build;
+ avoid falling back to CPU-only version (python);
+ simplify TravisCI config;
+ update INSTALL.md;
+ add configure flag for specifying target architectures (--with-cuda-arch);
+ fix Makefile for gpu tests;
+ fix various Makefile issues;
+ remove stale file (gpu/utils/DeviceUtils.cpp).
2019-04-05 11:50:39 +02:00
Lucas Hosseini 6c1cb3cd5c Fix ivfpq demo. (#763)
Makes sense.
2019-04-03 11:24:33 +02:00
Minjoon Seo c6a53c078b Bug fix: data needed to be added with ids (#723)
When data is being added to each index block, it needs to explicitly identify ids.
2019-02-10 05:44:05 +01:00
Lucas Hosseini 6880286ea0
Facebook sync (#504)
* Facebook sync

* Update swig wrappers.

* Fix comment.
2018-07-06 14:12:11 +02:00
Lucas Hosseini cf18101f6d Refactor makefiles and add configure script (#466)
* Refactors Makefiles and add configure script.

* Give MKL higher priority in configure script.

* Clean up Linux example makefile.inc.

* Cleanup makefile.inc examples.

* Fix python clean Makefile target.

* Regen swig wrappers.

* Remove useless CUDAFLAGS variable.

* Fix python linking flags.

* Separate compile and link phase in python makefile.

* Add macro to look for swig.

* Add CUDA check in configure script.

* Cleanup make depend targets.

* Cleanup CUDA flags.

* Fix linking flags.

* Fix python GPU linking.

* Remove useless flags from python gpu module linking.

* Add check for cuda libs.

* Cleanup GPU targets.

* Clean up test target.

* Add cpu/gpu targets to python makefile.

* Clean up tutorial Makefile.

* Remove stale OS var from example makefiles.

* Clean up cuda example flags.
2018-06-02 08:35:30 +02:00
Matthijs Douze 0c482e54eb sync with FB version 2018-02-23 (#347)
- support on-disk IVF
2018-02-23 07:49:45 -08:00