Skip to content

Commit 93c8cc6

Browse files
authored
Merge pull request #64 from amd/add-windows-wheels-release
Add Windows wheel release job to nightly-wheels CI
2 parents 22c5a5a + dda86b9 commit 93c8cc6

5 files changed

Lines changed: 271 additions & 53 deletions

File tree

.github/workflows/nightly-wheels.yml

Lines changed: 200 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,192 @@ jobs:
139139
name: triton-wheel-py${{ matrix.python_version }}
140140
path: wheelhouse/*.whl
141141

142-
- name: Release wheels
143-
if: |
144-
github.event_name == 'workflow_dispatch' ||
145-
github.event_name == 'schedule' ||
146-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
142+
build-wheels-windows:
143+
name: Build triton wheel Windows (Python ${{ matrix.python_version }})
144+
needs: [check-changes]
145+
if: >-
146+
always() &&
147+
(needs.check-changes.result == 'skipped' ||
148+
needs.check-changes.outputs.has_new_commits == 'true')
149+
150+
runs-on: windows-latest
151+
152+
permissions:
153+
id-token: write
154+
contents: write
155+
packages: read
156+
157+
strategy:
158+
fail-fast: false
159+
matrix:
160+
# Python matrix is narrower than Linux: Xilinx publishes mlir-air
161+
# Windows wheels only for cp310/cp311/cp312 (no cp313/cp314).
162+
python_version: ["3.10", "3.11", "3.12"]
163+
164+
env:
165+
# Pinned XRT Windows SDK release. Provides headers, xrt_coreutil.lib,
166+
# and xclbinutil/aiebu-asm. The build expects the SDK at
167+
# C:\Program Files\AMD\xrt (see utils/env_setup.ps1).
168+
XRT_WINDOWS_SDK_URL: "https://github.com/Xilinx/XRT/releases/download/2.21.75/xrt_windows_sdk.zip"
169+
170+
steps:
171+
- name: Disable Git CRLF conversion
172+
# Must run before checkout. windows-latest defaults to
173+
# core.autocrlf=true, which rewrites text files to CRLF on
174+
# checkout. The third_party/triton_shared.patch hunks were
175+
# generated with LF context lines, so the rewrite makes
176+
# `git apply --check` fail and apply_patches.py aborts —
177+
# the build then dies with a C2397 narrowing-conversion
178+
# error in PtrAnalysis.cpp that the patch was supposed to
179+
# fix. Forcing LF avoids the conversion entirely.
180+
shell: bash
181+
run: |
182+
git config --global core.autocrlf false
183+
git config --global core.eol lf
184+
185+
- name: Checkout repository
186+
uses: actions/checkout@v4
187+
with:
188+
fetch-depth: 2
189+
submodules: recursive
190+
191+
- name: Set up Python ${{ matrix.python_version }}
192+
uses: actions/setup-python@v5
193+
with:
194+
python-version: ${{ matrix.python_version }}
195+
196+
- name: Get commit info
197+
id: commit-info
198+
run: |
199+
if [ -n "${{ inputs.TRITON_XDNA_COMMIT }}" ]; then
200+
COMMIT="${{ inputs.TRITON_XDNA_COMMIT }}"
201+
else
202+
COMMIT=$(git rev-parse --short=7 HEAD)
203+
fi
204+
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
205+
echo "datetime=$(date +%Y%m%d%H)" >> $GITHUB_OUTPUT
206+
echo "Building triton-xdna commit: $COMMIT"
207+
208+
- name: Install XRT Windows SDK
209+
shell: pwsh
210+
run: |
211+
Write-Host "Downloading $env:XRT_WINDOWS_SDK_URL"
212+
Invoke-WebRequest -Uri $env:XRT_WINDOWS_SDK_URL -OutFile xrt_windows_sdk.zip
213+
# Zip layout is xrt_sdk/xrt/{include,lib,...}; extract to a temp
214+
# location and move the inner xrt/ folder to where the build
215+
# expects it (C:\Program Files\AMD\xrt).
216+
$tempDir = Join-Path $env:RUNNER_TEMP "xrt_extract"
217+
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
218+
Expand-Archive -Path xrt_windows_sdk.zip -DestinationPath $tempDir -Force
219+
$srcXrt = Join-Path $tempDir "xrt_sdk\xrt"
220+
if (-not (Test-Path $srcXrt)) {
221+
Write-Error "Unexpected SDK zip layout: $srcXrt not found"
222+
exit 1
223+
}
224+
New-Item -ItemType Directory -Force -Path "C:\Program Files\AMD" | Out-Null
225+
Move-Item -Path $srcXrt -Destination "C:\Program Files\AMD\xrt" -Force
226+
$hdr = "C:\Program Files\AMD\xrt\include\xrt\xrt_bo.h"
227+
if (-not (Test-Path $hdr)) {
228+
Write-Error "XRT SDK extraction failed: $hdr not found"
229+
exit 1
230+
}
231+
Write-Host "XRT SDK installed at C:\Program Files\AMD\xrt"
232+
Remove-Item xrt_windows_sdk.zip
233+
Remove-Item -Recurse -Force $tempDir
234+
235+
- name: Set up MSVC developer environment
236+
# cibuildwheel doesn't activate vcvars on Windows; without this step
237+
# cmake fails with "Could not find compiler set in environment
238+
# variable CXX: cl.exe" because PATH/INCLUDE/LIB aren't populated.
239+
uses: ilammy/msvc-dev-cmd@v1
240+
with:
241+
arch: x64
242+
243+
- name: Install cibuildwheel
244+
# Use `python -m pip` instead of `pip` because Windows can't replace
245+
# the running pip.exe wrapper while it holds the file open.
246+
run: |
247+
python -m pip install --upgrade pip
248+
python -m pip install cibuildwheel
249+
250+
- name: Build wheels with cibuildwheel
251+
env:
252+
TRITON_XDNA_PROJECT_COMMIT: ${{ steps.commit-info.outputs.commit }}
253+
DATETIME: ${{ steps.commit-info.outputs.datetime }}
254+
XILINX_XRT: "C:\\Program Files\\AMD\\xrt"
255+
run: |
256+
# Convert python version (e.g., "3.11" -> "cp311")
257+
PY_VERSION="${{ matrix.python_version }}"
258+
CIBW_BUILD="cp${PY_VERSION//./}-win_amd64"
259+
echo "Building for: $CIBW_BUILD"
260+
261+
CIBW_BUILD="$CIBW_BUILD" cibuildwheel --platform windows --output-dir wheelhouse
262+
263+
- name: List built wheels
264+
run: |
265+
ls -la wheelhouse/
266+
echo "Built wheels:"
267+
ls wheelhouse/*.whl
268+
269+
- name: Upload wheel artifact
270+
uses: actions/upload-artifact@v4
271+
with:
272+
name: triton-wheel-windows-py${{ matrix.python_version }}
273+
path: wheelhouse/*.whl
274+
275+
publish-release:
276+
name: Publish wheels to GitHub release
277+
needs: [build-wheels, build-wheels-windows]
278+
# Run after both build matrices finish, regardless of partial failures —
279+
# publish whatever wheels did build. Skipped on pull_request / merge_group
280+
# to avoid mutating release tags from non-mainline events.
281+
if: |
282+
always() &&
283+
(
284+
github.event_name == 'workflow_dispatch' ||
285+
github.event_name == 'schedule' ||
286+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
287+
) &&
288+
(
289+
needs.build-wheels.result == 'success' ||
290+
needs.build-wheels-windows.result == 'success'
291+
)
292+
293+
runs-on: ubuntu-latest
294+
295+
permissions:
296+
contents: write
297+
298+
steps:
299+
- name: Checkout repository
300+
uses: actions/checkout@v4
301+
with:
302+
fetch-depth: 1
303+
304+
- name: Get commit info
305+
id: commit-info
306+
run: |
307+
if [ -n "${{ inputs.TRITON_XDNA_COMMIT }}" ]; then
308+
COMMIT="${{ inputs.TRITON_XDNA_COMMIT }}"
309+
else
310+
COMMIT=$(git rev-parse --short=7 HEAD)
311+
fi
312+
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
313+
echo "datetime=$(date +%Y%m%d%H)" >> $GITHUB_OUTPUT
314+
315+
- name: Download all wheel artifacts
316+
uses: actions/download-artifact@v4
317+
with:
318+
pattern: triton-wheel-*
319+
merge-multiple: true
320+
path: wheelhouse
321+
322+
- name: List collected wheels
323+
run: |
324+
ls -la wheelhouse/
325+
echo "Wheel count: $(ls wheelhouse/*.whl 2>/dev/null | wc -l)"
326+
327+
- name: Publish release
147328
uses: ncipollo/release-action@v1.12.0
148329
with:
149330
artifacts: wheelhouse/*.whl
@@ -155,9 +336,11 @@ jobs:
155336
156337
**Commit:** ${{ steps.commit-info.outputs.commit }}
157338
**Build Date:** ${{ steps.commit-info.outputs.datetime }}
158-
**Python Version:** ${{ matrix.python_version }}
159339
160-
### Installation
340+
Linux wheels: Python 3.10–3.14 (manylinux_x86_64)
341+
Windows wheels: Python 3.10–3.12 (win_amd64)
342+
343+
### Installation (Linux)
161344
162345
```bash
163346
pip install triton-xdna \
@@ -166,6 +349,16 @@ jobs:
166349
--find-links https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly \
167350
--find-links https://github.com/Xilinx/mlir-air/releases/expanded_assets/latest-air-wheels-no-rtti
168351
```
352+
353+
### Installation (Windows)
354+
355+
```powershell
356+
pip install triton-xdna `
357+
--find-links https://github.com/${{ github.repository }}/releases/expanded_assets/latest-wheels `
358+
--find-links https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-no-rtti `
359+
--find-links https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly `
360+
--find-links https://github.com/Xilinx/mlir-air/releases/expanded_assets/latest-air-wheels-no-rtti
361+
```
169362
allowUpdates: true
170363
replacesArtifacts: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
171364
makeLatest: ${{ github.event_name == 'push' }}

README.md

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ compilation pipeline (Triton → MLIR → xclbin → XRT dispatch) runs natively
129129

130130
- **Windows 10/11** (x64)
131131
- **Visual Studio 2022** with "Desktop development with C++" workload
132-
- **Python 3.12+**
132+
- **Python 3.10, 3.11, or 3.12** (Xilinx Windows wheels do not yet support 3.13+)
133133
- **CMake 3.20+** and **Ninja** (via pip or standalone)
134134
- **AMD NPU driver** (installs `xrt_coreutil.dll` runtime)
135135

@@ -147,52 +147,45 @@ pip install --upgrade pip setuptools wheel
147147

148148
Prepare XRT development files (headers, import library, xclbinutil). Download
149149
`xrt_windows_sdk.zip` from [Xilinx/XRT releases](https://github.com/Xilinx/XRT/releases)
150-
and extract the `xrt/` directory to `C:\Program Files\AMD\xrt`:
150+
and extract the inner `xrt_sdk/xrt/` directory (note the zip's top-level
151+
folder is `xrt_sdk/`) to `C:\Program Files\AMD\xrt`:
151152

152153
```powershell
153-
# The xrt/ folder inside the zip should end up at:
154+
# The contents of xrt_sdk/xrt/ inside the zip should end up at:
154155
# C:\Program Files\AMD\xrt\include\xrt\xrt_bo.h
155156
# C:\Program Files\AMD\xrt\lib\xrt_coreutil.lib
156157
```
157158

158-
Run the automated build:
159+
Run the automated environment setup (must be dot-sourced so PATH/env vars
160+
persist in the current shell):
159161

160162
```powershell
161-
.\utils\build_windows.ps1
163+
. .\utils\env_setup.ps1
162164
```
163165

164-
This installs pre-built wheels (triton-windows, mlir-aie, llvm-aie), builds mlir-air
165-
from source, and installs the Triton-XDNA backend. Takes approximately 30–60 minutes.
166+
This installs the pre-built wheels (`triton-windows`, `mlir-air[aie]` which
167+
transitively pulls `mlir-aie` and `llvm-aie`) and the Triton-XDNA backend.
166168

167169
### Windows Manual Build
168170

171+
Install build tools, PyTorch, and the MLIR-AIE/AIR/LLVM-AIE stack. The
172+
`mlir_air[aie]` extra transitively pins matching `mlir-aie` and pulls
173+
`llvm-aie`, so a single resolver pass installs the whole stack from the
174+
Xilinx release pages:
175+
169176
```powershell
170177
pip install cmake ninja lit numpy PyYAML nanobind scipy
171178
pip install torch --index-url https://download.pytorch.org/whl/cpu
172179
pip install triton-windows
173-
pip install mlir-aie -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-no-rtti
174-
pip install llvm-aie -f https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly
180+
pip install "mlir_air[aie]" `
181+
-f https://github.com/Xilinx/mlir-air/releases/expanded_assets/latest-air-wheels-no-rtti `
182+
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-no-rtti `
183+
-f https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly
175184
```
176185

177-
mlir-air must be built from source (no Windows wheels yet):
178-
179-
```powershell
180-
git clone https://github.com/Xilinx/mlir-air.git
181-
cd mlir-air
182-
git checkout <commit-from-utils/mlir-air-hash.txt>
183-
git submodule update --init --recursive
184-
185-
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release `
186-
-DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl `
187-
-DMLIR_DIR=<mlir-distro>/lib/cmake/mlir `
188-
-DLLVM_DIR=<mlir-distro>/lib/cmake/llvm `
189-
-DAIE_DIR=<mlir-aie-python-pkg>/lib/cmake/aie `
190-
-DLLVM_ENABLE_RTTI=OFF -DBUILD_SHARED_LIBS=OFF `
191-
-DAIR_RUNTIME_TARGETS="" -DAIR_ENABLE_GPU=OFF `
192-
-B build -S .
193-
ninja -C build -j $env:NUMBER_OF_PROCESSORS
194-
ninja -C build install
195-
```
186+
To pin a specific mlir-air version, use the values from
187+
`utils/mlir-air-hash.txt`:
188+
`mlir_air[aie]==<Version>.<Timestamp>+<short-commit>.no.rtti`.
196189

197190
Install Triton-XDNA:
198191

@@ -228,6 +221,7 @@ python vec-add.py
228221

229222
### Windows Known Limitations
230223

231-
- mlir-air must be built from source (no Windows wheels published)
224+
- Python 3.10, 3.11, and 3.12 only — Xilinx does not publish `mlir-air` /
225+
`mlir-aie` Windows wheels for 3.13+ yet
232226
- xclbinutil and aiebu-asm must be on PATH (from XRT Windows SDK)
233227
- NPU driver must be installed

scripts/apply_patches.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ def check_patch_applicable(patch_file: Path, target_dir: Path) -> tuple[bool, st
7777
Returns:
7878
(can_apply, reason) tuple
7979
"""
80+
# --ignore-whitespace tolerates CRLF/LF differences in context lines,
81+
# which matters on Windows where git checkout converts text files to
82+
# CRLF by default but our patches were generated with LF.
8083
result = run_git(
81-
["apply", "--check", str(patch_file)],
84+
["apply", "--check", "--ignore-whitespace", str(patch_file)],
8285
cwd=target_dir,
8386
check=False,
8487
)
@@ -88,7 +91,7 @@ def check_patch_applicable(patch_file: Path, target_dir: Path) -> tuple[bool, st
8891

8992
# Check if patch is already applied by trying reverse
9093
result_reverse = run_git(
91-
["apply", "--check", "--reverse", str(patch_file)],
94+
["apply", "--check", "--reverse", "--ignore-whitespace", str(patch_file)],
9295
cwd=target_dir,
9396
check=False,
9497
)
@@ -102,7 +105,7 @@ def check_patch_applicable(patch_file: Path, target_dir: Path) -> tuple[bool, st
102105
def apply_patch(patch_file: Path, target_dir: Path) -> bool:
103106
"""Apply a patch file to the target directory."""
104107
try:
105-
run_git(["apply", str(patch_file)], cwd=target_dir)
108+
run_git(["apply", "--ignore-whitespace", str(patch_file)], cwd=target_dir)
106109
return True
107110
except subprocess.CalledProcessError as e:
108111
print(f" ✗ Failed to apply patch: {e.stderr}", file=sys.stderr)

setup.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,14 @@ def download_llvm_for_triton_windows(triton_dir: Path) -> Path:
380380

381381
print(" Extracting...")
382382
with tarfile.open(download_path, "r:gz") as tar:
383-
tar.extractall(triton_dir.parent, filter="data")
383+
# filter="data" requires Python 3.12+ (PEP 706) or a backport
384+
# patch release (3.10.12+, 3.11.4+). cibuildwheel's bundled
385+
# nuget-cpython for 3.10/3.11 isn't always a backported version,
386+
# so guard the kwarg.
387+
if sys.version_info >= (3, 12):
388+
tar.extractall(triton_dir.parent, filter="data")
389+
else:
390+
tar.extractall(triton_dir.parent)
384391

385392
if not llvm_dir.exists():
386393
raise RuntimeError(f"Extracted LLVM directory not found: {llvm_dir}")
@@ -701,12 +708,21 @@ def _rename_package(self, unpack_dir: Path):
701708
new_lines.append("Name: triton-xdna\n")
702709
elif line.startswith("Version: "):
703710
new_lines.append(f"Version: {our_version}\n")
711+
elif line.startswith("Author: "):
712+
new_lines.append("Author: Erwei Wang\n")
713+
elif line.startswith("Author-email: "):
714+
new_lines.append("Author-email: erwei.wang@amd.com\n")
715+
elif line.startswith("Home-page: "):
716+
new_lines.append("Home-page: https://github.com/amd/Triton-XDNA\n")
704717
else:
705718
new_lines.append(line)
706719

707720
with open(metadata_path, "w") as f:
708721
f.writelines(new_lines)
709-
print(" Updated Name and Version in METADATA", file=sys.stderr)
722+
print(
723+
" Updated Name/Version/Author/Author-email/Home-page in METADATA",
724+
file=sys.stderr,
725+
)
710726

711727
# Update WHEEL file if needed (usually doesn't need changes)
712728
wheel_path = new_dist_info / "WHEEL"

0 commit comments

Comments
 (0)