From c56d0ae529ed191717cc085f2d9b8fcf671ce5c5 Mon Sep 17 00:00:00 2001 From: Michael Melesse Date: Wed, 5 Jun 2024 10:54:37 -0500 Subject: [PATCH] add test --- .github/workflows/amd_tests.yml | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/amd_tests.yml diff --git a/.github/workflows/amd_tests.yml b/.github/workflows/amd_tests.yml new file mode 100644 index 000000000..e97d90595 --- /dev/null +++ b/.github/workflows/amd_tests.yml @@ -0,0 +1,91 @@ +name: AMD Perf Kernel Tests + +on: + workflow_dispatch: + pull_request: + branches: [main_perf] + merge_group: + branches: [main_perf] + types: [checks_requested] + push: + branches: [main_perf] + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main_perf' }} + +permissions: read-all + + +jobs: + Runner-Preparation-AMD: + runs-on: ubuntu-latest + timeout-minutes: 30 + outputs: + matrix-HIP: ${{ steps.set-matrix.outputs.matrix-HIP }} + steps: + - name: Prepare runner matrix + id: set-matrix + run: | + if [ x"${{ github.repository }}" == x"ROCm/flash-attention" ]; then + echo '::set-output name=matrix-HIP::[["self-hosted", "rocm"]]' + else + echo '::set-output name=matrix-HIP::[["ubuntu-latest"]]' + fi + + pre-commit: + name: pre-commit (code formatting) + needs: Runner-Preparation-AMD + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + - name: Compute hash of pre-commit config + id: cache-key + run: | + echo "pre_commit_hash=$(sha256sum .pre-commit-config.yaml)" >> $GITHUB_OUTPUT + shell: bash + - name: Cache pre-commit's cache dir + uses: actions/cache@v4 + with: + # Note that we cannot use environment variables here given there is + # no shell to interpret them in the paths. + path: | + ~/.cache/pre-commit + key: ${{ runner.os }}-${{ steps.cache-key.outputs.pre_commit_hash }} + - name: Check pre-commit + run: | + python3 -m pip install --upgrade pre-commit + # TODO: ignore the first yapf failure until https://github.com/google/yapf/issues/1164 is fixed + python3 -m pre_commit run --all-files --verbose yapf &> /dev/null || true + # If first run of yapf worked and made changes reset the tree to the original state + git reset --hard + python3 -m pre_commit run --all-files --verbose + - name: Print diff of changes if pre-commit failed + if: failure() + run: | + git diff + + Integration-Tests-AMD: + needs: Runner-Preparation-AMD + if: needs.Runner-Preparation-AMD.outputs.matrix-HIP != '' + runs-on: ${{ matrix.runner }} + timeout-minutes: 60 + strategy: + matrix: + runner: ${{fromJson(needs.Runner-Preparation-AMD.outputs.matrix-HIP)}} + container: + image: rocm/pytorch:rocm6.0.2_ubuntu22.04_py3.10_pytorch_2.1.2 + options: --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --user root + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build + run: | + FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE python setup.py install + - name: Test + pytest -n 32 -v tests/test_flash_attn.py::test_flash_attn_output \ No newline at end of file