23 Commits

Author SHA1 Message Date
Amir Sadoughi
caa3b341b0 Increment next release, v1.9.0 (#3887)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3887

Reviewed By: kuarora

Differential Revision: D63355030

Pulled By: asadoughi

fbshipit-source-id: 38792e49fe678c2811896faca7a3ddcab19f8bd0
2024-10-04 12:44:15 -07:00
Ramil Bakhshyiev
7657e812c4 Change index_cpu_to_gpu to throw for indices not implemented on GPU (#3336)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3336

Issues:
https://github.com/facebookresearch/faiss/issues/3269
https://github.com/facebookresearch/faiss/issues/3024

List of implemented GPU indices: https://github.com/facebookresearch/faiss/wiki/Faiss-on-the-GPU#implemented-indexes

Reviewed By: mdouze

Differential Revision: D55577576

fbshipit-source-id: 49f490cfba6784661e378acf4de3cce4195bb43b
2024-04-05 18:13:03 -07:00
Junjie Qi
943d08bdad Prepare for v.1.8.0 release (#3265)
Summary:
Prepare for v1.8.0 release

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

Reviewed By: mdouze

Differential Revision: D54232846

Pulled By: junjieqi

fbshipit-source-id: f92efc93e340507262321c5033bab7fede7d7f40
2024-02-29 13:24:50 -08:00
Matthijs Douze
32f0e8cf92 Generalize ResultHanlder, support range search for HNSW and Fast Scan (#3190)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3190

This diff adds more result handlers in order to expose them externally.
This enables range search for HSNW and Fast Scan, and nprobe parameter support for FastScan.

Reviewed By: pemazare

Differential Revision: D52547384

fbshipit-source-id: 271da5ffea6411df3d8e50641abade18bd7b774b
2024-01-11 11:46:30 -08:00
Maria Lomeli
d87888b13e Prepare for v1.7.4 release (#2820)
Summary:
Updated the changelog with features since last release, see https://github.com/facebookresearch/faiss/compare/1.7.3_release...main for details. Please comment if you want to highlight anything that I've missed.

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

Reviewed By: mdouze

Differential Revision: D44922916

Pulled By: mlomeli1

fbshipit-source-id: db16754698af4dd0fb8dddff7ec9885170a3d5c4
2023-04-19 06:18:30 -07:00
Maria
19f7696dee Updated changelog with implemented features for 1.7.3 release (#2564)
Summary:
This PR adds the features that AbdelrahmanElmeniawy worked on during his internship and the speedups by alexanderguzhva in the CHANGELOG, ahead of the 1.7.3 release

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

Reviewed By: algoriddle

Differential Revision: D41119343

Pulled By: mlomeli1

fbshipit-source-id: b41ce354440dea2a6f8f214bf6654ff453ef10e7
2022-11-08 03:44:51 -08:00
Maria
02ef6b6c09 Prepare for v1.7.3 release (#2560)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2560

Reviewed By: mdouze

Differential Revision: D40947377

Pulled By: mlomeli1

fbshipit-source-id: b7c6f0ea85b5c3b2005e96af3d504edd137e42fc
2022-11-04 09:48:11 -07:00
Matthijs Douze
af25054e2d support IDSelector in more classes (#2509)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2509

Adds support for:
- IDSelector for Flat and SQ
- search_type in SearchParametersPQ
- IDSelectors implemented in Python (slow but good for testing)

Start optimization of IDSelectorRange and IDSelectorArray for IndexFlat and IDSelectorRange for IndexIVF

Reviewed By: alexanderguzhva

Differential Revision: D40037795

fbshipit-source-id: 61e01acb43c6aa39fea2c3b67a8bba9072383b74
2022-10-06 23:03:23 -07:00
Check Deng
838f85cb52 Implement search methods for ProductAdditiveQuantizer (#2336)
Summary:
Work in progress.

This PR is going to implement the following search methods for ProductAdditiveQuantizer, including index factory and I/O:

- [x] IndexProductAdditiveQuantizer
- [x] IndexIVFProductAdditiveQuantizer
- [x] IndexProductAdditiveQuantizerFastScan
- [x] IndexIVFProductAdditiveQuantizerFastScan

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

Test Plan:
buck test //faiss/tests/:test_fast_scan
buck test //faiss/tests/:test_fast_scan_ivf
buck test //faiss/tests/:test_local_search_quantizer
buck test //faiss/tests/:test_residual_quantizer

Reviewed By: alexanderguzhva

Differential Revision: D37172745

Pulled By: mdouze

fbshipit-source-id: 6ff18bfc462525478c90cd42e21805ab8605bd0f
2022-07-27 05:32:15 -07:00
Matthijs Douze
291353c5a9 Generalize DistanceComputer for flat indexes (#2255)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2255

The `DistanceComputer` object is derived from an Index (obtained with `get_distance_computer()`). It maintains a current query and quickly computes distances from that query to any item in the database. This is useful, eg. for the IndexHNSW and IndexNSG that rely on query-to-point comparisons in the datasets.

This diff introduces the `FlatCodesDistanceComputer`, that inherits from `DistanceComputer` for Flat indexes. In addition to the distance-to-item function, it adds a `distance_to_code` that computes the distance from any code to the current query, even if it is not stored in the index.

This is implemented for all FlatCode indexes (IndexFlat, IndexPQ, IndexScalarQuantizer and IndexAdditiveQuantizer).

In the process, the two classes were extracted to their own header file `impl/DistanceComputer.h`

Reviewed By: beauby

Differential Revision: D34863609

fbshipit-source-id: 39d8c66475e55c3223c4a6a210827aa48bca292d
2022-03-20 23:43:33 -07:00
Matthijs Douze
b8fe92dfee contrib clustering module (#2217)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2217

This diff introduces a new Faiss contrib module that contains:
- generic k-means implemented in python (was in distributed_ondisk)
- the two-level clustering code, including a simple function that runs it on a Faiss IVF index.
- sparse clustering code (new)

The main idea is that that code is often re-used so better have it in contrib.

Reviewed By: beauby

Differential Revision: D34170932

fbshipit-source-id: cc297cc56d241b5ef421500ed410d8e2be0f1b77
2022-02-28 14:18:47 -08:00
Lucas Hosseini
c08cbff1a4 Prepare for v1.7.2 release. (#2151)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2151

Reviewed By: mdouze

Differential Revision: D33157463

Pulled By: beauby

fbshipit-source-id: 8f8580a7ad953484f41fbbb2d001f3484fab4c3d
2021-12-16 15:44:23 -08:00
Chengqi Deng
26abede812 Non-uniform quantization of vector norms (#2037)
Summary:
This diff implemented non-uniform quantization of vector norms in additive quantizers. index_factory and I/O are supported.

index_factory:  `XXX_Ncqint{nbits}` where `nbits` is the number of bits to quantize vector norm.

For 8 bits code, it is almost the same as 8-bit uniform quantization. It will slightly improve the accuracy if the code size is less than 8 bits.
```
RQ4x8_Nqint8:  R@1 0.1116
RQ4x8_Ncqint8: R@1 0.1117

RQ4x8_Nqint4:  R@1 0.0901
RQ4x8_Ncqint4: R@1 0.0989
```

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

Test Plan:
buck test //faiss/tests/:test_clustering -- TestClustering1D
buck test //faiss/tests/:test_lsq -- test_index_accuracy_cqint
buck test //faiss/tests/:test_residual_quantizer -- test_norm_cqint
buck test //faiss/tests/:test_residual_quantizer -- test_search_L2

Reviewed By: beauby

Differential Revision: D31083476

Pulled By: mdouze

fbshipit-source-id: f34c3dafc4eb1c6f44a63e68137158911aa4a2f4
2021-10-11 14:13:16 -07:00
Chengqi Deng
eba1cb1a90 Support LSQ on GPU (#1978)
Summary:
## Description

This PR added support for LSQ on GPU. Only the encoding part is running on GPU and the others are still running on CPU.

Multi-GPU is also supported.

## Usage

``` python
lsq = faiss.LocalSearchQuantizer(d, M, nbits)
ngpus = faiss.get_num_gpus()
lsq.icm_encoder_factory = faiss.GpuIcmEncoderFactory(ngpus)  # we use all gpus

lsq.train(xt)
codes = lsq.compute_codes(xb)
decoded = lsq.decode(codes)
```

## Performance on SIFT1M

On 1 GPU:
```
===== lsq-gpu:
        mean square error = 17337.878528
        training time: 40.9857234954834 s
        encoding time: 27.12640070915222 s
```

On 2 GPUs:
```
===== lsq-gpu:
        mean square error = 17364.658176
        training time: 25.832106113433838 s
        encoding time: 14.879548072814941 s
```

On CPU:
```
===== lsq:
        mean square error = 17305.880576
        training time: 152.57522344589233 s
        encoding time: 110.01779270172119 s
```

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

Test Plan: buck test mode/dev-nosan //faiss/gpu/test/:test_gpu_index_py -- TestLSQIcmEncoder

Reviewed By: wickedfoo

Differential Revision: D29609763

Pulled By: mdouze

fbshipit-source-id: b6ffa2a3c02bf696a4e52348132affa0dd838870
2021-09-09 09:13:15 -07:00
Lucas Hosseini
b4eb51dae8 Change default branch references from master to main. (#2029)
Summary:
This is required for the renaming of the default branch from `master` to `main`, in accordance with the new Facebook OSS guidelines.

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

Reviewed By: mdouze

Differential Revision: D30672862

Pulled By: beauby

fbshipit-source-id: 0b6458a4ff02a12aae14cf94057e85fdcbcbff96
2021-09-01 09:26:20 -07:00
Lucas Hosseini
cff072b78e Prepare for release v1.7.1. (#1915)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1915

Reviewed By: mdouze

Differential Revision: D28749880

Pulled By: beauby

fbshipit-source-id: 4dcb0a5eac8f84d26570a0fb6f3e357bc2f1151c
2021-05-27 10:49:37 -07:00
Chengqi Deng
c087f87730 Add LocalSearchQuantizer (#1906)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1906

This PR implemented LSQ/LSQ++, a vector quantization technique described in the following two papers:

1. Revisiting additive quantization
2. LSQ++: Lower running time and higher recall in multi-codebook quantization

Here is a benchmark running on SIFT1M for 64 bits encoding:
```
===== lsq:
        mean square error = 17335.390208
        training time: 312.729779958725 s
        encoding time: 244.6277096271515 s
===== pq:
        mean square error = 23743.004672
        training time: 1.1610801219940186 s
        encoding time: 2.636141061782837 s
===== rq:
        mean square error = 20999.737344
        training time: 31.813055515289307 s
        encoding time: 307.51959800720215 s
```

Changes:

1. Add LocalSearchQuantizer object
2. Fix an out of memory bug in ResidualQuantizer
3. Add a benchmark for evaluating quantizers
4. Add tests for LocalSearchQuantizer

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

Test Plan:
```
buck test //faiss/tests/:test_lsq

buck run mode/opt //faiss/benchs/:bench_quantizer -- lsq pq rq
```

Reviewed By: beauby

Differential Revision: D28376369

Pulled By: mdouze

fbshipit-source-id: 2a394d38bf75b9de0a1c2cd6faddf7dd362a6fa8
2021-05-21 01:33:55 -07:00
Matthijs Douze
8bc7fb6294 Fix CMakeLists for Residual quantizer (#1846)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1846

Forgot to add the IndexResidual to the CMakeLists.txt

Reviewed By: beauby

Differential Revision: D28024663

fbshipit-source-id: 64cfb14f140b6c34d740c63543f88ae5d2980e72
2021-04-27 04:46:57 -07:00
Matthijs Douze
7559cf5c5b add ResidualQuantizer
Summary:
This diff includes:
- progressive dimension k-means.
- the ResidualQuantizer object
- GpuProgressiveDimIndexFactory so that it can be trained on GPU
- corresponding tests
- reference Python implementation of the same in scripts/matthijs/LCC_encoding

Reviewed By: wickedfoo

Differential Revision: D27608029

fbshipit-source-id: 9a8cf3310c8439a93641961ca8b042941f0f4249
2021-04-14 13:11:54 -07:00
H. Vetinari
9c58ae00f1 Portable SWIG Vectors (#1742)
Summary:
After initial positive feedback to the idea in https://github.com/facebookresearch/faiss/issues/1741 from mdouze, here are the patches
I currently have as a basis for discussion.

Matthijs suggests to not bother with the deprecation warnings at all, which is fine for me
as well, though I would normally still advocate to provide users with _some_ advance notice
before removing parts of an interface.

Fixes https://github.com/facebookresearch/faiss/issues/1741

PS. The deprecation warning is only shown once per session (per class)
PPS. I have tested in https://github.com/conda-forge/faiss-split-feedstock/pull/32 that the respective
classes remain available both through `import faiss` and `from faiss import *`.

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

Reviewed By: mdouze

Differential Revision: D26978886

Pulled By: beauby

fbshipit-source-id: b52e2b5b5b0117af7cd95ef5df3128e9914633ad
2021-04-02 07:11:47 -07:00
Check Deng
b35103a138 Add NSG (#1707)
Summary:
## Description:
This diff implemented Navigating Spreading-out Graph (NSG) which accepts a KNN graph as input.
Here is the interface of building an NSG graph:
``` c++
void IndexNSG::build(idx_t n, const float *x, idx_t *knn_graph, int GK);
```
where `GK` is the nb of neighbors per node and `knn_graph[i * GK + j]` is the j-th neighbor of node i.

The `add` method is not implemented yet.

The unit tests could be found in `tests/test_nsg.cpp`.

mdouze beauby Maybe I need some advice on how to design the interface and support python.

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

Test Plan: buck test //faiss/tests/:test_index -- TestNSG

Reviewed By: beauby

Differential Revision: D26748498

Pulled By: mdouze

fbshipit-source-id: 3280f705fb1b5f9c8cc5efeba63b904c3b832544
2021-03-10 15:03:00 -08: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
Lucas Hosseini
6f271490e8 Add CHANGELOG.md. (#1688)
Summary:
The file follows the format described in
https://keepachangelog.com/en/1.0.0/.

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

Reviewed By: mdouze

Differential Revision: D26454197

Pulled By: beauby

fbshipit-source-id: 16bafed43897479c7e87fae202b08e95107c6658
2021-02-16 06:31:22 -08:00