Skip to content

Commit eb3b48f

Browse files
authored
Merge branch 'main' into avx512-bf16-opt
2 parents 00b656c + bb298a2 commit eb3b48f

61 files changed

Lines changed: 1931 additions & 1390 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/build_cmake/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ runs:
5252
conda install -y -q "conda<=25.07"
5353
echo "$CONDA/bin" >> $GITHUB_PATH
5454
55-
conda install -y -q python=3.12 cmake=3.30.4 make=4.2 swig=4.0 "numpy>=2.0,<3.0" scipy=1.16 pytest=7.4 gflags=2.2
55+
conda install -y -q python=3.12 cmake=3.30.4 make=4.2 swig=4.0 "numpy>=2.0,<3.0" scipy=1.16 pytest=7.4 gflags=2.2 setuptools
5656
5757
# install base packages for ARM64
5858
if [ "${{ runner.arch }}" = "ARM64" ]; then

.github/actions/build_conda/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ runs:
6969
PACKAGE_TYPE: ${{ inputs.label }}
7070
run: |
7171
conda list --show-channel-urls
72-
conda build faiss --user pytorch --label ${{ inputs.label }} -c pytorch
72+
conda build faiss --python 3.12 --user pytorch --label ${{ inputs.label }} -c pytorch
7373
- name: Conda build (GPU)
7474
if: inputs.label == '' && inputs.cuda != '' && inputs.cuvs == ''
7575
shell: ${{ steps.choose_shell.outputs.shell }}
@@ -86,7 +86,7 @@ runs:
8686
PACKAGE_TYPE: ${{ inputs.label }}
8787
run: |
8888
conda list --show-channel-urls
89-
conda build faiss-gpu --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
89+
conda build faiss-gpu --python 3.12 --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
9090
--user pytorch --label ${{ inputs.label }} -c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia
9191
- name: Conda build (GPU w/ cuVS)
9292
if: inputs.label == '' && inputs.cuda != '' && inputs.cuvs != ''
@@ -104,7 +104,7 @@ runs:
104104
PACKAGE_TYPE: ${{ inputs.label }}
105105
run: |
106106
conda list --show-channel-urls
107-
conda build faiss-gpu-cuvs --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
107+
conda build faiss-gpu-cuvs --python 3.12 --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
108108
--user pytorch --label ${{ inputs.label }} -c pytorch -c rapidsai -c rapidsai-nightly -c conda-forge -c nvidia
109109
- name: Check installed packages channel
110110
shell: ${{ steps.choose_shell.outputs.shell }}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ jobs:
5050
shell: bash
5151
run: |
5252
eval "$(conda shell.bash hook)"
53-
conda create -n faiss_conda_read -y python=3.11
53+
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.13.2
55+
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.1
5656
conda list
5757
5858
- name: Run Conda reader (read Faiss index and verify)
@@ -87,9 +87,9 @@ jobs:
8787
shell: bash
8888
run: |
8989
eval "$(conda shell.bash hook)"
90-
conda create -n faiss_conda_write -y python=3.11
90+
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.13.2
92+
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.1
9393
conda list
9494
9595
- name: Create shared data directory

conda/faiss-gpu-cuvs/meta.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ outputs:
4747
- cmake >=3.30.4
4848
- make =4.2 # [not win]
4949
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
50-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
51-
- mkl-devel >=2024.2.2,<2025.0a0 # [x86_64]
50+
- mkl >=2024.2.2 # [x86_64]
51+
- mkl-devel >=2024.2.2 # [x86_64]
5252
- cuda-toolkit {{ cudatoolkit }}
5353
- cuda-cudart {{ cudart_constraints }}
5454
- cuda-cudart-dev {{ cudart_constraints }}
@@ -58,14 +58,14 @@ outputs:
5858
- cuda-cudart-static_linux-64 {{ cudart_constraints }} # [linux64]
5959
host:
6060
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
61-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
61+
- mkl >=2024.2.2 # [x86_64]
6262
- openblas =0.3.30 # [not x86_64]
6363
- libcuvs =25.10
6464
- cuda-version {{ cuda_constraints }}
6565
- libsvs-runtime =0.2.0 # [x86_64 and linux]
6666
run:
6767
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
68-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
68+
- mkl >=2024.2.2 # [x86_64]
6969
- openblas =0.3.30 # [not x86_64]
7070
- cuda-cudart {{ cuda_constraints }}
7171
- libcublas {{ libcublas_constraints }}
@@ -97,16 +97,17 @@ outputs:
9797
- cmake >=3.26.4
9898
- make =4.2 # [not win]
9999
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
100-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
100+
- mkl >=2024.2.2 # [x86_64]
101101
- cuda-toolkit {{ cudatoolkit }}
102102
host:
103-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
103+
- mkl >=2024.2.2 # [x86_64]
104104
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
105105
- python {{ python }}
106106
- numpy >=2.0,<2.3
107+
- setuptools
107108
- {{ pin_subpackage('libfaiss', exact=True) }}
108109
run:
109-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
110+
- mkl >=2024.2.2 # [x86_64]
110111
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
111112
- python {{ python }}
112113
- numpy >=2.0,<2.3

conda/faiss-gpu/meta.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ outputs:
4848
- cmake >=3.24.0
4949
- make =4.2 # [not win and not (osx and arm64)]
5050
- make =4.4 # [osx and arm64]
51-
- mkl-devel >=2024.2.2,<2025.0a0 # [x86_64]
51+
- mkl-devel >=2024.2.2 # [x86_64]
5252
- cuda-toolkit {{ cudatoolkit }}
5353
host:
54-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
54+
- mkl >=2024.2.2 # [x86_64]
5555
- openblas =0.3.30 # [not x86_64]
5656
- libsvs-runtime =0.2.0 # [x86_64 and linux]
5757
run:
58-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
58+
- mkl >=2024.2.2 # [x86_64]
5959
- openblas =0.3.30 # [not x86_64]
6060
- cuda-cudart {{ cuda_constraints }}
6161
- libcublas {{ libcublas_constraints }}
@@ -86,15 +86,16 @@ outputs:
8686
- make =4.4 # [osx and arm64]
8787
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
8888
- cuda-toolkit {{ cudatoolkit }}
89-
- mkl-devel >=2024.2.2,<2025.0a0 # [x86_64]
89+
- mkl-devel >=2024.2.2 # [x86_64]
9090
host:
91-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
91+
- mkl >=2024.2.2 # [x86_64]
9292
- python {{ python }}
9393
- numpy >=2.0,<3.0
94+
- setuptools
9495
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
9596
- {{ pin_subpackage('libfaiss', exact=True) }}
9697
run:
97-
- mkl >=2024.2.2,<2025.0a0 # [x86_64]
98+
- mkl >=2024.2.2 # [x86_64]
9899
- python {{ python }}
99100
- numpy >=2.0,<3.0
100101
- packaging

conda/faiss/meta.yaml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,28 @@ outputs:
4545
- make =4.2 # [not win and not (osx and arm64)]
4646
- make =4.4 # [osx and arm64]
4747
{% if PY_VER == '3.10' or PY_VER == '3.11' %}
48-
- mkl-devel =2024.2.2 # [x86_64]
48+
- mkl-devel >=2024.2.2 # [x86_64]
4949
- python_abi <3.12
5050
{% elif PY_VER == '3.12' %}
51-
- mkl-devel =2024.2.2 # [x86_64 and not win]
52-
- mkl-devel =2024.2.2 # [x86_64 and win]
51+
- mkl-devel >=2024.2.2 # [x86_64 and not win]
52+
- mkl-devel >=2024.2.2 # [x86_64 and win]
5353
- python_abi =3.12
54+
{% else %}
55+
- mkl-devel >=2024.2.2 # [x86_64 and not win]
56+
- mkl-devel >=2024.2.2 # [x86_64 and win]
57+
- python_abi
5458
{% endif %}
5559
- libopenblas=0.3.30=openmp_h60d53f8_1 # [osx]
5660
host:
5761
- python {{ python }}
5862
- libcxx =20.1.1 # [osx and arm64]
5963
- libsvs-runtime =0.2.0 # [x86_64 and linux]
6064
{% if PY_VER == '3.10' or PY_VER == '3.11' %}
61-
- mkl =2024.2.2 # [x86_64]
65+
- mkl >=2024.2.2 # [x86_64]
6266
- python_abi <3.12
6367
{% elif PY_VER == '3.12' %}
64-
- mkl =2024.2.2 # [x86_64 and not win]
65-
- mkl =2024.2.2 # [x86_64 and win]
68+
- mkl >=2024.2.2 # [x86_64 and not win]
69+
- mkl >=2024.2.2 # [x86_64 and win]
6670
- python_abi =3.12
6771
{% endif %}
6872
- openblas =0.3.30 # [not x86_64]
@@ -72,11 +76,11 @@ outputs:
7276
- libcxx =20.1.1 # [osx and arm64]
7377
- libsvs-runtime =0.2.0 # [x86_64 and linux]
7478
{% if PY_VER == '3.10' or PY_VER == '3.11' %}
75-
- mkl =2024.2.2 # [x86_64]
79+
- mkl >=2024.2.2 # [x86_64]
7680
- python_abi <3.12
7781
{% elif PY_VER == '3.12' %}
78-
- mkl =2024.2.2 # [x86_64 and not win]
79-
- mkl =2024.2.2 # [x86_64 and win]
82+
- mkl >=2024.2.2 # [x86_64 and not win]
83+
- mkl >=2024.2.2 # [x86_64 and win]
8084
- python_abi =3.12
8185
{% endif %}
8286
- openblas =0.3.30 # [not x86_64]
@@ -109,26 +113,27 @@ outputs:
109113
- make =4.4 # [osx and arm64]
110114
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
111115
{% if PY_VER == '3.10' or PY_VER == '3.11' %}
112-
- mkl =2024.2.2 # [x86_64]
116+
- mkl >=2024.2.2 # [x86_64]
113117
- python_abi <3.12
114118
{% elif PY_VER == '3.12' %}
115-
- mkl =2024.2.2 # [x86_64 and not win]
116-
- mkl =2024.2.2 # [x86_64 and win]
119+
- mkl >=2024.2.2 # [x86_64 and not win]
120+
- mkl >=2024.2.2 # [x86_64 and win]
117121
- python_abi =3.12
118122
{% endif %}
119123
- libopenblas=0.3.30=openmp_h60d53f8_1 # [osx]
120124
host:
121125
- python {{ python }}
122126
- numpy >=2.0,<3.0
127+
- setuptools
123128
- {{ pin_subpackage('libfaiss', exact=True) }}
124129
- libcxx =20.1.1 # [osx and arm64]
125130
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
126131
{% if PY_VER == '3.10' or PY_VER == '3.11' %}
127-
- mkl =2024.2.2 # [x86_64]
132+
- mkl >=2024.2.2 # [x86_64]
128133
- python_abi <3.12
129134
{% elif PY_VER == '3.12' %}
130-
- mkl =2024.2.2 # [x86_64 and not win]
131-
- mkl =2024.2.2 # [x86_64 and win]
135+
- mkl >=2024.2.2 # [x86_64 and not win]
136+
- mkl >=2024.2.2 # [x86_64 and win]
132137
- python_abi =3.12
133138
{% endif %}
134139
- libopenblas=0.3.30=openmp_h60d53f8_1 # [osx]
@@ -139,11 +144,11 @@ outputs:
139144
- {{ pin_subpackage('libfaiss', exact=True) }}
140145
- libcxx =20.1.1 # [osx and arm64]
141146
{% if PY_VER == '3.10' or PY_VER == '3.11' %}
142-
- mkl =2024.2.2 # [x86_64]
147+
- mkl >=2024.2.2 # [x86_64]
143148
- python_abi <3.12
144149
{% elif PY_VER == '3.12' %}
145-
- mkl =2024.2.2 # [x86_64 and not win]
146-
- mkl =2024.2.2 # [x86_64 and win]
150+
- mkl >=2024.2.2 # [x86_64 and not win]
151+
- mkl >=2024.2.2 # [x86_64 and win]
147152
- python_abi =3.12
148153
{% endif %}
149154
- libopenblas=0.3.30=openmp_h60d53f8_1 # [osx]
@@ -153,11 +158,11 @@ outputs:
153158
- scipy
154159
- pytorch-cpu >=2.7
155160
{% if PY_VER == '3.10' or PY_VER == '3.11' %}
156-
- mkl =2024.2.2 # [x86_64]
161+
- mkl >=2024.2.2 # [x86_64]
157162
- python_abi <3.12
158163
{% elif PY_VER == '3.12' %}
159-
- mkl =2024.2.2 # [x86_64 and not win]
160-
- mkl =2024.2.2 # [x86_64 and win]
164+
- mkl >=2024.2.2 # [x86_64 and not win]
165+
- mkl >=2024.2.2 # [x86_64 and win]
161166
- python_abi =3.12
162167
{% endif %}
163168
commands:

faiss/CMakeLists.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,13 @@ set(FAISS_HEADERS
300300
utils/rabitq_simd.h
301301
utils/random.h
302302
utils/sorting.h
303-
utils/simdlib.h
304-
utils/simdlib_avx2.h
305-
utils/simdlib_avx512.h
306-
utils/simdlib_emulated.h
307-
utils/simdlib_neon.h
308-
utils/simdlib_ppc64.h
303+
impl/simdlib/simdlib.h
304+
impl/simdlib/simdlib_dispatch.h
305+
impl/simdlib/simdlib_avx2.h
306+
impl/simdlib/simdlib_avx512.h
307+
impl/simdlib/simdlib_emulated.h
308+
impl/simdlib/simdlib_neon.h
309+
impl/simdlib/simdlib_ppc64.h
309310
utils/utils.h
310311
utils/simd_levels.h
311312
utils/distances_fused/avx512.h
@@ -325,6 +326,7 @@ set(FAISS_HEADERS
325326
utils/hamming_distance/avx2-inl.h
326327
utils/hamming_distance/avx512-inl.h
327328
utils/simd_impl/distances_autovec-inl.h
329+
utils/simd_impl/distances_simdlib256.h
328330
utils/simd_impl/distances_sse-inl.h
329331
)
330332

@@ -470,6 +472,14 @@ if(FAISS_OPT_LEVEL STREQUAL "dd")
470472
endif()
471473
endif()
472474

475+
# NEON is mandatory on ARM64 — ensure COMPILE_SIMD_ARM_NEON is always defined
476+
# and NEON source files are always compiled into the main faiss target.
477+
# (On x86, AVX2/AVX512 are optional and only compiled per opt_level above.)
478+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64|arm64|ARM64)")
479+
target_compile_definitions(faiss PRIVATE COMPILE_SIMD_ARM_NEON)
480+
target_sources(faiss PRIVATE ${FAISS_SIMD_NEON_SRC})
481+
endif()
482+
473483
if(FAISS_ENABLE_SVS)
474484
find_package(svs_runtime 0.2.0 REQUIRED)
475485

faiss/IndexBinaryHNSW.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,14 @@ IndexBinaryHNSW::IndexBinaryHNSW() {
172172
is_trained = true;
173173
}
174174

175-
IndexBinaryHNSW::IndexBinaryHNSW(int d, int M)
176-
: IndexBinary(d),
177-
hnsw(M),
178-
own_fields(true),
179-
storage(new IndexBinaryFlat(d)) {
175+
IndexBinaryHNSW::IndexBinaryHNSW(int d, int M) : IndexBinary(d), hnsw(M) {
176+
storage = std::make_unique<IndexBinaryFlat>(d).release();
177+
own_fields = true;
180178
is_trained = true;
181179
}
182180

183181
IndexBinaryHNSW::IndexBinaryHNSW(IndexBinary* storage, int M)
184-
: IndexBinary(storage->d),
185-
hnsw(M),
186-
own_fields(false),
187-
storage(storage) {
182+
: IndexBinary(storage->d), hnsw(M), storage(storage) {
188183
is_trained = true;
189184
}
190185

faiss/IndexBinaryHNSW.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ struct IndexBinaryHNSW : IndexBinary {
2525
HNSW hnsw;
2626

2727
// the sequential storage
28-
bool own_fields;
29-
IndexBinary* storage;
28+
bool own_fields = false;
29+
IndexBinary* storage = nullptr;
3030

3131
// When set to false, level 0 in the knn graph is not initialized.
3232
// This option is used by GpuIndexBinaryCagra::copyTo(IndexBinaryHNSW*)

faiss/IndexBinaryHash.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <cinttypes>
1313
#include <cstdio>
14+
#include <memory>
1415
#include <unordered_set>
1516

1617
#include <faiss/utils/hamming.h>
@@ -286,18 +287,14 @@ IndexBinaryHashStats indexBinaryHash_stats;
286287
******************************************************/
287288

288289
IndexBinaryMultiHash::IndexBinaryMultiHash(int d, int nhash, int b)
289-
: IndexBinary(d),
290-
storage(new IndexBinaryFlat(d)),
291-
own_fields(true),
292-
maps(nhash),
293-
nhash(nhash),
294-
b(b),
295-
nflip(0) {
290+
: IndexBinary(d), maps(nhash), nhash(nhash), b(b), nflip(0) {
296291
FAISS_THROW_IF_NOT(nhash * b <= d);
292+
storage = std::make_unique<IndexBinaryFlat>(d).release();
293+
own_fields = true;
297294
}
298295

299296
IndexBinaryMultiHash::IndexBinaryMultiHash()
300-
: storage(nullptr), own_fields(true), nhash(0), b(0), nflip(0) {}
297+
: storage(nullptr), nhash(0), b(0), nflip(0) {}
301298

302299
IndexBinaryMultiHash::~IndexBinaryMultiHash() {
303300
if (own_fields) {

0 commit comments

Comments
 (0)