Skip to content

Commit 09cf1fb

Browse files
authored
Merge branch 'main' into sq-avx512-spr-opt
2 parents 0530a43 + cb69d7c commit 09cf1fb

147 files changed

Lines changed: 10798 additions & 1789 deletions

File tree

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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ runs:
4040
uses: conda-incubator/setup-miniconda@v3
4141
with:
4242
python-version: '3.12'
43-
miniforge-version: latest # ensures conda-forge channel is used.
43+
miniforge-version: latest
4444
channels: conda-forge
4545
conda-remove-defaults: 'true'
4646
# Set to aarch64 if we're on arm64 because there's no miniforge ARM64 package, just aarch64.
@@ -50,18 +50,15 @@ runs:
5050
if: inputs.metal != 'ON'
5151
shell: bash
5252
run: |
53-
# initialize Conda
54-
conda config --set solver libmamba
5553
# Ensure starting packages are from conda-forge.
5654
conda list --show-channel-urls
57-
conda install -y -q "conda<=25.07"
5855
echo "$CONDA/bin" >> $GITHUB_PATH
5956
6057
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
6158
6259
# install base packages for ARM64
6360
if [ "${{ runner.arch }}" = "ARM64" ]; then
64-
conda install -y -q -c conda-forge openblas=0.3.29 gxx_linux-aarch64=14.2 sysroot_linux-aarch64=2.17
61+
conda install -y -q -c conda-forge openblas=0.3.33 gxx_linux-aarch64=14.2 sysroot_linux-aarch64=2.17
6562
fi
6663
6764
# install base packages for X86_64
@@ -79,7 +76,11 @@ runs:
7976
conda install -y -q cuda-libraries-dev=12.6 cuda-nvcc=12.6 cuda-nvtx=12.6 cuda-cupti=12.6 cuda-cudart-dev=12.6 gxx_linux-64=12.4 -c "nvidia/label/cuda-12.6"
8077
# and CUDA from cuVS channel for cuVS builds
8178
elif [ "${{ inputs.cuvs }}" = "ON" ]; then
82-
conda install -y -q libcuvs=26.02 'cuda-version=12.9' cuda-toolkit=12.9 sysroot_linux-64=2.34 -c rapidsai -c rapidsai-nightly -c conda-forge
79+
conda install -y -q libcuvs=26.02 'cuda-version=12.9' sysroot_linux-64=2.34 -c rapidsai -c rapidsai-nightly -c conda-forge
80+
# Clean index cache to prevent sqlite3 "database is locked" errors
81+
# from conda-libmamba-solver's shards cache between consecutive installs.
82+
# See: https://github.com/conda/conda-libmamba-solver/issues/667
83+
conda clean --index-cache 2>/dev/null || true
8384
fi
8485
8586
# install SVS runtime for SVS builds
@@ -241,6 +242,7 @@ runs:
241242
shell: bash
242243
run: |
243244
conda list --show-channel-urls
245+
conda install -y -q "pip<26"
244246
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.1
245247
- name: Python tests (CPU only)
246248
if: inputs.gpu == 'OFF' && inputs.metal != 'ON'

.github/actions/build_conda/action.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ runs:
3030
uses: conda-incubator/setup-miniconda@v3
3131
with:
3232
python-version: '3.12'
33-
miniforge-version: latest # ensures conda-forge channel is used.
33+
miniforge-version: latest
3434
channels: conda-forge
3535
conda-remove-defaults: 'true'
36+
activate-environment: 'base'
3637
# Set to runner.arch=aarch64 if we're on arm64 because
3738
# there's no miniforge ARM64 package, just aarch64.
3839
# They are the same thing, just named differently.
@@ -43,7 +44,7 @@ runs:
4344
run: |
4445
# Ensure starting packages are from conda-forge.
4546
conda list --show-channel-urls
46-
conda install -y -q "conda!=24.11.0,<=25.07"
47+
conda install -y -q "conda!=24.11.0,<25.7"
4748
conda install -y -q "conda-build=25.3.1" "liblief=0.14.1"
4849
- name: Enable anaconda uploads
4950
if: inputs.label != ''
@@ -80,7 +81,7 @@ runs:
8081
working-directory: conda
8182
run: |
8283
conda list --show-channel-urls
83-
conda build faiss-gpu --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
84+
conda build faiss-gpu --python 3.12 --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
8485
-c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia
8586
- name: Conda build (GPU) w/ anaconda upload
8687
if: inputs.label != '' && inputs.cuda != '' && inputs.cuvs == ''
@@ -98,7 +99,7 @@ runs:
9899
working-directory: conda
99100
run: |
100101
conda list --show-channel-urls
101-
conda build faiss-gpu-cuvs --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
102+
conda build faiss-gpu-cuvs --python 3.12 --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
102103
-c pytorch -c rapidsai -c rapidsai-nightly -c conda-forge -c nvidia
103104
- name: Conda build (GPU w/ cuVS) w/ anaconda upload
104105
if: inputs.label != '' && inputs.cuda != '' && inputs.cuvs != ''

.github/workflows/build-pip.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
name: Build pip wheels
7+
8+
on:
9+
workflow_call:
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-wheels:
14+
name: Build wheels on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
timeout-minutes: 120
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macos-14, macos-15-intel, windows-2022, 2-core-ubuntu-arm]
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
fetch-depth: 0
26+
fetch-tags: true
27+
28+
- name: Build wheels
29+
uses: pypa/cibuildwheel@ee02a1537ce3071a004a6b08c41e72f0fdc42d9a # v3.4.0
30+
env:
31+
CIBW_BUILD_VERBOSITY: 1
32+
33+
- name: Upload wheels
34+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
35+
with:
36+
name: wheels-${{ matrix.os }}
37+
path: wheelhouse/*.whl
38+
39+
publish:
40+
name: Publish to PyPI
41+
needs: [build-wheels]
42+
runs-on: ubuntu-latest
43+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
44+
environment:
45+
name: pypi
46+
url: https://pypi.org/p/faiss-cpu
47+
permissions:
48+
id-token: write
49+
contents: read
50+
steps:
51+
- name: Download wheel artifacts
52+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
53+
with:
54+
path: dist
55+
pattern: wheels-*
56+
merge-multiple: true
57+
58+
- name: Publish to PyPI
59+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
60+
61+
publish-testpypi:
62+
name: Publish to TestPyPI
63+
needs: [build-wheels]
64+
runs-on: ubuntu-latest
65+
if: github.event_name == 'workflow_dispatch'
66+
environment:
67+
name: testpypi
68+
url: https://test.pypi.org/p/faiss-cpu
69+
permissions:
70+
id-token: write
71+
contents: read
72+
steps:
73+
- name: Download wheel artifacts
74+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
75+
with:
76+
path: dist
77+
pattern: wheels-*
78+
merge-multiple: true
79+
80+
- name: Publish to TestPyPI
81+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
82+
with:
83+
repository-url: https://test.pypi.org/legacy/
84+
skip-existing: true
85+
verbose: true

.github/workflows/build-pull-request.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,21 @@ jobs:
276276
fetch-tags: true
277277
- name: Build and Package (conda)
278278
uses: ./.github/actions/build_conda
279+
linux-x86_64-GPU-conda:
280+
name: Linux x86_64 GPU (conda, CUDA 12.6)
281+
runs-on: 4-core-ubuntu-gpu-t4
282+
env:
283+
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
284+
steps:
285+
- name: Checkout
286+
uses: actions/checkout@v4
287+
with:
288+
fetch-depth: 0
289+
fetch-tags: true
290+
- name: Build and Package (conda)
291+
uses: ./.github/actions/build_conda
292+
with:
293+
cuda: "12.6"
279294
linux-x86_64-svs:
280295
name: Linux x86_64 w/ SVS (cmake)
281296
needs: linux-x86_64-cmake
@@ -287,6 +302,109 @@ jobs:
287302
uses: ./.github/actions/build_cmake
288303
with:
289304
svs: ON
305+
linux-riscv64-DD-cmake:
306+
name: Linux riscv64 Dynamic Dispatch cross-compile (cmake)
307+
needs: linux-x86_64-cmake
308+
runs-on: ubuntu-latest
309+
steps:
310+
- name: Checkout
311+
uses: actions/checkout@v4
312+
313+
- name: Set up riscv64 cross-compilation environment
314+
run: |
315+
sudo dpkg --add-architecture riscv64
316+
317+
# Restrict existing apt sources to amd64/i386 so that apt does not
318+
# try (and fail) to fetch riscv64 packages from the main Ubuntu
319+
# mirror, which does not carry riscv64.
320+
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
321+
# Ubuntu 24.04+ deb822 format: insert Architectures field.
322+
sudo sed -i '/^Types: deb$/a Architectures: amd64 i386' \
323+
/etc/apt/sources.list.d/ubuntu.sources
324+
fi
325+
if grep -q '^deb http' /etc/apt/sources.list 2>/dev/null; then
326+
# Ubuntu 22.04 traditional .list format.
327+
sudo sed -i 's|^deb http|deb [arch=amd64,i386] http|g' \
328+
/etc/apt/sources.list
329+
fi
330+
331+
# Add Ubuntu Ports as the riscv64 package source.
332+
CODENAME=$(. /etc/os-release && echo "$VERSION_CODENAME")
333+
echo "deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME} main restricted universe" \
334+
| sudo tee /etc/apt/sources.list.d/riscv64-ports.list
335+
echo "deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-updates main restricted universe" \
336+
| sudo tee -a /etc/apt/sources.list.d/riscv64-ports.list
337+
338+
sudo apt-get update -qq
339+
sudo apt-get install -y -qq \
340+
cmake \
341+
gcc-riscv64-linux-gnu \
342+
g++-riscv64-linux-gnu \
343+
libopenblas-dev:riscv64 \
344+
libgomp1:riscv64 \
345+
qemu-user-static
346+
347+
# Bridge Ubuntu's multiarch library directory into the sysroot so
348+
# that CMake's find_library() (ONLY mode, root=/usr/riscv64-linux-gnu)
349+
# can reach packages installed as :riscv64.
350+
# CMake searches ${root}/usr/lib/<multiarch-tuple>/ thanks to the
351+
# compiler's -print-multiarch output (riscv64-linux-gnu).
352+
sudo mkdir -p /usr/riscv64-linux-gnu/usr/lib
353+
sudo ln -sfn /usr/lib/riscv64-linux-gnu \
354+
/usr/riscv64-linux-gnu/usr/lib/riscv64-linux-gnu
355+
356+
- name: Setup ccache
357+
uses: hendrikmuhs/ccache-action@v1
358+
with:
359+
key: linux-riscv64-dd
360+
max-size: 2G
361+
update-package-index: true
362+
363+
- name: Configure (cmake)
364+
run: |
365+
cmake -B build \
366+
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/riscv64-linux-gnu.cmake \
367+
-DBUILD_TESTING=ON \
368+
-DBUILD_SHARED_LIBS=ON \
369+
-DFAISS_ENABLE_GPU=OFF \
370+
-DFAISS_OPT_LEVEL=dd \
371+
-DFAISS_ENABLE_PYTHON=OFF \
372+
-DFAISS_ENABLE_C_API=OFF \
373+
-DBLA_VENDOR=OpenBLAS \
374+
-DCMAKE_BUILD_TYPE=Release \
375+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
376+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
377+
-DCMAKE_BUILD_RPATH=/usr/lib/riscv64-linux-gnu \
378+
.
379+
380+
- name: Build faiss_test (includes test_factory_tools)
381+
run: cmake --build build --target faiss_test -j$(nproc)
382+
383+
- name: Verify binary with ldd (via qemu)
384+
run: |
385+
file build/tests/faiss_test
386+
file build/tests/faiss_test | grep -q "RISC-V" || \
387+
{ echo "ERROR: not a RISC-V binary"; exit 1; }
388+
389+
# Expose riscv64 libs inside the qemu sysroot so the riscv64 ld.so
390+
# launched by qemu can resolve NEEDED entries.
391+
sudo mkdir -p /usr/riscv64-linux-gnu/usr/lib
392+
sudo ln -sfn /usr/lib/riscv64-linux-gnu \
393+
/usr/riscv64-linux-gnu/usr/lib/riscv64-linux-gnu
394+
395+
# Invoke the riscv64 dynamic linker under qemu with --list, which
396+
# is exactly what ldd does on native hardware.
397+
RISCV64_LD=$(find /usr/riscv64-linux-gnu/lib \
398+
-name "ld-linux-riscv64-*.so.1" | head -1)
399+
qemu-riscv64-static -L /usr/riscv64-linux-gnu \
400+
"$RISCV64_LD" --list build/tests/faiss_test
401+
402+
- name: Run test_simd_levels (via QEMU)
403+
run: |
404+
qemu-riscv64-static -L /usr/riscv64-linux-gnu \
405+
build/tests/faiss_test \
406+
--gtest_filter="SIMDConfig.*:SIMDLevel.*:CompileOptions.*"
407+
290408
index-io-backward-compatibility:
291409
needs: linux-x86_64-cmake
292410
name: Index serialization backward compatibility

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ jobs:
1515
secrets:
1616
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
1717
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
18+
build-pip:
19+
uses: ./.github/workflows/build-pip.yml

.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
55+
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.1 "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
92+
conda install -y -c pytorch -c conda-forge faiss-cpu=1.14.1 "mkl>=2024.2.2,<2026"
9393
conda list
9494
9595
- name: Create shared data directory

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ endif()
127127
include(CTest)
128128
if(BUILD_TESTING)
129129
add_subdirectory(tests)
130-
if(NOT WIN32)
130+
if(NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
131131
add_subdirectory(perf_tests)
132132
endif()
133133
if(FAISS_ENABLE_GPU)

0 commit comments

Comments
 (0)