Skip to content

Commit f32aee9

Browse files
authored
Merge branch 'main' into static-dispatch-fix
2 parents 7531d62 + 8f03848 commit f32aee9

390 files changed

Lines changed: 27871 additions & 8375 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: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ inputs:
2020
description: 'Enable SVS support.'
2121
required: false
2222
default: OFF
23+
metal:
24+
description: 'Enable Metal GPU backend (macOS Apple Silicon).'
25+
required: false
26+
default: OFF
2327
setup_conda:
2428
description: 'Setup miniconda environment.'
2529
required: false
@@ -32,31 +36,29 @@ runs:
3236
using: composite
3337
steps:
3438
- name: Setup miniconda
35-
if: inputs.setup_conda == 'true'
39+
if: inputs.setup_conda == 'true' && inputs.metal != 'ON'
3640
uses: conda-incubator/setup-miniconda@v3
3741
with:
3842
python-version: '3.12'
39-
miniforge-version: latest # ensures conda-forge channel is used.
43+
miniforge-version: latest
4044
channels: conda-forge
4145
conda-remove-defaults: 'true'
4246
# Set to aarch64 if we're on arm64 because there's no miniforge ARM64 package, just aarch64.
4347
# They are the same thing, just named differently.
4448
architecture: ${{ runner.arch == 'ARM64' && 'aarch64' || runner.arch }}
4549
- name: Configure build environment
50+
if: inputs.metal != 'ON'
4651
shell: bash
4752
run: |
48-
# initialize Conda
49-
conda config --set solver libmamba
5053
# Ensure starting packages are from conda-forge.
5154
conda list --show-channel-urls
52-
conda install -y -q "conda<=25.07"
5355
echo "$CONDA/bin" >> $GITHUB_PATH
5456
5557
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
5658
5759
# install base packages for ARM64
5860
if [ "${{ runner.arch }}" = "ARM64" ]; then
59-
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
6062
fi
6163
6264
# install base packages for X86_64
@@ -71,10 +73,14 @@ runs:
7173
:
7274
# regular CUDA for GPU builds
7375
elif [ "${{ inputs.gpu }}" = "ON" ] && [ "${{ inputs.cuvs }}" = "OFF" ]; then
74-
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"
76+
conda install -y -q cuda-libraries-dev=13.2 cuda-nvcc=13.2 cuda-nvtx=13.2 cuda-cupti=13.2 cuda-cudart-dev=13.2 gxx_linux-64=14.2 -c "nvidia/label/cuda-13.2"
7577
# and CUDA from cuVS channel for cuVS builds
7678
elif [ "${{ inputs.cuvs }}" = "ON" ]; then
77-
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=13.2' 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
7884
fi
7985
8086
# install SVS runtime for SVS builds
@@ -87,7 +93,10 @@ runs:
8793
: # skip torch install via conda, we need to install via pip to get
8894
# ROCm-enabled version until it's supported in conda by PyTorch
8995
elif [ "${{ inputs.gpu }}" = "ON" ]; then
90-
conda install -y -q "pytorch>=2.7" "pytorch-gpu>=2.7" -c pytorch -c "nvidia/label/12.9"
96+
# PyTorch deprecated its official Anaconda channel (pytorch/pytorch#138506),
97+
# so we install via pip for CUDA builds. --break-system-packages is needed
98+
# because the CI runner's Python is PEP 668 externally-managed.
99+
pip install "torch>=2.7" --break-system-packages --index-url https://download.pytorch.org/whl/cu132
91100
else
92101
# TestLowLevelIVF.IVFRQ hangs on pytorch>=2.7, so left it as <2.5 for now.
93102
conda install -y -q "pytorch<2.5" -c pytorch
@@ -159,7 +168,18 @@ runs:
159168
if: inputs.gpu == 'ON' && inputs.rocm == 'ON'
160169
shell: bash
161170
run: rocm-smi
171+
- name: Setup ccache
172+
uses: hendrikmuhs/ccache-action@v1
173+
with:
174+
key: ${{ runner.os }}-${{ runner.arch }}-${{ inputs.opt_level }}-gpu${{ inputs.gpu }}-cuvs${{ inputs.cuvs }}-rocm${{ inputs.rocm }}-svs${{ inputs.svs }}
175+
max-size: 2G
176+
update-package-index: true
177+
- name: Setup macOS Metal environment
178+
if: inputs.metal == 'ON'
179+
shell: bash
180+
run: brew install cmake libomp gflags
162181
- name: Build all targets
182+
if: inputs.metal != 'ON'
163183
shell: bash
164184
run: |
165185
eval "$(conda shell.bash hook)"
@@ -176,23 +196,45 @@ runs:
176196
-DFAISS_ENABLE_C_API=ON \
177197
-DPYTHON_EXECUTABLE=$CONDA/bin/python \
178198
-DCMAKE_BUILD_TYPE=Release \
199+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
200+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
201+
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
179202
-DBLA_VENDOR=${{ runner.arch == 'X64' && 'Intel10_64_dyn' || '' }} \
180203
-DCMAKE_CUDA_FLAGS=${{ runner.arch == 'X64' && '"-gencode arch=compute_75,code=sm_75"' || '' }} \
181204
.
182205
make -k -C build -j$(nproc)
206+
- name: Build Metal targets
207+
if: inputs.metal == 'ON'
208+
shell: bash
209+
run: |
210+
cmake -B build \
211+
-DFAISS_ENABLE_METAL=ON \
212+
-DFAISS_ENABLE_GPU=OFF \
213+
-DFAISS_ENABLE_PYTHON=OFF \
214+
-DBUILD_TESTING=ON \
215+
-DCMAKE_BUILD_TYPE=Release \
216+
-DCMAKE_PREFIX_PATH="$(brew --prefix libomp)" \
217+
.
218+
cmake --build build --target faiss_metal TestMetalIndexFlat -j$(sysctl -n hw.logicalcpu)
183219
- name: C++ tests
220+
if: inputs.metal != 'ON'
184221
shell: bash
185222
run: |
186223
conda list --show-channel-urls
187224
export GTEST_OUTPUT="xml:$(realpath .)/test-results/googletest/"
188225
make -C build test
226+
- name: C++ tests (Metal)
227+
if: inputs.metal == 'ON'
228+
shell: bash
229+
run: cd build && ctest -R TestMetalIndexFlat --output-on-failure
189230
- name: C++ perf benchmarks
231+
if: inputs.rocm == 'OFF' && inputs.metal != 'ON'
190232
shell: bash
191-
if: inputs.rocm == 'OFF'
192233
run: |
193234
conda list --show-channel-urls
194235
find ./build/perf_tests/ -executable -type f -name "bench*" -exec '{}' -v \;
195236
- name: Install Python extension
237+
if: inputs.metal != 'ON'
196238
shell: bash
197239
working-directory: build/faiss/python
198240
run: |
@@ -203,9 +245,10 @@ runs:
203245
shell: bash
204246
run: |
205247
conda list --show-channel-urls
248+
conda install -y -q "pip<26"
206249
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.1
207250
- name: Python tests (CPU only)
208-
if: inputs.gpu == 'OFF'
251+
if: inputs.gpu == 'OFF' && inputs.metal != 'ON'
209252
shell: bash
210253
run: |
211254
conda list --show-channel-urls
@@ -235,6 +278,7 @@ runs:
235278
name: test-results-arch=${{ runner.arch }}-opt=${{ inputs.opt_level }}-gpu=${{ inputs.gpu }}-cuvs=${{ inputs.cuvs }}-rocm=${{ inputs.rocm }}-svs=${{ inputs.svs }}
236279
path: test-results
237280
- name: Check installed packages channel
281+
if: inputs.metal != 'ON'
238282
shell: bash
239283
run: |
240284
# Shows that all installed packages are from conda-forge.

.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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
with:
61+
verbose: true
62+
attestations: false
63+
64+
publish-testpypi:
65+
name: Publish to TestPyPI
66+
needs: [build-wheels]
67+
runs-on: ubuntu-latest
68+
if: github.event_name == 'workflow_dispatch'
69+
environment:
70+
name: testpypi
71+
url: https://test.pypi.org/p/faiss-cpu
72+
permissions:
73+
id-token: write
74+
contents: read
75+
steps:
76+
- name: Download wheel artifacts
77+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
78+
with:
79+
path: dist
80+
pattern: wheels-*
81+
merge-multiple: true
82+
83+
- name: Publish to TestPyPI
84+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
85+
with:
86+
repository-url: https://test.pypi.org/legacy/
87+
skip-existing: true
88+
verbose: true

0 commit comments

Comments
 (0)