GitHub workflow to build PyTorch wheels #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PyTorch wheels | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - .github/workflows/wheels-pytorch.yml | |
| - .github/pins/pytorch.txt | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - .github/workflows/wheels-pytorch.yml | |
| - .github/pins/pytorch.txt | |
| permissions: read-all | |
| env: | |
| NEW_WORKSPACE: C:\gh${{ github.run_id }} | |
| jobs: | |
| windows: | |
| runs-on: | |
| - windows | |
| - b580 | |
| steps: | |
| - name: Checkout Triton repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Clean up old workspaces | |
| shell: bash | |
| run: | | |
| rm -rf /c/gh* | |
| # Copy workspace to a temporary location with a shorter name. | |
| - name: Copy workspace | |
| run: | | |
| Copy-Item -Path ${{ github.workspace }} -Destination ${{ env.NEW_WORKSPACE }} -Recurse | |
| - name: Checkout PyTorch repository | |
| run: | | |
| cd ${{ env.NEW_WORKSPACE }} | |
| $pytorch_commit = Get-Content .github/pins/pytorch.txt | |
| git clone --single-branch -b main --recurse-submodules -j8 https://github.com/pytorch/pytorch.git | |
| cd pytorch | |
| git checkout $pytorch_commit | |
| git submodule update --init --recursive | |
| bash -c '../scripts/patch-pytorch.sh' | |
| - name: Create venv | |
| run: | | |
| cd ${{ env.NEW_WORKSPACE }} | |
| python -m venv .venv | |
| - name: Install build dependencies | |
| run: | | |
| cd ${{ env.NEW_WORKSPACE }} | |
| .venv\Scripts\activate.ps1 | |
| cd pytorch | |
| pip install cibuildwheel | |
| - name: Identify runtime dependencies | |
| run: | | |
| cd ${{ env.NEW_WORKSPACE }} | |
| .venv\Scripts\activate.ps1 | |
| cd pytorch/.github/scripts | |
| python -c 'from generate_binary_build_matrix import PYTORCH_EXTRA_INSTALL_REQUIREMENTS; print(PYTORCH_EXTRA_INSTALL_REQUIREMENTS["xpu"])' | Tee-Object -Variable PYTORCH_EXTRA_INSTALL_REQUIREMENTS | |
| echo "PYTORCH_EXTRA_INSTALL_REQUIREMENTS=$env:PYTORCH_EXTRA_INSTALL_REQUIREMENTS" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: Build PyTorch wheels | |
| run: | | |
| cd ${{ env.NEW_WORKSPACE }} | |
| .venv\Scripts\activate.ps1 | |
| Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" | |
| cd pytorch | |
| # Required to build on Windows | |
| $env:CMAKE_SHARED_LINKER_FLAGS = "/FORCE:MULTIPLE" | |
| $env:CMAKE_MODULE_LINKER_FLAGS = "/FORCE:MULTIPLE" | |
| $env:CMAKE_EXE_LINKER_FLAGS = "/FORCE:MULTIPLE" | |
| $env:TORCH_XPU_ARCH_LIST = "bmg,dg2,arl-h,mtl-h" | |
| $env:CIBW_BUILD_VERBOSITY = "3" | |
| $env:CIBW_SKIP = "cp{35,36,37}-*" | |
| $env:CIBW_BUILD="cp3{9,10,11,12,13}*-win_amd64" | |
| python -m cibuildwheel --output-dir wheelhouse | |
| # - name: Clean up workspace | |
| # if: ${{ always() }} | |
| # run: | | |
| # Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore | |
| - name: Clean up temporary files | |
| if: ${{ always() }} | |
| shell: bash | |
| run: | | |
| rm -rf rm -rf /tmp/triton-* /tmp/tmp* | |