Skip to content

Commit

Permalink
[CI] Workflow to build and test Triton on Windows (#3075)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pbchekin and gshimansky authored Dec 28, 2024
1 parent 18b8b75 commit 118f6ed
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 25 deletions.
66 changes: 42 additions & 24 deletions .github/workflows/build-test-windows.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
name: Build on Windows
name: Build and test on Windows

on:
workflow_dispatch:

pull_request:
branches:
- main
- release/**
push:
branches:
- main
- release/**
schedule:
- cron: "1 5 * * *"

permissions: read-all

env:
NEW_WORKSPACE: C:\gh${{ github.run_id }}
ZE_PATH: C:\level_zero
PYTEST_MAX_PROCESSES: 8
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

jobs:
build:
name: Build
runs-on: avc336
name: Build and test
runs-on: win-a770
steps:
- name: Enable long paths
run: |
Expand All @@ -29,7 +25,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Python
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
Expand All @@ -39,25 +35,47 @@ jobs:
run: |
Copy-Item -Path ${{ github.workspace }} -Destination ${{ env.NEW_WORKSPACE }} -Recurse
- name: PyTorch version
run: |
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
python -c 'import torch;print(torch.__version__)'
# We need ninja >= 1.12.0 to support long names on Windows. At the moment there is no required
# version in pypi, so instead of installing ninja with pip we use a preinstalled 1.12.1 on the
# runner.
- name: Build Triton
- name: Setup Triton
run: |
cd ${{ env.NEW_WORKSPACE }}
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
cd python
pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1'
pip install -v --no-build-isolation '.[build,tests,tutorials]'
cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 && set' | ForEach-Object {
if ($_ -match '^(.*?)=(.*)$') {
[Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}
- name: Triton version
run: |
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
python -c 'import triton; print(triton.__version__)'
cd python
pip install -U wheel pybind11 certifi cython cmake setuptools>=65.6.1
python -m certifi
pip install -v --no-build-isolation '.[build]'
- name: Install test dependencies
run: |
pip install -r scripts\requirements-test.txt
- name: Run core tests
run: |
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
${{ env.TRITON_TEST_CMD }} --core
- name: Run interpreter tests
run: |
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
${{ env.TRITON_TEST_CMD }} --interpreter
- name: Pass rate
run: |
pip install defusedxml
python scripts/pass_rate.py --reports reports --skip-list scripts/skiplist/a770
- name: Clean
- name: Clean up workspace
if: ${{ always() }}
run: |
Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore
63 changes: 63 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build on Windows

on:
workflow_dispatch:

pull_request:
branches:
- main
- release/**
push:
branches:
- main
- release/**

permissions: read-all

env:
NEW_WORKSPACE: C:\gh${{ github.run_id }}

jobs:
build:
name: Build
runs-on: avc336
steps:
- name: Enable long paths
run: |
git config --system core.longPaths true
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

# Copy workspace to a temporary location with a shorter name.
- name: Copy workspace
run: |
Copy-Item -Path ${{ github.workspace }} -Destination ${{ env.NEW_WORKSPACE }} -Recurse
# We need ninja >= 1.12.0 to support long names on Windows. At the moment there is no required
# version in pypi, so instead of installing ninja with pip we use a preinstalled 1.12.1 on the
# runner.
- name: Build Triton
run: |
cd ${{ env.NEW_WORKSPACE }}
cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 && set' | ForEach-Object {
if ($_ -match '^(.*?)=(.*)$') {
[Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}
cd python
pip install -U wheel pybind11 certifi cython cmake setuptools>=65.6.1
python -m certifi
pip install -v --no-build-isolation '.[build]'
- name: Clean
if: ${{ always() }}
run: |
Remove-Item -LiteralPath ${{ env.NEW_WORKSPACE }} -Force -Recurse -ErrorAction Ignore
10 changes: 9 additions & 1 deletion python/triton/runtime/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,15 @@ def put(self, data, filename, binary=True) -> str:
f.write(data)
# Replace is guaranteed to be atomic on POSIX systems if it succeeds
# so filepath cannot see a partial write
os.replace(temp_path, filepath)
try:
os.replace(temp_path, filepath)
except PermissionError:
# Ignore PermissionError on Windows because it happens when another process already
# put a file into the cache and locked it by opening it.
if os.name == "nt":
os.remove(temp_path)
else:
raise
os.removedirs(temp_dir)
return filepath

Expand Down

0 comments on commit 118f6ed

Please sign in to comment.