Skip to content

Commit 118f6ed

Browse files
pbchekingshimansky
andauthored
[CI] Workflow to build and test Triton on Windows (#3075)
Adding initial workflow to run some tests on Windows+A770 daily. Currently tutorials, instrumentation and e2e tests are skipped. Separate workflows to build and test on Windows: * `build-windows.yml` - runs on every PR, builds only. * `build-test-windows.yml` - runs daily, builds and tests. --------- Signed-off-by: Gregory Shimansky <[email protected]> Co-authored-by: Gregory Shimansky <[email protected]>
1 parent 18b8b75 commit 118f6ed

File tree

3 files changed

+114
-25
lines changed

3 files changed

+114
-25
lines changed
Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
name: Build on Windows
1+
name: Build and test on Windows
22

33
on:
44
workflow_dispatch:
5-
6-
pull_request:
7-
branches:
8-
- main
9-
- release/**
10-
push:
11-
branches:
12-
- main
13-
- release/**
5+
schedule:
6+
- cron: "1 5 * * *"
147

158
permissions: read-all
169

1710
env:
1811
NEW_WORKSPACE: C:\gh${{ github.run_id }}
12+
ZE_PATH: C:\level_zero
13+
PYTEST_MAX_PROCESSES: 8
14+
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
1915

2016
jobs:
2117
build:
22-
name: Build
23-
runs-on: avc336
18+
name: Build and test
19+
runs-on: win-a770
2420
steps:
2521
- name: Enable long paths
2622
run: |
@@ -29,7 +25,7 @@ jobs:
2925
- name: Checkout repository
3026
uses: actions/checkout@v4
3127

32-
- name: Install Python
28+
- name: Setup Python
3329
uses: actions/setup-python@v5
3430
with:
3531
python-version: '3.9'
@@ -39,25 +35,47 @@ jobs:
3935
run: |
4036
Copy-Item -Path ${{ github.workspace }} -Destination ${{ env.NEW_WORKSPACE }} -Recurse
4137
38+
- name: PyTorch version
39+
run: |
40+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
41+
python -c 'import torch;print(torch.__version__)'
42+
4243
# We need ninja >= 1.12.0 to support long names on Windows. At the moment there is no required
4344
# version in pypi, so instead of installing ninja with pip we use a preinstalled 1.12.1 on the
4445
# runner.
45-
- name: Build Triton
46+
- name: Setup Triton
4647
run: |
4748
cd ${{ env.NEW_WORKSPACE }}
49+
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
50+
cd python
51+
pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1'
52+
pip install -v --no-build-isolation '.[build,tests,tutorials]'
4853
49-
cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 && set' | ForEach-Object {
50-
if ($_ -match '^(.*?)=(.*)$') {
51-
[Environment]::SetEnvironmentVariable($matches[1], $matches[2])
52-
}
53-
}
54+
- name: Triton version
55+
run: |
56+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
57+
python -c 'import triton; print(triton.__version__)'
5458
55-
cd python
56-
pip install -U wheel pybind11 certifi cython cmake setuptools>=65.6.1
57-
python -m certifi
58-
pip install -v --no-build-isolation '.[build]'
59+
- name: Install test dependencies
60+
run: |
61+
pip install -r scripts\requirements-test.txt
62+
63+
- name: Run core tests
64+
run: |
65+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
66+
${{ env.TRITON_TEST_CMD }} --core
67+
68+
- name: Run interpreter tests
69+
run: |
70+
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
71+
${{ env.TRITON_TEST_CMD }} --interpreter
72+
73+
- name: Pass rate
74+
run: |
75+
pip install defusedxml
76+
python scripts/pass_rate.py --reports reports --skip-list scripts/skiplist/a770
5977
60-
- name: Clean
78+
- name: Clean up workspace
6179
if: ${{ always() }}
6280
run: |
6381
Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build on Windows
2+
3+
on:
4+
workflow_dispatch:
5+
6+
pull_request:
7+
branches:
8+
- main
9+
- release/**
10+
push:
11+
branches:
12+
- main
13+
- release/**
14+
15+
permissions: read-all
16+
17+
env:
18+
NEW_WORKSPACE: C:\gh${{ github.run_id }}
19+
20+
jobs:
21+
build:
22+
name: Build
23+
runs-on: avc336
24+
steps:
25+
- name: Enable long paths
26+
run: |
27+
git config --system core.longPaths true
28+
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Install Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.9'
36+
37+
# Copy workspace to a temporary location with a shorter name.
38+
- name: Copy workspace
39+
run: |
40+
Copy-Item -Path ${{ github.workspace }} -Destination ${{ env.NEW_WORKSPACE }} -Recurse
41+
42+
# We need ninja >= 1.12.0 to support long names on Windows. At the moment there is no required
43+
# version in pypi, so instead of installing ninja with pip we use a preinstalled 1.12.1 on the
44+
# runner.
45+
- name: Build Triton
46+
run: |
47+
cd ${{ env.NEW_WORKSPACE }}
48+
49+
cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 && set' | ForEach-Object {
50+
if ($_ -match '^(.*?)=(.*)$') {
51+
[Environment]::SetEnvironmentVariable($matches[1], $matches[2])
52+
}
53+
}
54+
55+
cd python
56+
pip install -U wheel pybind11 certifi cython cmake setuptools>=65.6.1
57+
python -m certifi
58+
pip install -v --no-build-isolation '.[build]'
59+
60+
- name: Clean
61+
if: ${{ always() }}
62+
run: |
63+
Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore

python/triton/runtime/cache.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,15 @@ def put(self, data, filename, binary=True) -> str:
131131
f.write(data)
132132
# Replace is guaranteed to be atomic on POSIX systems if it succeeds
133133
# so filepath cannot see a partial write
134-
os.replace(temp_path, filepath)
134+
try:
135+
os.replace(temp_path, filepath)
136+
except PermissionError:
137+
# Ignore PermissionError on Windows because it happens when another process already
138+
# put a file into the cache and locked it by opening it.
139+
if os.name == "nt":
140+
os.remove(temp_path)
141+
else:
142+
raise
135143
os.removedirs(temp_dir)
136144
return filepath
137145

0 commit comments

Comments
 (0)