From 34bbe5e540bbc4edd0de38cb98bf0a563b2bae45 Mon Sep 17 00:00:00 2001 From: mengdilin Date: Fri, 26 Jul 2024 17:27:39 -0700 Subject: [PATCH] Add ARM64 build to build_cmake actions for SVE (#3653) Summary: Add instructions to download arm64 specific conda dependencies and cmake command and run it on CI. This should prepare us to turn on CI with SVE optimization Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3653 Reviewed By: ramilbakhshyiev Differential Revision: D60043435 Pulled By: mengdilin fbshipit-source-id: d81bb1c1022681c3da8f98bbf080d5e1d65d6b80 --- .github/actions/build_cmake/action.yml | 60 +++++++++++++++++++------- .github/workflows/build.yml | 13 ++++++ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/.github/actions/build_cmake/action.yml b/.github/actions/build_cmake/action.yml index 2bc476add5..873daacc1e 100644 --- a/.github/actions/build_cmake/action.yml +++ b/.github/actions/build_cmake/action.yml @@ -28,9 +28,20 @@ runs: 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 + conda install -y -q python=3.11 cmake make swig numpy scipy pytest + + # install base packages for ARM64 + if [ "${{ runner.arch }}" = "ARM64" ]; then + conda install -y -q -c conda-forge openblas gxx_linux-aarch64 sysroot_linux-aarch64 + fi + + # install base packages for X86_64 + if [ "${{ runner.arch }}" = "X64" ]; then + # TODO: unpin versions for gxx_linux-64 and sysroot_linux-64 and merge it with ARM64 below + conda install -y -q -c conda-forge gxx_linux-64=11.2 sysroot_linux-64=2.28 + conda install -y -q mkl=2023 mkl-devel=2023 + fi + # install CUDA packages if [ "${{ inputs.gpu }}" = "ON" ] && [ "${{ inputs.raft }}" = "OFF" ]; then @@ -54,18 +65,35 @@ runs: 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" \ - . + + if [ "${{ runner.arch }}" = "X64" ]; then + 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" \ + . + elif [ "${{ runner.arch }}" = "ARM64" ]; then + 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 \ + . + else + echo "Encountered unexpected platform ${{ runner.arch }}" + exit 1 + fi make -k -C build -j$(nproc) - name: C++ tests shell: bash @@ -101,5 +129,5 @@ runs: - name: Upload test results uses: actions/upload-artifact@v4 with: - name: test-results-${{ inputs.opt_level }}-${{ inputs.gpu }}-${{ inputs.raft }} + name: test-results-${{ runner.arch }}-${{ inputs.opt_level }}-${{ inputs.gpu }}-${{ inputs.raft }} path: test-results diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed3f371bb0..c0eca51393 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,6 +88,19 @@ jobs: with: gpu: ON raft: ON + linux-arm64-SVE-cmake: + name: Linux arm64 SVE (cmake) + runs-on: faiss-aws-r8g.large + continue-on-error: true # non-blocking mode for now + steps: + - name: Checkout + continue-on-error: true # non-blocking mode for now + uses: actions/checkout@v4 + - uses: ./.github/actions/build_cmake + continue-on-error: true # non-blocking mode for now + # TODO(T197096427): uncomment this once SVE PR is merged + # with: + # opt_level: sve linux-x86_64-conda: name: Linux x86_64 (conda) needs: linux-x86_64-cmake