faiss 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (293) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/LICENSE.txt +1 -1
  4. data/lib/faiss/version.rb +1 -1
  5. data/vendor/faiss/faiss/AutoTune.cpp +2 -2
  6. data/vendor/faiss/faiss/AutoTune.h +3 -3
  7. data/vendor/faiss/faiss/Clustering.cpp +37 -6
  8. data/vendor/faiss/faiss/Clustering.h +12 -3
  9. data/vendor/faiss/faiss/IVFlib.cpp +6 -3
  10. data/vendor/faiss/faiss/IVFlib.h +2 -2
  11. data/vendor/faiss/faiss/Index.cpp +6 -2
  12. data/vendor/faiss/faiss/Index.h +30 -8
  13. data/vendor/faiss/faiss/Index2Layer.cpp +2 -2
  14. data/vendor/faiss/faiss/Index2Layer.h +2 -2
  15. data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +7 -7
  16. data/vendor/faiss/faiss/IndexAdditiveQuantizer.h +2 -2
  17. data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +14 -16
  18. data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h +2 -2
  19. data/vendor/faiss/faiss/IndexBinary.cpp +13 -2
  20. data/vendor/faiss/faiss/IndexBinary.h +8 -2
  21. data/vendor/faiss/faiss/IndexBinaryFlat.cpp +2 -3
  22. data/vendor/faiss/faiss/IndexBinaryFlat.h +2 -2
  23. data/vendor/faiss/faiss/IndexBinaryFromFloat.cpp +2 -2
  24. data/vendor/faiss/faiss/IndexBinaryFromFloat.h +2 -2
  25. data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +2 -7
  26. data/vendor/faiss/faiss/IndexBinaryHNSW.h +3 -3
  27. data/vendor/faiss/faiss/IndexBinaryHash.cpp +2 -3
  28. data/vendor/faiss/faiss/IndexBinaryHash.h +2 -2
  29. data/vendor/faiss/faiss/IndexBinaryIVF.cpp +3 -3
  30. data/vendor/faiss/faiss/IndexBinaryIVF.h +2 -2
  31. data/vendor/faiss/faiss/IndexFastScan.cpp +32 -18
  32. data/vendor/faiss/faiss/IndexFastScan.h +11 -2
  33. data/vendor/faiss/faiss/IndexFlat.cpp +13 -10
  34. data/vendor/faiss/faiss/IndexFlat.h +2 -2
  35. data/vendor/faiss/faiss/IndexFlatCodes.cpp +170 -7
  36. data/vendor/faiss/faiss/IndexFlatCodes.h +25 -5
  37. data/vendor/faiss/faiss/IndexHNSW.cpp +156 -96
  38. data/vendor/faiss/faiss/IndexHNSW.h +54 -5
  39. data/vendor/faiss/faiss/IndexIDMap.cpp +19 -3
  40. data/vendor/faiss/faiss/IndexIDMap.h +5 -2
  41. data/vendor/faiss/faiss/IndexIVF.cpp +5 -6
  42. data/vendor/faiss/faiss/IndexIVF.h +13 -4
  43. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +21 -7
  44. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +5 -2
  45. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +3 -14
  46. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +2 -4
  47. data/vendor/faiss/faiss/IndexIVFFastScan.cpp +201 -91
  48. data/vendor/faiss/faiss/IndexIVFFastScan.h +33 -9
  49. data/vendor/faiss/faiss/IndexIVFFlat.cpp +2 -2
  50. data/vendor/faiss/faiss/IndexIVFFlat.h +2 -2
  51. data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.cpp +2 -2
  52. data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.h +2 -2
  53. data/vendor/faiss/faiss/IndexIVFPQ.cpp +3 -6
  54. data/vendor/faiss/faiss/IndexIVFPQ.h +2 -2
  55. data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +7 -14
  56. data/vendor/faiss/faiss/IndexIVFPQFastScan.h +2 -4
  57. data/vendor/faiss/faiss/IndexIVFPQR.cpp +2 -2
  58. data/vendor/faiss/faiss/IndexIVFPQR.h +2 -2
  59. data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +2 -3
  60. data/vendor/faiss/faiss/IndexIVFSpectralHash.h +2 -2
  61. data/vendor/faiss/faiss/IndexLSH.cpp +2 -3
  62. data/vendor/faiss/faiss/IndexLSH.h +2 -2
  63. data/vendor/faiss/faiss/IndexLattice.cpp +3 -21
  64. data/vendor/faiss/faiss/IndexLattice.h +5 -24
  65. data/vendor/faiss/faiss/IndexNNDescent.cpp +2 -31
  66. data/vendor/faiss/faiss/IndexNNDescent.h +3 -3
  67. data/vendor/faiss/faiss/IndexNSG.cpp +2 -5
  68. data/vendor/faiss/faiss/IndexNSG.h +3 -3
  69. data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +56 -0
  70. data/vendor/faiss/faiss/IndexNeuralNetCodec.h +49 -0
  71. data/vendor/faiss/faiss/IndexPQ.cpp +26 -26
  72. data/vendor/faiss/faiss/IndexPQ.h +2 -2
  73. data/vendor/faiss/faiss/IndexPQFastScan.cpp +2 -5
  74. data/vendor/faiss/faiss/IndexPQFastScan.h +2 -11
  75. data/vendor/faiss/faiss/IndexPreTransform.cpp +2 -2
  76. data/vendor/faiss/faiss/IndexPreTransform.h +3 -3
  77. data/vendor/faiss/faiss/IndexRefine.cpp +46 -9
  78. data/vendor/faiss/faiss/IndexRefine.h +9 -2
  79. data/vendor/faiss/faiss/IndexReplicas.cpp +2 -2
  80. data/vendor/faiss/faiss/IndexReplicas.h +2 -2
  81. data/vendor/faiss/faiss/IndexRowwiseMinMax.cpp +2 -2
  82. data/vendor/faiss/faiss/IndexRowwiseMinMax.h +2 -2
  83. data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +5 -4
  84. data/vendor/faiss/faiss/IndexScalarQuantizer.h +2 -2
  85. data/vendor/faiss/faiss/IndexShards.cpp +2 -2
  86. data/vendor/faiss/faiss/IndexShards.h +2 -2
  87. data/vendor/faiss/faiss/IndexShardsIVF.cpp +2 -2
  88. data/vendor/faiss/faiss/IndexShardsIVF.h +2 -2
  89. data/vendor/faiss/faiss/MatrixStats.cpp +2 -2
  90. data/vendor/faiss/faiss/MatrixStats.h +2 -2
  91. data/vendor/faiss/faiss/MetaIndexes.cpp +2 -3
  92. data/vendor/faiss/faiss/MetaIndexes.h +2 -2
  93. data/vendor/faiss/faiss/MetricType.h +9 -4
  94. data/vendor/faiss/faiss/VectorTransform.cpp +2 -2
  95. data/vendor/faiss/faiss/VectorTransform.h +2 -2
  96. data/vendor/faiss/faiss/clone_index.cpp +2 -2
  97. data/vendor/faiss/faiss/clone_index.h +2 -2
  98. data/vendor/faiss/faiss/cppcontrib/SaDecodeKernels.h +2 -2
  99. data/vendor/faiss/faiss/cppcontrib/detail/CoarseBitType.h +2 -2
  100. data/vendor/faiss/faiss/cppcontrib/detail/UintReader.h +97 -19
  101. data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +192 -0
  102. data/vendor/faiss/faiss/cppcontrib/factory_tools.h +29 -0
  103. data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h +2 -2
  104. data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +85 -32
  105. data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-neon-inl.h +2 -2
  106. data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMax-inl.h +2 -2
  107. data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMaxFP16-inl.h +2 -2
  108. data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-avx2-inl.h +2 -2
  109. data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-inl.h +2 -2
  110. data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-neon-inl.h +2 -2
  111. data/vendor/faiss/faiss/gpu/GpuAutoTune.cpp +2 -5
  112. data/vendor/faiss/faiss/gpu/GpuAutoTune.h +2 -2
  113. data/vendor/faiss/faiss/gpu/GpuCloner.cpp +45 -13
  114. data/vendor/faiss/faiss/gpu/GpuCloner.h +2 -2
  115. data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +12 -6
  116. data/vendor/faiss/faiss/gpu/GpuDistance.h +11 -7
  117. data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +3 -3
  118. data/vendor/faiss/faiss/gpu/GpuIcmEncoder.h +2 -2
  119. data/vendor/faiss/faiss/gpu/GpuIndex.h +10 -15
  120. data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +2 -2
  121. data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +285 -0
  122. data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +2 -2
  123. data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +8 -2
  124. data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +4 -2
  125. data/vendor/faiss/faiss/gpu/GpuIndexIVFPQ.h +3 -3
  126. data/vendor/faiss/faiss/gpu/GpuIndexIVFScalarQuantizer.h +2 -2
  127. data/vendor/faiss/faiss/gpu/GpuIndicesOptions.h +2 -2
  128. data/vendor/faiss/faiss/gpu/GpuResources.cpp +7 -2
  129. data/vendor/faiss/faiss/gpu/GpuResources.h +11 -4
  130. data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +66 -11
  131. data/vendor/faiss/faiss/gpu/StandardGpuResources.h +15 -5
  132. data/vendor/faiss/faiss/gpu/impl/IndexUtils.h +2 -2
  133. data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.cpp +28 -23
  134. data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.h +2 -2
  135. data/vendor/faiss/faiss/gpu/impl/RemapIndices.cpp +2 -2
  136. data/vendor/faiss/faiss/gpu/impl/RemapIndices.h +2 -2
  137. data/vendor/faiss/faiss/gpu/perf/IndexWrapper-inl.h +2 -2
  138. data/vendor/faiss/faiss/gpu/perf/IndexWrapper.h +2 -2
  139. data/vendor/faiss/faiss/gpu/perf/PerfClustering.cpp +8 -2
  140. data/vendor/faiss/faiss/gpu/perf/PerfIVFPQAdd.cpp +2 -3
  141. data/vendor/faiss/faiss/gpu/perf/WriteIndex.cpp +2 -2
  142. data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +10 -7
  143. data/vendor/faiss/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp +2 -2
  144. data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +54 -54
  145. data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +144 -77
  146. data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFPQ.cpp +51 -51
  147. data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFScalarQuantizer.cpp +2 -2
  148. data/vendor/faiss/faiss/gpu/test/TestGpuMemoryException.cpp +3 -3
  149. data/vendor/faiss/faiss/gpu/test/TestGpuResidualQuantizer.cpp +70 -0
  150. data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +74 -4
  151. data/vendor/faiss/faiss/gpu/test/TestUtils.h +2 -2
  152. data/vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp +3 -3
  153. data/vendor/faiss/faiss/gpu/utils/{RaftUtils.h → CuvsUtils.h} +12 -11
  154. data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +8 -2
  155. data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp +2 -2
  156. data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.h +2 -2
  157. data/vendor/faiss/faiss/gpu/utils/StaticUtils.h +2 -2
  158. data/vendor/faiss/faiss/gpu/utils/Timer.cpp +6 -3
  159. data/vendor/faiss/faiss/gpu/utils/Timer.h +3 -3
  160. data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +79 -11
  161. data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +17 -5
  162. data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +27 -2
  163. data/vendor/faiss/faiss/impl/AuxIndexStructures.h +11 -3
  164. data/vendor/faiss/faiss/impl/CodePacker.cpp +2 -2
  165. data/vendor/faiss/faiss/impl/CodePacker.h +2 -2
  166. data/vendor/faiss/faiss/impl/DistanceComputer.h +48 -2
  167. data/vendor/faiss/faiss/impl/FaissAssert.h +6 -4
  168. data/vendor/faiss/faiss/impl/FaissException.cpp +2 -2
  169. data/vendor/faiss/faiss/impl/FaissException.h +2 -3
  170. data/vendor/faiss/faiss/impl/HNSW.cpp +378 -205
  171. data/vendor/faiss/faiss/impl/HNSW.h +55 -24
  172. data/vendor/faiss/faiss/impl/IDSelector.cpp +2 -2
  173. data/vendor/faiss/faiss/impl/IDSelector.h +2 -2
  174. data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +10 -10
  175. data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +2 -2
  176. data/vendor/faiss/faiss/impl/LookupTableScaler.h +36 -2
  177. data/vendor/faiss/faiss/impl/NNDescent.cpp +15 -10
  178. data/vendor/faiss/faiss/impl/NNDescent.h +2 -2
  179. data/vendor/faiss/faiss/impl/NSG.cpp +26 -49
  180. data/vendor/faiss/faiss/impl/NSG.h +20 -8
  181. data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +2 -2
  182. data/vendor/faiss/faiss/impl/PolysemousTraining.h +2 -2
  183. data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp +2 -4
  184. data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h +2 -2
  185. data/vendor/faiss/faiss/impl/ProductQuantizer-inl.h +2 -2
  186. data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +3 -2
  187. data/vendor/faiss/faiss/impl/ProductQuantizer.h +7 -3
  188. data/vendor/faiss/faiss/impl/Quantizer.h +2 -2
  189. data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +2 -36
  190. data/vendor/faiss/faiss/impl/ResidualQuantizer.h +3 -13
  191. data/vendor/faiss/faiss/impl/ResultHandler.h +153 -34
  192. data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +721 -104
  193. data/vendor/faiss/faiss/impl/ScalarQuantizer.h +5 -2
  194. data/vendor/faiss/faiss/impl/ThreadedIndex-inl.h +2 -2
  195. data/vendor/faiss/faiss/impl/ThreadedIndex.h +2 -2
  196. data/vendor/faiss/faiss/impl/code_distance/code_distance-avx2.h +7 -2
  197. data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +248 -0
  198. data/vendor/faiss/faiss/impl/code_distance/code_distance-generic.h +2 -2
  199. data/vendor/faiss/faiss/impl/code_distance/code_distance-sve.h +440 -0
  200. data/vendor/faiss/faiss/impl/code_distance/code_distance.h +55 -2
  201. data/vendor/faiss/faiss/impl/index_read.cpp +31 -20
  202. data/vendor/faiss/faiss/impl/index_read_utils.h +37 -0
  203. data/vendor/faiss/faiss/impl/index_write.cpp +30 -16
  204. data/vendor/faiss/faiss/impl/io.cpp +15 -7
  205. data/vendor/faiss/faiss/impl/io.h +6 -6
  206. data/vendor/faiss/faiss/impl/io_macros.h +8 -9
  207. data/vendor/faiss/faiss/impl/kmeans1d.cpp +2 -3
  208. data/vendor/faiss/faiss/impl/kmeans1d.h +2 -2
  209. data/vendor/faiss/faiss/impl/lattice_Zn.cpp +2 -3
  210. data/vendor/faiss/faiss/impl/lattice_Zn.h +2 -2
  211. data/vendor/faiss/faiss/impl/platform_macros.h +34 -2
  212. data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +13 -2
  213. data/vendor/faiss/faiss/impl/pq4_fast_scan.h +20 -2
  214. data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +3 -3
  215. data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +450 -3
  216. data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +8 -8
  217. data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +3 -3
  218. data/vendor/faiss/faiss/impl/simd_result_handlers.h +151 -67
  219. data/vendor/faiss/faiss/index_factory.cpp +51 -34
  220. data/vendor/faiss/faiss/index_factory.h +2 -2
  221. data/vendor/faiss/faiss/index_io.h +14 -7
  222. data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +30 -10
  223. data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +5 -2
  224. data/vendor/faiss/faiss/invlists/DirectMap.cpp +11 -3
  225. data/vendor/faiss/faiss/invlists/DirectMap.h +2 -2
  226. data/vendor/faiss/faiss/invlists/InvertedLists.cpp +57 -19
  227. data/vendor/faiss/faiss/invlists/InvertedLists.h +20 -11
  228. data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +2 -2
  229. data/vendor/faiss/faiss/invlists/InvertedListsIOHook.h +2 -2
  230. data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +23 -9
  231. data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +4 -3
  232. data/vendor/faiss/faiss/python/python_callbacks.cpp +5 -5
  233. data/vendor/faiss/faiss/python/python_callbacks.h +2 -2
  234. data/vendor/faiss/faiss/utils/AlignedTable.h +5 -3
  235. data/vendor/faiss/faiss/utils/Heap.cpp +2 -2
  236. data/vendor/faiss/faiss/utils/Heap.h +107 -2
  237. data/vendor/faiss/faiss/utils/NeuralNet.cpp +346 -0
  238. data/vendor/faiss/faiss/utils/NeuralNet.h +147 -0
  239. data/vendor/faiss/faiss/utils/WorkerThread.cpp +2 -2
  240. data/vendor/faiss/faiss/utils/WorkerThread.h +2 -2
  241. data/vendor/faiss/faiss/utils/approx_topk/approx_topk.h +2 -2
  242. data/vendor/faiss/faiss/utils/approx_topk/avx2-inl.h +2 -2
  243. data/vendor/faiss/faiss/utils/approx_topk/generic.h +2 -2
  244. data/vendor/faiss/faiss/utils/approx_topk/mode.h +2 -2
  245. data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +2 -2
  246. data/vendor/faiss/faiss/utils/bf16.h +36 -0
  247. data/vendor/faiss/faiss/utils/distances.cpp +249 -90
  248. data/vendor/faiss/faiss/utils/distances.h +8 -8
  249. data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +2 -2
  250. data/vendor/faiss/faiss/utils/distances_fused/avx512.h +2 -2
  251. data/vendor/faiss/faiss/utils/distances_fused/distances_fused.cpp +2 -2
  252. data/vendor/faiss/faiss/utils/distances_fused/distances_fused.h +2 -2
  253. data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +2 -2
  254. data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.h +2 -2
  255. data/vendor/faiss/faiss/utils/distances_simd.cpp +1543 -56
  256. data/vendor/faiss/faiss/utils/extra_distances-inl.h +72 -2
  257. data/vendor/faiss/faiss/utils/extra_distances.cpp +87 -140
  258. data/vendor/faiss/faiss/utils/extra_distances.h +5 -4
  259. data/vendor/faiss/faiss/utils/fp16-arm.h +2 -2
  260. data/vendor/faiss/faiss/utils/fp16-fp16c.h +2 -2
  261. data/vendor/faiss/faiss/utils/fp16-inl.h +2 -2
  262. data/vendor/faiss/faiss/utils/fp16.h +2 -2
  263. data/vendor/faiss/faiss/utils/hamming-inl.h +2 -2
  264. data/vendor/faiss/faiss/utils/hamming.cpp +3 -4
  265. data/vendor/faiss/faiss/utils/hamming.h +2 -2
  266. data/vendor/faiss/faiss/utils/hamming_distance/avx2-inl.h +2 -2
  267. data/vendor/faiss/faiss/utils/hamming_distance/avx512-inl.h +490 -0
  268. data/vendor/faiss/faiss/utils/hamming_distance/common.h +2 -2
  269. data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +6 -3
  270. data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +7 -3
  271. data/vendor/faiss/faiss/utils/hamming_distance/neon-inl.h +5 -5
  272. data/vendor/faiss/faiss/utils/ordered_key_value.h +2 -2
  273. data/vendor/faiss/faiss/utils/partitioning.cpp +2 -2
  274. data/vendor/faiss/faiss/utils/partitioning.h +2 -2
  275. data/vendor/faiss/faiss/utils/prefetch.h +2 -2
  276. data/vendor/faiss/faiss/utils/quantize_lut.cpp +2 -2
  277. data/vendor/faiss/faiss/utils/quantize_lut.h +2 -2
  278. data/vendor/faiss/faiss/utils/random.cpp +45 -2
  279. data/vendor/faiss/faiss/utils/random.h +27 -2
  280. data/vendor/faiss/faiss/utils/simdlib.h +12 -3
  281. data/vendor/faiss/faiss/utils/simdlib_avx2.h +2 -2
  282. data/vendor/faiss/faiss/utils/simdlib_avx512.h +296 -0
  283. data/vendor/faiss/faiss/utils/simdlib_emulated.h +2 -2
  284. data/vendor/faiss/faiss/utils/simdlib_neon.h +7 -4
  285. data/vendor/faiss/faiss/utils/simdlib_ppc64.h +1084 -0
  286. data/vendor/faiss/faiss/utils/sorting.cpp +2 -2
  287. data/vendor/faiss/faiss/utils/sorting.h +2 -2
  288. data/vendor/faiss/faiss/utils/transpose/transpose-avx2-inl.h +2 -2
  289. data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +176 -0
  290. data/vendor/faiss/faiss/utils/utils.cpp +17 -10
  291. data/vendor/faiss/faiss/utils/utils.h +7 -3
  292. metadata +22 -11
  293. data/vendor/faiss/faiss/impl/code_distance/code_distance_avx512.h +0 -102
@@ -1,3 +1,4 @@
1
+ // @lint-ignore-every LICENSELINT
1
2
  /**
2
3
  * Copyright (c) Facebook, Inc. and its affiliates.
3
4
  *
@@ -5,7 +6,7 @@
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  */
7
8
  /*
8
- * Copyright (c) 2023, NVIDIA CORPORATION.
9
+ * Copyright (c) 2023-2024, NVIDIA CORPORATION.
9
10
  *
10
11
  * Licensed under the Apache License, Version 2.0 (the "License");
11
12
  * you may not use this file except in compliance with the License.
@@ -57,7 +58,7 @@ struct Options {
57
58
 
58
59
  device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
59
60
 
60
- useRaft = false;
61
+ useCuvs = false;
61
62
  }
62
63
 
63
64
  std::string toString() const {
@@ -65,7 +66,7 @@ struct Options {
65
66
  str << "IVFFlat device " << device << " numVecs " << numAdd << " dim "
66
67
  << dim << " numCentroids " << numCentroids << " nprobe " << nprobe
67
68
  << " numQuery " << numQuery << " k " << k << " indicesOpt "
68
- << indicesOpt << " useRaft " << useRaft;
69
+ << indicesOpt << " useCuvs " << useCuvs;
69
70
 
70
71
  return str.str();
71
72
  }
@@ -79,7 +80,7 @@ struct Options {
79
80
  int k;
80
81
  int device;
81
82
  faiss::gpu::IndicesOptions indicesOpt;
82
- bool useRaft;
83
+ bool useCuvs;
83
84
  };
84
85
 
85
86
  void queryTest(
@@ -110,7 +111,7 @@ void queryTest(
110
111
  config.device = opt.device;
111
112
  config.indicesOptions = opt.indicesOpt;
112
113
  config.flatConfig.useFloat16 = useFloat16CoarseQuantizer;
113
- config.use_raft = opt.useRaft;
114
+ config.use_cuvs = opt.useCuvs;
114
115
 
115
116
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
116
117
  &res, cpuIndex.d, cpuIndex.nlist, cpuIndex.metric_type, config);
@@ -137,9 +138,10 @@ void queryTest(
137
138
  void addTest(
138
139
  faiss::MetricType metricType,
139
140
  bool useFloat16CoarseQuantizer,
140
- bool useRaft) {
141
+ bool useCuvs) {
141
142
  for (int tries = 0; tries < 2; ++tries) {
142
143
  Options opt;
144
+ opt.useCuvs = useCuvs;
143
145
 
144
146
  std::vector<float> trainVecs =
145
147
  faiss::gpu::randVecs(opt.numTrain, opt.dim);
@@ -162,9 +164,9 @@ void addTest(
162
164
  faiss::gpu::GpuIndexIVFFlatConfig config;
163
165
  config.device = opt.device;
164
166
  config.indicesOptions =
165
- useRaft ? faiss::gpu::INDICES_64_BIT : opt.indicesOpt;
167
+ opt.useCuvs ? faiss::gpu::INDICES_64_BIT : opt.indicesOpt;
166
168
  config.flatConfig.useFloat16 = useFloat16CoarseQuantizer;
167
- config.use_raft = useRaft;
169
+ config.use_cuvs = opt.useCuvs;
168
170
 
169
171
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
170
172
  &res, cpuIndex.d, cpuIndex.nlist, cpuIndex.metric_type, config);
@@ -188,7 +190,7 @@ void addTest(
188
190
  }
189
191
  }
190
192
 
191
- void copyToTest(bool useFloat16CoarseQuantizer, bool useRaft) {
193
+ void copyToTest(bool useFloat16CoarseQuantizer, bool useCuvs) {
192
194
  Options opt;
193
195
  std::vector<float> trainVecs = faiss::gpu::randVecs(opt.numTrain, opt.dim);
194
196
  std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
@@ -199,9 +201,9 @@ void copyToTest(bool useFloat16CoarseQuantizer, bool useRaft) {
199
201
  faiss::gpu::GpuIndexIVFFlatConfig config;
200
202
  config.device = opt.device;
201
203
  config.indicesOptions =
202
- useRaft ? faiss::gpu::INDICES_64_BIT : opt.indicesOpt;
204
+ useCuvs ? faiss::gpu::INDICES_64_BIT : opt.indicesOpt;
203
205
  config.flatConfig.useFloat16 = useFloat16CoarseQuantizer;
204
- config.use_raft = useRaft;
206
+ config.use_cuvs = useCuvs;
205
207
 
206
208
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
207
209
  &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
@@ -241,7 +243,7 @@ void copyToTest(bool useFloat16CoarseQuantizer, bool useRaft) {
241
243
  compFloat16 ? 0.30f : 0.015f);
242
244
  }
243
245
 
244
- void copyFromTest(bool useFloat16CoarseQuantizer, bool useRaft) {
246
+ void copyFromTest(bool useFloat16CoarseQuantizer, bool useCuvs) {
245
247
  Options opt;
246
248
  std::vector<float> trainVecs = faiss::gpu::randVecs(opt.numTrain, opt.dim);
247
249
  std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
@@ -260,9 +262,9 @@ void copyFromTest(bool useFloat16CoarseQuantizer, bool useRaft) {
260
262
  faiss::gpu::GpuIndexIVFFlatConfig config;
261
263
  config.device = opt.device;
262
264
  config.indicesOptions =
263
- useRaft ? faiss::gpu::INDICES_64_BIT : opt.indicesOpt;
265
+ useCuvs ? faiss::gpu::INDICES_64_BIT : opt.indicesOpt;
264
266
  config.flatConfig.useFloat16 = useFloat16CoarseQuantizer;
265
- config.use_raft = useRaft;
267
+ config.use_cuvs = useCuvs;
266
268
 
267
269
  faiss::gpu::GpuIndexIVFFlat gpuIndex(&res, 1, 1, faiss::METRIC_L2, config);
268
270
  gpuIndex.nprobe = 1;
@@ -296,7 +298,7 @@ void copyFromTest(bool useFloat16CoarseQuantizer, bool useRaft) {
296
298
  TEST(TestGpuIndexIVFFlat, Float32_32_Add_L2) {
297
299
  addTest(faiss::METRIC_L2, false, false);
298
300
 
299
- #if defined USE_NVIDIA_RAFT
301
+ #if defined USE_NVIDIA_CUVS
300
302
  addTest(faiss::METRIC_L2, false, true);
301
303
  #endif
302
304
  }
@@ -304,7 +306,7 @@ TEST(TestGpuIndexIVFFlat, Float32_32_Add_L2) {
304
306
  TEST(TestGpuIndexIVFFlat, Float32_32_Add_IP) {
305
307
  addTest(faiss::METRIC_INNER_PRODUCT, false, false);
306
308
 
307
- #if defined USE_NVIDIA_RAFT
309
+ #if defined USE_NVIDIA_CUVS
308
310
  addTest(faiss::METRIC_INNER_PRODUCT, false, true);
309
311
  #endif
310
312
  }
@@ -312,7 +314,7 @@ TEST(TestGpuIndexIVFFlat, Float32_32_Add_IP) {
312
314
  TEST(TestGpuIndexIVFFlat, Float16_32_Add_L2) {
313
315
  addTest(faiss::METRIC_L2, true, false);
314
316
 
315
- #if defined USE_NVIDIA_RAFT
317
+ #if defined USE_NVIDIA_CUVS
316
318
  addTest(faiss::METRIC_L2, true, true);
317
319
  #endif
318
320
  }
@@ -320,7 +322,7 @@ TEST(TestGpuIndexIVFFlat, Float16_32_Add_L2) {
320
322
  TEST(TestGpuIndexIVFFlat, Float16_32_Add_IP) {
321
323
  addTest(faiss::METRIC_INNER_PRODUCT, true, false);
322
324
 
323
- #if defined USE_NVIDIA_RAFT
325
+ #if defined USE_NVIDIA_CUVS
324
326
  addTest(faiss::METRIC_INNER_PRODUCT, true, true);
325
327
  #endif
326
328
  }
@@ -333,8 +335,8 @@ TEST(TestGpuIndexIVFFlat, Float32_Query_L2) {
333
335
  Options opt;
334
336
  queryTest(opt, faiss::METRIC_L2, false);
335
337
 
336
- #if defined USE_NVIDIA_RAFT
337
- opt.useRaft = true;
338
+ #if defined USE_NVIDIA_CUVS
339
+ opt.useCuvs = true;
338
340
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
339
341
  queryTest(opt, faiss::METRIC_L2, false);
340
342
  #endif
@@ -344,8 +346,8 @@ TEST(TestGpuIndexIVFFlat, Float32_Query_IP) {
344
346
  Options opt;
345
347
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, false);
346
348
 
347
- #if defined USE_NVIDIA_RAFT
348
- opt.useRaft = true;
349
+ #if defined USE_NVIDIA_CUVS
350
+ opt.useCuvs = true;
349
351
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
350
352
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, false);
351
353
  #endif
@@ -357,8 +359,8 @@ TEST(TestGpuIndexIVFFlat, LargeBatch) {
357
359
  opt.numQuery = 100000;
358
360
  queryTest(opt, faiss::METRIC_L2, false);
359
361
 
360
- #if defined USE_NVIDIA_RAFT
361
- opt.useRaft = true;
362
+ #if defined USE_NVIDIA_CUVS
363
+ opt.useCuvs = true;
362
364
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
363
365
  queryTest(opt, faiss::METRIC_L2, false);
364
366
  #endif
@@ -370,8 +372,8 @@ TEST(TestGpuIndexIVFFlat, Float16_32_Query_L2) {
370
372
  Options opt;
371
373
  queryTest(opt, faiss::METRIC_L2, true);
372
374
 
373
- #if defined USE_NVIDIA_RAFT
374
- opt.useRaft = true;
375
+ #if defined USE_NVIDIA_CUVS
376
+ opt.useCuvs = true;
375
377
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
376
378
  queryTest(opt, faiss::METRIC_L2, true);
377
379
  #endif
@@ -381,8 +383,8 @@ TEST(TestGpuIndexIVFFlat, Float16_32_Query_IP) {
381
383
  Options opt;
382
384
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, true);
383
385
 
384
- #if defined USE_NVIDIA_RAFT
385
- opt.useRaft = true;
386
+ #if defined USE_NVIDIA_CUVS
387
+ opt.useCuvs = true;
386
388
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
387
389
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, true);
388
390
  #endif
@@ -398,8 +400,8 @@ TEST(TestGpuIndexIVFFlat, Float32_Query_L2_64) {
398
400
  opt.dim = 64;
399
401
  queryTest(opt, faiss::METRIC_L2, false);
400
402
 
401
- #if defined USE_NVIDIA_RAFT
402
- opt.useRaft = true;
403
+ #if defined USE_NVIDIA_CUVS
404
+ opt.useCuvs = true;
403
405
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
404
406
  queryTest(opt, faiss::METRIC_L2, false);
405
407
  #endif
@@ -410,8 +412,8 @@ TEST(TestGpuIndexIVFFlat, Float32_Query_IP_64) {
410
412
  opt.dim = 64;
411
413
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, false);
412
414
 
413
- #if defined USE_NVIDIA_RAFT
414
- opt.useRaft = true;
415
+ #if defined USE_NVIDIA_CUVS
416
+ opt.useCuvs = true;
415
417
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
416
418
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, false);
417
419
  #endif
@@ -422,8 +424,8 @@ TEST(TestGpuIndexIVFFlat, Float32_Query_L2_128) {
422
424
  opt.dim = 128;
423
425
  queryTest(opt, faiss::METRIC_L2, false);
424
426
 
425
- #if defined USE_NVIDIA_RAFT
426
- opt.useRaft = true;
427
+ #if defined USE_NVIDIA_CUVS
428
+ opt.useCuvs = true;
427
429
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
428
430
  queryTest(opt, faiss::METRIC_L2, false);
429
431
  #endif
@@ -434,8 +436,8 @@ TEST(TestGpuIndexIVFFlat, Float32_Query_IP_128) {
434
436
  opt.dim = 128;
435
437
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, false);
436
438
 
437
- #if defined USE_NVIDIA_RAFT
438
- opt.useRaft = true;
439
+ #if defined USE_NVIDIA_CUVS
440
+ opt.useCuvs = true;
439
441
  opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
440
442
  queryTest(opt, faiss::METRIC_INNER_PRODUCT, false);
441
443
  #endif
@@ -448,7 +450,7 @@ TEST(TestGpuIndexIVFFlat, Float32_Query_IP_128) {
448
450
  TEST(TestGpuIndexIVFFlat, Float32_32_CopyTo) {
449
451
  copyToTest(false, false);
450
452
 
451
- #if defined USE_NVIDIA_RAFT
453
+ #if defined USE_NVIDIA_CUVS
452
454
  copyToTest(false, true);
453
455
  #endif
454
456
  }
@@ -456,7 +458,7 @@ TEST(TestGpuIndexIVFFlat, Float32_32_CopyTo) {
456
458
  TEST(TestGpuIndexIVFFlat, Float32_32_CopyFrom) {
457
459
  copyFromTest(false, false);
458
460
 
459
- #if defined USE_NVIDIA_RAFT
461
+ #if defined USE_NVIDIA_CUVS
460
462
  copyFromTest(false, true);
461
463
  #endif
462
464
  }
@@ -499,7 +501,7 @@ TEST(TestGpuIndexIVFFlat, Float32_negative) {
499
501
  faiss::gpu::GpuIndexIVFFlatConfig config;
500
502
  config.device = opt.device;
501
503
  config.indicesOptions = opt.indicesOpt;
502
- config.use_raft = false;
504
+ config.use_cuvs = false;
503
505
 
504
506
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
505
507
  &res, cpuIndex.d, cpuIndex.nlist, cpuIndex.metric_type, config);
@@ -522,19 +524,19 @@ TEST(TestGpuIndexIVFFlat, Float32_negative) {
522
524
  compFloat16 ? 0.99f : 0.1f,
523
525
  compFloat16 ? 0.65f : 0.015f);
524
526
 
525
- #if defined USE_NVIDIA_RAFT
526
- config.use_raft = true;
527
+ #if defined USE_NVIDIA_CUVS
528
+ config.use_cuvs = true;
527
529
  config.indicesOptions = faiss::gpu::INDICES_64_BIT;
528
530
 
529
- faiss::gpu::GpuIndexIVFFlat raftGpuIndex(
531
+ faiss::gpu::GpuIndexIVFFlat cuvsGpuIndex(
530
532
  &res, cpuIndex.d, cpuIndex.nlist, cpuIndex.metric_type, config);
531
- raftGpuIndex.copyFrom(&cpuIndex);
532
- raftGpuIndex.nprobe = opt.nprobe;
533
+ cuvsGpuIndex.copyFrom(&cpuIndex);
534
+ cuvsGpuIndex.nprobe = opt.nprobe;
533
535
 
534
536
  faiss::gpu::compareIndices(
535
537
  queryVecs,
536
538
  cpuIndex,
537
- raftGpuIndex,
539
+ cuvsGpuIndex,
538
540
  opt.numQuery,
539
541
  opt.dim,
540
542
  opt.k,
@@ -572,7 +574,7 @@ TEST(TestGpuIndexIVFFlat, QueryNaN) {
572
574
  config.device = opt.device;
573
575
  config.indicesOptions = opt.indicesOpt;
574
576
  config.flatConfig.useFloat16 = faiss::gpu::randBool();
575
- config.use_raft = false;
577
+ config.use_cuvs = false;
576
578
 
577
579
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
578
580
  &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
@@ -593,19 +595,19 @@ TEST(TestGpuIndexIVFFlat, QueryNaN) {
593
595
  }
594
596
  }
595
597
 
596
- #if defined USE_NVIDIA_RAFT
597
- config.use_raft = true;
598
+ #if defined USE_NVIDIA_CUVS
599
+ config.use_cuvs = true;
598
600
  config.indicesOptions = faiss::gpu::INDICES_64_BIT;
599
601
  std::fill(distances.begin(), distances.end(), 0);
600
602
  std::fill(indices.begin(), indices.end(), 0);
601
- faiss::gpu::GpuIndexIVFFlat raftGpuIndex(
603
+ faiss::gpu::GpuIndexIVFFlat cuvsGpuIndex(
602
604
  &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
603
- raftGpuIndex.nprobe = opt.nprobe;
605
+ cuvsGpuIndex.nprobe = opt.nprobe;
604
606
 
605
- raftGpuIndex.train(opt.numTrain, trainVecs.data());
606
- raftGpuIndex.add(opt.numAdd, addVecs.data());
607
+ cuvsGpuIndex.train(opt.numTrain, trainVecs.data());
608
+ cuvsGpuIndex.add(opt.numAdd, addVecs.data());
607
609
 
608
- raftGpuIndex.search(
610
+ cuvsGpuIndex.search(
609
611
  numQuery, nans.data(), opt.k, distances.data(), indices.data());
610
612
 
611
613
  for (int q = 0; q < numQuery; ++q) {
@@ -641,7 +643,7 @@ TEST(TestGpuIndexIVFFlat, AddNaN) {
641
643
  config.device = opt.device;
642
644
  config.indicesOptions = opt.indicesOpt;
643
645
  config.flatConfig.useFloat16 = faiss::gpu::randBool();
644
- config.use_raft = false;
646
+ config.use_cuvs = false;
645
647
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
646
648
  &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
647
649
  gpuIndex.nprobe = opt.nprobe;
@@ -663,20 +665,20 @@ TEST(TestGpuIndexIVFFlat, AddNaN) {
663
665
  distance.data(),
664
666
  indices.data());
665
667
 
666
- #if defined USE_NVIDIA_RAFT
667
- config.use_raft = true;
668
+ #if defined USE_NVIDIA_CUVS
669
+ config.use_cuvs = true;
668
670
  config.indicesOptions = faiss::gpu::INDICES_64_BIT;
669
- faiss::gpu::GpuIndexIVFFlat raftGpuIndex(
671
+ faiss::gpu::GpuIndexIVFFlat cuvsGpuIndex(
670
672
  &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
671
- raftGpuIndex.nprobe = opt.nprobe;
672
- raftGpuIndex.train(opt.numTrain, trainVecs.data());
673
+ cuvsGpuIndex.nprobe = opt.nprobe;
674
+ cuvsGpuIndex.train(opt.numTrain, trainVecs.data());
673
675
 
674
676
  // should not crash
675
- EXPECT_EQ(raftGpuIndex.ntotal, 0);
676
- raftGpuIndex.add(numNans, nans.data());
677
+ EXPECT_EQ(cuvsGpuIndex.ntotal, 0);
678
+ cuvsGpuIndex.add(numNans, nans.data());
677
679
 
678
680
  // should not crash
679
- raftGpuIndex.search(
681
+ cuvsGpuIndex.search(
680
682
  opt.numQuery,
681
683
  queryVecs.data(),
682
684
  opt.k,
@@ -723,7 +725,7 @@ TEST(TestGpuIndexIVFFlat, UnifiedMemory) {
723
725
  faiss::gpu::GpuIndexIVFFlatConfig config;
724
726
  config.device = device;
725
727
  config.memorySpace = faiss::gpu::MemorySpace::Unified;
726
- config.use_raft = false;
728
+ config.use_cuvs = false;
727
729
 
728
730
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
729
731
  &res, dim, numCentroids, faiss::METRIC_L2, config);
@@ -741,17 +743,17 @@ TEST(TestGpuIndexIVFFlat, UnifiedMemory) {
741
743
  0.1f,
742
744
  0.015f);
743
745
 
744
- #if defined USE_NVIDIA_RAFT
745
- config.use_raft = true;
746
+ #if defined USE_NVIDIA_CUVS
747
+ config.use_cuvs = true;
746
748
  config.indicesOptions = faiss::gpu::INDICES_64_BIT;
747
- faiss::gpu::GpuIndexIVFFlat raftGpuIndex(
749
+ faiss::gpu::GpuIndexIVFFlat cuvsGpuIndex(
748
750
  &res, dim, numCentroids, faiss::METRIC_L2, config);
749
- raftGpuIndex.copyFrom(&cpuIndex);
750
- raftGpuIndex.nprobe = nprobe;
751
+ cuvsGpuIndex.copyFrom(&cpuIndex);
752
+ cuvsGpuIndex.nprobe = nprobe;
751
753
 
752
754
  faiss::gpu::compareIndices(
753
755
  cpuIndex,
754
- raftGpuIndex,
756
+ cuvsGpuIndex,
755
757
  numQuery,
756
758
  dim,
757
759
  k,
@@ -801,7 +803,7 @@ TEST(TestGpuIndexIVFFlat, LongIVFList) {
801
803
 
802
804
  faiss::gpu::GpuIndexIVFFlatConfig config;
803
805
  config.device = device;
804
- config.use_raft = false;
806
+ config.use_cuvs = false;
805
807
 
806
808
  faiss::gpu::GpuIndexIVFFlat gpuIndex(
807
809
  &res, dim, numCentroids, faiss::METRIC_L2, config);
@@ -820,18 +822,18 @@ TEST(TestGpuIndexIVFFlat, LongIVFList) {
820
822
  0.1f,
821
823
  0.015f);
822
824
 
823
- #if defined USE_NVIDIA_RAFT
824
- config.use_raft = true;
825
+ #if defined USE_NVIDIA_CUVS
826
+ config.use_cuvs = true;
825
827
  config.indicesOptions = faiss::gpu::INDICES_64_BIT;
826
- faiss::gpu::GpuIndexIVFFlat raftGpuIndex(
828
+ faiss::gpu::GpuIndexIVFFlat cuvsGpuIndex(
827
829
  &res, dim, numCentroids, faiss::METRIC_L2, config);
828
- raftGpuIndex.train(numTrain, trainVecs.data());
829
- raftGpuIndex.add(numAdd, addVecs.data());
830
- raftGpuIndex.nprobe = 1;
830
+ cuvsGpuIndex.train(numTrain, trainVecs.data());
831
+ cuvsGpuIndex.add(numAdd, addVecs.data());
832
+ cuvsGpuIndex.nprobe = 1;
831
833
 
832
834
  faiss::gpu::compareIndices(
833
835
  cpuIndex,
834
- raftGpuIndex,
836
+ cuvsGpuIndex,
835
837
  numQuery,
836
838
  dim,
837
839
  k,
@@ -842,6 +844,71 @@ TEST(TestGpuIndexIVFFlat, LongIVFList) {
842
844
  #endif
843
845
  }
844
846
 
847
+ TEST(TestGpuIndexIVFFlat, Reconstruct_n) {
848
+ Options opt;
849
+
850
+ std::vector<float> trainVecs = faiss::gpu::randVecs(opt.numTrain, opt.dim);
851
+ std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
852
+
853
+ faiss::IndexFlatL2 cpuQuantizer(opt.dim);
854
+ faiss::IndexIVFFlat cpuIndex(
855
+ &cpuQuantizer, opt.dim, opt.numCentroids, faiss::METRIC_L2);
856
+ cpuIndex.nprobe = opt.nprobe;
857
+ cpuIndex.train(opt.numTrain, trainVecs.data());
858
+ cpuIndex.add(opt.numAdd, addVecs.data());
859
+
860
+ faiss::gpu::StandardGpuResources res;
861
+ res.noTempMemory();
862
+
863
+ faiss::gpu::GpuIndexIVFFlatConfig config;
864
+ config.device = opt.device;
865
+ config.indicesOptions = faiss::gpu::INDICES_64_BIT;
866
+ config.use_cuvs = false;
867
+
868
+ faiss::gpu::GpuIndexIVFFlat gpuIndex(
869
+ &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
870
+ gpuIndex.nprobe = opt.nprobe;
871
+
872
+ gpuIndex.train(opt.numTrain, trainVecs.data());
873
+ gpuIndex.add(opt.numAdd, addVecs.data());
874
+
875
+ std::vector<float> gpuVals(opt.numAdd * opt.dim);
876
+
877
+ gpuIndex.reconstruct_n(0, gpuIndex.ntotal, gpuVals.data());
878
+
879
+ std::vector<float> cpuVals(opt.numAdd * opt.dim);
880
+
881
+ cpuIndex.reconstruct_n(0, cpuIndex.ntotal, cpuVals.data());
882
+
883
+ EXPECT_EQ(gpuVals, cpuVals);
884
+
885
+ config.indicesOptions = faiss::gpu::INDICES_32_BIT;
886
+
887
+ faiss::gpu::GpuIndexIVFFlat gpuIndex1(
888
+ &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
889
+ gpuIndex1.nprobe = opt.nprobe;
890
+
891
+ gpuIndex1.train(opt.numTrain, trainVecs.data());
892
+ gpuIndex1.add(opt.numAdd, addVecs.data());
893
+
894
+ gpuIndex1.reconstruct_n(0, gpuIndex1.ntotal, gpuVals.data());
895
+
896
+ EXPECT_EQ(gpuVals, cpuVals);
897
+
898
+ config.indicesOptions = faiss::gpu::INDICES_CPU;
899
+
900
+ faiss::gpu::GpuIndexIVFFlat gpuIndex2(
901
+ &res, opt.dim, opt.numCentroids, faiss::METRIC_L2, config);
902
+ gpuIndex2.nprobe = opt.nprobe;
903
+
904
+ gpuIndex2.train(opt.numTrain, trainVecs.data());
905
+ gpuIndex2.add(opt.numAdd, addVecs.data());
906
+
907
+ gpuIndex2.reconstruct_n(0, gpuIndex2.ntotal, gpuVals.data());
908
+
909
+ EXPECT_EQ(gpuVals, cpuVals);
910
+ }
911
+
845
912
  int main(int argc, char** argv) {
846
913
  testing::InitGoogleTest(&argc, argv);
847
914