Skip to content

Commit 7991350

Browse files
Bump Faiss commit from 1f42e81 to 0cbc2a8 (#2381)
Signed-off-by: Naveen Tatikonda <navtat@amazon.com>
1 parent b2a47d8 commit 7991350

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4444
* Added null checks for fieldInfo in ExactSearcher to avoid NPE while running exact search for segments with no vector field (#2278)[https://github.com/opensearch-project/k-NN/pull/2278]
4545
* Added Lucene BWC tests (#2313)[https://github.com/opensearch-project/k-NN/pull/2313]
4646
* Upgrade jsonpath from 2.8.0 to 2.9.0[2325](https://github.com/opensearch-project/k-NN/pull/2325)
47+
* Bump Faiss commit from 1f42e81 to 0cbc2a8 to accelerate hamming distance calculation using _mm512_popcnt_epi64 intrinsic and also add avx512-fp16 instructions to boost performance [#2381](https://github.com/opensearch-project/k-NN/pull/2381)
4748
### Refactoring

jni/external/faiss

Submodule faiss updated 738 files

jni/patches/faiss/0002-Enable-precomp-table-to-be-shared-ivfpq.patch

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 9b33874562c9e62abf4a863657c54f0d349b0f67 Mon Sep 17 00:00:00 2001
1+
From 1605542c1f4f7982fe0c5447090ae96f84f27484 Mon Sep 17 00:00:00 2001
22
From: John Mazanec <jmazane@amazon.com>
33
Date: Wed, 21 Feb 2024 15:34:15 -0800
44
Subject: [PATCH] Enable precomp table to be shared ivfpq
@@ -22,10 +22,10 @@ Signed-off-by: John Mazanec <jmazane@amazon.com>
2222
create mode 100644 tests/test_ivfpq_share_table.cpp
2323

2424
diff --git a/faiss/IndexIVFPQ.cpp b/faiss/IndexIVFPQ.cpp
25-
index 100f499c..09508890 100644
25+
index e9d6eead2..97c8c010d 100644
2626
--- a/faiss/IndexIVFPQ.cpp
2727
+++ b/faiss/IndexIVFPQ.cpp
28-
@@ -59,6 +59,29 @@ IndexIVFPQ::IndexIVFPQ(
28+
@@ -58,6 +58,29 @@ IndexIVFPQ::IndexIVFPQ(
2929
polysemous_training = nullptr;
3030
do_polysemous_training = false;
3131
polysemous_ht = 0;
@@ -55,7 +55,7 @@ index 100f499c..09508890 100644
5555
}
5656

5757
/****************************************************************
58-
@@ -464,11 +487,23 @@ void IndexIVFPQ::precompute_table() {
58+
@@ -463,11 +486,23 @@ void IndexIVFPQ::precompute_table() {
5959
use_precomputed_table,
6060
quantizer,
6161
pq,
@@ -80,7 +80,7 @@ index 100f499c..09508890 100644
8080
namespace {
8181

8282
#define TIC t0 = get_cycles()
83-
@@ -648,7 +683,7 @@ struct QueryTables {
83+
@@ -647,7 +682,7 @@ struct QueryTables {
8484

8585
fvec_madd(
8686
pq.M * pq.ksub,
@@ -89,7 +89,7 @@ index 100f499c..09508890 100644
8989
-2.0,
9090
sim_table_2,
9191
sim_table);
92-
@@ -677,7 +712,7 @@ struct QueryTables {
92+
@@ -676,7 +711,7 @@ struct QueryTables {
9393
k >>= cpq.nbits;
9494

9595
// get corresponding table
@@ -98,7 +98,7 @@ index 100f499c..09508890 100644
9898
(ki * pq.M + cm * Mf) * pq.ksub;
9999

100100
if (polysemous_ht == 0) {
101-
@@ -707,7 +742,7 @@ struct QueryTables {
101+
@@ -706,7 +741,7 @@ struct QueryTables {
102102
dis0 = coarse_dis;
103103

104104
const float* s =
@@ -107,7 +107,7 @@ index 100f499c..09508890 100644
107107
for (int m = 0; m < pq.M; m++) {
108108
sim_table_ptrs[m] = s;
109109
s += pq.ksub;
110-
@@ -727,7 +762,7 @@ struct QueryTables {
110+
@@ -726,7 +761,7 @@ struct QueryTables {
111111
int ki = k & ((uint64_t(1) << cpq.nbits) - 1);
112112
k >>= cpq.nbits;
113113

@@ -116,7 +116,7 @@ index 100f499c..09508890 100644
116116
(ki * pq.M + cm * Mf) * pq.ksub;
117117

118118
for (int m = m0; m < m0 + Mf; m++) {
119-
@@ -1344,6 +1379,8 @@ IndexIVFPQ::IndexIVFPQ() {
119+
@@ -1343,6 +1378,8 @@ IndexIVFPQ::IndexIVFPQ() {
120120
do_polysemous_training = false;
121121
polysemous_ht = 0;
122122
polysemous_training = nullptr;
@@ -126,7 +126,7 @@ index 100f499c..09508890 100644
126126

127127
struct CodeCmp {
128128
diff --git a/faiss/IndexIVFPQ.h b/faiss/IndexIVFPQ.h
129-
index d5d21da4..850bbe44 100644
129+
index 7bf97ec0f..f647e5f87 100644
130130
--- a/faiss/IndexIVFPQ.h
131131
+++ b/faiss/IndexIVFPQ.h
132132
@@ -48,7 +48,8 @@ struct IndexIVFPQ : IndexIVF {
@@ -167,10 +167,10 @@ index d5d21da4..850bbe44 100644
167167
};
168168

169169
diff --git a/faiss/IndexIVFPQFastScan.cpp b/faiss/IndexIVFPQFastScan.cpp
170-
index 2844ae49..895df342 100644
170+
index 9d1cdfcae..647644e36 100644
171171
--- a/faiss/IndexIVFPQFastScan.cpp
172172
+++ b/faiss/IndexIVFPQFastScan.cpp
173-
@@ -46,6 +46,8 @@ IndexIVFPQFastScan::IndexIVFPQFastScan(
173+
@@ -42,6 +42,8 @@ IndexIVFPQFastScan::IndexIVFPQFastScan(
174174
: IndexIVFFastScan(quantizer, d, nlist, 0, metric), pq(d, M, nbits) {
175175
by_residual = false; // set to false by default because it's faster
176176

@@ -179,7 +179,7 @@ index 2844ae49..895df342 100644
179179
init_fastscan(M, nbits, nlist, metric, bbs);
180180
}
181181

182-
@@ -53,6 +55,17 @@ IndexIVFPQFastScan::IndexIVFPQFastScan() {
182+
@@ -49,6 +51,17 @@ IndexIVFPQFastScan::IndexIVFPQFastScan() {
183183
by_residual = false;
184184
bbs = 0;
185185
M2 = 0;
@@ -197,7 +197,7 @@ index 2844ae49..895df342 100644
197197
}
198198

199199
IndexIVFPQFastScan::IndexIVFPQFastScan(const IndexIVFPQ& orig, int bbs)
200-
@@ -71,13 +84,15 @@ IndexIVFPQFastScan::IndexIVFPQFastScan(const IndexIVFPQ& orig, int bbs)
200+
@@ -67,13 +80,15 @@ IndexIVFPQFastScan::IndexIVFPQFastScan(const IndexIVFPQ& orig, int bbs)
201201
ntotal = orig.ntotal;
202202
is_trained = orig.is_trained;
203203
nprobe = orig.nprobe;
@@ -218,7 +218,7 @@ index 2844ae49..895df342 100644
218218
}
219219

220220
for (size_t i = 0; i < nlist; i++) {
221-
@@ -102,6 +117,12 @@ IndexIVFPQFastScan::IndexIVFPQFastScan(const IndexIVFPQ& orig, int bbs)
221+
@@ -98,6 +113,12 @@ IndexIVFPQFastScan::IndexIVFPQFastScan(const IndexIVFPQ& orig, int bbs)
222222
orig_invlists = orig.invlists;
223223
}
224224

@@ -231,7 +231,7 @@ index 2844ae49..895df342 100644
231231
/*********************************************************
232232
* Training
233233
*********************************************************/
234-
@@ -127,11 +148,23 @@ void IndexIVFPQFastScan::precompute_table() {
234+
@@ -123,11 +144,23 @@ void IndexIVFPQFastScan::precompute_table() {
235235
use_precomputed_table,
236236
quantizer,
237237
pq,
@@ -256,7 +256,7 @@ index 2844ae49..895df342 100644
256256
/*********************************************************
257257
* Code management functions
258258
*********************************************************/
259-
@@ -229,7 +262,7 @@ void IndexIVFPQFastScan::compute_LUT(
259+
@@ -225,7 +258,7 @@ void IndexIVFPQFastScan::compute_LUT(
260260
if (cij >= 0) {
261261
fvec_madd_simd(
262262
dim12,
@@ -266,7 +266,7 @@ index 2844ae49..895df342 100644
266266
ip_table.get() + i * dim12,
267267
tab);
268268
diff --git a/faiss/IndexIVFPQFastScan.h b/faiss/IndexIVFPQFastScan.h
269-
index 00dd2f11..91f35a6e 100644
269+
index a2cce3266..1e1f0049c 100644
270270
--- a/faiss/IndexIVFPQFastScan.h
271271
+++ b/faiss/IndexIVFPQFastScan.h
272272
@@ -38,7 +38,8 @@ struct IndexIVFPQFastScan : IndexIVFFastScan {
@@ -302,19 +302,19 @@ index 00dd2f11..91f35a6e 100644
302302
/// same as the regular IVFPQ encoder. The codes are not reorganized by
303303
/// blocks a that point
304304
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
305-
index 87ab2020..a859516c 100644
305+
index ae6cc7878..16c99e04d 100644
306306
--- a/tests/CMakeLists.txt
307307
+++ b/tests/CMakeLists.txt
308308
@@ -38,6 +38,7 @@ set(FAISS_TEST_SRC
309-
test_common_ivf_empty_index.cpp
310309
test_callback.cpp
311310
test_utils.cpp
311+
test_hamming.cpp
312312
+ test_ivfpq_share_table.cpp
313313
)
314314

315315
add_executable(faiss_test ${FAISS_TEST_SRC})
316316
diff --git a/tests/test_disable_pq_sdc_tables.cpp b/tests/test_disable_pq_sdc_tables.cpp
317-
index b211a5c4..a27973d5 100644
317+
index f94aac870..60c59d7ba 100644
318318
--- a/tests/test_disable_pq_sdc_tables.cpp
319319
+++ b/tests/test_disable_pq_sdc_tables.cpp
320320
@@ -15,7 +15,9 @@
@@ -327,10 +327,10 @@ index b211a5c4..a27973d5 100644
327327
+}
328328

329329
TEST(IO, TestReadHNSWPQ_whenSDCDisabledFlagPassed_thenDisableSDCTable) {
330-
Tempfilename index_filename(&temp_file_mutex, "/tmp/faiss_TestReadHNSWPQ");
330+
// Create a temp file name with a randomized component for stress runs
331331
diff --git a/tests/test_ivfpq_share_table.cpp b/tests/test_ivfpq_share_table.cpp
332332
new file mode 100644
333-
index 00000000..f827315d
333+
index 000000000..f827315d8
334334
--- /dev/null
335335
+++ b/tests/test_ivfpq_share_table.cpp
336336
@@ -0,0 +1,173 @@

0 commit comments

Comments
 (0)