Skip to content

Commit eff8143

Browse files
authored
Workflow to test Triton with nightly PyTorch wheels on Windows (#3204)
1 parent 1341d82 commit eff8143

File tree

4 files changed

+159
-30
lines changed

4 files changed

+159
-30
lines changed

.github/workflows/build-test-windows.yml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@ name: Build and test on Windows
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
pytorch_mode:
7-
description: PyTorch mode, source or wheels
8-
type: choice
9-
options:
10-
- source
11-
- wheels
12-
default: source
135

146
schedule:
157
- cron: "1 5 * * *"
@@ -46,24 +38,17 @@ jobs:
4638
4739
- name: Create venv
4840
run:
49-
python -m venv ${{ env.NEW_WORKSPACE }}\venv
41+
python -m venv .venv
5042

5143
# FIXME: the runner has PyTorch wheels pre-compiled from sources in a specific location
5244
- name: Install PyTorch (source)
53-
if: ${{ (inputs.pytorch_mode || 'source') == 'source' }}
5445
run: |
55-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
46+
.venv\Scripts\activate.ps1
5647
pip install (Get-Item C:\pytorch\dist\*.whl)
5748
58-
- name: Install PyTorch (wheels)
59-
if: ${{ (inputs.pytorch_mode || 'source') == 'wheels' }}
60-
run: |
61-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
62-
pip install torch --index-url https://download.pytorch.org/whl/nightly/xpu
63-
6449
- name: PyTorch version
6550
run: |
66-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
51+
.venv\Scripts\activate.ps1
6752
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
6853
python -c 'import torch;print(torch.__version__)'
6954
@@ -77,41 +62,42 @@ jobs:
7762
# runner.
7863
- name: Setup Triton
7964
run: |
80-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
81-
cd ${{ env.NEW_WORKSPACE }}
65+
.venv\Scripts\activate.ps1
8266
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
67+
cd ${{ env.NEW_WORKSPACE }}
8368
cd python
8469
pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1'
8570
pip install -v --no-build-isolation '.[build,tests,tutorials]'
8671
8772
- name: Triton version
8873
run: |
89-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
74+
.venv\Scripts\activate.ps1
9075
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
9176
python -c 'import triton; print(triton.__version__)'
9277
9378
- name: Install test dependencies
9479
run: |
95-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
80+
.venv\Scripts\activate.ps1
9681
pip install -r scripts\requirements-test.txt
9782
9883
- name: Run core tests
9984
run: |
100-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
85+
.venv\Scripts\activate.ps1
10186
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
10287
${{ env.TRITON_TEST_CMD }} --core
10388
10489
- name: Run interpreter tests
10590
run: |
106-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
91+
.venv\Scripts\activate.ps1
10792
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
10893
${{ env.TRITON_TEST_CMD }} --interpreter
10994
11095
- name: Pass rate
11196
run: |
112-
${{ env.NEW_WORKSPACE }}\venv\Scripts\Activate.ps1
113-
pip install defusedxml
97+
.venv\Scripts\activate.ps1
98+
# oneAPI is required for sycl-ls, which is used by scripts/capture-hw-details.sh
11499
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
100+
pip install defusedxml
115101
bash -c "\
116102
source ./scripts/capture-hw-details.sh; \
117103
python scripts/pass_rate.py --reports reports ${{ env.SKIPLIST }}; \
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Test with pip on Windows
2+
3+
on:
4+
workflow_dispatch:
5+
6+
# run workflow on changes to the driver, which handles the libraries logic
7+
pull_request:
8+
branches:
9+
- main
10+
paths:
11+
- third_party/intel/backend/driver.py
12+
push:
13+
branches:
14+
- main
15+
paths:
16+
- third_party/intel/backend/driver.py
17+
18+
schedule:
19+
- cron: "3 5 * * *"
20+
21+
permissions: read-all
22+
23+
env:
24+
NEW_WORKSPACE: C:\gh${{ github.run_id }}
25+
ZE_PATH: C:\level_zero
26+
PYTEST_MAX_PROCESSES: 8
27+
TRITON_TEST_CMD: bash -x scripts/test-triton.sh --skip-pytorch-install --skip-pip-install --skip-list scripts/skiplist/a770 --reports-dir reports --ignore-errors
28+
29+
jobs:
30+
build:
31+
name: Build and test
32+
runs-on: win-a770
33+
steps:
34+
- name: Enable long paths
35+
run: |
36+
git config --system core.longPaths true
37+
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
41+
- name: Setup Python
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: '3.9'
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: Create venv
52+
run:
53+
python -m venv .venv
54+
55+
- name: Install PyTorch (wheels)
56+
run: |
57+
.venv\Scripts\activate.ps1
58+
# The latest wheel does not work, see https://github.com/intel/intel-xpu-backend-for-triton/issues/3177#issuecomment-2599817729
59+
# Use the latest good one
60+
pip install torch==2.7.0.dev20250110+xpu --index-url https://download.pytorch.org/whl/nightly/xpu
61+
62+
- name: PyTorch version
63+
run: |
64+
.venv\Scripts\activate.ps1
65+
python -c 'import torch;print(torch.__version__)'
66+
67+
- name: Clean up Triton cache
68+
shell: bash
69+
run: |
70+
rm -rf ~/.triton/cache
71+
72+
# We need ninja >= 1.12.0 to support long names on Windows. At the moment there is no required
73+
# version in pypi, so instead of installing ninja with pip we use a preinstalled 1.12.1 on the
74+
# runner.
75+
- name: Setup Triton
76+
run: |
77+
.venv\Scripts\activate.ps1
78+
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
79+
cd ${{ env.NEW_WORKSPACE }}
80+
cd python
81+
pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1'
82+
python setup.py -v bdist_wheel
83+
pip install (Get-Item ${{ env.NEW_WORKSPACE }}\python\dist\*.whl)
84+
85+
- name: Triton version
86+
run: |
87+
.venv\Scripts\activate.ps1
88+
python -c 'import triton; print(triton.__version__)'
89+
90+
- name: Install test dependencies
91+
run: |
92+
.venv\Scripts\activate.ps1
93+
pip install -r scripts\requirements-test.txt
94+
95+
- name: Show installed pip packages
96+
run: |
97+
.venv\Scripts\activate.ps1
98+
pip list -v
99+
100+
- name: Run core tests
101+
run: |
102+
.venv\Scripts\activate.ps1
103+
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
104+
${{ env.TRITON_TEST_CMD }} --core
105+
106+
- name: Run interpreter tests
107+
run: |
108+
.venv\Scripts\activate.ps1
109+
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
110+
${{ env.TRITON_TEST_CMD }} --interpreter
111+
112+
- name: Pass rate
113+
run: |
114+
.venv\Scripts\activate.ps1
115+
pip install defusedxml
116+
bash -c "\
117+
source ./scripts/capture-hw-details.sh; \
118+
python scripts/pass_rate.py --reports reports ${{ env.SKIPLIST }}; \
119+
python scripts/pass_rate.py --reports reports --json ${{ env.SKIPLIST }} > pass_rate.json; \
120+
python scripts/pass_rate.py --reports reports --suite tutorials --json ${{ env.SKIPLIST }} > pass_rate_tutorials.json; \
121+
"
122+
123+
- name: Upload pass rate report
124+
# upload reports only for the default branch
125+
if: github.ref_name == 'main'
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: pass_rate
129+
path: pass_rate*.json
130+
131+
- name: Clean up workspace
132+
if: ${{ always() }}
133+
run: |
134+
Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore
135+
136+
- name: Clean up temporary files
137+
shell: bash
138+
run: |
139+
rm -rf rm -rf /tmp/triton-* /tmp/tmp*

scripts/pytest-utils.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pytest() {
4949
fi
5050

5151
export TEST_UNSKIP
52-
python3 -u -m pytest "${pytest_extra_args[@]}" "$@" || $TRITON_TEST_IGNORE_ERRORS
52+
python -u -m pytest "${pytest_extra_args[@]}" "$@" || $TRITON_TEST_IGNORE_ERRORS
5353
}
5454

5555
run_tutorial_test() {
@@ -66,9 +66,9 @@ run_tutorial_test() {
6666
fi
6767

6868
if [[ $TRITON_TEST_REPORTS = true ]]; then
69-
RUN_TUTORIAL="python3 -u $SCRIPTS_DIR/run_tutorial.py --reports $TRITON_TEST_REPORTS_DIR $1.py"
69+
RUN_TUTORIAL="python -u $SCRIPTS_DIR/run_tutorial.py --reports $TRITON_TEST_REPORTS_DIR $1.py"
7070
else
71-
RUN_TUTORIAL="python3 -u $1.py"
71+
RUN_TUTORIAL="python -u $1.py"
7272
fi
7373

7474
if [[ $TUTORIAL_RESULT = TODO ]]; then

scripts/test-triton.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ if [ "$TEST_UNIT" = false ] && [ "$TEST_CORE" = false ] && [ "$TEST_INTERPRETER"
131131
fi
132132

133133
if [ "$VENV" = true ]; then
134-
source .venv/bin/activate
134+
if [[ $OSTYPE = msys ]]; then
135+
source .venv/Scripts/activate
136+
else
137+
source .venv/bin/activate
138+
fi
135139
fi
136140

137141

0 commit comments

Comments
 (0)