faiss 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (292) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -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 +2 -2
  7. data/vendor/faiss/faiss/Clustering.cpp +2 -2
  8. data/vendor/faiss/faiss/Clustering.h +2 -2
  9. data/vendor/faiss/faiss/IVFlib.cpp +2 -2
  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 +10 -3
  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 +2 -2
  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 +2 -2
  30. data/vendor/faiss/faiss/IndexBinaryIVF.h +2 -2
  31. data/vendor/faiss/faiss/IndexFastScan.cpp +10 -14
  32. data/vendor/faiss/faiss/IndexFastScan.h +11 -2
  33. data/vendor/faiss/faiss/IndexFlat.cpp +2 -3
  34. data/vendor/faiss/faiss/IndexFlat.h +2 -2
  35. data/vendor/faiss/faiss/IndexFlatCodes.cpp +11 -2
  36. data/vendor/faiss/faiss/IndexFlatCodes.h +5 -2
  37. data/vendor/faiss/faiss/IndexHNSW.cpp +13 -6
  38. data/vendor/faiss/faiss/IndexHNSW.h +2 -2
  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 +2 -3
  42. data/vendor/faiss/faiss/IndexIVF.h +5 -4
  43. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +6 -7
  44. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +2 -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 +71 -34
  48. data/vendor/faiss/faiss/IndexIVFFastScan.h +19 -2
  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 +2 -3
  54. data/vendor/faiss/faiss/IndexIVFPQ.h +2 -2
  55. data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +7 -33
  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 +2 -2
  64. data/vendor/faiss/faiss/IndexLattice.h +2 -2
  65. data/vendor/faiss/faiss/IndexNNDescent.cpp +2 -2
  66. data/vendor/faiss/faiss/IndexNNDescent.h +2 -2
  67. data/vendor/faiss/faiss/IndexNSG.cpp +2 -5
  68. data/vendor/faiss/faiss/IndexNSG.h +2 -2
  69. data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +2 -2
  70. data/vendor/faiss/faiss/IndexNeuralNetCodec.h +2 -2
  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 +2 -2
  77. data/vendor/faiss/faiss/IndexRefine.cpp +41 -4
  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 +2 -3
  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 +2 -2
  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 +2 -2
  101. data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +44 -4
  102. data/vendor/faiss/faiss/cppcontrib/factory_tools.h +7 -2
  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 +2 -2
  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 +13 -13
  114. data/vendor/faiss/faiss/gpu/GpuCloner.h +2 -2
  115. data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +6 -6
  116. data/vendor/faiss/faiss/gpu/GpuDistance.h +11 -7
  117. data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +2 -2
  118. data/vendor/faiss/faiss/gpu/GpuIcmEncoder.h +2 -2
  119. data/vendor/faiss/faiss/gpu/GpuIndex.h +8 -7
  120. data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +2 -2
  121. data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +6 -3
  122. data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +2 -2
  123. data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +2 -2
  124. data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +2 -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 +51 -21
  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 +2 -2
  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 +2 -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 +2 -2
  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 +80 -78
  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 +2 -2
  153. data/vendor/faiss/faiss/gpu/utils/{RaftUtils.h → CuvsUtils.h} +12 -11
  154. data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +2 -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 +2 -2
  159. data/vendor/faiss/faiss/gpu/utils/Timer.h +2 -2
  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 +2 -2
  163. data/vendor/faiss/faiss/impl/AuxIndexStructures.h +2 -2
  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 +2 -2
  167. data/vendor/faiss/faiss/impl/FaissAssert.h +2 -2
  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 +24 -19
  171. data/vendor/faiss/faiss/impl/HNSW.h +12 -2
  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 +2 -2
  175. data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +2 -2
  176. data/vendor/faiss/faiss/impl/LookupTableScaler.h +2 -2
  177. data/vendor/faiss/faiss/impl/NNDescent.cpp +2 -2
  178. data/vendor/faiss/faiss/impl/NNDescent.h +2 -2
  179. data/vendor/faiss/faiss/impl/NSG.cpp +27 -21
  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 +2 -2
  187. data/vendor/faiss/faiss/impl/ProductQuantizer.h +2 -2
  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 +2 -2
  192. data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +2 -2
  193. data/vendor/faiss/faiss/impl/ScalarQuantizer.h +2 -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 +2 -2
  197. data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +2 -2
  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 +2 -5
  202. data/vendor/faiss/faiss/impl/index_read_utils.h +2 -2
  203. data/vendor/faiss/faiss/impl/index_write.cpp +2 -6
  204. data/vendor/faiss/faiss/impl/io.cpp +2 -2
  205. data/vendor/faiss/faiss/impl/io.h +2 -2
  206. data/vendor/faiss/faiss/impl/io_macros.h +2 -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 +12 -2
  212. data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +2 -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 +2 -2
  215. data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +2 -2
  216. data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +3 -3
  217. data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +2 -2
  218. data/vendor/faiss/faiss/impl/simd_result_handlers.h +18 -18
  219. data/vendor/faiss/faiss/index_factory.cpp +20 -21
  220. data/vendor/faiss/faiss/index_factory.h +2 -2
  221. data/vendor/faiss/faiss/index_io.h +2 -2
  222. data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +2 -2
  223. data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +2 -2
  224. data/vendor/faiss/faiss/invlists/DirectMap.cpp +2 -2
  225. data/vendor/faiss/faiss/invlists/DirectMap.h +2 -2
  226. data/vendor/faiss/faiss/invlists/InvertedLists.cpp +2 -2
  227. data/vendor/faiss/faiss/invlists/InvertedLists.h +2 -2
  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 +2 -3
  231. data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +2 -2
  232. data/vendor/faiss/faiss/python/python_callbacks.cpp +2 -2
  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 +2 -2
  237. data/vendor/faiss/faiss/utils/NeuralNet.cpp +11 -7
  238. data/vendor/faiss/faiss/utils/NeuralNet.h +2 -2
  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 +2 -2
  247. data/vendor/faiss/faiss/utils/distances.cpp +191 -2
  248. data/vendor/faiss/faiss/utils/distances.h +3 -3
  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 +502 -3
  256. data/vendor/faiss/faiss/utils/extra_distances-inl.h +2 -2
  257. data/vendor/faiss/faiss/utils/extra_distances.cpp +2 -3
  258. data/vendor/faiss/faiss/utils/extra_distances.h +2 -2
  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 +2 -3
  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 +2 -2
  270. data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +5 -2
  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 +2 -2
  279. data/vendor/faiss/faiss/utils/random.h +2 -2
  280. data/vendor/faiss/faiss/utils/simdlib.h +2 -2
  281. data/vendor/faiss/faiss/utils/simdlib_avx2.h +2 -2
  282. data/vendor/faiss/faiss/utils/simdlib_avx512.h +2 -2
  283. data/vendor/faiss/faiss/utils/simdlib_emulated.h +2 -2
  284. data/vendor/faiss/faiss/utils/simdlib_neon.h +2 -2
  285. data/vendor/faiss/faiss/utils/simdlib_ppc64.h +2 -2
  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 +2 -2
  290. data/vendor/faiss/faiss/utils/utils.cpp +7 -7
  291. data/vendor/faiss/faiss/utils/utils.h +4 -3
  292. metadata +9 -10
@@ -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.
@@ -20,7 +21,7 @@
20
21
  * limitations under the License.
21
22
  */
22
23
 
23
- #if defined USE_NVIDIA_RAFT
24
+ #if defined USE_NVIDIA_CUVS
24
25
  #include <raft/core/device_resources.hpp>
25
26
  #include <rmm/mr/device/managed_memory_resource.hpp>
26
27
  #include <rmm/mr/device/per_device_resource.hpp>
@@ -90,7 +91,7 @@ std::string allocsToString(const std::unordered_map<void*, AllocRequest>& map) {
90
91
 
91
92
  StandardGpuResourcesImpl::StandardGpuResourcesImpl()
92
93
  :
93
- #if defined USE_NVIDIA_RAFT
94
+ #if defined USE_NVIDIA_CUVS
94
95
  mmr_(new rmm::mr::managed_memory_resource),
95
96
  pmr_(new rmm::mr::pinned_memory_resource),
96
97
  #endif
@@ -129,6 +130,10 @@ StandardGpuResourcesImpl::~StandardGpuResourcesImpl() {
129
130
  FAISS_ASSERT_MSG(
130
131
  !allocError, "GPU memory allocations not properly cleaned up");
131
132
 
133
+ #if defined USE_NVIDIA_CUVS
134
+ raftHandles_.clear();
135
+ #endif
136
+
132
137
  for (auto& entry : defaultStreams_) {
133
138
  DeviceScope scope(entry.first);
134
139
 
@@ -158,7 +163,7 @@ StandardGpuResourcesImpl::~StandardGpuResourcesImpl() {
158
163
  }
159
164
 
160
165
  if (pinnedMemAlloc_) {
161
- #if defined USE_NVIDIA_RAFT
166
+ #if defined USE_NVIDIA_CUVS
162
167
  pmr_->deallocate(pinnedMemAlloc_, pinnedMemAllocSize_);
163
168
  #else
164
169
  auto err = cudaFreeHost(pinnedMemAlloc_);
@@ -201,6 +206,13 @@ size_t StandardGpuResourcesImpl::getDefaultTempMemForGPU(
201
206
  return requested;
202
207
  }
203
208
 
209
+ /// Does the given GPU support bfloat16?
210
+ bool StandardGpuResourcesImpl::supportsBFloat16(int device) {
211
+ initializeForDevice(device);
212
+ auto& prop = getDeviceProperties(device);
213
+ return prop.major >= 8;
214
+ }
215
+
204
216
  void StandardGpuResourcesImpl::noTempMemory() {
205
217
  setTempMemory(0);
206
218
  }
@@ -257,12 +269,12 @@ void StandardGpuResourcesImpl::setDefaultStream(
257
269
  if (prevStream != stream) {
258
270
  streamWait({stream}, {prevStream});
259
271
  }
260
- #if defined USE_NVIDIA_RAFT
272
+ #if defined USE_NVIDIA_CUVS
261
273
  // delete the raft handle for this device, which will be initialized
262
274
  // with the updated stream during any subsequent calls to getRaftHandle
263
275
  auto it2 = raftHandles_.find(device);
264
276
  if (it2 != raftHandles_.end()) {
265
- raftHandles_.erase(it2);
277
+ raft::resource::set_cuda_stream(it2->second, stream);
266
278
  }
267
279
  #endif
268
280
  }
@@ -282,15 +294,25 @@ void StandardGpuResourcesImpl::revertDefaultStream(int device) {
282
294
  cudaStream_t newStream = defaultStreams_[device];
283
295
 
284
296
  streamWait({newStream}, {prevStream});
285
- }
286
- #if defined USE_NVIDIA_RAFT
287
- // delete the raft handle for this device, which will be initialized
288
- // with the updated stream during any subsequent calls to getRaftHandle
289
- auto it2 = raftHandles_.find(device);
290
- if (it2 != raftHandles_.end()) {
291
- raftHandles_.erase(it2);
292
- }
297
+
298
+ #if defined USE_NVIDIA_CUVS
299
+ // update the stream on the raft handle for this device
300
+ auto it2 = raftHandles_.find(device);
301
+ if (it2 != raftHandles_.end()) {
302
+ raft::resource::set_cuda_stream(it2->second, newStream);
303
+ }
304
+ #endif
305
+ } else {
306
+ #if defined USE_NVIDIA_CUVS
307
+ // delete the raft handle for this device, which will be initialized
308
+ // with the updated stream during any subsequent calls to
309
+ // getRaftHandle
310
+ auto it2 = raftHandles_.find(device);
311
+ if (it2 != raftHandles_.end()) {
312
+ raftHandles_.erase(it2);
313
+ }
293
314
  #endif
315
+ }
294
316
  }
295
317
 
296
318
  userDefaultStreams_.erase(device);
@@ -323,7 +345,7 @@ void StandardGpuResourcesImpl::initializeForDevice(int device) {
323
345
  // If this is the first device that we're initializing, create our
324
346
  // pinned memory allocation
325
347
  if (defaultStreams_.empty() && pinnedMemSize_ > 0) {
326
- #if defined USE_NVIDIA_RAFT
348
+ #if defined USE_NVIDIA_CUVS
327
349
  // If this is the first device that we're initializing, create our
328
350
  // pinned memory allocation
329
351
  if (defaultStreams_.empty() && pinnedMemSize_ > 0) {
@@ -385,7 +407,7 @@ void StandardGpuResourcesImpl::initializeForDevice(int device) {
385
407
 
386
408
  defaultStreams_[device] = defaultStream;
387
409
 
388
- #if defined USE_NVIDIA_RAFT
410
+ #if defined USE_NVIDIA_CUVS
389
411
  raftHandles_.emplace(std::make_pair(device, defaultStream));
390
412
  #endif
391
413
 
@@ -451,7 +473,7 @@ cudaStream_t StandardGpuResourcesImpl::getDefaultStream(int device) {
451
473
  return defaultStreams_[device];
452
474
  }
453
475
 
454
- #if defined USE_NVIDIA_RAFT
476
+ #if defined USE_NVIDIA_CUVS
455
477
  raft::device_resources& StandardGpuResourcesImpl::getRaftHandle(int device) {
456
478
  initializeForDevice(device);
457
479
 
@@ -522,7 +544,7 @@ void* StandardGpuResourcesImpl::allocMemory(const AllocRequest& req) {
522
544
  // Otherwise, we can handle this locally
523
545
  p = tempMemory_[adjReq.device]->allocMemory(adjReq.stream, adjReq.size);
524
546
  } else if (adjReq.space == MemorySpace::Device) {
525
- #if defined USE_NVIDIA_RAFT
547
+ #if defined USE_NVIDIA_CUVS
526
548
  try {
527
549
  rmm::mr::device_memory_resource* current_mr =
528
550
  rmm::mr::get_per_device_resource(
@@ -556,7 +578,7 @@ void* StandardGpuResourcesImpl::allocMemory(const AllocRequest& req) {
556
578
  }
557
579
  #endif
558
580
  } else if (adjReq.space == MemorySpace::Unified) {
559
- #if defined USE_NVIDIA_RAFT
581
+ #if defined USE_NVIDIA_CUVS
560
582
  try {
561
583
  // for now, use our own managed MR to do Unified Memory allocations.
562
584
  // TODO: change this to use the current device resource once RMM has
@@ -625,7 +647,7 @@ void StandardGpuResourcesImpl::deallocMemory(int device, void* p) {
625
647
  } else if (
626
648
  req.space == MemorySpace::Device ||
627
649
  req.space == MemorySpace::Unified) {
628
- #if defined USE_NVIDIA_RAFT
650
+ #if defined USE_NVIDIA_CUVS
629
651
  req.mr->deallocate_async(p, req.size, req.stream);
630
652
  #else
631
653
  auto err = cudaFree(p);
@@ -686,6 +708,14 @@ std::shared_ptr<GpuResources> StandardGpuResources::getResources() {
686
708
  return res_;
687
709
  }
688
710
 
711
+ bool StandardGpuResources::supportsBFloat16(int device) {
712
+ return res_->supportsBFloat16(device);
713
+ }
714
+
715
+ bool StandardGpuResources::supportsBFloat16CurrentDevice() {
716
+ return res_->supportsBFloat16CurrentDevice();
717
+ }
718
+
689
719
  void StandardGpuResources::noTempMemory() {
690
720
  res_->noTempMemory();
691
721
  }
@@ -719,7 +749,7 @@ cudaStream_t StandardGpuResources::getDefaultStream(int device) {
719
749
  return res_->getDefaultStream(device);
720
750
  }
721
751
 
722
- #if defined USE_NVIDIA_RAFT
752
+ #if defined USE_NVIDIA_CUVS
723
753
  raft::device_resources& StandardGpuResources::getRaftHandle(int device) {
724
754
  return res_->getRaftHandle(device);
725
755
  }
@@ -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.
@@ -22,7 +23,7 @@
22
23
 
23
24
  #pragma once
24
25
 
25
- #if defined USE_NVIDIA_RAFT
26
+ #if defined USE_NVIDIA_CUVS
26
27
  #include <raft/core/device_resources.hpp>
27
28
  #include <rmm/mr/host/pinned_memory_resource.hpp>
28
29
  #endif
@@ -47,6 +48,9 @@ class StandardGpuResourcesImpl : public GpuResources {
47
48
 
48
49
  ~StandardGpuResourcesImpl() override;
49
50
 
51
+ /// Does the given GPU support bfloat16?
52
+ bool supportsBFloat16(int device) override;
53
+
50
54
  /// Disable allocation of temporary memory; all temporary memory
51
55
  /// requests will call cudaMalloc / cudaFree at the point of use
52
56
  void noTempMemory();
@@ -79,7 +83,7 @@ class StandardGpuResourcesImpl : public GpuResources {
79
83
  /// this stream upon exit from an index or other Faiss GPU call.
80
84
  cudaStream_t getDefaultStream(int device) override;
81
85
 
82
- #if defined USE_NVIDIA_RAFT
86
+ #if defined USE_NVIDIA_CUVS
83
87
  /// Returns the raft handle for the given device which can be used to
84
88
  /// make calls to other raft primitives.
85
89
  raft::device_resources& getRaftHandle(int device) override;
@@ -151,7 +155,7 @@ class StandardGpuResourcesImpl : public GpuResources {
151
155
  /// cuBLAS handle for each device
152
156
  std::unordered_map<int, cublasHandle_t> blasHandles_;
153
157
 
154
- #if defined USE_NVIDIA_RAFT
158
+ #if defined USE_NVIDIA_CUVS
155
159
  /// raft handle for each device
156
160
  std::unordered_map<int, raft::device_resources> raftHandles_;
157
161
 
@@ -198,6 +202,12 @@ class StandardGpuResources : public GpuResourcesProvider {
198
202
 
199
203
  std::shared_ptr<GpuResources> getResources() override;
200
204
 
205
+ /// Whether or not the given device supports native bfloat16 arithmetic
206
+ bool supportsBFloat16(int device);
207
+
208
+ /// Whether or not the current device supports native bfloat16 arithmetic
209
+ bool supportsBFloat16CurrentDevice();
210
+
201
211
  /// Disable allocation of temporary memory; all temporary memory
202
212
  /// requests will call cudaMalloc / cudaFree at the point of use
203
213
  void noTempMemory();
@@ -234,7 +244,7 @@ class StandardGpuResources : public GpuResourcesProvider {
234
244
  /// Returns the current default stream
235
245
  cudaStream_t getDefaultStream(int device);
236
246
 
237
- #if defined USE_NVIDIA_RAFT
247
+ #if defined USE_NVIDIA_CUVS
238
248
  /// Returns the raft handle for the given device which can be used to
239
249
  /// make calls to other raft primitives.
240
250
  raft::device_resources& getRaftHandle(int device);
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.