|  | 
|  | 1 | +name: CI Test on AMD | 
|  | 2 | +on: [pull_request] | 
|  | 3 | + | 
|  | 4 | +concurrency: | 
|  | 5 | +  group: "${{ github.workflow }}-${{ github.ref }}" | 
|  | 6 | +  cancel-in-progress: ${{ github.event_name == 'pull_request' }} | 
|  | 7 | + | 
|  | 8 | +env: | 
|  | 9 | +  PYTHON_VERSION: '3.12' | 
|  | 10 | +  VENV_DIR: tilelang_ci | 
|  | 11 | +  PYTORCH_INDEX_URL: https://download.pytorch.org/whl/nightly/rocm6.3/ | 
|  | 12 | + | 
|  | 13 | +jobs: | 
|  | 14 | +  format-check: | 
|  | 15 | +    runs-on: [self-hosted, amd, gpu] | 
|  | 16 | + | 
|  | 17 | +    permissions: | 
|  | 18 | +      contents: write | 
|  | 19 | + | 
|  | 20 | +    steps: | 
|  | 21 | +    - name: Checkout repository | 
|  | 22 | +      uses: actions/checkout@v5 | 
|  | 23 | +      with: | 
|  | 24 | +        fetch-depth: 0 | 
|  | 25 | + | 
|  | 26 | +    - name: Set up Python | 
|  | 27 | +      uses: actions/setup-python@v6 | 
|  | 28 | +      with: | 
|  | 29 | +        python-version: ${{ env.PYTHON_VERSION }} | 
|  | 30 | + | 
|  | 31 | +    - name: Ensure venv (local & persistent) | 
|  | 32 | +      run: | | 
|  | 33 | +        set -e | 
|  | 34 | +        REQS_HASH=$(sha256sum requirements-rocm.txt 2>/dev/null | awk '{print $1}' || echo "no_requirements") | 
|  | 35 | +        MARKER="${{ runner.tool_cache }}/.venv_marker_${{ env.PYTHON_VERSION }}_${REQS_HASH:0:8}" | 
|  | 36 | +
 | 
|  | 37 | +        if [[ -f "$MARKER" ]] && [[ -f "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" ]]; then | 
|  | 38 | +          echo "venv exists and hash matches – reuse it" | 
|  | 39 | +        else | 
|  | 40 | +          echo "venv stale or missing – recreating" | 
|  | 41 | +          rm -rf "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" "$MARKER" | 
|  | 42 | +          python -m venv "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" | 
|  | 43 | +          # shellcheck source=/dev/null | 
|  | 44 | +          source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 45 | +          python -m pip install --upgrade pip --no-user | 
|  | 46 | +          [[ -f requirements-rocm.txt ]] && \ | 
|  | 47 | +            PIP_NO_BUILD_ISOLATION=1 pip install -r requirements-rocm.txt --no-user | 
|  | 48 | +          touch "$MARKER" | 
|  | 49 | +        fi | 
|  | 50 | +
 | 
|  | 51 | +    - name: Run format check | 
|  | 52 | +      run: | | 
|  | 53 | +        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 54 | +        git submodule update --init --recursive --checkout | 
|  | 55 | +        mkdir -p build | 
|  | 56 | +        cd build; USE_ROCM=1 cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON; cd .. | 
|  | 57 | +        if ! output=$(./format.sh 2>&1); then | 
|  | 58 | +          echo "------------------------------------" | 
|  | 59 | +          echo "message:" | 
|  | 60 | +          echo "$output" | 
|  | 61 | +          printf '%s\n' "$output" | grep "Please review and stage the changes." | 
|  | 62 | +          echo "------------------------------------" | 
|  | 63 | +          exit 1 | 
|  | 64 | +        fi | 
|  | 65 | +        rm -rf build | 
|  | 66 | +
 | 
|  | 67 | +  build-test-amd: | 
|  | 68 | +    runs-on: [self-hosted, amd, gpu] | 
|  | 69 | +    needs: format-check | 
|  | 70 | +    permissions: | 
|  | 71 | +      contents: read | 
|  | 72 | +    steps: | 
|  | 73 | +    - name: Checkout repository | 
|  | 74 | +      uses: actions/checkout@v5 | 
|  | 75 | +      with: | 
|  | 76 | +        fetch-depth: 1 | 
|  | 77 | +        repository: ${{ github.event.pull_request.head.repo.full_name }} | 
|  | 78 | +        ref: ${{ github.event.pull_request.head.ref }} | 
|  | 79 | + | 
|  | 80 | +    - name: Set up Python | 
|  | 81 | +      uses: actions/setup-python@v6 | 
|  | 82 | +      with: | 
|  | 83 | +        python-version: ${{ env.PYTHON_VERSION }} | 
|  | 84 | + | 
|  | 85 | +    - name: Ensure venv (local & persistent) | 
|  | 86 | +      run: | | 
|  | 87 | +        set -e | 
|  | 88 | +        REQS_HASH=$(sha256sum requirements-rocm.txt 2>/dev/null | awk '{print $1}' || echo "no_requirements") | 
|  | 89 | +        MARKER="${{ runner.tool_cache }}/.venv_marker_${{ env.PYTHON_VERSION }}_${REQS_HASH:0:8}" | 
|  | 90 | +
 | 
|  | 91 | +        if [[ -f "$MARKER" ]] && [[ -f "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" ]]; then | 
|  | 92 | +          echo "venv exists and hash matches – reuse it" | 
|  | 93 | +        else | 
|  | 94 | +          echo "venv stale or missing – recreating" | 
|  | 95 | +          rm -rf "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" "$MARKER" | 
|  | 96 | +          python -m venv "${{ runner.tool_cache }}/${{ env.VENV_DIR }}" | 
|  | 97 | +          # shellcheck source=/dev/null | 
|  | 98 | +          source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 99 | +          python -m pip install --upgrade pip --no-user | 
|  | 100 | +          [[ -f requirements-rocm.txt ]] && \ | 
|  | 101 | +            PIP_NO_BUILD_ISOLATION=1 pip install -r requirements-rocm.txt --no-user | 
|  | 102 | +          touch "$MARKER" | 
|  | 103 | +        fi | 
|  | 104 | +
 | 
|  | 105 | +    - name: Install project (wheel form) | 
|  | 106 | +      run: | | 
|  | 107 | +        echo "Installing project (wheel form)" | 
|  | 108 | +        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 109 | +
 | 
|  | 110 | +        echo "::group::torch.utils.collect_env" | 
|  | 111 | +        python -m torch.utils.collect_env | 
|  | 112 | +        echo "::endgroup::" | 
|  | 113 | +
 | 
|  | 114 | +        git submodule update --init --recursive --checkout --recommend-shallow | 
|  | 115 | +        USE_ROCM=True pip install . --no-user | 
|  | 116 | +
 | 
|  | 117 | +    - name: Run tests | 
|  | 118 | +      run: | | 
|  | 119 | +        echo "Running tests" | 
|  | 120 | +        source "${{ runner.tool_cache }}/${{ env.VENV_DIR }}/bin/activate" | 
|  | 121 | +        cd testing/python/amd | 
|  | 122 | +        unset PYTHONPATH | 
|  | 123 | +        python -m pytest -v --cache-clear test_tilelang_test_amd.py | 
0 commit comments