facebookresearch / faiss

A library for efficient similarity search and clustering of dense vectors.

Home Page:https://faiss.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GpuIndexFlatL2 doesn't produce distances for the last 8 queries

JulianThijssen opened this issue · comments

Platform

OS: Windows 10
Faiss version: 1.7.3

Installed from: Compiled using Visual Studio 17 2022

Faiss compilation options: Using MKL 2202.2.1

Cuda version: 12.0.0

GPU: GTX 1060

Running on:

  • CPU
  • GPU

Interface:

  • C++
  • Python

Reproduction instructions

Using the test file linked below, faiss makes a CPU index and a GPU index. Then performs a query search on the first 1000 vectors from a 100000 vector database. Code copied directly from 1-Flat for the CPU portion, and 4-GPU for the GPU portion.

Consistently, the last 8 vectors from the distance matrix are all 0's. Whether querying 1000 elements, or 10000 elements, it's only the last 8 elements.

6-GPU-CPU.zip

Output of the program is as follows:

Building data
Make index
is_trained = true
ntotal = 100000
I (5 first results)=
    0   723   254   152   403    92   368  1129   673   571
    1   995   136   183   223   555   880   671     5    68
    2   312   253    29   124   148   112   718   713   260
    3   983   467    88   786   327   326   684   367  1053
    4   403   112   643   430   679   142   733   119   382
I (10 last results)=
  990   962  2284   863  1133  1683  1463  2339  1730  2228
  991  1026   995   540  1396   365  1348  1271  1861   975
  992   257   163   135  1489  1315   878  1017   219   777
  993  1331   210  1362   286   444  1329   608  1191   986
  994   155   134   631   469  1044   388  1042   766  1561
  995   511     1   664   991  1800   689    37   634   631
  996   770  1043   827  1264  1310  1828  1504  1535   876
  997  1288   920   742  1432   840  1174  1337  1041  1113
  998   689  1044   810  1229  2199  1448  2112  1888  1442
  999  1722   901  1161  1044  1251   505  1310   791   308
D (10 last results)=
      0 6.46885 6.56971 6.80382 7.19488 7.25274 7.44602 7.56737 7.75592  7.8215
      0 5.75124 5.96521 6.00626 6.17735  6.6787 6.74106 6.87712 6.89094 6.89425
      0 5.82659 6.08222 6.16805 6.19852 6.25793 6.56962 6.60474 6.71429 6.72893
      0 6.79663 6.83468  6.9018 6.90929 7.06563 7.07221 7.15147 7.18442 7.20781
      0 6.02754 6.53414 6.62136 6.73151 6.83076 6.85785 6.86768 6.87643 6.89012
      0 5.52238 5.78548 5.80803 5.96521 5.97704 6.12522  6.1321 6.18419 6.51028
      0 5.73736 6.25742 6.38132 6.43517 6.63315 6.70425 6.81538 6.84794  6.8531
      0 6.59953 6.84864 7.11777 7.33908 7.38752 7.39641 7.48399 7.52819 7.60603
      0 5.54166 5.68894 5.72082 5.98355 6.49582 6.52649  6.5502 6.66038 6.66049
      0 6.26311 6.37093 6.39842 6.62256 6.73258 6.82148 6.83769 6.84539 6.91491
is_trained = true
ntotal = 100000
I (5 first results)=
    0   723   254   152   403    92   368  1129   673   571
    1   995   136   183   223   555   880   671     5    68
    2   312   253    29   124   148   112   718   713   260
    3   983   467    88   786   327   326   684   367  1053
    4   403   112   643   430   679   142   733   119   382
I (10 last results)=
  990   962  2284   863  1133  1683  1463  2339  1730  2228
  991  1026   995   540  1396   365  1348  1271  1861   975
  992   257   163   135  1489  1315   878  1017   219   777
  993  1331   210  1362   286   444  1329   608  1191   986
  994   155   134   631   469  1044   388  1042   766  1561
  995   511     1   664   991  1800   689    37   634   631
  996   770  1043   827  1264  1310  1828  1504  1535   876
  997  1288   920   742  1432   840  1174  1337  1041  1113
  998   689  1044   810  1229  2199  1448  2112  1888  1442
  999  1722   901  1161  1044  1251   505  1310   791   308
D (10 last results)=
7.62939e-06 6.46885 6.56971 6.80381 7.19488 7.25273 7.44602 7.56738 7.75592  7.8215
      0 5.75124 5.96521 6.00626 6.17735 6.67871 6.74106 6.87711 6.89094 6.89426
      0       0       0       0       0       0       0       0       0       0
      0       0       0       0       0       0       0       0       0       0
      0       0       0       0       0       0       0       0       0       0
      0       0       0       0       0       0       0       0       0       0
      0       0       0       0       0       0       0       0       0       0
      0       0       0       0       0       0       0       0       0       0
      0       0       0       0       0       0       0       0       0       0
      0       0       0       0       0       0       0       0       0       0

Compiled with the current Faiss, a Quadro GP100, Cuda 11.3: the problem does not occur.