Skip to content

Commit 3506e9b

Browse files
authored
Merge branch 'main' into rabitq-optim
2 parents db91a6c + 8f03848 commit 3506e9b

14 files changed

Lines changed: 357 additions & 34 deletions

.github/workflows/build-pip.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ jobs:
5757

5858
- name: Publish to PyPI
5959
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
60+
with:
61+
verbose: true
62+
attestations: false
6063

6164
publish-testpypi:
6265
name: Publish to TestPyPI

.github/workflows/index-io-backward-compatibility.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
eval "$(conda shell.bash hook)"
5353
conda create -n faiss_conda_read -y python=3.12
5454
conda activate faiss_conda_read
55-
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.1 "mkl>=2024.2.2,<2026"
55+
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.2 "mkl>=2024.2.2,<2026"
5656
conda list
5757
5858
- name: Run Conda reader (read Faiss index and verify)
@@ -89,7 +89,7 @@ jobs:
8989
eval "$(conda shell.bash hook)"
9090
conda create -n faiss_conda_write -y python=3.12
9191
conda activate faiss_conda_write
92-
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.1 "mkl>=2024.2.2,<2026"
92+
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.2 "mkl>=2024.2.2,<2026"
9393
conda list
9494
9595
- name: Create shared data directory

CHANGELOG.md

Lines changed: 280 additions & 1 deletion
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if(FAISS_ENABLE_CUVS)
5151
endif()
5252

5353
project(faiss
54-
VERSION 1.14.1
54+
VERSION 1.14.2
5555
DESCRIPTION "A library for efficient similarity search and clustering of dense vectors."
5656
HOMEPAGE_URL "https://github.com/facebookresearch/faiss"
5757
LANGUAGES ${FAISS_LANGUAGES})

INSTALL.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ To install the latest stable release:
1212

1313
``` shell
1414
# CPU-only version
15-
$ conda install -c pytorch -c conda-forge faiss-cpu=1.14.1
15+
$ conda install -c pytorch -c conda-forge faiss-cpu=1.14.2
1616

1717
# GPU(+CPU) version
18-
$ conda install -c pytorch -c nvidia -c conda-forge faiss-gpu=1.14.1
18+
$ conda install -c pytorch -c nvidia -c conda-forge faiss-gpu=1.14.2
1919

2020
# GPU(+CPU) version with NVIDIA cuVS
21-
$ conda install -c pytorch -c nvidia -c rapidsai -c conda-forge libnvjitlink faiss-gpu-cuvs=1.14.1
21+
$ conda install -c pytorch -c nvidia -c rapidsai -c conda-forge libnvjitlink faiss-gpu-cuvs=1.14.2
2222

2323
# GPU(+CPU) version using AMD ROCm not yet available
2424
```
@@ -34,15 +34,15 @@ If you prefer [Pixi](https://pixi.sh/latest/), you can use the same channels and
3434
``` shell
3535
# CPU-only version
3636
$ pixi init -c pytorch -c conda-forge
37-
$ pixi add faiss-cpu=1.14.1
37+
$ pixi add faiss-cpu=1.14.2
3838

3939
# GPU(+CPU) version
4040
$ pixi init -c pytorch -c nvidia -c conda-forge
41-
$ pixi add faiss-gpu=1.14.1
41+
$ pixi add faiss-gpu=1.14.2
4242

4343
# GPU(+CPU) version with NVIDIA cuVS
4444
$ pixi init -c pytorch -c nvidia -c rapidsai -c conda-forge
45-
$ pixi add libnvjitlink faiss-gpu-cuvs=1.14.1
45+
$ pixi add libnvjitlink faiss-gpu-cuvs=1.14.2
4646
```
4747

4848
Pixi resolves packages from the listed Conda channels, so the same channel requirements described above still apply.
@@ -54,7 +54,7 @@ Nightly pre-release packages can be installed as follows:
5454
$ conda install -c pytorch/label/nightly -c conda-forge faiss-cpu
5555

5656
# GPU(+CPU) version
57-
$ conda install -c pytorch/label/nightly -c nvidia -c conda-forge faiss-gpu=1.14.1
57+
$ conda install -c pytorch/label/nightly -c nvidia -c conda-forge faiss-gpu=1.14.2
5858

5959
# GPU(+CPU) version with NVIDIA cuVS (package built with CUDA 13.2)
6060
conda install -c pytorch -c rapidsai -c rapidsai-nightly -c conda-forge -c nvidia pytorch/label/nightly::faiss-gpu-cuvs 'cuda-version=13.2'

faiss/Index.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#define FAISS_VERSION_MAJOR 1
1919
#define FAISS_VERSION_MINOR 14
20-
#define FAISS_VERSION_PATCH 1
20+
#define FAISS_VERSION_PATCH 2
2121

2222
// Macro to combine the version components into a single string
2323
#ifndef FAISS_STRINGIFY

faiss/IndexFlat.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ inline void flat_pano_search_core(
627627
{
628628
SingleResultHandler res(handler);
629629

630-
std::vector<float> query_cum_norms(index.n_levels + 1);
630+
std::vector<float> query_cum_norms(index.pano.n_levels + 1);
631631
std::vector<uint32_t> active_indices(index.batch_size);
632632
std::vector<uint8_t> active_byteset(index.batch_size);
633633
std::vector<float> exact_distances(index.batch_size);
@@ -698,7 +698,7 @@ void IndexFlatPanorama::add(idx_t n, const float* x) {
698698
size_t num_batches = (ntotal + batch_size - 1) / batch_size;
699699

700700
codes.resize(num_batches * batch_size * code_size);
701-
cum_sums.resize(num_batches * batch_size * (n_levels + 1));
701+
cum_sums.resize(num_batches * batch_size * (pano.n_levels + 1));
702702

703703
const uint8_t* code = reinterpret_cast<const uint8_t*>(x);
704704
pano.copy_codes_to_level_layout(codes.data(), offset, n, code);
@@ -771,7 +771,7 @@ size_t IndexFlatPanorama::remove_ids(const IDSelector& sel) {
771771
ntotal = j;
772772
size_t num_batches = (ntotal + batch_size - 1) / batch_size;
773773
codes.resize(num_batches * batch_size * code_size);
774-
cum_sums.resize(num_batches * batch_size * (n_levels + 1));
774+
cum_sums.resize(num_batches * batch_size * (pano.n_levels + 1));
775775
}
776776
return nremove;
777777
}
@@ -843,7 +843,7 @@ void IndexFlatPanorama::search_subset(
843843
{
844844
SingleResultHandler res(handler);
845845

846-
std::vector<float> query_cum_norms(n_levels + 1);
846+
std::vector<float> query_cum_norms(pano.n_levels + 1);
847847

848848
// Panorama's optimized point-wise refinement (Algorithm 2):
849849
// Batch-wise Panorama, as implemented in Panorama.h, incurs
@@ -881,7 +881,7 @@ void IndexFlatPanorama::search_subset(
881881
continue;
882882
}
883883

884-
size_t cum_sum_offset = (n_levels + 1) * idx;
884+
size_t cum_sum_offset = (pano.n_levels + 1) * idx;
885885
float cum_sum = cum_sums[cum_sum_offset];
886886
float exact_distance = 0.0f;
887887
if constexpr (!is_sim) {
@@ -897,7 +897,7 @@ void IndexFlatPanorama::search_subset(
897897
local_stats.total_dims += d;
898898

899899
bool pruned = false;
900-
for (size_t level = 0; level < n_levels; level++) {
900+
for (size_t level = 0; level < pano.n_levels; level++) {
901901
local_stats.total_dims_scanned +=
902902
pano.level_width_floats;
903903

faiss/IndexHNSW.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,10 @@ IndexHNSWFlat::IndexHNSWFlat(int d_in, int M, MetricType metric)
707707
**************************************************************/
708708

709709
IndexHNSWFlatPanorama::IndexHNSWFlatPanorama()
710-
: IndexHNSWFlat(), cum_sums(), pano(0, 1, 1), num_panorama_levels(0) {}
710+
: IndexHNSWFlat(),
711+
cum_sums(),
712+
pano(sizeof(float), 1, 1),
713+
num_panorama_levels(0) {}
711714

712715
IndexHNSWFlatPanorama::IndexHNSWFlatPanorama(
713716
int d_in,

faiss/impl/Panorama.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,20 @@ Panorama::Panorama(
6767
void Panorama::set_derived_values() {
6868
FAISS_THROW_IF_NOT_MSG(n_levels > 0, "Panorama: n_levels must be > 0");
6969
this->d = code_size / sizeof(float);
70+
FAISS_THROW_IF_NOT_MSG(n_levels <= d, "Panorama: n_levels must be <= d");
7071
this->level_width_floats = ((d + n_levels - 1) / n_levels);
7172
this->level_width = this->level_width_floats * sizeof(float);
73+
size_t n_real_levels = d / level_width_floats;
74+
if (d > n_real_levels * level_width_floats) {
75+
n_real_levels++;
76+
}
77+
if (this->n_levels != n_real_levels) {
78+
fprintf(stderr,
79+
"WARNING truncating nlevels from %zu to %zu\n",
80+
this->n_levels,
81+
n_real_levels);
82+
this->n_levels = n_real_levels;
83+
}
7284
}
7385

7486
/**
@@ -151,12 +163,12 @@ void Panorama::reconstruct(idx_t key, float* recons, const uint8_t* codes_base)
151163

152164
for (size_t level = 0; level < n_levels; level++) {
153165
size_t level_offset = level * level_width * batch_size;
166+
size_t actual_level_width =
167+
std::min(level_width, code_size - level * level_width);
154168
const uint8_t* src = codes_base + batch_offset + level_offset +
155-
pos_in_batch * level_width;
169+
pos_in_batch * actual_level_width;
156170
uint8_t* dest = recons_buffer + level * level_width;
157-
size_t copy_size =
158-
std::min(level_width, code_size - level * level_width);
159-
memcpy(dest, src, copy_size);
171+
memcpy(dest, src, actual_level_width);
160172
}
161173
}
162174

faiss/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"""
115115
setup(
116116
name="faiss",
117-
version="1.14.1",
117+
version="1.14.2",
118118
description="A library for efficient similarity search and clustering of dense vectors",
119119
long_description=long_description,
120120
long_description_content_type="text/plain",

0 commit comments

Comments
 (0)