Skip to content

Commit 6205b3d

Browse files
committed
GitHub workflow to build PyTorch wheels
Signed-off-by: Pavel Chekin <[email protected]>
1 parent 052c792 commit 6205b3d

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: PyTorch wheels
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
paths:
9+
- .github/workflows/wheels-pytorch.yml
10+
- .github/pins/pytorch.txt
11+
push:
12+
branches:
13+
- main
14+
paths:
15+
- .github/workflows/wheels-pytorch.yml
16+
- .github/pins/pytorch.txt
17+
18+
permissions: read-all
19+
20+
env:
21+
NEW_WORKSPACE: C:\gh${{ github.run_id }}
22+
23+
jobs:
24+
windows:
25+
runs-on:
26+
- windows
27+
- b580
28+
strategy:
29+
matrix:
30+
python:
31+
- "3.9"
32+
fail-fast: false
33+
max-parallel: 1
34+
steps:
35+
- name: Checkout Triton repository
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: ${{ matrix.python }}
42+
43+
- name: Clean up old workspaces
44+
shell: bash
45+
run: |
46+
rm -rf /c/gh*
47+
48+
# Copy workspace to a temporary location with a shorter name.
49+
- name: Copy workspace
50+
run: |
51+
Copy-Item -Path ${{ github.workspace }} -Destination ${{ env.NEW_WORKSPACE }} -Recurse
52+
53+
- name: Checkout PyTorch repository
54+
run: |
55+
cd ${{ env.NEW_WORKSPACE }}
56+
$pytorch_commit = Get-Content .github/pins/pytorch.txt
57+
git clone --single-branch -b main --recurse-submodules -j8 https://github.com/pytorch/pytorch.git
58+
cd pytorch
59+
git checkout $pytorch_commit
60+
git submodule update --init --recursive
61+
bash -c '../scripts/patch-pytorch.sh'
62+
63+
- name: Create venv
64+
run: |
65+
cd ${{ env.NEW_WORKSPACE }}
66+
python -m venv .venv
67+
68+
- name: Install build dependencies
69+
run: |
70+
cd ${{ env.NEW_WORKSPACE }}
71+
.venv\Scripts\activate.ps1
72+
cd pytorch
73+
# FIXME: Compatibility with versions of CMake older than 3.5 has been removed, this breaks compilation of third_party/protobuf:
74+
# CMake Error at third_party/protobuf/cmake/CMakeLists.txt:2 (cmake_minimum_required)
75+
pip install 'cmake<4.0.0' ninja -r requirements.txt cibuildwheel
76+
77+
- name: Identify runtime dependencies
78+
run: |
79+
cd ${{ env.NEW_WORKSPACE }}
80+
.venv\Scripts\activate.ps1
81+
cd pytorch/.github/scripts
82+
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
83+
echo "PYTORCH_EXTRA_INSTALL_REQUIREMENTS=$env:PYTORCH_EXTRA_INSTALL_REQUIREMENTS" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
84+
85+
- name: Build PyTorch wheels
86+
run: |
87+
cd ${{ env.NEW_WORKSPACE }}
88+
.venv\Scripts\activate.ps1
89+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
90+
91+
cd pytorch
92+
# Required to build on Windows
93+
$env:CMAKE_SHARED_LINKER_FLAGS = "/FORCE:MULTIPLE"
94+
$env:CMAKE_MODULE_LINKER_FLAGS = "/FORCE:MULTIPLE"
95+
$env:CMAKE_EXE_LINKER_FLAGS = "/FORCE:MULTIPLE"
96+
$env:TORCH_XPU_ARCH_LIST = "bmg,dg2,arl-h,mtl-h"
97+
98+
$env:CIBW_BUILD_VERBOSITY = "1"
99+
$env:CIBW_SKIP = "cp{35,36,37}-*"
100+
$env:CIBW_BUILD="cp3{9,10,11,12,13}*-win_amd64"
101+
102+
python -m cibuildwheel --output-dir wheelhouse
103+
104+
# - name: Clean up workspace
105+
# if: ${{ always() }}
106+
# run: |
107+
# Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore
108+
109+
- name: Clean up temporary files
110+
if: ${{ always() }}
111+
shell: bash
112+
run: |
113+
rm -rf rm -rf /tmp/triton-* /tmp/tmp*
114+
115+
116+

0 commit comments

Comments
 (0)