463 Commits

Author SHA1 Message Date
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
H. Vetinari
1afaddbb28 Windows: portable intrinsics (#1684)
Summary:
Trying to compile windows for AVX2 in https://github.com/conda-forge/faiss-split-feedstock/pull/27
(after https://github.com/facebookresearch/faiss/issues/1600) surfaced a bunch of things (https://github.com/facebookresearch/faiss/issues/1680, https://github.com/facebookresearch/faiss/issues/1681, https://github.com/facebookresearch/faiss/issues/1682), but the most voluminous problem
was MSVC being much worse at dealing with operator overloads and casts around `__m128` / `__m256`.

This lead to loads of errors that looked as follows:
```
[...]\faiss\utils\distances_simd.cpp(411): error C2676: binary '+=': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(440): error C2676: binary '-': '__m256' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(441): error C2676: binary '*': 'const __m256' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(446): error C2676: binary '+=': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(451): error C2676: binary '-': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(452): error C2676: binary '*': 'const __m128' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(459): error C2676: binary '-': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(460): error C2676: binary '*': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator
[...]\faiss\utils\distances_simd.cpp(471): error C2440: '<function-style-cast>': cannot convert from '__m256i' to '__m256'
```

I've followed https://software.intel.com/sites/landingpage/IntrinsicsGuide/ to try to replace everything correctly,
but this will surely require close review, because I'm not sure how well these code-paths are checked by the
test suite.

In any case, with the commits from https://github.com/facebookresearch/faiss/issues/1600 #1666 https://github.com/facebookresearch/faiss/issues/1680 #1681 https://github.com/facebookresearch/faiss/issues/1682, I was able to build `libfaiss` & `faiss`
for AVX2 on windows (while remaining "green" on linux/osx, both with & without AVX2).

Sidenote: the issues in the last commit (26fc7cf139)
were uncovered by adding the `__SSE3__` compat macros in https://github.com/facebookresearch/faiss/issues/1681.

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

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

Reviewed By: beauby

Differential Revision: D26454443

Pulled By: mdouze

fbshipit-source-id: 70df0818e357f1ecea6a056d619618df0236e0eb
2021-02-18 11:28:47 -08:00
H. Vetinari
d0ad3d71f4 make setup.py win+avx2 compatible (#1682)
Summary:
While working on https://github.com/conda-forge/faiss-split-feedstock/pull/27, it turned out I needed
to patch `setup.py` anyway. In order to unify how the extension of the built lib is set, I fell back
to another patch that would/will become necessary if faiss ever wants to support PyPy
(see discussion in https://github.com/conda-forge/faiss-split-feedstock/pull/22).

It would be nice if this was done natively by CMake, but as far as I can tell from
https://gitlab.kitware.com/cmake/cmake/-/issues/21070, cmake is not likely to do that right away.

I didn't particularly expect this patch to be upstreamed (especially if there is no interest for PyPy support, for example),
but beauby [invited](https://github.com/conda-forge/faiss-split-feedstock/pull/27#issuecomment-777291797)
me to post it so here goes (plus necessary adaptations to the conda recipes)

Related to https://github.com/facebookresearch/faiss/issues/1600, https://github.com/facebookresearch/faiss/issues/1680, https://github.com/facebookresearch/faiss/issues/1681

PS. I thought about using `logger.INFO` in case of an import failure for AVX2, but since it's a setup file,
I thought `print` would actually be more useful. Happy to change or remove if desired.

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

Reviewed By: wickedfoo

Differential Revision: D26484393

Pulled By: beauby

fbshipit-source-id: 6cd2598838c4070dbf83d6f27ce15ce9faa6bf20
2021-02-17 15:09:04 -08:00
H. Vetinari
7ef4b030ee add msvc-compatible AVX2 switch in CMakeLists.txt (#1680)
Summary:
Upstreaming patches from https://github.com/conda-forge/faiss-split-feedstock/pull/27, follow-up (sorta) to https://github.com/facebookresearch/faiss/issues/1600.

Not sure if there are more CMake-native tricks to use here, but given that the flags don't have
an equivalent on the MSVC side, I think this approach is reasonable.

Without this patch, we would get:
```
cl : Command line warning D9002: ignoring unknown option '-mavx2'
cl : Command line warning D9002: ignoring unknown option '-mfma'
cl : Command line warning D9002: ignoring unknown option '-mf16c'
cl : Command line warning D9002: ignoring unknown option '-mpopcnt'
```

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

Reviewed By: wickedfoo

Differential Revision: D26484347

Pulled By: beauby

fbshipit-source-id: 2803132f2d81fe37dc494fc4c824b6e240ae973b
2021-02-17 14:06:54 -08:00
Lucas Hosseini
442c4317a0 Avoid building packages for compute_86 with CUDA 11.0. (#1694)
Summary:
Compute capability 86 is only available from CUDA 11.1 onwards, for
which Anaconda does not have a `cudatoolkit` package yet.

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

Reviewed By: wickedfoo

Differential Revision: D26482788

Pulled By: beauby

fbshipit-source-id: c0c84e0433ea9d9b04a1572001bd7c0d2ee82988
2021-02-17 09:53:24 -08:00
H. Vetinari
6d8afffadd Win+AVX2 compat (#1681)
Summary:
Upstreaming patches from conda-forge/faiss-split-feedstock#27, follow-up (sorta) to https://github.com/facebookresearch/faiss/issues/1600.

All these should be fairly uncontroversial, I think (mostly just oversights or stuff that never got
triggered on windows due to not having https://github.com/facebookresearch/faiss/issues/1680 so far).

Things work without `#include <faiss/impl/platform_macros.h>`, but I preferred to be explicit here,
because the `__SSEx__` macros (that are used in the affected files) are only defined there for windows.

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

Reviewed By: beauby

Differential Revision: D26454427

Pulled By: mdouze

fbshipit-source-id: 345e0ef45888f338e71bba004454a701572f9afb
2021-02-17 08:05:55 -08:00
Jeff Johnson
96d0d331a7 Fix CircleCI IVFPQ GPU tests (#1690)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1690

The GPU and CPU were trained separately in the failing test, leading to fairly different PQ centroids. Instead, just train on the GPU and copy to the CPU like other tests.

Also silences the not enough centroids warnings.

Reviewed By: beauby

Differential Revision: D26470199

fbshipit-source-id: 1f7c036671c03ed4a97c8c4a44d3c5b9767019cb
2021-02-16 16:03:48 -08:00
Chengqi Deng
b4a0a9c617 Handle the situation where nprobe > nlist in IndexIVF (#1673)
Summary:
## Description

Fix the bug mentioned in https://github.com/facebookresearch/faiss/issues/1010. When `nprobe` is greater than `nlist` in `IndexIVF`, the program will crash because the index will ask the quantizer to return more centroids than it owns.

## Changes:
1. Set `nprobe` as `nlist` if it is greater than `nlist` during searching.
2. Add one test to detect this bug.
3. Fix typo in `IndexPQ.cpp`.

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

Reviewed By: wickedfoo

Differential Revision: D26454420

Pulled By: mdouze

fbshipit-source-id: d1d0949e30802602e975a94ba873f9db29abd5ab
2021-02-16 09:54:23 -08:00
Lucas Hosseini
2a01135127 Add missing copyright headers. (#1689)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1689

Reviewed By: mdouze

Differential Revision: D26460606

Pulled By: beauby

fbshipit-source-id: ad35dd2ea3fb23a0b87bc04597a8fbc38393c997
2021-02-16 09:11:30 -08:00
Lucas Hosseini
0336293fec Update INSTALL.md. (#1686)
Summary:
Add detailed information about installing/building/testing.

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

Reviewed By: mdouze

Differential Revision: D26453860

Pulled By: beauby

fbshipit-source-id: a64f1ad46648d5576911459e833699ea37819c9d
2021-02-16 06:52:56 -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
Prabhat Roy
7a289d5418 Added C API to CMake and CircleCI (#1678)
Summary:
This supersedes https://github.com/facebookresearch/faiss/issues/1390 and https://github.com/facebookresearch/faiss/issues/1141.

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

Reviewed By: mdouze

Differential Revision: D26428986

Pulled By: beauby

fbshipit-source-id: 1e2718f457c1aca18c19edc2436d6baf9b627a60
2021-02-15 12:41:31 -08:00
Matthijs Douze
961dd8bfb8 Fix a few warnings with gcc
Summary: GCC flags a few more warnings than clang.

Reviewed By: wickedfoo

Differential Revision: D26421696

fbshipit-source-id: 3706ede205c03352667c1e483f014ca498666878
2021-02-15 03:55:00 -08: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
H. Vetinari
97ed48291a log success messages and errors in loader.py (#1683)
Summary:
This patch is to provide log information in case of failing to load the AVX2-enabled lib,
and also to log the successful loading of the libraries.

Otherwise, the programmatic detection of which library was loaded also needs to take
into account which other log statements were executed, if the original import failed due to an exception,
cf. the tests in https://github.com/conda-forge/faiss-split-feedstock/pull/27

Finally, this reduces the number of import statements by one - one non-AVX2 fallback is enough.

Related to https://github.com/facebookresearch/faiss/issues/1600, https://github.com/facebookresearch/faiss/issues/1680, https://github.com/facebookresearch/faiss/issues/1681, https://github.com/facebookresearch/faiss/issues/1682.

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

Reviewed By: mdouze

Differential Revision: D26424333

Pulled By: beauby

fbshipit-source-id: 16beddec7e0c098b913a7f5420cbb02d1cf515ad
2021-02-12 10:59:32 -08:00
Jeff Johnson
43ce2c93a4 CUDA 11 fixes + PQ training on the GPU
Summary:
This diff exposes the ProductQuantizer `pq` object to the user for manipulation in Python just as `IndexIVFPQ` does.

If no clustering index object is provided in `pq`, we create a `GpuIndexFlatL2` in order to perform the PQ training on the GPU as well.

Also raises the error threshold a bit in some tests, as the previous ones seem to be triggered on a V100 GPU.

Fixes an issue with AddException + (CUDA 11 and/or V100 GPUs) as well, where a `cudaMalloc` failure now seems to set state that is returned by `cudaGetLastError`. This we now clear before continuing.

Fixes an issue (possible cuBLAS bug, following up with Nvidia):

cublasSgemmEx in libcublas.so.11.1.0.229 returning CUBLAS_STATUS_NOT_SUPPORTED but would work fine in CUDA 9.2 (V100 GPU)

cublasSgemmEx(handle, CUBLAS_OP_T, CUBLAS_OP_N,
64, 8, 64,
&alpha,
A, CUDA_R_16F, 64,
B, CUDA_R_16F, 64,
&beta,
C, CUDA_R_32F, 64);

Using cublasGemmEx with CUBLAS_COMPUTE_32F and CUBLAS_GEMM_DEFAULT would also fail, but using CUBLAS_COMPUTE_32F_PEDANTIC with cublasGemmEx succeeds. Using PEDANTIC for CUDA 11 + f16 arguments for now.

Reviewed By: mdouze

Differential Revision: D26331887

fbshipit-source-id: c65448c4c79b58dd49b0220b393056e431ef53c0
2021-02-10 15:22:51 -08:00
Lucas Hosseini
08a0ce72a2 Fix nightly build for CUDA 11. (#1675)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1675

Reviewed By: mdouze

Differential Revision: D26338704

Pulled By: beauby

fbshipit-source-id: f440bbd05d6dbc09280e4f3631e4a9af99bde5f5
2021-02-09 07:44:27 -08:00
Lucas Hosseini
f5a8c29c57 Parameterize CUDA_ARCHS in packaging jobs. (#1671)
Summary:
This will allow us to support compute capabilities 8.0 and 8.6 (for
Ampere devices) with CUDA 11.

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

Reviewed By: mdouze

Differential Revision: D26338700

Pulled By: beauby

fbshipit-source-id: f023e7a37504d79ab78a45319e5a9cb825e7604a
2021-02-09 07:37:51 -08:00
Matthijs Douze
10c8583b2d Fix order of results for IndexBinaryHash and IndexBinaryMultiHash
Summary: The IndexBinaryHash and IndexBinaryMultiHash knn search functions returned results in a random order. This diff fixes that to the standard decreasing Hamming distance order + adds a test for that. I noticed on a notebook from sc268.

Reviewed By: sc268

Differential Revision: D26324795

fbshipit-source-id: 1444e26950e24bfac297f34f3d481d902d8ee769
2021-02-08 18:22:55 -08:00
Authman
976a942838 Cuda 11.0 Dockerimage for CircleCI conf (#1669)
Summary:
This small change adds a dockerimage for cuda11.0.

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

Reviewed By: mdouze

Differential Revision: D26278940

Pulled By: beauby

fbshipit-source-id: 59af80c0eac1fe8b512a8543ec15b5c7174219fb
2021-02-08 00:53:03 -08:00
Jeff Johnson
f15ce621f3 Expect warpSize == 32 and align allocations
Summary:
When new GPU compute capabilities were released, DeviceDefs.cuh had to be manually updated to expect them, as we statically compile the warp size (32 in all of Nvidia's current GPUs) into kernel code.

In order to avoid having to change this header for each new GPU generation (e.g., the new RTX devices which are CC 8.6), instead we just assume the warp size is 32, but when we initialize a GPU device and its resources in StandardGpuResources, we check to make sure that the GPU has a warp size of 32 as expected. Much code would have to change for a non-32 warp size (e.g., 64, as seen in AMD GPUs), so this is a hard assert. It is likely that Nvidia will never change this anyways for this reason.

Also, as part of the PQ register change, I noticed that temporary memory allocations were only being aligned to 16 bytes. This could cause inefficiencies in terms of excess gmem transactions. Instead, we bump this up to 256 bytes as the guaranteed alignment for all temporary memory allocations, which is the same guarantee that cudaMalloc provides.

Reviewed By: mdouze

Differential Revision: D26259976

fbshipit-source-id: 10b5fc708fffc9433683e85b9fd60da18fa9ed28
2021-02-04 13:22:36 -08:00
H. Vetinari
73141fb872 Add missing headers in faiss/[gpu/]CMakeLists.txt (#1666)
Summary:
While preparing https://github.com/conda-forge/faiss-split-feedstock/pull/26, I grepped for the expected headers based on the files in the repo, à la:
```
>ls faiss/invlists/ | grep -E "h$"
BlockInvertedLists.h
DirectMap.h
InvertedLists.h
InvertedListsIOHook.h
OnDiskInvertedLists.h
```

Doing so uncovered that there were some headers missing (apparently) in `CMakeLists.txt`, namely:
```
faiss/impl/ResultHandler.h
faiss/gpu/impl/IVFInterleaved.cuh
faiss/gpu/impl/InterleavedCodes.h
faiss/gpu/utils/WarpPackedBits.cuh
```

It's possible that they were left out intentionally, but I didn't see something that would make me think so e.g. in [`ResultHandler.h`](https://github.com/facebookresearch/faiss/blob/master/faiss/impl/ResultHandler.h).

While I was at it, I decided to order the filenames consistently (alphabetically, except for the increasing bit-sizes for blockselect/warpselect, as is already the case for `impl/scan/IVFInterleaved<x>.cu`), but of course, those commits could easily be dropped.

By reviewing the commits separately, it should be clear (for the first two) from the equal number of deletions/insertions (and the simple diff) that this is just a reshuffle. The only additions are in the last commit.

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

Reviewed By: wickedfoo

Differential Revision: D26248038

Pulled By: mdouze

fbshipit-source-id: 4add4959446deb16126c59b2d1e3f0305e6236c1
2021-02-04 09:22:58 -08:00
Matthijs Douze
5602724979 make calling conventions uniform between faiss.knn and faiss.knn_gpu
Summary: The order of xb an xq was different between `faiss.knn` and `faiss.knn_gpu`. Also the metric argument was called distance_type. This diff fixes both. Hopefully not too much external code depends on it.

Reviewed By: wickedfoo

Differential Revision: D26222853

fbshipit-source-id: b43e143d64d9ecbbdf541734895c13847cf2696c
2021-02-03 12:21:40 -08:00
shengjun.li
cf33102a7e Improve performance of Hamming computer (#1661)
Summary:
Signed-off-by: shengjun.li <shengjun.li@zilliz.com>

Improve performance of Hamming computer

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

Reviewed By: wickedfoo

Differential Revision: D26222892

Pulled By: mdouze

fbshipit-source-id: 5c1228b9e6c0f196ebcdfb0227ecdf7a02610871
2021-02-03 10:32:24 -08:00
Matthijs Douze
8894ba7488 convert CPU fp16 scalar quantizer to GpuFlat index
Summary:
fp16 scalar quantizer is supported via IndexFlat with foat16 option.
This diff also splits the python GPU tests in 2 files.

Reviewed By: wickedfoo

Differential Revision: D26221563

fbshipit-source-id: c08fce27e6acedc486478b37ef77ccebcefb3dc0
2021-02-03 09:13:07 -08:00
H. Vetinari
16b4e88aca make AVX2-detection platform-independent (#1600)
Summary:
In the context of https://github.com/conda-forge/faiss-split-feedstock/issues/23, I discussed with some of the conda-folks how we should support AVX2 (and potentially other builds) for faiss. In the meantime, we'd like to follow the model that faiss itself is using (i.e. build with AVX2 and without and then load the corresponding library at runtime depending on CPU capabilities).

Since windows support for this is missing (and the other stuff is also non-portable in `loader.py`), I chased down `numpy.distutils.cpuinfo`, which is pretty outdated, and opened: https://github.com/numpy/numpy/issues/18058

While the [private API](https://github.com/numpy/numpy/issues/18058#issuecomment-749852711) is obviously something that _could_ change at any time, I still think it's better than platform-dependent shenanigans.

Opening this here to ideally upstream this right away, rather than carrying patches in the conda-forge feedstock.

TODO:
* [ ] adapt conda recipe for windows in this repo to also build avx2 version

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

Reviewed By: beauby

Differential Revision: D25994705

Pulled By: mdouze

fbshipit-source-id: 9986bcfd4be0f232a57c0a844c72ec0e308fff19
2021-02-03 08:02:14 -08:00
Matthijs Douze
04f777ead5 Re-enable fast scan on Windows tests (#1663)
Summary:
Fast-scan tests were disabled on windows because of a heap corruption. This diff enables them because the free_aligned bug was fixed in the meantime.

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

Reviewed By: beauby

Differential Revision: D26201040

Pulled By: mdouze

fbshipit-source-id: 8d6223b4e42ccb1ce2da6e2c51d9e0833199bde7
2021-02-03 07:48:52 -08:00
Matthijs Douze
27077c4627 Small fixes for compilation on ARM (#1655)
Summary:
This PR fixes a few small issues with compilation on ARM.
It has been tested on an AWS c6g.8xlarge machine with Ubuntu 18.04.5 LTS.
Compilation instructions are here: https://github.com/facebookresearch/faiss/wiki/Installing-Faiss#compiling-faiss-on-arm

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

Reviewed By: wickedfoo

Differential Revision: D26145921

Pulled By: mdouze

fbshipit-source-id: 007e57a610f489885e78ba22bc82605d67661c44
2021-01-29 10:06:45 -08:00
Lucas Hosseini
7c2d2388a4 Bump version to 1.7.0. (#1652)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1652

Reviewed By: mdouze

Differential Revision: D26077948

Pulled By: beauby

fbshipit-source-id: 599ee61edd2425250948577cb55d145d9179ab25
v1.7.0
2021-01-27 03:37:26 -08:00
Andrew Aksyonoff
bc35be3e77 fixed free vs aligned_free mismatch (crashes on Windows!) (#1647)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1647

Reviewed By: wickedfoo

Differential Revision: D26074437

Pulled By: mdouze

fbshipit-source-id: f72b56c1a3681694e14ae07400e56a4a657c327c
2021-01-26 09:03:01 -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
shengjun.li
908812266c Add heap_replace_top to simplify heap_pop + heap_push (#1597)
Summary:
Signed-off-by: shengjun.li <shengjun.li@zilliz.com>

Add heap_replace_top to simplify heap_pop + heap_push

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

Test Plan:
OMP_NUM_THREADS=1 buck run mode/opt //faiss/benchs/:bench_heap_replace
OMP_NUM_THREADS=8 buck run mode/opt //faiss/benchs/:bench_heap_replace

Reviewed By: beauby

Differential Revision: D25943140

Pulled By: mdouze

fbshipit-source-id: 66fe67779dd281a7753f597542c2e797ba0d7df5
2021-01-20 11:28:08 -08:00
Matthijs Douze
a2791322d9 Update ProductQuantizer.cpp (#1634)
Summary:
Make error message more clear.
See https://github.com/facebookresearch/faiss/issues/1632

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

Reviewed By: beauby

Differential Revision: D25942961

Pulled By: mdouze

fbshipit-source-id: e96ca808a9a0dcd1de5417a5e048d39431b30a5e
2021-01-20 00:12:54 -08:00
Eduardo Pinho
9503cf0d6a Add GPU device utility functions (#1613)
Summary:
This adds some more functions to the C API, under a new DeviceUtils_c.h module. Resolves https://github.com/facebookresearch/faiss/issues/1414.

- `faiss_get_num_gpus`
- `faiss_gpu_profiler_start`
- `faiss_gpu_profiler_stop`
- `faiss_gpu_sync_all_devices`

The only minor issue right now is that building this requires basing it against an older version of Faiss until the building system is updated to use CMake (https://github.com/facebookresearch/faiss/issues/1390). I have provided a separate branch with the same contribution which is based against a version that works and builds OK: [`imp/c_api/add_gpu_device_utils`](https://github.com/Enet4/faiss/tree/imp/c_api/add_gpu_device_utils)

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

Reviewed By: wickedfoo

Differential Revision: D25942933

Pulled By: mdouze

fbshipit-source-id: 5b73a86b0c1702dfb7b9e56bd741f72495aac2fd
2021-01-19 17:23:12 -08:00
Jeff Johnson
d8b64b5122 Improve transpose performance
Summary:
The general array transposition kernel for the GPU in Faiss had two issues.

One, there was a typo (`+` instead of `*`) which did not cause a correctness bug but was a severe performance issue, since the general transposition kernel was written in 2016/2017. This was causing large slowdowns with precomputed code usage that I noticed while profiling over IVFPQ issues.

Two, the general transposition code was written for the most generic case. The transposition that we care about/use the most in Faiss is a transposition of outermost dimensions, say transposing an array [s1 s2 s3] -> [s2 s1 s3], where there are one or more innermost dimensions which are still contiguous in the new layout. A separate kernel has been written to cover this transposition case.

Also updates the code to avoid `unsigned int` and `unsigned long` in lieu of `uint32_t` and `uint64_t`.

D25703821 (removing serialize tags for GPU tests) is reverted in this as well, as that change prevents all GPU tests from being run locally on devservers; RE might have implicit serialization, but local execution doesn't.

Reviewed By: beauby

Differential Revision: D25929892

fbshipit-source-id: 66ddfc56189305f698a85c44abdeb64eb95ffe6b
2021-01-19 13:22:27 -08:00
Lucas Hosseini
010b05712c Update README.md (#1635)
Summary:
Update link to API docs website.

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

Reviewed By: mdouze

Differential Revision: D25942944

Pulled By: beauby

fbshipit-source-id: 573024b01c61f2464ecbf33e233cd93b2903a493
2021-01-18 01:13:28 -08:00
LiuJuanXi
39c4ff218a Update IVFBase.cuh (#1625)
Summary:
visual Studio compile problem(undefine reference)

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

Reviewed By: beauby

Differential Revision: D25928255

Pulled By: wickedfoo

fbshipit-source-id: c123eb6f263e8748fca6390beac0f7c0f4868163
2021-01-18 00:30:24 -08:00
LiuJuanXi
149e66959f Update GpuIndexFlat.h (#1626)
Summary:
visual Studio compile problem(undefine reference)

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

Reviewed By: beauby

Differential Revision: D25928072

Pulled By: wickedfoo

fbshipit-source-id: 464ad453f8f85a802e81d28d8f1a5fbae0b388f3
2021-01-18 00:29:58 -08:00
Matthijs Douze
950c831d45 Fix number of threads in test_ivfpq_codec when running in sandcastle
Summary: When running in a heavily parallelized env, the test becomes very slow and causes timeouts. Here we reduce the nb of threads.

Reviewed By: wickedfoo, Ben0mega

Differential Revision: D25921771

fbshipit-source-id: 1e0aacbb3e4f6e8f33ec893984b343eb5a610424
2021-01-17 13:42:06 -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
c7fd8d7ac3 improved range search evaluation functions
Summary: For range search evaluation, this diff adds optimized functions for ground-truth generation (on GPU).

Reviewed By: beauby

Differential Revision: D25822716

fbshipit-source-id: c5278dfad0510d24c2a5c87c1f8c81161fa8c5d3
2021-01-11 08:12:10 -08:00
Matthijs Douze
9b2384f305 Fix serialization of large hash indexes
Summary:
64-bit cleanness issue for BitstringWriter.
Shows in HashIndex I/O, see https://github.com/facebookresearch/faiss/issues/1532

Reviewed By: beauby

Differential Revision: D25804891

fbshipit-source-id: d4cd3714d116a1b2fe1c9446eb1e9d3a8acf854e
2021-01-11 05:48:12 -08:00
H. Vetinari
3d3d539bb5 Some fixes for building on windows + cuda (#1614)
Summary:
Upstreaming some work towards https://github.com/facebookresearch/faiss/issues/1586 from https://github.com/conda-forge/faiss-split-feedstock/pull/19; complements https://github.com/facebookresearch/faiss/issues/1610

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

Reviewed By: mdouze

Differential Revision: D25864994

Pulled By: wickedfoo

fbshipit-source-id: 4abaaebf1c4102c24c3a9dca544744318e780581
2021-01-11 00:46:02 -08:00
Matthijs Douze
1c996d0db7 Fix refine implementation (#1607)
Summary:
The IndexRefineFlat with pre-populated indexes could not be used because of the order of construction of the parent class. This diff fixes is. This addresses https://github.com/facebookresearch/faiss/issues/1604.

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

Reviewed By: wickedfoo

Differential Revision: D25801869

Pulled By: mdouze

fbshipit-source-id: 6098065e497dff39f4dd7474fa7136ba3610ef7e
2021-01-06 20:49:02 -08:00
Lucas Hosseini
d494251b5d Increase no-output timeout for Linux GPU nightlies build. (#1605)
Summary:
Since https://github.com/facebookresearch/faiss/issues/1566, the build for GPU seems to take significantly longer, causing GPU nightly builds to timeout.

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

Reviewed By: mdouze

Differential Revision: D25780754

Pulled By: beauby

fbshipit-source-id: 879fcb55550711dd21030a640eed9cc1ee820fba
2021-01-05 05:04:06 -08:00
Matthijs Douze
05774f1996 Fix compile gcc 7.3.0 (#1593)
Summary:
A small compilation issue with gcc 7.3.0, does not appear with 7.4.0.

Also updated the readme.

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

Reviewed By: beauby

Differential Revision: D25705885

Pulled By: mdouze

fbshipit-source-id: 920b35264463cdd6ad10bbb09e07cf483fcaa724
2021-01-04 11:49:16 -08:00
Lucas Hosseini
4774951982 GitHub actions hooks for GitHub pages docs website. (#1599)
Summary:
These hooks, along with the creation of the `gh-pages` branch with a Sphinx-powered website ([preview](https://beauby.github.io/faiss/)) will ensure automatic rebuild of the C++ API (doxygen) docs upon modification on `master`.
Moreover,  direct changes to the `gh-pages` branch will trigger a rebuild of the website as well.

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

Reviewed By: wickedfoo

Differential Revision: D25723322

Pulled By: beauby

fbshipit-source-id: fafeed64b393dce8c569f9fd1f5bc3b004706589
2020-12-29 13:46:54 -08:00
Lucas Hosseini
e6a19f190a Replace tempnam with mkstemp in tests. (#1596)
Summary:
This avoids triggering the following warnings:
```
tests/test_ondisk_ivf.cpp:36:24: warning: 'tempnam' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead. [-Wdeprecated-declarations]
        char *cfname = tempnam (nullptr, prefix);
                       ^
tests/test_merge.cpp:34:24: warning: 'tempnam' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead. [-Wdeprecated-declarations]
        char *cfname = tempnam (nullptr, prefix);
```

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

Reviewed By: wickedfoo

Differential Revision: D25710654

Pulled By: beauby

fbshipit-source-id: 2aa027c3b32f6cf7f41eb55360424ada6d200901
2020-12-29 13:37:05 -08:00
Lucas Hosseini
544e08f660 Fix SWIG dependencies in CMake. (#1591)
Summary:
CMake's SWIG module does not track dependencies to header files by
default, and they have to be stated manually.

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

Reviewed By: wickedfoo

Differential Revision: D25705493

Pulled By: beauby

fbshipit-source-id: faf70415efb0db677ea3ee8e38495d9ed39432d7
2020-12-29 13:27:03 -08:00
egolearner
7dce45f10f fix typo (#1553)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1553

Reviewed By: mdouze

Differential Revision: D25704031

Pulled By: beauby

fbshipit-source-id: d5a632a529ad71b40a583340a383071e74c356da
2020-12-25 05:57:25 -08:00