Commit Graph

26 Commits (4bf99c317113bb09c7f451474521462b10bea2df)

Author SHA1 Message Date
Michael Norris eff0898a13 Enable linting: lint config changes plus arc lint command (#3966)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3966

This actually enables the linting.

Manual changes:
- tools/arcanist/lint/fbsource-licenselint-config.toml
- tools/arcanist/lint/fbsource-lint-engine.toml

Automated changes:
`arc lint --apply-patches --take LICENSELINT --paths-cmd 'hg files faiss'`

Reviewed By: asadoughi

Differential Revision: D64484165

fbshipit-source-id: 4f2f6e953c94ef6ebfea8a5ae035ccfbea65ed04
2024-10-22 09:46:48 -07:00
George Wang af70c5bcce 3893 - Fix index factory order of idmap and refinement (#3928)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3928

Fix issue in T203425107

Reviewed By: asadoughi

Differential Revision: D64068971

fbshipit-source-id: 56db439793539570a102773ff2c7158d48feb7a9
2024-10-08 17:18:13 -07:00
Matthijs Douze d85fda7fca Allow k and M suffixes in IVF indexes (#3812)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3812

Allows factory strings like `IVF3k,Flat` as a shorthand for 3072 centroids.

The main question is whether k or M should be metric (k=1000) or power of 2 (k=1024):

* pro-metric: standard,

* pro-power of 2: in practice we use powers of 2 most often

The suffixes ki and Mi should be used for powers of 2 but this makes the notation more heavy (which is what we wanted to avoid in the first place).

So I picked power of 2.

Reviewed By: mnorris11

Differential Revision: D62019941

fbshipit-source-id: f547962625123ecdfaa406067781c77386017793
2024-09-10 02:57:13 -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
Matthijs Douze 82352dd453 make nbits configurable for graph indices based on PQ (#3031)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3031

As requested in

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

Indeed, PQ sizes with nbits > 8 are good tradeoffs, so it is interesting to support them.

Reviewed By: pemazare

Differential Revision: D48860659

fbshipit-source-id: 6f3c642e0902e1523bef36db6be3af3688d529a5
2023-09-01 02:37:33 -07: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
Matthijs Douze a64c76fadd Fix sub-object ownership of python interface of IVFSpectralHash
Summary: Code would crash when deallocating the coarse quantizer for a IVFSpectralHash.

Reviewed By: algoriddle

Differential Revision: D40053030

fbshipit-source-id: 6a2987a6983f0e5fc5c5b6296d9000354176af83
2022-10-04 07:54:00 -07:00
Abdelrahman Elmeniawy f00de85645 T131797600 make index_factory support IDMap2 (#2478)
Summary:
makes index_factory support IDMap2 not only IDMap and add required tests
adding IDMap2 to index_factory would help users to take advantage of its extra features more than IDMap such as reconstruct the indices.

solves [issue 1864](https://github.com/facebookresearch/faiss/issues/1864)

+fix downcast_index IDMap / IDMap2 order

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

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

Reviewed By: mdouze

Differential Revision: D39660813

Pulled By: AbdelrahmanElmeniawy

fbshipit-source-id: 4881d325bb3b0eaf9637a544511d18c2084453eb
2022-09-23 06:16:36 -07:00
CodemodService Bot 02c8452eb9 fbcode//faiss/tests
Reviewed By: aijanai

Differential Revision: D35890159

fbshipit-source-id: a7962b36ae6879543c5f950ef73a619343541328
2022-04-25 17:55:46 -07:00
Matthijs Douze 8ffed8c219 common ancestor for quantizer classes (#2295)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2295

Makes a common ancestor for quantizer classes.
As a first application, adds a clone_Quantizer function

Reviewed By: alexanderguzhva

Differential Revision: D35561960

fbshipit-source-id: 896a4f3fc4ab992511cdc0642689a440f170f683
2022-04-20 01:34:01 -07:00
Matthijs Douze d68ff42195 Fix OPQ dimension parsing (#2147)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2147

There was a bug in the OPQ string parsing. This diff adds a test and fixes the error.

Reviewed By: aijanai

Differential Revision: D33020167

fbshipit-source-id: 32e43653849b258a3b6d0cfdc44a6c637433f2c8
2021-12-11 03:28:29 -08:00
Matthijs Douze a0b50e669f Re-factor factory string parsing (#2134)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2134

The old parsing was very complex and grew out of hand.
this diff just uses regex parsing.

Reviewed By: wickedfoo

Differential Revision: D32759110

fbshipit-source-id: 243029bba8a7fe70c71323f5edc7e2ce4e669757
2021-12-07 04:35:57 -08:00
Matthijs Douze 1829aa92a1 three small fixes (#1972)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1972

This fixes a few issues that I ran into + adds tests:

- range_search_max_results with IP search

- a few missing downcasts for VectorTRansforms

- ResultHeap supports max IP search

Reviewed By: wickedfoo

Differential Revision: D29525093

fbshipit-source-id: d4ff0aff1d83af9717ff1aaa2fe3cda7b53019a3
2021-07-01 16:08:45 -07:00
Check Deng 885d87f712 Support NSG in the index factory (#1758)
Summary:
## Description
This PR added NSG into the index factory. Here are the supported index strings:
1. `NSG{0}` or `NSG{0},Flat`: Create an IndexNSGFlat with `R = {0}`.
2. `IVF{0}_NSG{1},{2}`: Create an IndexIVF using NSG as a coarse quantizer where `ncentroids = {0}`, `R = {1}` and `{2}` is the second level quantizer.

These two types of indexes may be the most useful ones. Other composite indexes could be supported in the future.

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

Test Plan: buck test //faiss/tests/:test_factory

Reviewed By: beauby

Differential Revision: D27189479

Pulled By: mdouze

fbshipit-source-id: b60000f985c490ef2e7bc561b4e209f9f61c3cc8
2021-03-23 07:28:20 -07:00
Matthijs Douze 13e3039d5e Fix copy construction of AlignedTable
Summary: Copy construction of Aligned table was wrong, which crashed cloning of IVFPQ.

Reviewed By: wickedfoo

Differential Revision: D26426400

fbshipit-source-id: 1d43ea6309d0a56eb592f9d6c5b52282f494e653
2021-02-15 00:13:50 -08:00
Matthijs Douze c5975cda72 PQ4 fast scan benchmarks (#1555)
Summary:
Code + scripts for Faiss benchmarks around the  Fast scan codes.

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

Test Plan: buck test //faiss/tests/:test_refine

Reviewed By: wickedfoo

Differential Revision: D25546505

Pulled By: mdouze

fbshipit-source-id: 902486b7f47e36221a2671d124df8c114f25db58
2020-12-16 01:18:58 -08:00
Matthijs Douze 6d0bc58db6 Implementation of PQ4 search with SIMD instructions (#1542)
Summary:
IndexPQ and IndexIVFPQ implementations with AVX shuffle instructions.

The training and computing of the codes does not change wrt. the original PQ versions but the code layout is "packed" so that it can be used efficiently by the SIMD computation kernels.

The main changes are:

- new IndexPQFastScan and IndexIVFPQFastScan objects

- simdib.h for an abstraction above the AVX2 intrinsics

- BlockInvertedLists for invlists that are 32-byte aligned and where codes are not sequential

- pq4_fast_scan.h/.cpp:  for packing codes and look-up tables + optmized distance comptuation kernels

- simd_result_hander.h: SIMD version of result collection in heaps / reservoirs

Misc changes:

- added contrib.inspect_tools to access fields in C++ objects

- moved .h and .cpp code for inverted lists to an invlists/ subdirectory, and made a .h/.cpp for InvertedListsIOHook

- added a new inverted lists type with 32-byte aligned codes (for consumption by SIMD)

- moved Windows-specific intrinsics to platfrom_macros.h

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

Test Plan:
```
buck test mode/opt  -j 4  //faiss/tests/:test_fast_scan_ivf //faiss/tests/:test_fast_scan
buck test mode/opt  //faiss/manifold/...
```

Reviewed By: wickedfoo

Differential Revision: D25175439

Pulled By: mdouze

fbshipit-source-id: ad1a40c0df8c10f4b364bdec7172e43d71b56c34
2020-12-03 10:06:38 -08:00
Matthijs Douze e8c8db85ae fix #1213 2020-06-02 13:59:39 -07:00
Lucas Hosseini 22b7876ef5
Facebook sync (2020-03-10) (#1136) 2020-03-10 14:24:07 +01:00
Lucas Hosseini 2ba6985f81 Facebook sync 20191129 (#1048)
Looks good!
2019-12-04 07:21:02 +01: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 6880286ea0
Facebook sync (#504)
* Facebook sync

* Update swig wrappers.

* Fix comment.
2018-07-06 14:12:11 +02:00
Lucas Hosseini 6e40d6689f
Move python tests back together with C++ tests. (#479) 2018-06-04 12:20:44 +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 9933892ec9 sync with FB version 2017-01-09
- adding HNSW indexing method

- simultaneous search and reconstruction for IndexIVFPQ
2018-01-09 06:42:06 -08:00
matthijs fe446e41a2 bugfixes 2017-11-23 06:34:53 -08:00