faiss 0.3.0 → 0.3.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/ext/faiss/extconf.rb +9 -2
- data/ext/faiss/index.cpp +1 -1
- data/ext/faiss/index_binary.cpp +2 -2
- data/ext/faiss/product_quantizer.cpp +1 -1
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +7 -7
- data/vendor/faiss/faiss/AutoTune.h +1 -2
- data/vendor/faiss/faiss/Clustering.cpp +39 -22
- data/vendor/faiss/faiss/Clustering.h +40 -21
- data/vendor/faiss/faiss/IVFlib.cpp +26 -12
- data/vendor/faiss/faiss/Index.cpp +1 -1
- data/vendor/faiss/faiss/Index.h +40 -10
- data/vendor/faiss/faiss/Index2Layer.cpp +7 -7
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +176 -166
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +15 -15
- data/vendor/faiss/faiss/IndexBinary.cpp +9 -4
- data/vendor/faiss/faiss/IndexBinary.h +8 -19
- data/vendor/faiss/faiss/IndexBinaryFromFloat.cpp +2 -1
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +24 -31
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +1 -1
- data/vendor/faiss/faiss/IndexBinaryHash.cpp +25 -50
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +107 -188
- data/vendor/faiss/faiss/IndexFastScan.cpp +95 -146
- data/vendor/faiss/faiss/IndexFastScan.h +9 -8
- data/vendor/faiss/faiss/IndexFlat.cpp +206 -10
- data/vendor/faiss/faiss/IndexFlat.h +20 -1
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +170 -5
- data/vendor/faiss/faiss/IndexFlatCodes.h +23 -4
- data/vendor/faiss/faiss/IndexHNSW.cpp +231 -382
- data/vendor/faiss/faiss/IndexHNSW.h +62 -49
- data/vendor/faiss/faiss/IndexIDMap.cpp +69 -28
- data/vendor/faiss/faiss/IndexIDMap.h +24 -2
- data/vendor/faiss/faiss/IndexIVF.cpp +162 -56
- data/vendor/faiss/faiss/IndexIVF.h +46 -6
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +33 -26
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +6 -2
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +19 -46
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +4 -3
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +502 -401
- data/vendor/faiss/faiss/IndexIVFFastScan.h +63 -26
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +15 -5
- data/vendor/faiss/faiss/IndexIVFFlat.h +3 -2
- data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.cpp +172 -0
- data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.h +56 -0
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +79 -125
- data/vendor/faiss/faiss/IndexIVFPQ.h +6 -7
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +39 -52
- data/vendor/faiss/faiss/IndexIVFPQFastScan.h +4 -3
- data/vendor/faiss/faiss/IndexIVFPQR.cpp +45 -29
- data/vendor/faiss/faiss/IndexIVFPQR.h +5 -2
- data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +25 -27
- data/vendor/faiss/faiss/IndexIVFSpectralHash.h +6 -6
- data/vendor/faiss/faiss/IndexLSH.cpp +14 -16
- data/vendor/faiss/faiss/IndexLattice.cpp +1 -19
- data/vendor/faiss/faiss/IndexLattice.h +3 -22
- data/vendor/faiss/faiss/IndexNNDescent.cpp +3 -33
- data/vendor/faiss/faiss/IndexNNDescent.h +1 -1
- data/vendor/faiss/faiss/IndexNSG.cpp +11 -27
- data/vendor/faiss/faiss/IndexNSG.h +11 -11
- data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +56 -0
- data/vendor/faiss/faiss/IndexNeuralNetCodec.h +49 -0
- data/vendor/faiss/faiss/IndexPQ.cpp +72 -88
- data/vendor/faiss/faiss/IndexPQ.h +1 -4
- data/vendor/faiss/faiss/IndexPQFastScan.cpp +1 -1
- data/vendor/faiss/faiss/IndexPreTransform.cpp +25 -31
- data/vendor/faiss/faiss/IndexPreTransform.h +1 -1
- data/vendor/faiss/faiss/IndexRefine.cpp +54 -24
- data/vendor/faiss/faiss/IndexRefine.h +7 -0
- data/vendor/faiss/faiss/IndexReplicas.cpp +23 -26
- data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +25 -17
- data/vendor/faiss/faiss/IndexScalarQuantizer.h +6 -4
- data/vendor/faiss/faiss/IndexShards.cpp +21 -29
- data/vendor/faiss/faiss/IndexShardsIVF.cpp +1 -2
- data/vendor/faiss/faiss/MatrixStats.cpp +17 -32
- data/vendor/faiss/faiss/MatrixStats.h +21 -9
- data/vendor/faiss/faiss/MetaIndexes.cpp +35 -35
- data/vendor/faiss/faiss/MetricType.h +7 -2
- data/vendor/faiss/faiss/VectorTransform.cpp +13 -26
- data/vendor/faiss/faiss/VectorTransform.h +7 -7
- data/vendor/faiss/faiss/clone_index.cpp +15 -10
- data/vendor/faiss/faiss/clone_index.h +3 -0
- data/vendor/faiss/faiss/cppcontrib/detail/UintReader.h +95 -17
- data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +152 -0
- data/vendor/faiss/faiss/cppcontrib/factory_tools.h +24 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +83 -30
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +123 -8
- data/vendor/faiss/faiss/gpu/GpuCloner.h +22 -0
- data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +13 -0
- data/vendor/faiss/faiss/gpu/GpuDistance.h +46 -38
- data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +1 -1
- data/vendor/faiss/faiss/gpu/GpuIndex.h +30 -12
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +282 -0
- data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +4 -4
- data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +14 -9
- data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +20 -3
- data/vendor/faiss/faiss/gpu/GpuIndexIVFPQ.h +22 -11
- data/vendor/faiss/faiss/gpu/GpuIndexIVFScalarQuantizer.h +1 -3
- data/vendor/faiss/faiss/gpu/GpuResources.cpp +24 -3
- data/vendor/faiss/faiss/gpu/GpuResources.h +39 -11
- data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +142 -17
- data/vendor/faiss/faiss/gpu/StandardGpuResources.h +57 -3
- data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.cpp +26 -21
- data/vendor/faiss/faiss/gpu/perf/PerfClustering.cpp +7 -1
- data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +8 -5
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp +25 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +129 -9
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +332 -40
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFPQ.cpp +299 -208
- data/vendor/faiss/faiss/gpu/test/TestGpuMemoryException.cpp +1 -0
- data/vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp +1 -1
- data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +6 -0
- data/vendor/faiss/faiss/gpu/utils/RaftUtils.h +75 -0
- data/vendor/faiss/faiss/gpu/utils/Timer.cpp +4 -1
- data/vendor/faiss/faiss/gpu/utils/Timer.h +1 -1
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +3 -1
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +5 -5
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +26 -1
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +10 -3
- data/vendor/faiss/faiss/impl/DistanceComputer.h +70 -1
- data/vendor/faiss/faiss/impl/FaissAssert.h +4 -2
- data/vendor/faiss/faiss/impl/FaissException.h +13 -34
- data/vendor/faiss/faiss/impl/HNSW.cpp +605 -186
- data/vendor/faiss/faiss/impl/HNSW.h +52 -30
- data/vendor/faiss/faiss/impl/IDSelector.h +4 -4
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +11 -9
- data/vendor/faiss/faiss/impl/LookupTableScaler.h +34 -0
- data/vendor/faiss/faiss/impl/NNDescent.cpp +42 -27
- data/vendor/faiss/faiss/impl/NSG.cpp +0 -29
- data/vendor/faiss/faiss/impl/NSG.h +1 -1
- data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +14 -12
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +25 -22
- data/vendor/faiss/faiss/impl/ProductQuantizer.h +6 -2
- data/vendor/faiss/faiss/impl/Quantizer.h +1 -1
- data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +27 -1015
- data/vendor/faiss/faiss/impl/ResidualQuantizer.h +5 -63
- data/vendor/faiss/faiss/impl/ResultHandler.h +347 -172
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +1104 -147
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +3 -8
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx2.h +285 -42
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +248 -0
- data/vendor/faiss/faiss/impl/code_distance/code_distance-generic.h +21 -14
- data/vendor/faiss/faiss/impl/code_distance/code_distance.h +22 -12
- data/vendor/faiss/faiss/impl/index_read.cpp +74 -34
- data/vendor/faiss/faiss/impl/index_read_utils.h +37 -0
- data/vendor/faiss/faiss/impl/index_write.cpp +88 -51
- data/vendor/faiss/faiss/impl/io.cpp +23 -15
- data/vendor/faiss/faiss/impl/io.h +4 -4
- data/vendor/faiss/faiss/impl/io_macros.h +6 -0
- data/vendor/faiss/faiss/impl/lattice_Zn.cpp +1 -1
- data/vendor/faiss/faiss/impl/platform_macros.h +40 -1
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +14 -0
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +7 -6
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +52 -38
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +487 -49
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +960 -0
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +176 -0
- data/vendor/faiss/faiss/impl/simd_result_handlers.h +481 -225
- data/vendor/faiss/faiss/index_factory.cpp +41 -20
- data/vendor/faiss/faiss/index_io.h +12 -5
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +28 -8
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +3 -0
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +10 -2
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +73 -17
- data/vendor/faiss/faiss/invlists/InvertedLists.h +26 -8
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +24 -9
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +2 -1
- data/vendor/faiss/faiss/python/python_callbacks.cpp +4 -4
- data/vendor/faiss/faiss/utils/Heap.cpp +3 -1
- data/vendor/faiss/faiss/utils/Heap.h +105 -0
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +342 -0
- data/vendor/faiss/faiss/utils/NeuralNet.h +147 -0
- data/vendor/faiss/faiss/utils/WorkerThread.h +1 -0
- data/vendor/faiss/faiss/utils/bf16.h +36 -0
- data/vendor/faiss/faiss/utils/distances.cpp +147 -123
- data/vendor/faiss/faiss/utils/distances.h +86 -9
- data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +5 -5
- 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 +1 -1
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +5 -5
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.h +1 -1
- data/vendor/faiss/faiss/utils/distances_simd.cpp +1589 -243
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +70 -0
- data/vendor/faiss/faiss/utils/extra_distances.cpp +85 -137
- data/vendor/faiss/faiss/utils/extra_distances.h +3 -2
- data/vendor/faiss/faiss/utils/fp16-arm.h +29 -0
- data/vendor/faiss/faiss/utils/fp16.h +2 -0
- data/vendor/faiss/faiss/utils/hamming.cpp +163 -111
- data/vendor/faiss/faiss/utils/hamming.h +58 -0
- data/vendor/faiss/faiss/utils/hamming_distance/avx2-inl.h +16 -89
- data/vendor/faiss/faiss/utils/hamming_distance/common.h +1 -0
- data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +19 -88
- data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +58 -0
- data/vendor/faiss/faiss/utils/hamming_distance/neon-inl.h +14 -104
- data/vendor/faiss/faiss/utils/partitioning.cpp +3 -4
- data/vendor/faiss/faiss/utils/prefetch.h +77 -0
- data/vendor/faiss/faiss/utils/quantize_lut.cpp +0 -14
- data/vendor/faiss/faiss/utils/random.cpp +43 -0
- data/vendor/faiss/faiss/utils/random.h +25 -0
- data/vendor/faiss/faiss/utils/simdlib.h +10 -1
- data/vendor/faiss/faiss/utils/simdlib_avx2.h +0 -6
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +296 -0
- data/vendor/faiss/faiss/utils/simdlib_neon.h +77 -79
- data/vendor/faiss/faiss/utils/simdlib_ppc64.h +1084 -0
- data/vendor/faiss/faiss/utils/sorting.cpp +140 -5
- data/vendor/faiss/faiss/utils/sorting.h +27 -0
- data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +176 -0
- data/vendor/faiss/faiss/utils/utils.cpp +120 -7
- data/vendor/faiss/faiss/utils/utils.h +60 -20
- metadata +23 -4
- data/vendor/faiss/faiss/impl/code_distance/code_distance_avx512.h +0 -102
@@ -35,6 +35,22 @@ void pickEncoding(int& codes, int& dim) {
|
|
35
35
|
}
|
36
36
|
}
|
37
37
|
|
38
|
+
void pickRaftEncoding(int& codes, int& dim, int bitsPerCode) {
|
39
|
+
// Above 32 doesn't work with no precomputed codes
|
40
|
+
std::vector<int> dimSizes{4, 8, 10, 12, 16, 20, 24, 28, 32};
|
41
|
+
|
42
|
+
while (true) {
|
43
|
+
codes = faiss::gpu::randVal(0, 96);
|
44
|
+
dim = codes * dimSizes[faiss::gpu::randVal(0, dimSizes.size() - 1)];
|
45
|
+
|
46
|
+
// for such a small test, super-low or high dim is more likely to
|
47
|
+
// generate comparison errors
|
48
|
+
if (dim < 256 && dim >= 64 && (codes * bitsPerCode) % 8 == 0) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
38
54
|
struct Options {
|
39
55
|
Options() {
|
40
56
|
numAdd = faiss::gpu::randVal(2000, 5000);
|
@@ -43,9 +59,10 @@ struct Options {
|
|
43
59
|
|
44
60
|
pickEncoding(codes, dim);
|
45
61
|
|
46
|
-
// TODO: Change back to `faiss::gpu::randVal(3, 7)` when we
|
47
|
-
//
|
62
|
+
// TODO: Change back to `faiss::gpu::randVal(3, 7)` when we
|
63
|
+
// officially support non-multiple of 8 subcodes for IVFPQ.
|
48
64
|
bitsPerCode = 8;
|
65
|
+
|
49
66
|
nprobe = std::min(faiss::gpu::randVal(40, 1000), numCentroids);
|
50
67
|
numQuery = faiss::gpu::randVal(4, 8);
|
51
68
|
|
@@ -66,6 +83,9 @@ struct Options {
|
|
66
83
|
}
|
67
84
|
|
68
85
|
device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
|
86
|
+
|
87
|
+
interleavedLayout = false;
|
88
|
+
useRaft = false;
|
69
89
|
}
|
70
90
|
|
71
91
|
std::string toString() const {
|
@@ -105,50 +125,66 @@ struct Options {
|
|
105
125
|
faiss::gpu::IndicesOptions indicesOpt;
|
106
126
|
bool useFloat16;
|
107
127
|
int device;
|
128
|
+
bool interleavedLayout;
|
129
|
+
bool useRaft;
|
108
130
|
};
|
109
131
|
|
110
|
-
|
111
|
-
|
112
|
-
|
132
|
+
void queryTest(Options opt, faiss::MetricType metricType) {
|
133
|
+
std::vector<float> trainVecs = faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
134
|
+
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
113
135
|
|
114
|
-
|
115
|
-
|
116
|
-
|
136
|
+
faiss::IndexFlatL2 coarseQuantizerL2(opt.dim);
|
137
|
+
faiss::IndexFlatIP coarseQuantizerIP(opt.dim);
|
138
|
+
faiss::Index* quantizer = metricType == faiss::METRIC_L2
|
139
|
+
? (faiss::Index*)&coarseQuantizerL2
|
140
|
+
: (faiss::Index*)&coarseQuantizerIP;
|
117
141
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
opt.bitsPerCode);
|
125
|
-
cpuIndex.nprobe = opt.nprobe;
|
126
|
-
cpuIndex.train(opt.numTrain, trainVecs.data());
|
127
|
-
cpuIndex.add(opt.numAdd, addVecs.data());
|
142
|
+
faiss::IndexIVFPQ cpuIndex(
|
143
|
+
quantizer, opt.dim, opt.numCentroids, opt.codes, opt.bitsPerCode);
|
144
|
+
cpuIndex.metric_type = metricType;
|
145
|
+
cpuIndex.nprobe = opt.nprobe;
|
146
|
+
cpuIndex.train(opt.numTrain, trainVecs.data());
|
147
|
+
cpuIndex.add(opt.numAdd, addVecs.data());
|
128
148
|
|
129
|
-
|
130
|
-
|
131
|
-
|
149
|
+
// Use the default temporary memory management to test the memory
|
150
|
+
// manager
|
151
|
+
faiss::gpu::StandardGpuResources res;
|
132
152
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
153
|
+
faiss::gpu::GpuIndexIVFPQConfig config;
|
154
|
+
config.device = opt.device;
|
155
|
+
config.usePrecomputedTables = opt.usePrecomputed;
|
156
|
+
config.indicesOptions = opt.indicesOpt;
|
157
|
+
config.useFloat16LookupTables = opt.useFloat16;
|
158
|
+
config.interleavedLayout = opt.interleavedLayout;
|
159
|
+
config.use_raft = opt.useRaft;
|
138
160
|
|
139
|
-
|
140
|
-
|
161
|
+
faiss::gpu::GpuIndexIVFPQ gpuIndex(&res, &cpuIndex, config);
|
162
|
+
gpuIndex.nprobe = opt.nprobe;
|
141
163
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
164
|
+
faiss::gpu::compareIndices(
|
165
|
+
cpuIndex,
|
166
|
+
gpuIndex,
|
167
|
+
opt.numQuery,
|
168
|
+
opt.dim,
|
169
|
+
opt.k,
|
170
|
+
opt.toString(),
|
171
|
+
opt.getCompareEpsilon(),
|
172
|
+
opt.getPctMaxDiff1(),
|
173
|
+
opt.getPctMaxDiffN());
|
174
|
+
}
|
175
|
+
|
176
|
+
TEST(TestGpuIndexIVFPQ, Query_L2) {
|
177
|
+
for (int tries = 0; tries < 2; ++tries) {
|
178
|
+
Options opt;
|
179
|
+
opt.usePrecomputed = (tries % 2 == 0);
|
180
|
+
queryTest(opt, faiss::MetricType::METRIC_L2);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
TEST(TestGpuIndexIVFPQ, Query_IP) {
|
185
|
+
for (int tries = 0; tries < 2; ++tries) {
|
186
|
+
Options opt;
|
187
|
+
queryTest(opt, faiss::MetricType::METRIC_INNER_PRODUCT);
|
152
188
|
}
|
153
189
|
}
|
154
190
|
|
@@ -161,45 +197,10 @@ TEST(TestGpuIndexIVFPQ, LargeBatch) {
|
|
161
197
|
opt.dim = 4;
|
162
198
|
opt.numQuery = 100000;
|
163
199
|
opt.codes = 2;
|
200
|
+
opt.usePrecomputed = usePrecomputed;
|
201
|
+
opt.useFloat16 = false;
|
164
202
|
|
165
|
-
|
166
|
-
faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
167
|
-
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
168
|
-
|
169
|
-
faiss::IndexFlatL2 coarseQuantizer(opt.dim);
|
170
|
-
faiss::IndexIVFPQ cpuIndex(
|
171
|
-
&coarseQuantizer,
|
172
|
-
opt.dim,
|
173
|
-
opt.numCentroids,
|
174
|
-
opt.codes,
|
175
|
-
opt.bitsPerCode);
|
176
|
-
cpuIndex.nprobe = opt.nprobe;
|
177
|
-
cpuIndex.train(opt.numTrain, trainVecs.data());
|
178
|
-
cpuIndex.add(opt.numAdd, addVecs.data());
|
179
|
-
|
180
|
-
// Use the default temporary memory management to test the memory
|
181
|
-
// manager
|
182
|
-
faiss::gpu::StandardGpuResources res;
|
183
|
-
|
184
|
-
faiss::gpu::GpuIndexIVFPQConfig config;
|
185
|
-
config.device = opt.device;
|
186
|
-
config.usePrecomputedTables = usePrecomputed;
|
187
|
-
config.indicesOptions = opt.indicesOpt;
|
188
|
-
config.useFloat16LookupTables = false;
|
189
|
-
|
190
|
-
faiss::gpu::GpuIndexIVFPQ gpuIndex(&res, &cpuIndex, config);
|
191
|
-
gpuIndex.nprobe = opt.nprobe;
|
192
|
-
|
193
|
-
faiss::gpu::compareIndices(
|
194
|
-
cpuIndex,
|
195
|
-
gpuIndex,
|
196
|
-
opt.numQuery,
|
197
|
-
opt.dim,
|
198
|
-
opt.k,
|
199
|
-
opt.toString(),
|
200
|
-
opt.getCompareEpsilon(),
|
201
|
-
opt.getPctMaxDiff1(),
|
202
|
-
opt.getPctMaxDiffN());
|
203
|
+
queryTest(opt, faiss::MetricType::METRIC_L2);
|
203
204
|
}
|
204
205
|
}
|
205
206
|
|
@@ -234,6 +235,7 @@ void testMMCodeDistance(faiss::MetricType mt) {
|
|
234
235
|
config.usePrecomputedTables = false;
|
235
236
|
config.useMMCodeDistance = true;
|
236
237
|
config.indicesOptions = opt.indicesOpt;
|
238
|
+
config.use_raft = false;
|
237
239
|
|
238
240
|
// Make sure that the float16 version works as well
|
239
241
|
config.useFloat16LookupTables = (tries % 2 == 0);
|
@@ -284,6 +286,7 @@ void testMMCodeDistance(faiss::MetricType mt) {
|
|
284
286
|
config.device = opt.device;
|
285
287
|
config.usePrecomputedTables = false;
|
286
288
|
config.indicesOptions = opt.indicesOpt;
|
289
|
+
config.use_raft = false;
|
287
290
|
|
288
291
|
// Make sure that the float16 version works as well
|
289
292
|
config.useFloat16LookupTables = (dimPerSubQ == 7);
|
@@ -312,53 +315,6 @@ TEST(TestGpuIndexIVFPQ, Query_IP_MMCodeDistance) {
|
|
312
315
|
testMMCodeDistance(faiss::MetricType::METRIC_INNER_PRODUCT);
|
313
316
|
}
|
314
317
|
|
315
|
-
TEST(TestGpuIndexIVFPQ, Query_IP) {
|
316
|
-
for (int tries = 0; tries < 2; ++tries) {
|
317
|
-
Options opt;
|
318
|
-
|
319
|
-
std::vector<float> trainVecs =
|
320
|
-
faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
321
|
-
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
322
|
-
|
323
|
-
faiss::IndexFlatIP coarseQuantizer(opt.dim);
|
324
|
-
faiss::IndexIVFPQ cpuIndex(
|
325
|
-
&coarseQuantizer,
|
326
|
-
opt.dim,
|
327
|
-
opt.numCentroids,
|
328
|
-
opt.codes,
|
329
|
-
opt.bitsPerCode);
|
330
|
-
cpuIndex.metric_type = faiss::MetricType::METRIC_INNER_PRODUCT;
|
331
|
-
|
332
|
-
cpuIndex.nprobe = opt.nprobe;
|
333
|
-
cpuIndex.train(opt.numTrain, trainVecs.data());
|
334
|
-
cpuIndex.add(opt.numAdd, addVecs.data());
|
335
|
-
|
336
|
-
// Use the default temporary memory management to test the memory
|
337
|
-
// manager
|
338
|
-
faiss::gpu::StandardGpuResources res;
|
339
|
-
|
340
|
-
faiss::gpu::GpuIndexIVFPQConfig config;
|
341
|
-
config.device = opt.device;
|
342
|
-
config.usePrecomputedTables = false; // not supported/required for IP
|
343
|
-
config.indicesOptions = opt.indicesOpt;
|
344
|
-
config.useFloat16LookupTables = opt.useFloat16;
|
345
|
-
|
346
|
-
faiss::gpu::GpuIndexIVFPQ gpuIndex(&res, &cpuIndex, config);
|
347
|
-
gpuIndex.nprobe = opt.nprobe;
|
348
|
-
|
349
|
-
faiss::gpu::compareIndices(
|
350
|
-
cpuIndex,
|
351
|
-
gpuIndex,
|
352
|
-
opt.numQuery,
|
353
|
-
opt.dim,
|
354
|
-
opt.k,
|
355
|
-
opt.toString(),
|
356
|
-
opt.getCompareEpsilon(),
|
357
|
-
opt.getPctMaxDiff1(),
|
358
|
-
opt.getPctMaxDiffN());
|
359
|
-
}
|
360
|
-
}
|
361
|
-
|
362
318
|
TEST(TestGpuIndexIVFPQ, Float16Coarse) {
|
363
319
|
Options opt;
|
364
320
|
|
@@ -384,6 +340,7 @@ TEST(TestGpuIndexIVFPQ, Float16Coarse) {
|
|
384
340
|
config.usePrecomputedTables = opt.usePrecomputed;
|
385
341
|
config.indicesOptions = opt.indicesOpt;
|
386
342
|
config.useFloat16LookupTables = opt.useFloat16;
|
343
|
+
config.use_raft = false;
|
387
344
|
|
388
345
|
faiss::gpu::GpuIndexIVFPQ gpuIndex(&res, &cpuIndex, config);
|
389
346
|
gpuIndex.nprobe = opt.nprobe;
|
@@ -403,104 +360,68 @@ TEST(TestGpuIndexIVFPQ, Float16Coarse) {
|
|
403
360
|
opt.getPctMaxDiffN());
|
404
361
|
}
|
405
362
|
|
406
|
-
|
407
|
-
|
408
|
-
|
363
|
+
void addTest(Options opt, faiss::MetricType metricType) {
|
364
|
+
std::vector<float> trainVecs = faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
365
|
+
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
409
366
|
|
410
|
-
|
411
|
-
|
412
|
-
|
367
|
+
faiss::IndexFlatL2 coarseQuantizerL2(opt.dim);
|
368
|
+
faiss::IndexFlatIP coarseQuantizerIP(opt.dim);
|
369
|
+
faiss::Index* quantizer = metricType == faiss::METRIC_L2
|
370
|
+
? (faiss::Index*)&coarseQuantizerL2
|
371
|
+
: (faiss::Index*)&coarseQuantizerIP;
|
413
372
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
opt.codes,
|
420
|
-
opt.bitsPerCode);
|
421
|
-
cpuIndex.nprobe = opt.nprobe;
|
422
|
-
cpuIndex.train(opt.numTrain, trainVecs.data());
|
373
|
+
faiss::IndexIVFPQ cpuIndex(
|
374
|
+
quantizer, opt.dim, opt.numCentroids, opt.codes, opt.bitsPerCode);
|
375
|
+
cpuIndex.nprobe = opt.nprobe;
|
376
|
+
cpuIndex.metric_type = metricType;
|
377
|
+
cpuIndex.train(opt.numTrain, trainVecs.data());
|
423
378
|
|
424
|
-
|
425
|
-
|
426
|
-
|
379
|
+
// Use the default temporary memory management to test the memory
|
380
|
+
// manager
|
381
|
+
faiss::gpu::StandardGpuResources res;
|
427
382
|
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
383
|
+
faiss::gpu::GpuIndexIVFPQConfig config;
|
384
|
+
config.device = opt.device;
|
385
|
+
config.usePrecomputedTables = opt.usePrecomputed;
|
386
|
+
config.indicesOptions = opt.indicesOpt;
|
387
|
+
config.useFloat16LookupTables = opt.useFloat16;
|
388
|
+
config.interleavedLayout = opt.interleavedLayout;
|
389
|
+
config.use_raft = opt.useRaft;
|
433
390
|
|
434
|
-
|
435
|
-
|
391
|
+
faiss::gpu::GpuIndexIVFPQ gpuIndex(&res, &cpuIndex, config);
|
392
|
+
gpuIndex.nprobe = opt.nprobe;
|
436
393
|
|
437
|
-
|
438
|
-
|
394
|
+
gpuIndex.add(opt.numAdd, addVecs.data());
|
395
|
+
cpuIndex.add(opt.numAdd, addVecs.data());
|
439
396
|
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
397
|
+
faiss::gpu::compareIndices(
|
398
|
+
cpuIndex,
|
399
|
+
gpuIndex,
|
400
|
+
opt.numQuery,
|
401
|
+
opt.dim,
|
402
|
+
opt.k,
|
403
|
+
opt.toString(),
|
404
|
+
opt.getCompareEpsilon(),
|
405
|
+
opt.getPctMaxDiff1(),
|
406
|
+
opt.getPctMaxDiffN());
|
407
|
+
}
|
408
|
+
|
409
|
+
TEST(TestGpuIndexIVFPQ, Add_L2) {
|
410
|
+
for (int tries = 0; tries < 2; ++tries) {
|
411
|
+
Options opt;
|
412
|
+
addTest(opt, faiss::METRIC_L2);
|
450
413
|
}
|
451
414
|
}
|
452
415
|
|
453
416
|
TEST(TestGpuIndexIVFPQ, Add_IP) {
|
454
417
|
for (int tries = 0; tries < 2; ++tries) {
|
455
418
|
Options opt;
|
456
|
-
|
457
|
-
std::vector<float> trainVecs =
|
458
|
-
faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
459
|
-
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
460
|
-
|
461
|
-
faiss::IndexFlatIP coarseQuantizer(opt.dim);
|
462
|
-
faiss::IndexIVFPQ cpuIndex(
|
463
|
-
&coarseQuantizer,
|
464
|
-
opt.dim,
|
465
|
-
opt.numCentroids,
|
466
|
-
opt.codes,
|
467
|
-
opt.bitsPerCode);
|
468
|
-
cpuIndex.metric_type = faiss::MetricType::METRIC_INNER_PRODUCT;
|
469
|
-
cpuIndex.nprobe = opt.nprobe;
|
470
|
-
cpuIndex.train(opt.numTrain, trainVecs.data());
|
471
|
-
|
472
|
-
// Use the default temporary memory management to test the memory
|
473
|
-
// manager
|
474
|
-
faiss::gpu::StandardGpuResources res;
|
475
|
-
|
476
|
-
faiss::gpu::GpuIndexIVFPQConfig config;
|
477
|
-
config.device = opt.device;
|
478
|
-
config.usePrecomputedTables = opt.usePrecomputed;
|
479
|
-
config.indicesOptions = opt.indicesOpt;
|
480
|
-
config.useFloat16LookupTables = opt.useFloat16;
|
481
|
-
|
482
|
-
faiss::gpu::GpuIndexIVFPQ gpuIndex(&res, &cpuIndex, config);
|
483
|
-
gpuIndex.nprobe = opt.nprobe;
|
484
|
-
|
485
|
-
gpuIndex.add(opt.numAdd, addVecs.data());
|
486
|
-
cpuIndex.add(opt.numAdd, addVecs.data());
|
487
|
-
|
488
|
-
faiss::gpu::compareIndices(
|
489
|
-
cpuIndex,
|
490
|
-
gpuIndex,
|
491
|
-
opt.numQuery,
|
492
|
-
opt.dim,
|
493
|
-
opt.k,
|
494
|
-
opt.toString(),
|
495
|
-
opt.getCompareEpsilon(),
|
496
|
-
opt.getPctMaxDiff1(),
|
497
|
-
opt.getPctMaxDiffN());
|
419
|
+
addTest(opt, faiss::METRIC_INNER_PRODUCT);
|
498
420
|
}
|
499
421
|
}
|
500
422
|
|
501
|
-
|
423
|
+
void copyToTest(Options opt) {
|
502
424
|
for (int tries = 0; tries < 2; ++tries) {
|
503
|
-
Options opt;
|
504
425
|
std::vector<float> trainVecs =
|
505
426
|
faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
506
427
|
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
@@ -511,9 +432,11 @@ TEST(TestGpuIndexIVFPQ, CopyTo) {
|
|
511
432
|
|
512
433
|
faiss::gpu::GpuIndexIVFPQConfig config;
|
513
434
|
config.device = opt.device;
|
514
|
-
config.usePrecomputedTables =
|
435
|
+
config.usePrecomputedTables = false;
|
515
436
|
config.indicesOptions = opt.indicesOpt;
|
516
437
|
config.useFloat16LookupTables = opt.useFloat16;
|
438
|
+
config.interleavedLayout = opt.interleavedLayout;
|
439
|
+
config.use_raft = opt.useRaft;
|
517
440
|
|
518
441
|
faiss::gpu::GpuIndexIVFPQ gpuIndex(
|
519
442
|
&res,
|
@@ -561,8 +484,12 @@ TEST(TestGpuIndexIVFPQ, CopyTo) {
|
|
561
484
|
}
|
562
485
|
}
|
563
486
|
|
564
|
-
TEST(TestGpuIndexIVFPQ,
|
487
|
+
TEST(TestGpuIndexIVFPQ, CopyTo) {
|
565
488
|
Options opt;
|
489
|
+
copyToTest(opt);
|
490
|
+
}
|
491
|
+
|
492
|
+
void copyFromTest(Options opt) {
|
566
493
|
std::vector<float> trainVecs = faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
567
494
|
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
568
495
|
|
@@ -585,6 +512,8 @@ TEST(TestGpuIndexIVFPQ, CopyFrom) {
|
|
585
512
|
config.usePrecomputedTables = opt.usePrecomputed;
|
586
513
|
config.indicesOptions = opt.indicesOpt;
|
587
514
|
config.useFloat16LookupTables = opt.useFloat16;
|
515
|
+
config.interleavedLayout = opt.interleavedLayout;
|
516
|
+
config.use_raft = opt.useRaft;
|
588
517
|
|
589
518
|
// Use garbage values to see if we overwrite them
|
590
519
|
faiss::gpu::GpuIndexIVFPQ gpuIndex(
|
@@ -621,9 +550,12 @@ TEST(TestGpuIndexIVFPQ, CopyFrom) {
|
|
621
550
|
opt.getPctMaxDiffN());
|
622
551
|
}
|
623
552
|
|
624
|
-
TEST(TestGpuIndexIVFPQ,
|
553
|
+
TEST(TestGpuIndexIVFPQ, CopyFrom) {
|
625
554
|
Options opt;
|
555
|
+
copyFromTest(opt);
|
556
|
+
}
|
626
557
|
|
558
|
+
void queryNaNTest(Options opt) {
|
627
559
|
std::vector<float> trainVecs = faiss::gpu::randVecs(opt.numTrain, opt.dim);
|
628
560
|
std::vector<float> addVecs = faiss::gpu::randVecs(opt.numAdd, opt.dim);
|
629
561
|
|
@@ -635,6 +567,8 @@ TEST(TestGpuIndexIVFPQ, QueryNaN) {
|
|
635
567
|
config.usePrecomputedTables = opt.usePrecomputed;
|
636
568
|
config.indicesOptions = opt.indicesOpt;
|
637
569
|
config.useFloat16LookupTables = opt.useFloat16;
|
570
|
+
config.use_raft = opt.useRaft;
|
571
|
+
config.interleavedLayout = opt.useRaft ? true : opt.interleavedLayout;
|
638
572
|
|
639
573
|
faiss::gpu::GpuIndexIVFPQ gpuIndex(
|
640
574
|
&res,
|
@@ -670,9 +604,13 @@ TEST(TestGpuIndexIVFPQ, QueryNaN) {
|
|
670
604
|
}
|
671
605
|
}
|
672
606
|
|
673
|
-
TEST(TestGpuIndexIVFPQ,
|
607
|
+
TEST(TestGpuIndexIVFPQ, QueryNaN) {
|
674
608
|
Options opt;
|
609
|
+
opt.useRaft = false;
|
610
|
+
queryNaNTest(opt);
|
611
|
+
}
|
675
612
|
|
613
|
+
void addNaNTest(Options opt) {
|
676
614
|
// Use the default temporary memory management to test the memory manager
|
677
615
|
faiss::gpu::StandardGpuResources res;
|
678
616
|
|
@@ -681,6 +619,8 @@ TEST(TestGpuIndexIVFPQ, AddNaN) {
|
|
681
619
|
config.usePrecomputedTables = opt.usePrecomputed;
|
682
620
|
config.indicesOptions = opt.indicesOpt;
|
683
621
|
config.useFloat16LookupTables = opt.useFloat16;
|
622
|
+
config.interleavedLayout = opt.interleavedLayout;
|
623
|
+
config.use_raft = opt.useRaft;
|
684
624
|
|
685
625
|
faiss::gpu::GpuIndexIVFPQ gpuIndex(
|
686
626
|
&res,
|
@@ -722,6 +662,128 @@ TEST(TestGpuIndexIVFPQ, AddNaN) {
|
|
722
662
|
indices.data());
|
723
663
|
}
|
724
664
|
|
665
|
+
TEST(TestGpuIndexIVFPQ, AddNaN) {
|
666
|
+
Options opt;
|
667
|
+
opt.useRaft = false;
|
668
|
+
addNaNTest(opt);
|
669
|
+
}
|
670
|
+
|
671
|
+
#if defined USE_NVIDIA_RAFT
|
672
|
+
TEST(TestGpuIndexIVFPQ, Query_L2_Raft) {
|
673
|
+
for (int tries = 0; tries < 2; ++tries) {
|
674
|
+
Options opt;
|
675
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
676
|
+
opt.useRaft = true;
|
677
|
+
opt.interleavedLayout = true;
|
678
|
+
opt.usePrecomputed = false;
|
679
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
680
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
681
|
+
queryTest(opt, faiss::MetricType::METRIC_L2);
|
682
|
+
}
|
683
|
+
}
|
684
|
+
|
685
|
+
TEST(TestGpuIndexIVFPQ, Query_IP_Raft) {
|
686
|
+
for (int tries = 0; tries < 2; ++tries) {
|
687
|
+
Options opt;
|
688
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
689
|
+
opt.useRaft = true;
|
690
|
+
opt.interleavedLayout = true;
|
691
|
+
opt.usePrecomputed = false;
|
692
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
693
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
694
|
+
queryTest(opt, faiss::MetricType::METRIC_INNER_PRODUCT);
|
695
|
+
}
|
696
|
+
}
|
697
|
+
|
698
|
+
// Large batch sizes (>= 65536) should also work
|
699
|
+
TEST(TestGpuIndexIVFPQ, LargeBatch_Raft) {
|
700
|
+
Options opt;
|
701
|
+
|
702
|
+
// override for large sizes
|
703
|
+
opt.dim = 4;
|
704
|
+
opt.numQuery = 100000;
|
705
|
+
opt.codes = 2;
|
706
|
+
opt.useRaft = true;
|
707
|
+
opt.interleavedLayout = true;
|
708
|
+
opt.usePrecomputed = false;
|
709
|
+
opt.useFloat16 = false;
|
710
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
711
|
+
opt.bitsPerCode = 8;
|
712
|
+
|
713
|
+
queryTest(opt, faiss::MetricType::METRIC_L2);
|
714
|
+
}
|
715
|
+
|
716
|
+
TEST(TestGpuIndexIVFPQ, CopyFrom_Raft) {
|
717
|
+
Options opt;
|
718
|
+
opt.useRaft = true;
|
719
|
+
opt.interleavedLayout = true;
|
720
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
721
|
+
opt.usePrecomputed = false;
|
722
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
723
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
724
|
+
copyFromTest(opt);
|
725
|
+
}
|
726
|
+
|
727
|
+
TEST(TestGpuIndexIVFPQ, Add_L2_Raft) {
|
728
|
+
for (int tries = 0; tries < 2; ++tries) {
|
729
|
+
Options opt;
|
730
|
+
opt.useRaft = true;
|
731
|
+
opt.interleavedLayout = true;
|
732
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
733
|
+
opt.usePrecomputed = false;
|
734
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
735
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
736
|
+
addTest(opt, faiss::METRIC_L2);
|
737
|
+
}
|
738
|
+
}
|
739
|
+
|
740
|
+
TEST(TestGpuIndexIVFPQ, Add_IP_Raft) {
|
741
|
+
for (int tries = 0; tries < 2; ++tries) {
|
742
|
+
Options opt;
|
743
|
+
opt.useRaft = true;
|
744
|
+
opt.interleavedLayout = true;
|
745
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
746
|
+
opt.usePrecomputed = false;
|
747
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
748
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
749
|
+
addTest(opt, faiss::METRIC_INNER_PRODUCT);
|
750
|
+
}
|
751
|
+
}
|
752
|
+
|
753
|
+
TEST(TestGpuIndexIVFPQ, QueryNaN_Raft) {
|
754
|
+
Options opt;
|
755
|
+
opt.useRaft = true;
|
756
|
+
opt.interleavedLayout = true;
|
757
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
758
|
+
opt.usePrecomputed = false;
|
759
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
760
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
761
|
+
queryNaNTest(opt);
|
762
|
+
}
|
763
|
+
|
764
|
+
TEST(TestGpuIndexIVFPQ, AddNaN_Raft) {
|
765
|
+
Options opt;
|
766
|
+
opt.useRaft = true;
|
767
|
+
opt.interleavedLayout = true;
|
768
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
769
|
+
opt.usePrecomputed = false;
|
770
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
771
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
772
|
+
addNaNTest(opt);
|
773
|
+
}
|
774
|
+
|
775
|
+
TEST(TestGpuIndexIVFPQ, CopyTo_Raft) {
|
776
|
+
Options opt;
|
777
|
+
opt.useRaft = true;
|
778
|
+
opt.interleavedLayout = true;
|
779
|
+
opt.bitsPerCode = faiss::gpu::randVal(4, 8);
|
780
|
+
opt.usePrecomputed = false;
|
781
|
+
opt.indicesOpt = faiss::gpu::INDICES_64_BIT;
|
782
|
+
pickRaftEncoding(opt.codes, opt.dim, opt.bitsPerCode);
|
783
|
+
copyToTest(opt);
|
784
|
+
}
|
785
|
+
#endif
|
786
|
+
|
725
787
|
TEST(TestGpuIndexIVFPQ, UnifiedMemory) {
|
726
788
|
// Construct on a random device to test multi-device, if we have
|
727
789
|
// multiple devices
|
@@ -762,6 +824,7 @@ TEST(TestGpuIndexIVFPQ, UnifiedMemory) {
|
|
762
824
|
faiss::gpu::GpuIndexIVFPQConfig config;
|
763
825
|
config.device = device;
|
764
826
|
config.memorySpace = faiss::gpu::MemorySpace::Unified;
|
827
|
+
config.use_raft = false;
|
765
828
|
|
766
829
|
faiss::gpu::GpuIndexIVFPQ gpuIndex(
|
767
830
|
&res,
|
@@ -784,6 +847,34 @@ TEST(TestGpuIndexIVFPQ, UnifiedMemory) {
|
|
784
847
|
0.015f,
|
785
848
|
0.1f,
|
786
849
|
0.015f);
|
850
|
+
|
851
|
+
#if defined USE_NVIDIA_RAFT
|
852
|
+
config.interleavedLayout = true;
|
853
|
+
config.use_raft = true;
|
854
|
+
config.indicesOptions = faiss::gpu::INDICES_64_BIT;
|
855
|
+
|
856
|
+
faiss::gpu::GpuIndexIVFPQ raftGpuIndex(
|
857
|
+
&res,
|
858
|
+
dim,
|
859
|
+
numCentroids,
|
860
|
+
codes,
|
861
|
+
bitsPerCode,
|
862
|
+
faiss::METRIC_L2,
|
863
|
+
config);
|
864
|
+
raftGpuIndex.copyFrom(&cpuIndex);
|
865
|
+
raftGpuIndex.nprobe = nprobe;
|
866
|
+
|
867
|
+
faiss::gpu::compareIndices(
|
868
|
+
cpuIndex,
|
869
|
+
raftGpuIndex,
|
870
|
+
numQuery,
|
871
|
+
dim,
|
872
|
+
k,
|
873
|
+
"Unified Memory",
|
874
|
+
0.015f,
|
875
|
+
0.1f,
|
876
|
+
0.015f);
|
877
|
+
#endif
|
787
878
|
}
|
788
879
|
|
789
880
|
int main(int argc, char** argv) {
|
@@ -31,6 +31,7 @@ TEST(TestGpuMemoryException, AddException) {
|
|
31
31
|
|
32
32
|
faiss::gpu::GpuIndexFlatConfig config;
|
33
33
|
config.device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
|
34
|
+
config.use_raft = false;
|
34
35
|
|
35
36
|
faiss::gpu::GpuIndexFlatL2 gpuIndexL2Broken(
|
36
37
|
&res, (int)brokenAddDims, config);
|