faiss 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -14,7 +14,6 @@
14
14
  #include <faiss/gpu/utils/DeviceUtils.h>
15
15
  #include <faiss/gpu/utils/Timer.h>
16
16
  #include <gflags/gflags.h>
17
- #include <map>
18
17
  #include <vector>
19
18
 
20
19
  DEFINE_int32(batches, 10, "number of batches of vectors to add");
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -7,6 +7,7 @@
7
7
 
8
8
  #include <faiss/gpu/impl/InterleavedCodes.h>
9
9
  #include <faiss/gpu/test/TestUtils.h>
10
+ #include <faiss/gpu/utils/DeviceUtils.h>
10
11
  #include <faiss/gpu/utils/StaticUtils.h>
11
12
  #include <gtest/gtest.h>
12
13
  #include <cmath>
@@ -119,8 +120,9 @@ TEST(TestCodePacking, InterleavedCodes_UnpackPack) {
119
120
  std::cout << bitsPerCode << " " << dims << " " << numVecs
120
121
  << "\n";
121
122
 
122
- int blocks = utils::divUp(numVecs, 32);
123
- int bytesPerDimBlock = 32 * bitsPerCode / 8;
123
+ int warpSize = getWarpSizeCurrentDevice();
124
+ int blocks = utils::divUp(numVecs, warpSize);
125
+ int bytesPerDimBlock = warpSize * bitsPerCode / 8;
124
126
  int bytesPerBlock = bytesPerDimBlock * dims;
125
127
  int size = blocks * bytesPerBlock;
126
128
 
@@ -132,9 +134,9 @@ TEST(TestCodePacking, InterleavedCodes_UnpackPack) {
132
134
 
133
135
  for (int i = 0; i < blocks; ++i) {
134
136
  for (int j = 0; j < dims; ++j) {
135
- for (int k = 0; k < 32; ++k) {
137
+ for (int k = 0; k < warpSize; ++k) {
136
138
  for (int l = 0; l < bytesPerCode; ++l) {
137
- int vec = i * 32 + k;
139
+ int vec = i * warpSize + k;
138
140
  if (vec < numVecs) {
139
141
  data[i * bytesPerBlock +
140
142
  j * bytesPerDimBlock +
@@ -148,7 +150,8 @@ TEST(TestCodePacking, InterleavedCodes_UnpackPack) {
148
150
  for (int i = 0; i < blocks; ++i) {
149
151
  for (int j = 0; j < dims; ++j) {
150
152
  for (int k = 0; k < bytesPerDimBlock; ++k) {
151
- int loVec = i * 32 + (k * 8) / bitsPerCode;
153
+ int loVec =
154
+ i * warpSize + (k * 8) / bitsPerCode;
152
155
  int hiVec = loVec + 1;
153
156
  int hiVec2 = hiVec + 1;
154
157
 
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -29,7 +29,7 @@ struct TestFlatOptions {
29
29
  numQueriesOverride(-1),
30
30
  kOverride(-1),
31
31
  dimOverride(-1),
32
- use_raft(false) {}
32
+ use_cuvs(false) {}
33
33
 
34
34
  faiss::MetricType metric;
35
35
  float metricArg;
@@ -39,7 +39,7 @@ struct TestFlatOptions {
39
39
  int numQueriesOverride;
40
40
  int kOverride;
41
41
  int dimOverride;
42
- bool use_raft;
42
+ bool use_cuvs;
43
43
  };
44
44
 
45
45
  void testFlat(const TestFlatOptions& opt) {
@@ -75,7 +75,7 @@ void testFlat(const TestFlatOptions& opt) {
75
75
  faiss::gpu::GpuIndexFlatConfig config;
76
76
  config.device = device;
77
77
  config.useFloat16 = opt.useFloat16;
78
- config.use_raft = opt.use_raft;
78
+ config.use_cuvs = opt.use_cuvs;
79
79
 
80
80
  faiss::gpu::GpuIndexFlat gpuIndex(&res, dim, opt.metric, config);
81
81
  gpuIndex.metric_arg = opt.metricArg;
@@ -114,8 +114,8 @@ TEST(TestGpuIndexFlat, IP_Float32) {
114
114
 
115
115
  testFlat(opt);
116
116
 
117
- #if defined USE_NVIDIA_RAFT
118
- opt.use_raft = true;
117
+ #if defined USE_NVIDIA_CUVS
118
+ opt.use_cuvs = true;
119
119
  testFlat(opt);
120
120
  #endif
121
121
  }
@@ -128,8 +128,8 @@ TEST(TestGpuIndexFlat, L1_Float32) {
128
128
 
129
129
  testFlat(opt);
130
130
 
131
- #if defined USE_NVIDIA_RAFT
132
- opt.use_raft = true;
131
+ #if defined USE_NVIDIA_CUVS
132
+ opt.use_cuvs = true;
133
133
  testFlat(opt);
134
134
  #endif
135
135
  }
@@ -141,8 +141,8 @@ TEST(TestGpuIndexFlat, Lp_Float32) {
141
141
  opt.useFloat16 = false;
142
142
 
143
143
  testFlat(opt);
144
- #if defined USE_NVIDIA_RAFT
145
- opt.use_raft = true;
144
+ #if defined USE_NVIDIA_CUVS
145
+ opt.use_cuvs = true;
146
146
  testFlat(opt);
147
147
  #endif
148
148
  }
@@ -155,8 +155,8 @@ TEST(TestGpuIndexFlat, L2_Float32) {
155
155
  opt.useFloat16 = false;
156
156
 
157
157
  testFlat(opt);
158
- #if defined USE_NVIDIA_RAFT
159
- opt.use_raft = true;
158
+ #if defined USE_NVIDIA_CUVS
159
+ opt.use_cuvs = true;
160
160
  testFlat(opt);
161
161
  #endif
162
162
  }
@@ -173,8 +173,8 @@ TEST(TestGpuIndexFlat, L2_k_2048) {
173
173
  opt.numVecsOverride = 10000;
174
174
 
175
175
  testFlat(opt);
176
- #if defined USE_NVIDIA_RAFT
177
- opt.use_raft = true;
176
+ #if defined USE_NVIDIA_CUVS
177
+ opt.use_cuvs = true;
178
178
  testFlat(opt);
179
179
  #endif
180
180
  }
@@ -189,8 +189,8 @@ TEST(TestGpuIndexFlat, L2_Float32_K1) {
189
189
  opt.kOverride = 1;
190
190
 
191
191
  testFlat(opt);
192
- #if defined USE_NVIDIA_RAFT
193
- opt.use_raft = true;
192
+ #if defined USE_NVIDIA_CUVS
193
+ opt.use_cuvs = true;
194
194
  testFlat(opt);
195
195
  #endif
196
196
  }
@@ -203,8 +203,8 @@ TEST(TestGpuIndexFlat, IP_Float16) {
203
203
  opt.useFloat16 = true;
204
204
 
205
205
  testFlat(opt);
206
- #if defined USE_NVIDIA_RAFT
207
- opt.use_raft = true;
206
+ #if defined USE_NVIDIA_CUVS
207
+ opt.use_cuvs = true;
208
208
  testFlat(opt);
209
209
  #endif
210
210
  }
@@ -217,8 +217,8 @@ TEST(TestGpuIndexFlat, L2_Float16) {
217
217
  opt.useFloat16 = true;
218
218
 
219
219
  testFlat(opt);
220
- #if defined USE_NVIDIA_RAFT
221
- opt.use_raft = true;
220
+ #if defined USE_NVIDIA_CUVS
221
+ opt.use_cuvs = true;
222
222
  testFlat(opt);
223
223
  #endif
224
224
  }
@@ -233,8 +233,8 @@ TEST(TestGpuIndexFlat, L2_Float16_K1) {
233
233
  opt.kOverride = 1;
234
234
 
235
235
  testFlat(opt);
236
- #if defined USE_NVIDIA_RAFT
237
- opt.use_raft = true;
236
+ #if defined USE_NVIDIA_CUVS
237
+ opt.use_cuvs = true;
238
238
  testFlat(opt);
239
239
  #endif
240
240
  }
@@ -254,8 +254,8 @@ TEST(TestGpuIndexFlat, L2_Tiling) {
254
254
  opt.kOverride = 64;
255
255
 
256
256
  testFlat(opt);
257
- #if defined USE_NVIDIA_RAFT
258
- opt.use_raft = true;
257
+ #if defined USE_NVIDIA_CUVS
258
+ opt.use_cuvs = true;
259
259
  testFlat(opt);
260
260
  #endif
261
261
  }
@@ -268,7 +268,7 @@ TEST(TestGpuIndexFlat, QueryEmpty) {
268
268
  faiss::gpu::GpuIndexFlatConfig config;
269
269
  config.device = 0;
270
270
  config.useFloat16 = false;
271
- config.use_raft = false;
271
+ config.use_cuvs = false;
272
272
  int dim = 128;
273
273
  faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, dim, config);
274
274
 
@@ -292,7 +292,7 @@ TEST(TestGpuIndexFlat, QueryEmpty) {
292
292
  }
293
293
  }
294
294
 
295
- void testCopyFrom(bool use_raft) {
295
+ void testCopyFrom(bool use_cuvs) {
296
296
  int numVecs = faiss::gpu::randVal(100, 200);
297
297
  int dim = faiss::gpu::randVal(1, 1000);
298
298
 
@@ -310,7 +310,7 @@ void testCopyFrom(bool use_raft) {
310
310
  faiss::gpu::GpuIndexFlatConfig config;
311
311
  config.device = device;
312
312
  config.useFloat16 = useFloat16;
313
- config.use_raft = use_raft;
313
+ config.use_cuvs = use_cuvs;
314
314
 
315
315
  // Fill with garbage values
316
316
  faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, 2000, config);
@@ -343,13 +343,13 @@ TEST(TestGpuIndexFlat, CopyFrom) {
343
343
  testCopyFrom(false);
344
344
  }
345
345
 
346
- #if defined USE_NVIDIA_RAFT
347
- TEST(TestRaftGpuIndexFlat, CopyFrom) {
346
+ #if defined USE_NVIDIA_CUVS
347
+ TEST(TestCuvsGpuIndexFlat, CopyFrom) {
348
348
  testCopyFrom(true);
349
349
  }
350
350
  #endif
351
351
 
352
- void testCopyTo(bool use_raft) {
352
+ void testCopyTo(bool use_cuvs) {
353
353
  faiss::gpu::StandardGpuResources res;
354
354
  res.noTempMemory();
355
355
 
@@ -363,7 +363,7 @@ void testCopyTo(bool use_raft) {
363
363
  faiss::gpu::GpuIndexFlatConfig config;
364
364
  config.device = device;
365
365
  config.useFloat16 = useFloat16;
366
- config.use_raft = use_raft;
366
+ config.use_cuvs = use_cuvs;
367
367
 
368
368
  faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, dim, config);
369
369
  gpuIndex.add(numVecs, vecs.data());
@@ -394,13 +394,13 @@ TEST(TestGpuIndexFlat, CopyTo) {
394
394
  testCopyTo(false);
395
395
  }
396
396
 
397
- #if defined USE_NVIDIA_RAFT
398
- TEST(TestRaftGpuIndexFlat, CopyTo) {
397
+ #if defined USE_NVIDIA_CUVS
398
+ TEST(TestCuvsGpuIndexFlat, CopyTo) {
399
399
  testCopyTo(true);
400
400
  }
401
401
  #endif
402
402
 
403
- void testUnifiedMemory(bool use_raft) {
403
+ void testUnifiedMemory(bool use_cuvs) {
404
404
  // Construct on a random device to test multi-device, if we have
405
405
  // multiple devices
406
406
  int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
@@ -426,7 +426,7 @@ void testUnifiedMemory(bool use_raft) {
426
426
  faiss::gpu::GpuIndexFlatConfig config;
427
427
  config.device = device;
428
428
  config.memorySpace = faiss::gpu::MemorySpace::Unified;
429
- config.use_raft = use_raft;
429
+ config.use_cuvs = use_cuvs;
430
430
 
431
431
  faiss::gpu::GpuIndexFlatL2 gpuIndexL2(&res, dim, config);
432
432
 
@@ -452,13 +452,13 @@ TEST(TestGpuIndexFlat, UnifiedMemory) {
452
452
  testUnifiedMemory(false);
453
453
  }
454
454
 
455
- #if defined USE_NVIDIA_RAFT
456
- TEST(TestRaftGpuIndexFlat, UnifiedMemory) {
455
+ #if defined USE_NVIDIA_CUVS
456
+ TEST(TestCuvsGpuIndexFlat, UnifiedMemory) {
457
457
  testUnifiedMemory(true);
458
458
  }
459
459
  #endif
460
460
 
461
- void testLargeIndex(bool use_raft) {
461
+ void testLargeIndex(bool use_cuvs) {
462
462
  // Construct on a random device to test multi-device, if we have
463
463
  // multiple devices
464
464
  int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
@@ -489,7 +489,7 @@ void testLargeIndex(bool use_raft) {
489
489
 
490
490
  faiss::gpu::GpuIndexFlatConfig config;
491
491
  config.device = device;
492
- config.use_raft = use_raft;
492
+ config.use_cuvs = use_cuvs;
493
493
  faiss::gpu::GpuIndexFlatL2 gpuIndexL2(&res, dim, config);
494
494
 
495
495
  cpuIndexL2.add(nb, xb.data());
@@ -513,13 +513,13 @@ TEST(TestGpuIndexFlat, LargeIndex) {
513
513
  testLargeIndex(false);
514
514
  }
515
515
 
516
- #if defined USE_NVIDIA_RAFT
517
- TEST(TestRaftGpuIndexFlat, LargeIndex) {
516
+ #if defined USE_NVIDIA_CUVS
517
+ TEST(TestCuvsGpuIndexFlat, LargeIndex) {
518
518
  testLargeIndex(true);
519
519
  }
520
520
  #endif
521
521
 
522
- void testResidual(bool use_raft) {
522
+ void testResidual(bool use_cuvs) {
523
523
  // Construct on a random device to test multi-device, if we have
524
524
  // multiple devices
525
525
  int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
@@ -529,7 +529,7 @@ void testResidual(bool use_raft) {
529
529
 
530
530
  faiss::gpu::GpuIndexFlatConfig config;
531
531
  config.device = device;
532
- config.use_raft = use_raft;
532
+ config.use_cuvs = use_cuvs;
533
533
 
534
534
  int dim = 32;
535
535
  faiss::IndexFlat cpuIndex(dim, faiss::MetricType::METRIC_L2);
@@ -566,13 +566,13 @@ TEST(TestGpuIndexFlat, Residual) {
566
566
  testResidual(false);
567
567
  }
568
568
 
569
- #if defined USE_NVIDIA_RAFT
570
- TEST(TestRaftGpuIndexFlat, Residual) {
569
+ #if defined USE_NVIDIA_CUVS
570
+ TEST(TestCuvsGpuIndexFlat, Residual) {
571
571
  testResidual(true);
572
572
  }
573
573
  #endif
574
574
 
575
- void testReconstruct(bool use_raft) {
575
+ void testReconstruct(bool use_cuvs) {
576
576
  // Construct on a random device to test multi-device, if we have
577
577
  // multiple devices
578
578
  int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
@@ -589,7 +589,7 @@ void testReconstruct(bool use_raft) {
589
589
  faiss::gpu::GpuIndexFlatConfig config;
590
590
  config.device = device;
591
591
  config.useFloat16 = useFloat16;
592
- config.use_raft = use_raft;
592
+ config.use_cuvs = use_cuvs;
593
593
 
594
594
  faiss::gpu::GpuIndexFlat gpuIndex(
595
595
  &res, dim, faiss::MetricType::METRIC_L2, config);
@@ -657,13 +657,13 @@ void testReconstruct(bool use_raft) {
657
657
  TEST(TestGpuIndexFlat, Reconstruct) {
658
658
  testReconstruct(false);
659
659
  }
660
- #if defined USE_NVIDIA_RAFT
661
- TEST(TestRaftGpuIndexFlat, Reconstruct) {
660
+ #if defined USE_NVIDIA_CUVS
661
+ TEST(TestCuvsGpuIndexFlat, Reconstruct) {
662
662
  testReconstruct(true);
663
663
  }
664
664
  #endif
665
665
 
666
- void testSearchAndReconstruct(bool use_raft) {
666
+ void testSearchAndReconstruct(bool use_cuvs) {
667
667
  // Construct on a random device to test multi-device, if we have
668
668
  // multiple devices
669
669
  int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
@@ -683,7 +683,7 @@ void testSearchAndReconstruct(bool use_raft) {
683
683
 
684
684
  faiss::gpu::GpuIndexFlatConfig config;
685
685
  config.device = device;
686
- config.use_raft = use_raft;
686
+ config.use_cuvs = use_cuvs;
687
687
  faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, dim, config);
688
688
 
689
689
  cpuIndex.add(nb, xb.data());
@@ -754,8 +754,8 @@ TEST(TestGpuIndexFlat, SearchAndReconstruct) {
754
754
  testSearchAndReconstruct(false);
755
755
  }
756
756
 
757
- #if defined USE_NVIDIA_RAFT
758
- TEST(TestRaftGpuIndexFlat, SearchAndReconstruct) {
757
+ #if defined USE_NVIDIA_CUVS
758
+ TEST(TestCuvsGpuIndexFlat, SearchAndReconstruct) {
759
759
  testSearchAndReconstruct(true);
760
760
  }
761
761
  #endif