Skip to content

Commit b9cdf50

Browse files
authored
Merge branch 'main' into arm64_failures
2 parents 5942a11 + 084496a commit b9cdf50

15 files changed

+97
-100
lines changed

.circleci/config.yml

-86
This file was deleted.

.github/actions/build_cmake/action.yml

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ runs:
136136
.
137137
make -k -C build -j$(nproc)
138138
- name: C++ tests
139-
if: inputs.rocm == 'OFF'
140139
shell: bash
141140
run: |
142141
export GTEST_OUTPUT="xml:$(realpath .)/test-results/googletest/"

.github/workflows/retry_build.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ jobs:
1616
GH_DEBUG: api
1717
run: |
1818
gh run watch ${{ inputs.run_id }} > /dev/null 2>&1
19-
gh run rerun ${{ inputs.run_id }} --failed
19+
20+
# Only retry if there are failed jobs
21+
if gh run view ${{ inputs.run_id }} --exit-status; then
22+
echo Workflow succeeded - no retry necessary.
23+
else
24+
gh run rerun ${{ inputs.run_id }} --failed
25+
fi

benchs/bench_fw/descriptors.py

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class DatasetDescriptor:
8080

8181
embedding_column: Optional[str] = None
8282

83+
sampling_rate: Optional[float] = None
84+
85+
# sampling column for xdb
86+
sampling_column: Optional[str] = None
87+
8388
def __hash__(self):
8489
return hash(self.get_filename())
8590

faiss/IndexIVFAdditiveQuantizer.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ void IndexIVFAdditiveQuantizer::sa_decode(
116116
}
117117
}
118118

119+
void IndexIVFAdditiveQuantizer::reconstruct_from_offset(
120+
int64_t list_no,
121+
int64_t offset,
122+
float* recons) const {
123+
const uint8_t* code = invlists->get_single_code(list_no, offset);
124+
aq->decode(code, recons, 1);
125+
if (by_residual) {
126+
std::vector<float> centroid(d);
127+
quantizer->reconstruct(list_no, centroid.data());
128+
for (int i = 0; i < d; ++i) {
129+
recons[i] += centroid[i];
130+
}
131+
}
132+
}
133+
119134
IndexIVFAdditiveQuantizer::~IndexIVFAdditiveQuantizer() = default;
120135

121136
/*********************************************

faiss/IndexIVFAdditiveQuantizer.h

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ struct IndexIVFAdditiveQuantizer : IndexIVF {
5656

5757
void sa_decode(idx_t n, const uint8_t* codes, float* x) const override;
5858

59+
void reconstruct_from_offset(int64_t list_no, int64_t offset, float* recons)
60+
const override;
61+
5962
~IndexIVFAdditiveQuantizer() override;
6063
};
6164

faiss/gpu/GpuIndex.cu

+4
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,10 @@ struct InitGpuCompileOptions {
537537
#ifdef USE_NVIDIA_RAFT
538538
gpu_compile_options += "NVIDIA_RAFT ";
539539
#endif
540+
541+
#ifdef USE_AMD_ROCM
542+
gpu_compile_options += "AMD_ROCM ";
543+
#endif
540544
}
541545
};
542546

faiss/gpu/test/TestGpuIndexIVFPQ.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,16 @@ void testMMCodeDistance(faiss::MetricType mt) {
307307
}
308308
}
309309

310+
// FIXME: https://github.com/facebookresearch/faiss/issues/3787
311+
#ifndef USE_AMD_ROCM
310312
TEST(TestGpuIndexIVFPQ, Query_L2_MMCodeDistance) {
311313
testMMCodeDistance(faiss::MetricType::METRIC_L2);
312314
}
313315

314316
TEST(TestGpuIndexIVFPQ, Query_IP_MMCodeDistance) {
315317
testMMCodeDistance(faiss::MetricType::METRIC_INNER_PRODUCT);
316318
}
319+
#endif // USE_AMD_ROCM
317320

318321
TEST(TestGpuIndexIVFPQ, Float16Coarse) {
319322
Options opt;

faiss/impl/index_read.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#include <faiss/impl/index_read_utils.h>
89
#include <faiss/index_io.h>
910

1011
#include <faiss/impl/io_macros.h>
@@ -61,7 +62,7 @@ namespace faiss {
6162
* Read
6263
**************************************************************/
6364

64-
static void read_index_header(Index* idx, IOReader* f) {
65+
void read_index_header(Index* idx, IOReader* f) {
6566
READ1(idx->d);
6667
READ1(idx->ntotal);
6768
idx_t dummy;
@@ -230,7 +231,7 @@ InvertedLists* read_InvertedLists(IOReader* f, int io_flags) {
230231
}
231232
}
232233

233-
static void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) {
234+
void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) {
234235
InvertedLists* ils = read_InvertedLists(f, io_flags);
235236
if (ils) {
236237
FAISS_THROW_IF_NOT(ils->nlist == ivf->nlist);
@@ -438,7 +439,7 @@ ProductQuantizer* read_ProductQuantizer(IOReader* reader) {
438439
return pq;
439440
}
440441

441-
static void read_direct_map(DirectMap* dm, IOReader* f) {
442+
void read_direct_map(DirectMap* dm, IOReader* f) {
442443
char maintain_direct_map;
443444
READ1(maintain_direct_map);
444445
dm->type = (DirectMap::Type)maintain_direct_map;
@@ -454,10 +455,10 @@ static void read_direct_map(DirectMap* dm, IOReader* f) {
454455
}
455456
}
456457

457-
static void read_ivf_header(
458+
void read_ivf_header(
458459
IndexIVF* ivf,
459460
IOReader* f,
460-
std::vector<std::vector<idx_t>>* ids = nullptr) {
461+
std::vector<std::vector<idx_t>>* ids) {
461462
read_index_header(ivf, f);
462463
READ1(ivf->nlist);
463464
READ1(ivf->nprobe);

faiss/impl/index_read_utils.h

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// Utils for index_read
9+
10+
#ifndef FAISS_INDEX_READ_UTILS_H
11+
#define FAISS_INDEX_READ_UTILS_H
12+
13+
#include <faiss/IndexIVF.h>
14+
#include <faiss/impl/io.h>
15+
16+
#pragma once
17+
18+
namespace faiss {
19+
20+
void read_index_header(Index* idx, IOReader* f);
21+
void read_direct_map(DirectMap* dm, IOReader* f);
22+
void read_ivf_header(
23+
IndexIVF* ivf,
24+
IOReader* f,
25+
std::vector<std::vector<idx_t>>* ids = nullptr);
26+
void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags);
27+
28+
} // namespace faiss
29+
30+
#endif

faiss/python/class_wrappers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def replacement_train_encoded(self, x, codec, index, weights=None):
9696
Index used to decode the vectors. Should have dimension `self.d`.
9797
index : faiss.Index
9898
Index used for assignment. The dimension of the index should be `self.d`.
99-
weigths : array_like, optional
99+
weights : array_like, optional
100100
Per training sample weight (size n) used when computing the weighted
101101
average to obtain the centroid (default is 1 for all training vectors).
102102
"""

faiss/python/extra_wrappers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def knn(xq, xb, k, metric=METRIC_L2, metric_arg=0.0):
345345
`dtype` must be float32.
346346
k : int
347347
Number of nearest neighbors.
348-
distance_type : MetricType, optional
348+
metric : MetricType, optional
349349
distance measure to use (either METRIC_L2 or METRIC_INNER_PRODUCT)
350350
351351
Returns

faiss/utils/utils.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ std::string get_compile_options() {
115115
options += "OPTIMIZE ";
116116
#endif
117117

118-
#ifdef __AVX2__
119-
options += "AVX2 ";
120-
#elif __AVX512F__
118+
#ifdef __AVX512F__
121119
options += "AVX512 ";
120+
#elif defined(__AVX2__)
121+
options += "AVX2 ";
122122
#elif defined(__ARM_FEATURE_SVE)
123123
options += "SVE NEON ";
124124
#elif defined(__aarch64__)

tests/test_index.py

+17
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,23 @@ def test_IndexIVFPQ(self):
493493

494494
self.run_search_and_reconstruct(index, xb, xq, eps=1.0)
495495

496+
def test_IndexIVFRQ(self):
497+
d = 32
498+
nb = 1000
499+
nt = 1500
500+
nq = 200
501+
502+
(xt, xb, xq) = get_dataset(d, nb, nt, nq)
503+
504+
quantizer = faiss.IndexFlatL2(d)
505+
index = faiss.IndexIVFResidualQuantizer(quantizer, d, 32, 8, 8)
506+
index.cp.min_points_per_centroid = 5 # quiet warning
507+
index.nprobe = 4
508+
index.train(xt)
509+
index.add(xb)
510+
511+
self.run_search_and_reconstruct(index, xb, xq, eps=1.0)
512+
496513
def test_MultiIndex(self):
497514
d = 32
498515
nb = 1000

tests/test_index_accuracy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -633,14 +633,14 @@ def test_OIVFPQ(self):
633633
d = ev.d
634634
quantizer = faiss.IndexFlatL2(d)
635635
index = faiss.IndexIVFPQ(quantizer, d, ncentroids, M, 8)
636-
index.nprobe = 12
636+
index.nprobe = 20
637637

638638
res = ev.launch("IVFPQ", index)
639639
e_ivfpq = ev.evalres(res)
640640

641641
quantizer = faiss.IndexFlatL2(d)
642642
index_ivfpq = faiss.IndexIVFPQ(quantizer, d, ncentroids, M, 8)
643-
index_ivfpq.nprobe = 12
643+
index_ivfpq.nprobe = 20
644644
opq_matrix = faiss.OPQMatrix(d, M)
645645
opq_matrix.niter = 10
646646
index = faiss.IndexPreTransform(opq_matrix, index_ivfpq)

0 commit comments

Comments
 (0)