Skip to content

Commit

Permalink
Merge branch 'facebookresearch:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
guangzegu authored Jun 19, 2024
2 parents 2f3fdf9 + e758973 commit a15c5cc
Show file tree
Hide file tree
Showing 180 changed files with 7,349 additions and 2,392 deletions.
428 changes: 12 additions & 416 deletions .circleci/config.yml

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions .github/actions/build_cmake/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build cmake
inputs:
opt_level:
description: 'Compile options / optimization level.'
required: false
default: generic
gpu:
description: 'Enable GPU support.'
required: false
default: OFF
raft:
description: 'Enable RAFT support.'
required: false
default: OFF
runs:
using: composite
steps:
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
miniconda-version: latest
- name: Configure build environment
shell: bash
run: |
# initialize Conda
conda config --set solver libmamba
conda update -y -q conda
echo "$CONDA/bin" >> $GITHUB_PATH
# install base packages
conda install -y -q -c conda-forge gxx_linux-64=11.2 sysroot_linux-64=2.28
conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest
# install CUDA packages
if [ "${{ inputs.gpu }}" = "ON" ] && [ "${{ inputs.raft }}" = "OFF" ]; then
conda install -y -q cuda-toolkit -c "nvidia/label/cuda-11.8.0"
fi
# install RAFT packages
if [ "${{ inputs.raft }}" = "ON" ]; then
conda install -y -q libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge
fi
# install test packages
conda install -y pytest
if [ "${{ inputs.gpu }}" = "ON" ]; then
conda install -y -q pytorch pytorch-cuda=11.8 -c pytorch -c nvidia/label/cuda-11.8.0
else
conda install -y -q pytorch -c pytorch
fi
- name: Build all targets
shell: bash
run: |
eval "$(conda shell.bash hook)"
conda activate
cmake -B build \
-DBUILD_TESTING=ON \
-DBUILD_SHARED_LIBS=ON \
-DFAISS_ENABLE_GPU=${{ inputs.gpu }} \
-DFAISS_ENABLE_RAFT=${{ inputs.raft }} \
-DFAISS_OPT_LEVEL=${{ inputs.opt_level }} \
-DFAISS_ENABLE_C_API=ON \
-DPYTHON_EXECUTABLE=$CONDA/bin/python \
-DCMAKE_BUILD_TYPE=Release \
-DBLA_VENDOR=Intel10_64_dyn \
-DCMAKE_CUDA_FLAGS="-gencode arch=compute_75,code=sm_75" \
.
make -k -C build -j$(nproc)
- name: C++ tests
shell: bash
run: |
export GTEST_OUTPUT="xml:$(realpath .)/test-results/googletest/"
make -C build test
- name: Install Python extension
shell: bash
working-directory: build/faiss/python
run: |
$CONDA/bin/python setup.py install
- name: Python tests (CPU only)
if: inputs.gpu == 'OFF'
shell: bash
run: |
pytest --junitxml=test-results/pytest/results.xml tests/test_*.py
pytest --junitxml=test-results/pytest/results-torch.xml tests/torch_*.py
- name: Python tests (CPU + GPU)
if: inputs.gpu == 'ON'
shell: bash
run: |
pytest --junitxml=test-results/pytest/results.xml tests/test_*.py
pytest --junitxml=test-results/pytest/results-torch.xml tests/torch_*.py
cp tests/common_faiss_tests.py faiss/gpu/test
pytest --junitxml=test-results/pytest/results-gpu.xml faiss/gpu/test/test_*.py
pytest --junitxml=test-results/pytest/results-gpu-torch.xml faiss/gpu/test/torch_*.py
- name: Test avx2 loading
if: inputs.opt_level == 'avx2'
shell: bash
run: |
FAISS_DISABLE_CPU_FEATURES=AVX2 LD_DEBUG=libs $CONDA/bin/python -c "import faiss" 2>&1 | grep faiss.so
LD_DEBUG=libs $CONDA/bin/python -c "import faiss" 2>&1 | grep faiss_avx2.so
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results-${{ inputs.opt_level }}-${{ inputs.gpu }}-${{ inputs.raft }}
path: test-results
96 changes: 96 additions & 0 deletions .github/actions/build_conda/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Conda build
description: Builds FAISS inside a Conda environment and uploads to repository when label is provided.
inputs:
label:
description: "The label to be used for uploads to Conda."
default: ""
required: false
cuda:
description: "CUDA toolkit version to use."
default: ""
required: false
raft:
description: "Enable RAFT support."
default: ""
required: false
compiler_version:
description: "compiler_version"
default: "Compiler version for C/C++/CUDA."
required: false
runs:
using: composite
steps:
- name: Choose shell
shell: bash
id: choose_shell
run: |
# Use pwsh on Windows; bash everywhere else
if [ "${{ runner.os }}" != "Windows" ]; then
echo "shell=bash" >> "$GITHUB_OUTPUT"
else
echo "shell=pwsh" >> "$GITHUB_OUTPUT"
fi
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
miniconda-version: latest
- name: Install conda build tools
shell: ${{ steps.choose_shell.outputs.shell }}
run: |
conda update -y -q conda
conda install -y -q conda-build
- name: Enable anaconda uploads
if: inputs.label != ''
shell: ${{ steps.choose_shell.outputs.shell }}
env:
PACKAGE_TYPE: ${{ inputs.label }}
run: |
conda install -y -q anaconda-client
conda config --set anaconda_upload yes
- name: Conda build (CPU)
if: inputs.label == '' && inputs.cuda == ''
shell: ${{ steps.choose_shell.outputs.shell }}
working-directory: conda
run: |
conda build faiss --python 3.11 -c pytorch
- name: Conda build (CPU) w/ anaconda upload
if: inputs.label != '' && inputs.cuda == ''
shell: ${{ steps.choose_shell.outputs.shell }}
working-directory: conda
env:
PACKAGE_TYPE: ${{ inputs.label }}
run: |
conda build faiss --user pytorch --label ${{ inputs.label }} -c pytorch
- name: Conda build (GPU)
if: inputs.label == '' && inputs.cuda != '' && inputs.raft == ''
shell: ${{ steps.choose_shell.outputs.shell }}
working-directory: conda
run: |
conda build faiss-gpu --variants '{ "cudatoolkit": "${{ inputs.cuda }}", "c_compiler_version": "${{ inputs.compiler_version }}", "cxx_compiler_version": "${{ inputs.compiler_version }}" }' \
-c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia
- name: Conda build (GPU) w/ anaconda upload
if: inputs.label != '' && inputs.cuda != '' && inputs.raft == ''
shell: ${{ steps.choose_shell.outputs.shell }}
working-directory: conda
env:
PACKAGE_TYPE: ${{ inputs.label }}
run: |
conda build faiss-gpu --variants '{ "cudatoolkit": "${{ inputs.cuda }}", "c_compiler_version": "${{ inputs.compiler_version }}", "cxx_compiler_version": "${{ inputs.compiler_version }}" }' \
--user pytorch --label ${{ inputs.label }} -c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia
- name: Conda build (GPU w/ RAFT)
if: inputs.label == '' && inputs.cuda != '' && inputs.raft != ''
shell: ${{ steps.choose_shell.outputs.shell }}
working-directory: conda
run: |
conda build faiss-gpu-raft --variants '{ "cudatoolkit": "${{ inputs.cuda }}", "c_compiler_version": "${{ inputs.compiler_version }}", "cxx_compiler_version": "${{ inputs.compiler_version }}" }' \
-c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia -c rapidsai -c rapidsai-nightly -c conda-forge
- name: Conda build (GPU w/ RAFT) w/ anaconda upload
if: inputs.label != '' && inputs.cuda != '' && inputs.raft != ''
shell: ${{ steps.choose_shell.outputs.shell }}
working-directory: conda
env:
PACKAGE_TYPE: ${{ inputs.label }}
run: |
conda build faiss-gpu-raft --variants '{ "cudatoolkit": "${{ inputs.cuda }}", "c_compiler_version": "${{ inputs.compiler_version }}", "cxx_compiler_version": "${{ inputs.compiler_version }}" }' \
--user pytorch --label ${{ inputs.label }} -c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia -c rapidsai -c rapidsai-nightly -c conda-forge
Loading

0 comments on commit a15c5cc

Please sign in to comment.