@@ -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
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.
0 commit comments