|
| 1 | +name: PyTorch wheels |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - .github/workflows/wheels-pytorch.yml |
| 10 | + - .github/pins/pytorch.txt |
| 11 | + |
| 12 | +permissions: read-all |
| 13 | + |
| 14 | +env: |
| 15 | + NEW_WORKSPACE: C:\gh${{ github.run_id }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + windows: |
| 19 | + runs-on: |
| 20 | + - windows |
| 21 | + - b580 |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + python: |
| 25 | + - "3.9" |
| 26 | + - "3.10" |
| 27 | + - "3.11" |
| 28 | + - "3.12" |
| 29 | + - "3.13" |
| 30 | + fail-fast: false |
| 31 | + max-parallel: 2 |
| 32 | + steps: |
| 33 | + - name: Checkout Triton repository |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Setup Python |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: "3.12" |
| 40 | + |
| 41 | + - name: Clean up old workspaces |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + rm -rf /c/gh* |
| 45 | +
|
| 46 | + # Copy workspace to a temporary location with a shorter name. |
| 47 | + - name: Copy workspace |
| 48 | + run: | |
| 49 | + Copy-Item -Path ${{ github.workspace }} -Destination ${{ env.NEW_WORKSPACE }} -Recurse |
| 50 | +
|
| 51 | + - name: Checkout PyTorch repository |
| 52 | + run: | |
| 53 | + cd ${{ env.NEW_WORKSPACE }} |
| 54 | + $pytorch_commit = Get-Content .github/pins/pytorch.txt |
| 55 | + git clone --single-branch -b main --recurse-submodules -j8 https://github.com/pytorch/pytorch.git |
| 56 | + cd pytorch |
| 57 | + git checkout $pytorch_commit |
| 58 | + git submodule update --init --recursive |
| 59 | + bash -c '../scripts/patch-pytorch.sh' |
| 60 | + echo "PyTorch commit: $pytorch_commit" |
| 61 | +
|
| 62 | + - name: Create venv |
| 63 | + run: | |
| 64 | + cd ${{ env.NEW_WORKSPACE }} |
| 65 | + python -m venv .venv |
| 66 | +
|
| 67 | + - name: Install build dependencies |
| 68 | + run: | |
| 69 | + cd ${{ env.NEW_WORKSPACE }} |
| 70 | + .venv\Scripts\activate.ps1 |
| 71 | + cd pytorch |
| 72 | + pip install cibuildwheel |
| 73 | +
|
| 74 | + - name: Identify runtime dependencies |
| 75 | + run: | |
| 76 | + cd ${{ env.NEW_WORKSPACE }} |
| 77 | + .venv\Scripts\activate.ps1 |
| 78 | + cd pytorch/.github/scripts |
| 79 | + 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 |
| 80 | + echo "PYTORCH_EXTRA_INSTALL_REQUIREMENTS=$PYTORCH_EXTRA_INSTALL_REQUIREMENTS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 81 | +
|
| 82 | + - name: Set PyTorch version |
| 83 | + run: | |
| 84 | + cd ${{ env.NEW_WORKSPACE }} |
| 85 | + cd pytorch |
| 86 | + $pytorch_version = Get-Content version.txt |
| 87 | + $pytorch_version = "$pytorch_version.post$env:GITHUB_RUN_NUMBER" |
| 88 | + echo "$pytorch_version" > version.txt |
| 89 | + echo "PyTorch version: $pytorch_version" |
| 90 | +
|
| 91 | + - name: Build PyTorch wheels |
| 92 | + run: | |
| 93 | + cd ${{ env.NEW_WORKSPACE }} |
| 94 | + .venv\Scripts\activate.ps1 |
| 95 | + Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" |
| 96 | +
|
| 97 | + cd pytorch |
| 98 | +
|
| 99 | + # Required to build on Windows |
| 100 | + $env:CMAKE_SHARED_LINKER_FLAGS = "/FORCE:MULTIPLE" |
| 101 | + $env:CMAKE_MODULE_LINKER_FLAGS = "/FORCE:MULTIPLE" |
| 102 | + $env:CMAKE_EXE_LINKER_FLAGS = "/FORCE:MULTIPLE" |
| 103 | + $env:TORCH_XPU_ARCH_LIST = "bmg,dg2,arl-h,mtl-h" |
| 104 | +
|
| 105 | + $env:CIBW_BUILD_VERBOSITY = "1" |
| 106 | + $env:CIBW_SKIP = "cp{35,36,37}-*" |
| 107 | + $env:CIBW_BUILD = "cp" + "${{ matrix.python}}".replace(".", "") + "*-win_amd64" |
| 108 | + $env:CIBW_CACHE_PATH = "${{ env.NEW_WORKSPACE }}/cibw" |
| 109 | + $env:USE_XCCL = "1" |
| 110 | + $env:CIBW_BEFORE_BUILD = "pip install -r requirements.txt" |
| 111 | +
|
| 112 | + python -m cibuildwheel --output-dir wheelhouse |
| 113 | +
|
| 114 | + - name: Artifact name |
| 115 | + run: | |
| 116 | + (Get-ChildItem -Path "${{ env.NEW_WORKSPACE }}\pytorch\wheelhouse\*.whl").Name | Tee-Object -Variable WHEELS_NAME |
| 117 | + echo "WHEELS_NAME=$WHEELS_NAME" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 118 | +
|
| 119 | + - name: Upload wheels |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: ${{ env.WHEELS_NAME }} |
| 123 | + path: ${{ env.NEW_WORKSPACE }}\pytorch\wheelhouse\*.whl |
| 124 | + |
| 125 | + - name: Clean up workspace |
| 126 | + if: ${{ always() }} |
| 127 | + run: | |
| 128 | + Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore |
| 129 | +
|
| 130 | + - name: Clean up temporary files |
| 131 | + if: ${{ always() }} |
| 132 | + shell: bash |
| 133 | + run: | |
| 134 | + rm -rf rm -rf /tmp/triton-* /tmp/tmp* |
0 commit comments