-
Notifications
You must be signed in to change notification settings - Fork 6
365 lines (317 loc) · 12.7 KB
/
Copy pathnightly-wheels.yml
File metadata and controls
365 lines (317 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
name: Build Triton XDNA Wheels
on:
pull_request:
workflow_dispatch:
inputs:
TRITON_XDNA_COMMIT:
description: 'Commit hash to build (leave empty for HEAD)'
type: string
required: false
default: ''
push:
tags:
- 'v*.*.*'
merge_group:
schedule:
# Daily at 04:00 UTC (see https://crontab.guru)
- cron: '0 4 * * *'
defaults:
run:
shell: bash
concurrency:
# Cancel in-progress runs for same PR or commit
group: ci-build-wheels-${{ github.event.number || github.sha }}
cancel-in-progress: true
jobs:
check-changes:
name: Check for new commits
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
outputs:
has_new_commits: ${{ steps.check.outputs.has_new_commits }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for commits in last 24 hours
id: check
run: |
# Check if there are any commits in the last 25 hours
# (25h instead of 24h to add a buffer for cron scheduling jitter)
RECENT_COMMITS=$(git log --oneline --since="25 hours ago" HEAD)
if [ -z "$RECENT_COMMITS" ]; then
echo "No new commits in the last 25 hours. Skipping wheel build."
echo "has_new_commits=false" >> $GITHUB_OUTPUT
else
echo "New commits found:"
echo "$RECENT_COMMITS"
echo "has_new_commits=true" >> $GITHUB_OUTPUT
fi
build-wheels:
name: Build triton wheel (Python ${{ matrix.python_version }})
needs: [check-changes]
if: >-
always() &&
(needs.check-changes.result == 'skipped' ||
needs.check-changes.outputs.has_new_commits == 'true')
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: read
strategy:
fail-fast: false
matrix:
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Free disk space
uses: descriptinc/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: false
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: recursive
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Get commit info
id: commit-info
run: |
if [ -n "${{ inputs.TRITON_XDNA_COMMIT }}" ]; then
COMMIT="${{ inputs.TRITON_XDNA_COMMIT }}"
else
COMMIT=$(git rev-parse --short=7 HEAD)
fi
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
echo "datetime=$(date +%Y%m%d%H)" >> $GITHUB_OUTPUT
echo "Building triton-xdna commit: $COMMIT"
- name: Install cibuildwheel
run: |
pip install --upgrade pip
pip install cibuildwheel
- name: Build wheels with cibuildwheel
env:
TRITON_XDNA_PROJECT_COMMIT: ${{ steps.commit-info.outputs.commit }}
DATETIME: ${{ steps.commit-info.outputs.datetime }}
TRITON_BUILD_WITH_CLANG_LLD: "true"
run: |
# Convert python version (e.g., "3.11" -> "cp311")
PY_VERSION="${{ matrix.python_version }}"
CIBW_BUILD="cp${PY_VERSION//./}-manylinux_x86_64"
echo "Building for: $CIBW_BUILD"
# Build wheel using cibuildwheel
CIBW_BUILD="$CIBW_BUILD" cibuildwheel --platform linux --output-dir wheelhouse
- name: List built wheels
run: |
ls -la wheelhouse/
echo "Built wheels:"
ls wheelhouse/*.whl
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: triton-wheel-py${{ matrix.python_version }}
path: wheelhouse/*.whl
build-wheels-windows:
name: Build triton wheel Windows (Python ${{ matrix.python_version }})
needs: [check-changes]
if: >-
always() &&
(needs.check-changes.result == 'skipped' ||
needs.check-changes.outputs.has_new_commits == 'true')
runs-on: windows-latest
permissions:
id-token: write
contents: write
packages: read
strategy:
fail-fast: false
matrix:
# Python matrix is narrower than Linux: Xilinx publishes mlir-air
# Windows wheels only for cp310/cp311/cp312 (no cp313/cp314).
python_version: ["3.10", "3.11", "3.12"]
env:
# Pinned XRT Windows SDK release. Provides headers, xrt_coreutil.lib,
# and xclbinutil/aiebu-asm. The build expects the SDK at
# C:\Program Files\AMD\xrt (see utils/env_setup.ps1).
XRT_WINDOWS_SDK_URL: "https://github.com/Xilinx/XRT/releases/download/2.21.75/xrt_windows_sdk.zip"
steps:
- name: Disable Git CRLF conversion
# Must run before checkout. windows-latest defaults to
# core.autocrlf=true, which rewrites text files to CRLF on
# checkout. The third_party/triton_shared.patch hunks were
# generated with LF context lines, so the rewrite makes
# `git apply --check` fail and apply_patches.py aborts —
# the build then dies with a C2397 narrowing-conversion
# error in PtrAnalysis.cpp that the patch was supposed to
# fix. Forcing LF avoids the conversion entirely.
shell: bash
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: recursive
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Get commit info
id: commit-info
run: |
if [ -n "${{ inputs.TRITON_XDNA_COMMIT }}" ]; then
COMMIT="${{ inputs.TRITON_XDNA_COMMIT }}"
else
COMMIT=$(git rev-parse --short=7 HEAD)
fi
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
echo "datetime=$(date +%Y%m%d%H)" >> $GITHUB_OUTPUT
echo "Building triton-xdna commit: $COMMIT"
- name: Install XRT Windows SDK
shell: pwsh
run: |
Write-Host "Downloading $env:XRT_WINDOWS_SDK_URL"
Invoke-WebRequest -Uri $env:XRT_WINDOWS_SDK_URL -OutFile xrt_windows_sdk.zip
# Zip layout is xrt_sdk/xrt/{include,lib,...}; extract to a temp
# location and move the inner xrt/ folder to where the build
# expects it (C:\Program Files\AMD\xrt).
$tempDir = Join-Path $env:RUNNER_TEMP "xrt_extract"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
Expand-Archive -Path xrt_windows_sdk.zip -DestinationPath $tempDir -Force
$srcXrt = Join-Path $tempDir "xrt_sdk\xrt"
if (-not (Test-Path $srcXrt)) {
Write-Error "Unexpected SDK zip layout: $srcXrt not found"
exit 1
}
New-Item -ItemType Directory -Force -Path "C:\Program Files\AMD" | Out-Null
Move-Item -Path $srcXrt -Destination "C:\Program Files\AMD\xrt" -Force
$hdr = "C:\Program Files\AMD\xrt\include\xrt\xrt_bo.h"
if (-not (Test-Path $hdr)) {
Write-Error "XRT SDK extraction failed: $hdr not found"
exit 1
}
Write-Host "XRT SDK installed at C:\Program Files\AMD\xrt"
Remove-Item xrt_windows_sdk.zip
Remove-Item -Recurse -Force $tempDir
- name: Set up MSVC developer environment
# cibuildwheel doesn't activate vcvars on Windows; without this step
# cmake fails with "Could not find compiler set in environment
# variable CXX: cl.exe" because PATH/INCLUDE/LIB aren't populated.
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Install cibuildwheel
# Use `python -m pip` instead of `pip` because Windows can't replace
# the running pip.exe wrapper while it holds the file open.
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel
- name: Build wheels with cibuildwheel
env:
TRITON_XDNA_PROJECT_COMMIT: ${{ steps.commit-info.outputs.commit }}
DATETIME: ${{ steps.commit-info.outputs.datetime }}
XILINX_XRT: "C:\\Program Files\\AMD\\xrt"
run: |
# Convert python version (e.g., "3.11" -> "cp311")
PY_VERSION="${{ matrix.python_version }}"
CIBW_BUILD="cp${PY_VERSION//./}-win_amd64"
echo "Building for: $CIBW_BUILD"
CIBW_BUILD="$CIBW_BUILD" cibuildwheel --platform windows --output-dir wheelhouse
- name: List built wheels
run: |
ls -la wheelhouse/
echo "Built wheels:"
ls wheelhouse/*.whl
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: triton-wheel-windows-py${{ matrix.python_version }}
path: wheelhouse/*.whl
publish-release:
name: Publish wheels to GitHub release
needs: [build-wheels, build-wheels-windows]
# Run after both build matrices finish, regardless of partial failures —
# publish whatever wheels did build. Skipped on pull_request / merge_group
# to avoid mutating release tags from non-mainline events.
if: |
always() &&
(
github.event_name == 'workflow_dispatch' ||
github.event_name == 'schedule' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
) &&
(
needs.build-wheels.result == 'success' ||
needs.build-wheels-windows.result == 'success'
)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get commit info
id: commit-info
run: |
if [ -n "${{ inputs.TRITON_XDNA_COMMIT }}" ]; then
COMMIT="${{ inputs.TRITON_XDNA_COMMIT }}"
else
COMMIT=$(git rev-parse --short=7 HEAD)
fi
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
echo "datetime=$(date +%Y%m%d%H)" >> $GITHUB_OUTPUT
- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: triton-wheel-*
merge-multiple: true
path: wheelhouse
- name: List collected wheels
run: |
ls -la wheelhouse/
echo "Wheel count: $(ls wheelhouse/*.whl 2>/dev/null | wc -l)"
- name: Publish release
uses: ncipollo/release-action@v1.12.0
with:
artifacts: wheelhouse/*.whl
token: "${{ secrets.GITHUB_TOKEN }}"
tag: ${{ github.event_name == 'push' && github.ref_name || 'latest-wheels' }}
name: ${{ github.event_name == 'push' && github.ref_name || 'Nightly Wheels' }}
body: |
## Triton XDNA Wheels
**Commit:** ${{ steps.commit-info.outputs.commit }}
**Build Date:** ${{ steps.commit-info.outputs.datetime }}
Linux wheels: Python 3.10–3.14 (manylinux_x86_64)
Windows wheels: Python 3.10–3.12 (win_amd64)
### Installation (Linux)
```bash
pip install triton-xdna \
--find-links https://github.com/${{ github.repository }}/releases/expanded_assets/latest-wheels \
--find-links https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-no-rtti-2 \
--find-links https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly \
--find-links https://github.com/Xilinx/mlir-air/releases/expanded_assets/latest-air-wheels-no-rtti
```
### Installation (Windows)
```powershell
pip install triton-xdna `
--find-links https://github.com/${{ github.repository }}/releases/expanded_assets/latest-wheels `
--find-links https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-no-rtti-2 `
--find-links https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly `
--find-links https://github.com/Xilinx/mlir-air/releases/expanded_assets/latest-air-wheels-no-rtti
```
allowUpdates: true
replacesArtifacts: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
makeLatest: ${{ github.event_name == 'push' }}
prerelease: ${{ github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/') }}