From 364749e88624ae2c93c099e1a798c48a47c1ab2d Mon Sep 17 00:00:00 2001 From: Michael Norris Date: Tue, 7 Apr 2026 13:08:22 -0700 Subject: [PATCH] Re-enable ROCm runner for AMD GPU CI (#4854) Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4854 This re-enables the AMD ROCm runner that was previously disabled in D86250489. Changes from the original configuration: - Updated runner from `faiss-amd-MI200` to `linux-amd-rocm-mi325-ubuntu-24` to match the currently available GitHub Actions runner - Updated container image from Ubuntu 22.04 to Ubuntu 24.04 to align with the runner environment Test change: - seems like cuda and hip disagree about some small rounding errors, so AI updated the test. Reviewed By: subhadeepkaran Differential Revision: D94941142 fbshipit-source-id: d5158b7939e3b7327432aa89a9a0d2e5ed1ad190 --- .github/actions/build_cmake/action.yml | 48 +++++++++++++++++------- .github/workflows/build-pull-request.yml | 23 ++++++++++++ faiss/gpu/test/TestGpuIndexIVFPQ.cpp | 6 ++- 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/.github/actions/build_cmake/action.yml b/.github/actions/build_cmake/action.yml index 3a1306d2e..7b9d2c7bb 100644 --- a/.github/actions/build_cmake/action.yml +++ b/.github/actions/build_cmake/action.yml @@ -100,27 +100,43 @@ runs: sudo apt-get -qq update >/dev/null sudo apt-get -qq install -y kmod wget gpg >/dev/null + # Download, prepare, and install the package signing key + mkdir --parents --mode=0755 /etc/apt/keyrings + wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null + + - name: Add rocm repository + if: inputs.rocm == 'ON' + shell: bash + run: | # Get UBUNTU version name UBUNTU_VERSION_NAME=`cat /etc/os-release | grep UBUNTU_CODENAME | awk -F= '{print $2}'` # Set ROCm version ROCM_VERSION="6.2" - # Download, prepare, and install the package signing key - mkdir --parents --mode=0755 /etc/apt/keyrings - wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null + rocm_baseurl="https://repo.radeon.com/rocm/apt/${ROCM_VERSION}" + sudo mkdir -p /etc/apt/keyrings + wget -qO /tmp/rocm.gpg.key https://repo.radeon.com/rocm/rocm.gpg.key + echo "2de99e2354646a90d9903e2a669fc4e36b02c1bbff7075c481e12d7edab2c88b /tmp/rocm.gpg.key" | sha256sum --check - # Add rocm repository - wget -qO - http://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add - - rocm_baseurl="http://repo.radeon.com/rocm/apt/${ROCM_VERSION}" - echo "deb [arch=amd64] ${rocm_baseurl} ${UBUNTU_VERSION_NAME} main" | sudo tee /etc/apt/sources.list.d/rocm.list - sudo apt-get -qq update --allow-insecure-repositories >/dev/null - sudo apt-get -qq install -y --allow-unauthenticated \ - "rocm-dev${ROCM_VERSION}" "rocm-utils${ROCM_VERSION}" \ - "rocm-libs${ROCM_VERSION}" >/dev/null + echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] ${rocm_baseurl} ${UBUNTU_VERSION_NAME} main" | sudo tee /etc/apt/sources.list.d/rocm.list + + sudo apt-get -qq update >/dev/null + sudo apt-get -qq install -y \ + "rocm-dev${ROCM_VERSION}" "rocm-utils${ROCM_VERSION}" "rocm-libs${ROCM_VERSION}" >/dev/null + + + - name: Pin BLAS/LAPACK versions + if: inputs.rocm == 'ON' + shell: bash + run: | + conda install -y \ + "libblas=3.9.0=35_*" \ + "libcblas=3.9.0=35_*" \ + "liblapack=3.9.0=35_*" # Fake presence of MI200-class accelerators - echo "gfx90a" | sudo tee /opt/rocm/bin/target.lst + echo "gfx942" | sudo tee /opt/rocm/bin/target.lst # Cleanup sudo apt-get -qq autoclean >/dev/null @@ -135,10 +151,14 @@ runs: sudo ln -s /lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/libc_nonshared.a sudo ln -s /usr/lib/x86_64-linux-gnu/libpthread.so.0 /lib64/libpthread.so.0 sudo ln -s $HOME/miniconda3/x86_64-conda-linux-gnu/sysroot/usr/lib64/libpthread_nonshared.a /usr/lib64/libpthread_nonshared.a - - name: Print GPU info - if: inputs.gpu == 'ON' + - name: Print NVIDIA GPU info + if: inputs.gpu == 'ON' && inputs.rocm != 'ON' shell: bash run: nvidia-smi + - name: Print AMD GPU info + if: inputs.gpu == 'ON' && inputs.rocm == 'ON' + shell: bash + run: rocm-smi - name: Build all targets shell: bash run: | diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index 00e5491ab..05efb6010 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -96,6 +96,29 @@ jobs: uses: ./.github/actions/build_cmake with: gpu: ON + linux-x86_64-GPU-w-ROCm-cmake: + name: Linux x86_64 GPU w/ ROCm (cmake) + needs: linux-x86_64-cmake + runs-on: linux-amd-rocm-mi325-ubuntu-24 + container: + image: ubuntu:24.04 + options: --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size 16G --group-add video --cap-add=SYS_PTRACE --cap-add=SYS_ADMIN + steps: + - name: Container setup + run: | + if [ -f /.dockerenv ]; then + apt-get update && apt-get install -y sudo && apt-get install -y git + git config --global --add safe.directory '*' + else + echo 'Skipping. Current job is not running inside a container.' + fi + - name: Checkout + uses: actions/checkout@v4 + - name: Build and Test (cmake) + uses: ./.github/actions/build_cmake + with: + gpu: ON + rocm: ON linux-x86_64-GPU-w-CUVS-cmake: name: Linux x86_64 GPU w/ cuVS (cmake) needs: linux-x86_64-cmake diff --git a/faiss/gpu/test/TestGpuIndexIVFPQ.cpp b/faiss/gpu/test/TestGpuIndexIVFPQ.cpp index a9d39e4d7..4a74e7075 100644 --- a/faiss/gpu/test/TestGpuIndexIVFPQ.cpp +++ b/faiss/gpu/test/TestGpuIndexIVFPQ.cpp @@ -102,7 +102,11 @@ struct Options { } float getCompareEpsilon() const { - return 0.035f; + // With very low dimensionality (e.g., dim=4, codes=2 giving + // dimPerSubQuantizer=2), L2 distances can be very small + // (near-zero), causing relative error comparisons to be + // unstable despite tiny absolute differences. + return (dim <= 8) ? 0.15f : 0.035f; } float getPctMaxDiff1() const {