faiss 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +1 -1
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +2 -2
- data/vendor/faiss/faiss/AutoTune.h +2 -2
- data/vendor/faiss/faiss/Clustering.cpp +2 -2
- data/vendor/faiss/faiss/Clustering.h +2 -2
- data/vendor/faiss/faiss/IVFlib.cpp +2 -2
- data/vendor/faiss/faiss/IVFlib.h +2 -2
- data/vendor/faiss/faiss/Index.cpp +6 -2
- data/vendor/faiss/faiss/Index.h +10 -3
- data/vendor/faiss/faiss/Index2Layer.cpp +2 -2
- data/vendor/faiss/faiss/Index2Layer.h +2 -2
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +7 -7
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +14 -16
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h +2 -2
- data/vendor/faiss/faiss/IndexBinary.cpp +13 -2
- data/vendor/faiss/faiss/IndexBinary.h +8 -2
- data/vendor/faiss/faiss/IndexBinaryFlat.cpp +2 -3
- data/vendor/faiss/faiss/IndexBinaryFlat.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryFromFloat.cpp +2 -2
- data/vendor/faiss/faiss/IndexBinaryFromFloat.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +2 -7
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryHash.cpp +2 -3
- data/vendor/faiss/faiss/IndexBinaryHash.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +2 -2
- data/vendor/faiss/faiss/IndexBinaryIVF.h +2 -2
- data/vendor/faiss/faiss/IndexFastScan.cpp +10 -14
- data/vendor/faiss/faiss/IndexFastScan.h +11 -2
- data/vendor/faiss/faiss/IndexFlat.cpp +2 -3
- data/vendor/faiss/faiss/IndexFlat.h +2 -2
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +11 -2
- data/vendor/faiss/faiss/IndexFlatCodes.h +5 -2
- data/vendor/faiss/faiss/IndexHNSW.cpp +13 -6
- data/vendor/faiss/faiss/IndexHNSW.h +2 -2
- data/vendor/faiss/faiss/IndexIDMap.cpp +19 -3
- data/vendor/faiss/faiss/IndexIDMap.h +5 -2
- data/vendor/faiss/faiss/IndexIVF.cpp +2 -3
- data/vendor/faiss/faiss/IndexIVF.h +5 -4
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +6 -7
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +3 -14
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +2 -4
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +71 -34
- data/vendor/faiss/faiss/IndexIVFFastScan.h +19 -2
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +2 -2
- data/vendor/faiss/faiss/IndexIVFFlat.h +2 -2
- data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +2 -3
- data/vendor/faiss/faiss/IndexIVFPQ.h +2 -2
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +7 -33
- data/vendor/faiss/faiss/IndexIVFPQFastScan.h +2 -4
- data/vendor/faiss/faiss/IndexIVFPQR.cpp +2 -2
- data/vendor/faiss/faiss/IndexIVFPQR.h +2 -2
- data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +2 -3
- data/vendor/faiss/faiss/IndexIVFSpectralHash.h +2 -2
- data/vendor/faiss/faiss/IndexLSH.cpp +2 -3
- data/vendor/faiss/faiss/IndexLSH.h +2 -2
- data/vendor/faiss/faiss/IndexLattice.cpp +2 -2
- data/vendor/faiss/faiss/IndexLattice.h +2 -2
- data/vendor/faiss/faiss/IndexNNDescent.cpp +2 -2
- data/vendor/faiss/faiss/IndexNNDescent.h +2 -2
- data/vendor/faiss/faiss/IndexNSG.cpp +2 -5
- data/vendor/faiss/faiss/IndexNSG.h +2 -2
- data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +2 -2
- data/vendor/faiss/faiss/IndexNeuralNetCodec.h +2 -2
- data/vendor/faiss/faiss/IndexPQ.cpp +26 -26
- data/vendor/faiss/faiss/IndexPQ.h +2 -2
- data/vendor/faiss/faiss/IndexPQFastScan.cpp +2 -5
- data/vendor/faiss/faiss/IndexPQFastScan.h +2 -11
- data/vendor/faiss/faiss/IndexPreTransform.cpp +2 -2
- data/vendor/faiss/faiss/IndexPreTransform.h +2 -2
- data/vendor/faiss/faiss/IndexRefine.cpp +41 -4
- data/vendor/faiss/faiss/IndexRefine.h +9 -2
- data/vendor/faiss/faiss/IndexReplicas.cpp +2 -2
- data/vendor/faiss/faiss/IndexReplicas.h +2 -2
- data/vendor/faiss/faiss/IndexRowwiseMinMax.cpp +2 -2
- data/vendor/faiss/faiss/IndexRowwiseMinMax.h +2 -2
- data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +2 -3
- data/vendor/faiss/faiss/IndexScalarQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexShards.cpp +2 -2
- data/vendor/faiss/faiss/IndexShards.h +2 -2
- data/vendor/faiss/faiss/IndexShardsIVF.cpp +2 -2
- data/vendor/faiss/faiss/IndexShardsIVF.h +2 -2
- data/vendor/faiss/faiss/MatrixStats.cpp +2 -2
- data/vendor/faiss/faiss/MatrixStats.h +2 -2
- data/vendor/faiss/faiss/MetaIndexes.cpp +2 -3
- data/vendor/faiss/faiss/MetaIndexes.h +2 -2
- data/vendor/faiss/faiss/MetricType.h +2 -2
- data/vendor/faiss/faiss/VectorTransform.cpp +2 -2
- data/vendor/faiss/faiss/VectorTransform.h +2 -2
- data/vendor/faiss/faiss/clone_index.cpp +2 -2
- data/vendor/faiss/faiss/clone_index.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/SaDecodeKernels.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/detail/CoarseBitType.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/detail/UintReader.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +44 -4
- data/vendor/faiss/faiss/cppcontrib/factory_tools.h +7 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-neon-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMax-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMaxFP16-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-avx2-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-neon-inl.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuAutoTune.cpp +2 -5
- data/vendor/faiss/faiss/gpu/GpuAutoTune.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +13 -13
- data/vendor/faiss/faiss/gpu/GpuCloner.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +6 -6
- data/vendor/faiss/faiss/gpu/GpuDistance.h +11 -7
- data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIcmEncoder.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndex.h +8 -7
- data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +6 -3
- data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVFPQ.h +3 -3
- data/vendor/faiss/faiss/gpu/GpuIndexIVFScalarQuantizer.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndicesOptions.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuResources.cpp +7 -2
- data/vendor/faiss/faiss/gpu/GpuResources.h +11 -4
- data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +51 -21
- data/vendor/faiss/faiss/gpu/StandardGpuResources.h +15 -5
- data/vendor/faiss/faiss/gpu/impl/IndexUtils.h +2 -2
- data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.cpp +2 -2
- data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.h +2 -2
- data/vendor/faiss/faiss/gpu/impl/RemapIndices.cpp +2 -2
- data/vendor/faiss/faiss/gpu/impl/RemapIndices.h +2 -2
- data/vendor/faiss/faiss/gpu/perf/IndexWrapper-inl.h +2 -2
- data/vendor/faiss/faiss/gpu/perf/IndexWrapper.h +2 -2
- data/vendor/faiss/faiss/gpu/perf/PerfClustering.cpp +2 -2
- data/vendor/faiss/faiss/gpu/perf/PerfIVFPQAdd.cpp +2 -3
- data/vendor/faiss/faiss/gpu/perf/WriteIndex.cpp +2 -2
- data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +2 -2
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp +2 -2
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +54 -54
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +80 -78
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFPQ.cpp +51 -51
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFScalarQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/gpu/test/TestGpuMemoryException.cpp +3 -3
- data/vendor/faiss/faiss/gpu/test/TestGpuResidualQuantizer.cpp +70 -0
- data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +74 -4
- data/vendor/faiss/faiss/gpu/test/TestUtils.h +2 -2
- data/vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp +2 -2
- data/vendor/faiss/faiss/gpu/utils/{RaftUtils.h → CuvsUtils.h} +12 -11
- data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +2 -2
- data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp +2 -2
- data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.h +2 -2
- data/vendor/faiss/faiss/gpu/utils/StaticUtils.h +2 -2
- data/vendor/faiss/faiss/gpu/utils/Timer.cpp +2 -2
- data/vendor/faiss/faiss/gpu/utils/Timer.h +2 -2
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +79 -11
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +17 -5
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +2 -2
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +2 -2
- data/vendor/faiss/faiss/impl/CodePacker.cpp +2 -2
- data/vendor/faiss/faiss/impl/CodePacker.h +2 -2
- data/vendor/faiss/faiss/impl/DistanceComputer.h +2 -2
- data/vendor/faiss/faiss/impl/FaissAssert.h +2 -2
- data/vendor/faiss/faiss/impl/FaissException.cpp +2 -2
- data/vendor/faiss/faiss/impl/FaissException.h +2 -3
- data/vendor/faiss/faiss/impl/HNSW.cpp +24 -19
- data/vendor/faiss/faiss/impl/HNSW.h +12 -2
- data/vendor/faiss/faiss/impl/IDSelector.cpp +2 -2
- data/vendor/faiss/faiss/impl/IDSelector.h +2 -2
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +2 -2
- data/vendor/faiss/faiss/impl/LookupTableScaler.h +2 -2
- data/vendor/faiss/faiss/impl/NNDescent.cpp +2 -2
- data/vendor/faiss/faiss/impl/NNDescent.h +2 -2
- data/vendor/faiss/faiss/impl/NSG.cpp +27 -21
- data/vendor/faiss/faiss/impl/NSG.h +20 -8
- data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +2 -2
- data/vendor/faiss/faiss/impl/PolysemousTraining.h +2 -2
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp +2 -4
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h +2 -2
- data/vendor/faiss/faiss/impl/ProductQuantizer-inl.h +2 -2
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/impl/ProductQuantizer.h +2 -2
- data/vendor/faiss/faiss/impl/Quantizer.h +2 -2
- data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +2 -36
- data/vendor/faiss/faiss/impl/ResidualQuantizer.h +3 -13
- data/vendor/faiss/faiss/impl/ResultHandler.h +2 -2
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +2 -2
- data/vendor/faiss/faiss/impl/ThreadedIndex-inl.h +2 -2
- data/vendor/faiss/faiss/impl/ThreadedIndex.h +2 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx2.h +2 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +2 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-generic.h +2 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-sve.h +440 -0
- data/vendor/faiss/faiss/impl/code_distance/code_distance.h +55 -2
- data/vendor/faiss/faiss/impl/index_read.cpp +2 -5
- data/vendor/faiss/faiss/impl/index_read_utils.h +2 -2
- data/vendor/faiss/faiss/impl/index_write.cpp +2 -6
- data/vendor/faiss/faiss/impl/io.cpp +2 -2
- data/vendor/faiss/faiss/impl/io.h +2 -2
- data/vendor/faiss/faiss/impl/io_macros.h +2 -9
- data/vendor/faiss/faiss/impl/kmeans1d.cpp +2 -3
- data/vendor/faiss/faiss/impl/kmeans1d.h +2 -2
- data/vendor/faiss/faiss/impl/lattice_Zn.cpp +2 -3
- data/vendor/faiss/faiss/impl/lattice_Zn.h +2 -2
- data/vendor/faiss/faiss/impl/platform_macros.h +12 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +2 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +20 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +2 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +2 -2
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +3 -3
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +2 -2
- data/vendor/faiss/faiss/impl/simd_result_handlers.h +18 -18
- data/vendor/faiss/faiss/index_factory.cpp +20 -21
- data/vendor/faiss/faiss/index_factory.h +2 -2
- data/vendor/faiss/faiss/index_io.h +2 -2
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +2 -2
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +2 -2
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +2 -2
- data/vendor/faiss/faiss/invlists/DirectMap.h +2 -2
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +2 -2
- data/vendor/faiss/faiss/invlists/InvertedLists.h +2 -2
- data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +2 -2
- data/vendor/faiss/faiss/invlists/InvertedListsIOHook.h +2 -2
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +2 -3
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +2 -2
- data/vendor/faiss/faiss/python/python_callbacks.cpp +2 -2
- data/vendor/faiss/faiss/python/python_callbacks.h +2 -2
- data/vendor/faiss/faiss/utils/AlignedTable.h +5 -3
- data/vendor/faiss/faiss/utils/Heap.cpp +2 -2
- data/vendor/faiss/faiss/utils/Heap.h +2 -2
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +11 -7
- data/vendor/faiss/faiss/utils/NeuralNet.h +2 -2
- data/vendor/faiss/faiss/utils/WorkerThread.cpp +2 -2
- data/vendor/faiss/faiss/utils/WorkerThread.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/approx_topk.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/avx2-inl.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/generic.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/mode.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +2 -2
- data/vendor/faiss/faiss/utils/bf16.h +2 -2
- data/vendor/faiss/faiss/utils/distances.cpp +191 -2
- data/vendor/faiss/faiss/utils/distances.h +3 -3
- data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/avx512.h +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/distances_fused.cpp +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/distances_fused.h +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.h +2 -2
- data/vendor/faiss/faiss/utils/distances_simd.cpp +502 -3
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +2 -2
- data/vendor/faiss/faiss/utils/extra_distances.cpp +2 -3
- data/vendor/faiss/faiss/utils/extra_distances.h +2 -2
- data/vendor/faiss/faiss/utils/fp16-arm.h +2 -2
- data/vendor/faiss/faiss/utils/fp16-fp16c.h +2 -2
- data/vendor/faiss/faiss/utils/fp16-inl.h +2 -2
- data/vendor/faiss/faiss/utils/fp16.h +2 -2
- data/vendor/faiss/faiss/utils/hamming-inl.h +2 -2
- data/vendor/faiss/faiss/utils/hamming.cpp +2 -3
- data/vendor/faiss/faiss/utils/hamming.h +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/avx2-inl.h +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/avx512-inl.h +490 -0
- data/vendor/faiss/faiss/utils/hamming_distance/common.h +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +5 -2
- data/vendor/faiss/faiss/utils/hamming_distance/neon-inl.h +5 -5
- data/vendor/faiss/faiss/utils/ordered_key_value.h +2 -2
- data/vendor/faiss/faiss/utils/partitioning.cpp +2 -2
- data/vendor/faiss/faiss/utils/partitioning.h +2 -2
- data/vendor/faiss/faiss/utils/prefetch.h +2 -2
- data/vendor/faiss/faiss/utils/quantize_lut.cpp +2 -2
- data/vendor/faiss/faiss/utils/quantize_lut.h +2 -2
- data/vendor/faiss/faiss/utils/random.cpp +2 -2
- data/vendor/faiss/faiss/utils/random.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_avx2.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_emulated.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_neon.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_ppc64.h +2 -2
- data/vendor/faiss/faiss/utils/sorting.cpp +2 -2
- data/vendor/faiss/faiss/utils/sorting.h +2 -2
- data/vendor/faiss/faiss/utils/transpose/transpose-avx2-inl.h +2 -2
- data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +2 -2
- data/vendor/faiss/faiss/utils/utils.cpp +7 -7
- data/vendor/faiss/faiss/utils/utils.h +4 -3
- metadata +9 -10
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -25,7 +25,15 @@ const std::map<faiss::ScalarQuantizer::QuantizerType, std::string> sq_types = {
|
|
25
25
|
};
|
26
26
|
|
27
27
|
int get_hnsw_M(const faiss::IndexHNSW* index) {
|
28
|
-
if (index->hnsw.cum_nneighbor_per_level.size()
|
28
|
+
if (index->hnsw.cum_nneighbor_per_level.size() > 1) {
|
29
|
+
return index->hnsw.cum_nneighbor_per_level[1] / 2;
|
30
|
+
}
|
31
|
+
// Avoid runtime error, just return 0.
|
32
|
+
return 0;
|
33
|
+
}
|
34
|
+
|
35
|
+
int get_hnsw_M(const faiss::IndexBinaryHNSW* index) {
|
36
|
+
if (index->hnsw.cum_nneighbor_per_level.size() > 1) {
|
29
37
|
return index->hnsw.cum_nneighbor_per_level[1] / 2;
|
30
38
|
}
|
31
39
|
// Avoid runtime error, just return 0.
|
@@ -143,7 +151,39 @@ std::string reverse_index_factory(const faiss::Index* index) {
|
|
143
151
|
} else if (
|
144
152
|
const faiss::IndexScalarQuantizer* sq_index =
|
145
153
|
dynamic_cast<const faiss::IndexScalarQuantizer*>(index)) {
|
146
|
-
return
|
154
|
+
return sq_types.at(sq_index->sq.qtype);
|
155
|
+
} else if (
|
156
|
+
const faiss::IndexIDMap* idmap =
|
157
|
+
dynamic_cast<const faiss::IndexIDMap*>(index)) {
|
158
|
+
return std::string("IDMap,") + reverse_index_factory(idmap->index);
|
159
|
+
}
|
160
|
+
// Avoid runtime error, just return empty string for logging.
|
161
|
+
return "";
|
162
|
+
}
|
163
|
+
|
164
|
+
std::string reverse_index_factory(const faiss::IndexBinary* index) {
|
165
|
+
std::string prefix;
|
166
|
+
if (dynamic_cast<const faiss::IndexBinaryFlat*>(index)) {
|
167
|
+
return "BFlat";
|
168
|
+
} else if (
|
169
|
+
const faiss::IndexBinaryIVF* ivf_index =
|
170
|
+
dynamic_cast<const faiss::IndexBinaryIVF*>(index)) {
|
171
|
+
const faiss::IndexBinary* quantizer = ivf_index->quantizer;
|
172
|
+
|
173
|
+
if (dynamic_cast<const faiss::IndexBinaryFlat*>(quantizer)) {
|
174
|
+
return "BIVF" + std::to_string(ivf_index->nlist);
|
175
|
+
} else if (
|
176
|
+
const faiss::IndexBinaryHNSW* hnsw_index =
|
177
|
+
dynamic_cast<const faiss::IndexBinaryHNSW*>(
|
178
|
+
quantizer)) {
|
179
|
+
return "BIVF" + std::to_string(ivf_index->nlist) + "_HNSW" +
|
180
|
+
std::to_string(get_hnsw_M(hnsw_index));
|
181
|
+
}
|
182
|
+
// Add further cases for BinaryIVF here.
|
183
|
+
} else if (
|
184
|
+
const faiss::IndexBinaryHNSW* hnsw_index =
|
185
|
+
dynamic_cast<const faiss::IndexBinaryHNSW*>(index)) {
|
186
|
+
return "BHNSW" + std::to_string(get_hnsw_M(hnsw_index));
|
147
187
|
}
|
148
188
|
// Avoid runtime error, just return empty string for logging.
|
149
189
|
return "";
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -9,7 +9,11 @@
|
|
9
9
|
|
10
10
|
#pragma once
|
11
11
|
|
12
|
+
#include <faiss/IndexBinaryFlat.h>
|
13
|
+
#include <faiss/IndexBinaryHNSW.h>
|
14
|
+
#include <faiss/IndexBinaryIVF.h>
|
12
15
|
#include <faiss/IndexHNSW.h>
|
16
|
+
#include <faiss/IndexIDMap.h>
|
13
17
|
#include <faiss/IndexIVFFlat.h>
|
14
18
|
#include <faiss/IndexIVFPQFastScan.h>
|
15
19
|
#include <faiss/IndexLSH.h>
|
@@ -20,5 +24,6 @@
|
|
20
24
|
namespace faiss {
|
21
25
|
|
22
26
|
std::string reverse_index_factory(const faiss::Index* index);
|
27
|
+
std::string reverse_index_factory(const faiss::IndexBinary* index);
|
23
28
|
|
24
29
|
} // namespace faiss
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -17,10 +17,7 @@
|
|
17
17
|
#include <faiss/gpu/GpuIndexFlat.h>
|
18
18
|
#include <faiss/gpu/GpuIndexIVFFlat.h>
|
19
19
|
#include <faiss/gpu/GpuIndexIVFPQ.h>
|
20
|
-
#include <faiss/gpu/GpuIndexIVFScalarQuantizer.h>
|
21
20
|
#include <faiss/gpu/impl/IndexUtils.h>
|
22
|
-
#include <faiss/gpu/utils/DeviceUtils.h>
|
23
|
-
#include <faiss/impl/FaissAssert.h>
|
24
21
|
|
25
22
|
namespace faiss {
|
26
23
|
namespace gpu {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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,7 @@
|
|
14
14
|
|
15
15
|
#include <faiss/IndexBinaryFlat.h>
|
16
16
|
#include <faiss/IndexFlat.h>
|
17
|
-
#if defined
|
17
|
+
#if defined USE_NVIDIA_CUVS
|
18
18
|
#include <faiss/IndexHNSW.h>
|
19
19
|
#endif
|
20
20
|
#include <faiss/IndexIVF.h>
|
@@ -27,7 +27,7 @@
|
|
27
27
|
#include <faiss/MetaIndexes.h>
|
28
28
|
#include <faiss/gpu/GpuIndex.h>
|
29
29
|
#include <faiss/gpu/GpuIndexBinaryFlat.h>
|
30
|
-
#if defined
|
30
|
+
#if defined USE_NVIDIA_CUVS
|
31
31
|
#include <faiss/gpu/GpuIndexCagra.h>
|
32
32
|
#endif
|
33
33
|
#include <faiss/gpu/GpuIndexFlat.h>
|
@@ -92,7 +92,7 @@ Index* ToCPUCloner::clone_Index(const Index* index) {
|
|
92
92
|
// (inverse op of ToGpuClonerMultiple)
|
93
93
|
|
94
94
|
}
|
95
|
-
#if defined
|
95
|
+
#if defined USE_NVIDIA_CUVS
|
96
96
|
else if (auto icg = dynamic_cast<const GpuIndexCagra*>(index)) {
|
97
97
|
IndexHNSWCagra* res = new IndexHNSWCagra();
|
98
98
|
icg->copyTo(res);
|
@@ -138,7 +138,7 @@ Index* ToGpuCloner::clone_Index(const Index* index) {
|
|
138
138
|
GpuIndexFlatConfig config;
|
139
139
|
config.device = device;
|
140
140
|
config.useFloat16 = useFloat16;
|
141
|
-
config.
|
141
|
+
config.use_cuvs = use_cuvs;
|
142
142
|
return new GpuIndexFlat(provider, ifl, config);
|
143
143
|
} else if (
|
144
144
|
dynamic_cast<const IndexScalarQuantizer*>(index) &&
|
@@ -148,7 +148,7 @@ Index* ToGpuCloner::clone_Index(const Index* index) {
|
|
148
148
|
config.device = device;
|
149
149
|
config.useFloat16 = true;
|
150
150
|
FAISS_THROW_IF_NOT_MSG(
|
151
|
-
!
|
151
|
+
!use_cuvs, "this type of index is not implemented for cuVS");
|
152
152
|
GpuIndexFlat* gif = new GpuIndexFlat(
|
153
153
|
provider, index->d, index->metric_type, config);
|
154
154
|
// transfer data by blocks
|
@@ -166,7 +166,7 @@ Index* ToGpuCloner::clone_Index(const Index* index) {
|
|
166
166
|
config.device = device;
|
167
167
|
config.indicesOptions = indicesOptions;
|
168
168
|
config.flatConfig.useFloat16 = useFloat16CoarseQuantizer;
|
169
|
-
config.
|
169
|
+
config.use_cuvs = use_cuvs;
|
170
170
|
config.allowCpuCoarseQuantizer = allowCpuCoarseQuantizer;
|
171
171
|
|
172
172
|
GpuIndexIVFFlat* res = new GpuIndexIVFFlat(
|
@@ -185,7 +185,7 @@ Index* ToGpuCloner::clone_Index(const Index* index) {
|
|
185
185
|
config.indicesOptions = indicesOptions;
|
186
186
|
config.flatConfig.useFloat16 = useFloat16CoarseQuantizer;
|
187
187
|
FAISS_THROW_IF_NOT_MSG(
|
188
|
-
!
|
188
|
+
!use_cuvs, "this type of index is not implemented for cuVS");
|
189
189
|
|
190
190
|
GpuIndexIVFScalarQuantizer* res = new GpuIndexIVFScalarQuantizer(
|
191
191
|
provider,
|
@@ -218,8 +218,8 @@ Index* ToGpuCloner::clone_Index(const Index* index) {
|
|
218
218
|
config.flatConfig.useFloat16 = useFloat16CoarseQuantizer;
|
219
219
|
config.useFloat16LookupTables = useFloat16;
|
220
220
|
config.usePrecomputedTables = usePrecomputed;
|
221
|
-
config.
|
222
|
-
config.interleavedLayout =
|
221
|
+
config.use_cuvs = use_cuvs;
|
222
|
+
config.interleavedLayout = use_cuvs;
|
223
223
|
config.allowCpuCoarseQuantizer = allowCpuCoarseQuantizer;
|
224
224
|
|
225
225
|
GpuIndexIVFPQ* res = new GpuIndexIVFPQ(provider, ipq, config);
|
@@ -230,7 +230,7 @@ Index* ToGpuCloner::clone_Index(const Index* index) {
|
|
230
230
|
|
231
231
|
return res;
|
232
232
|
}
|
233
|
-
#if defined
|
233
|
+
#if defined USE_NVIDIA_CUVS
|
234
234
|
else if (auto icg = dynamic_cast<const faiss::IndexHNSWCagra*>(index)) {
|
235
235
|
GpuIndexCagraConfig config;
|
236
236
|
config.device = device;
|
@@ -541,7 +541,7 @@ faiss::IndexBinary* index_binary_cpu_to_gpu(
|
|
541
541
|
GpuIndexBinaryFlatConfig config;
|
542
542
|
config.device = device;
|
543
543
|
if (options) {
|
544
|
-
config.
|
544
|
+
config.use_cuvs = options->use_cuvs;
|
545
545
|
}
|
546
546
|
return new GpuIndexBinaryFlat(provider, ii, config);
|
547
547
|
} else {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -37,11 +37,11 @@ struct GpuClonerOptions {
|
|
37
37
|
/// Set verbose options on the index
|
38
38
|
bool verbose = false;
|
39
39
|
|
40
|
-
/// use the
|
41
|
-
#if defined
|
42
|
-
bool
|
40
|
+
/// use the cuVS implementation
|
41
|
+
#if defined USE_NVIDIA_CUVS
|
42
|
+
bool use_cuvs = true;
|
43
43
|
#else
|
44
|
-
bool
|
44
|
+
bool use_cuvs = false;
|
45
45
|
#endif
|
46
46
|
|
47
47
|
/// This flag controls the CPU fallback logic for coarse quantizer
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -19,6 +19,7 @@ class GpuResourcesProvider;
|
|
19
19
|
enum class DistanceDataType {
|
20
20
|
F32 = 1,
|
21
21
|
F16,
|
22
|
+
BF16,
|
22
23
|
};
|
23
24
|
|
24
25
|
// Scalar type of the indices data
|
@@ -106,14 +107,17 @@ struct GpuDistanceParams {
|
|
106
107
|
/// execution
|
107
108
|
int device = -1;
|
108
109
|
|
109
|
-
/// Should the index dispatch down to
|
110
|
-
|
111
|
-
bool
|
110
|
+
/// Should the index dispatch down to cuVS?
|
111
|
+
#if defined USE_NVIDIA_CUVS
|
112
|
+
bool use_cuvs = true;
|
113
|
+
#else
|
114
|
+
bool use_cuvs = false;
|
115
|
+
#endif
|
112
116
|
};
|
113
117
|
|
114
|
-
/// A function that determines whether
|
118
|
+
/// A function that determines whether cuVS should be used based on various
|
115
119
|
/// conditions (such as unsupported architecture)
|
116
|
-
bool
|
120
|
+
bool should_use_cuvs(GpuDistanceParams args);
|
117
121
|
|
118
122
|
/// A wrapper for gpu/impl/Distance.cuh to expose direct brute-force k-nearest
|
119
123
|
/// neighbor searches on an externally-provided region of memory (e.g., from a
|
@@ -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.
|
@@ -37,17 +38,17 @@ struct GpuIndexConfig {
|
|
37
38
|
/// more memory than is available on the GPU.
|
38
39
|
MemorySpace memorySpace = MemorySpace::Device;
|
39
40
|
|
40
|
-
/// Should the index dispatch down to
|
41
|
-
#if defined
|
42
|
-
bool
|
41
|
+
/// Should the index dispatch down to cuVS?
|
42
|
+
#if defined USE_NVIDIA_CUVS
|
43
|
+
bool use_cuvs = true;
|
43
44
|
#else
|
44
|
-
bool
|
45
|
+
bool use_cuvs = false;
|
45
46
|
#endif
|
46
47
|
};
|
47
48
|
|
48
|
-
/// A centralized function that determines whether
|
49
|
+
/// A centralized function that determines whether cuVS should
|
49
50
|
/// be used based on various conditions (such as unsupported architecture)
|
50
|
-
bool
|
51
|
+
bool should_use_cuvs(GpuIndexConfig config_);
|
51
52
|
|
52
53
|
class GpuIndex : public faiss::Index {
|
53
54
|
public:
|
@@ -1,3 +1,4 @@
|
|
1
|
+
// @lint-ignore-every LICENSELINT
|
1
2
|
/**
|
2
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
4
|
*
|
@@ -33,12 +34,12 @@ struct IndexHNSWCagra;
|
|
33
34
|
namespace faiss {
|
34
35
|
namespace gpu {
|
35
36
|
|
36
|
-
class
|
37
|
+
class CuvsCagra;
|
37
38
|
|
38
39
|
enum class graph_build_algo {
|
39
40
|
/// Use IVF-PQ to build all-neighbors knn graph
|
40
41
|
IVF_PQ,
|
41
|
-
///
|
42
|
+
/// Use NN-Descent to build all-neighbors knn graph
|
42
43
|
NN_DESCENT
|
43
44
|
};
|
44
45
|
|
@@ -174,6 +175,8 @@ struct GpuIndexCagraConfig : public GpuIndexConfig {
|
|
174
175
|
|
175
176
|
IVFPQBuildCagraConfig* ivf_pq_params = nullptr;
|
176
177
|
IVFPQSearchCagraConfig* ivf_pq_search_params = nullptr;
|
178
|
+
float refine_rate = 2.0f;
|
179
|
+
bool store_dataset = true;
|
177
180
|
};
|
178
181
|
|
179
182
|
enum class search_algo {
|
@@ -275,7 +278,7 @@ struct GpuIndexCagra : public GpuIndex {
|
|
275
278
|
const GpuIndexCagraConfig cagraConfig_;
|
276
279
|
|
277
280
|
/// Instance that we own; contains the inverted lists
|
278
|
-
std::shared_ptr<
|
281
|
+
std::shared_ptr<CuvsCagra> index_;
|
279
282
|
};
|
280
283
|
|
281
284
|
} // namespace gpu
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -34,7 +34,7 @@ struct GpuIndexIVFPQConfig : public GpuIndexIVFConfig {
|
|
34
34
|
|
35
35
|
/// Use the alternative memory layout for the IVF lists
|
36
36
|
/// WARNING: this is a feature under development, and is only supported with
|
37
|
-
///
|
37
|
+
/// cuVS enabled for the index. Do not use if cuVS is not enabled.
|
38
38
|
bool interleavedLayout = false;
|
39
39
|
|
40
40
|
/// Use GEMM-backed computation of PQ code distances for the no precomputed
|
@@ -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.
|
@@ -160,6 +161,10 @@ GpuMemoryReservation::~GpuMemoryReservation() {
|
|
160
161
|
|
161
162
|
GpuResources::~GpuResources() = default;
|
162
163
|
|
164
|
+
bool GpuResources::supportsBFloat16CurrentDevice() {
|
165
|
+
return supportsBFloat16(getCurrentDevice());
|
166
|
+
}
|
167
|
+
|
163
168
|
cublasHandle_t GpuResources::getBlasHandleCurrentDevice() {
|
164
169
|
return getBlasHandle(getCurrentDevice());
|
165
170
|
}
|
@@ -168,7 +173,7 @@ cudaStream_t GpuResources::getDefaultStreamCurrentDevice() {
|
|
168
173
|
return getDefaultStream(getCurrentDevice());
|
169
174
|
}
|
170
175
|
|
171
|
-
#if defined
|
176
|
+
#if defined USE_NVIDIA_CUVS
|
172
177
|
raft::device_resources& GpuResources::getRaftHandleCurrentDevice() {
|
173
178
|
return getRaftHandle(getCurrentDevice());
|
174
179
|
}
|
@@ -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.
|
@@ -30,7 +31,7 @@
|
|
30
31
|
#include <utility>
|
31
32
|
#include <vector>
|
32
33
|
|
33
|
-
#if defined
|
34
|
+
#if defined USE_NVIDIA_CUVS
|
34
35
|
#include <raft/core/device_resources.hpp>
|
35
36
|
#include <rmm/mr/device/device_memory_resource.hpp>
|
36
37
|
#endif
|
@@ -161,7 +162,7 @@ struct AllocRequest : public AllocInfo {
|
|
161
162
|
/// The size in bytes of the allocation
|
162
163
|
size_t size = 0;
|
163
164
|
|
164
|
-
#if defined
|
165
|
+
#if defined USE_NVIDIA_CUVS
|
165
166
|
rmm::mr::device_memory_resource* mr = nullptr;
|
166
167
|
#endif
|
167
168
|
};
|
@@ -204,6 +205,9 @@ class GpuResources {
|
|
204
205
|
/// of demand
|
205
206
|
virtual void initializeForDevice(int device) = 0;
|
206
207
|
|
208
|
+
/// Does the given GPU support bfloat16?
|
209
|
+
virtual bool supportsBFloat16(int device) = 0;
|
210
|
+
|
207
211
|
/// Returns the cuBLAS handle that we use for the given device
|
208
212
|
virtual cublasHandle_t getBlasHandle(int device) = 0;
|
209
213
|
|
@@ -211,7 +215,7 @@ class GpuResources {
|
|
211
215
|
/// given device
|
212
216
|
virtual cudaStream_t getDefaultStream(int device) = 0;
|
213
217
|
|
214
|
-
#if defined
|
218
|
+
#if defined USE_NVIDIA_CUVS
|
215
219
|
/// Returns the raft handle for the given device which can be used to
|
216
220
|
/// make calls to other raft primitives.
|
217
221
|
virtual raft::device_resources& getRaftHandle(int device) = 0;
|
@@ -251,6 +255,9 @@ class GpuResources {
|
|
251
255
|
/// Functions provided by default
|
252
256
|
///
|
253
257
|
|
258
|
+
/// Does the current GPU support bfloat16?
|
259
|
+
bool supportsBFloat16CurrentDevice();
|
260
|
+
|
254
261
|
/// Calls getBlasHandle with the current device
|
255
262
|
cublasHandle_t getBlasHandleCurrentDevice();
|
256
263
|
|