-
Notifications
You must be signed in to change notification settings - Fork 183
521 lines (441 loc) · 17.6 KB
/
buildRyzenWheels.yml
File metadata and controls
521 lines (441 loc) · 17.6 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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
name: Build wheels for Ryzen AI
on:
pull_request:
workflow_dispatch:
inputs:
AIE_COMMIT:
description: 'AIE commit to build'
type: string
required: false
default: ''
push:
tags:
- 'v*.*.*'
merge_group:
schedule:
# At 04:00. (see https://crontab.guru)
- cron: '0 4 * * *'
defaults:
run:
shell: bash
concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-ryzenai-experimental-${{ github.event.number || github.sha }}
cancel-in-progress: true
env:
DEBIAN_FRONTEND: noninteractive
VITIS: /opt/ryzen_ai-1.3.0/vitis_aie_essentials
XILINXD_LICENSE_FILE: /opt/xilinx/Xilinx.lic
PIP_RETRIES: "3"
PIP_RESUME_RETRIES: "3"
PIP_TIMEOUT: "60"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
jobs:
build-repo:
name: Build and upload mlir_aie wheels
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: read
strategy:
fail-fast: false
matrix:
include:
- python_version: "3.11"
ENABLE_RTTI: ON
- python_version: "3.11"
ENABLE_RTTI: OFF
- python_version: "3.12"
ENABLE_RTTI: ON
- python_version: "3.12"
ENABLE_RTTI: OFF
- python_version: "3.13"
ENABLE_RTTI: ON
- python_version: "3.13"
ENABLE_RTTI: OFF
- python_version: "3.14"
ENABLE_RTTI: ON
- python_version: "3.14"
ENABLE_RTTI: OFF
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
- uses: actions/checkout@v6
with:
submodules: "true"
fetch-depth: 0
fetch-tags: true
- name: Compute wheel version on host
id: wheel_version
env:
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
if [[ "${REF_TYPE}" == "tag" && "${REF_NAME}" == v* ]]; then
VERSION="${REF_NAME#v}"
else
VERSION=$(AIE_WHEEL_KEEP_LOCAL=1 python utils/mlir_aie_wheels/_version_helper.py)
fi
if [[ -z "${VERSION}" ]]; then
echo "::error::computed wheel version is empty" >&2
exit 1
fi
if ! [[ "${VERSION}" =~ ^[A-Za-z0-9][A-Za-z0-9.+_-]*$ ]]; then
echo "::error::computed wheel version contains unexpected characters: ${VERSION}" >&2
exit 1
fi
echo "Computed AIE_WHEEL_VERSION=${VERSION}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
- uses: uraimo/run-on-arch-action@v3
name: Build mlir-aie
id: runcmd
with:
distro: none
arch: none
base_image: ghcr.io/xilinx/mlir-aie/ubuntu22-ryzenai-1.3.0ea:1.2
githubToken: ${{ github.token }}
dockerRunArgs: |
--mac-address 02:42:ac:11:00:02
env: |
VITIS: ${{ env.VITIS }}
XILINXD_LICENSE_FILE: ${{ env.XILINXD_LICENSE_FILE }}
PIP_RETRIES: ${{ env.PIP_RETRIES }}
PIP_RESUME_RETRIES: ${{ env.PIP_RESUME_RETRIES }}
PIP_TIMEOUT: ${{ env.PIP_TIMEOUT }}
PIP_DISABLE_PIP_VERSION_CHECK: ${{ env.PIP_DISABLE_PIP_VERSION_CHECK }}
AIE_WHEEL_VERSION: ${{ steps.wheel_version.outputs.version }}
run: |
git config --global --add safe.directory $PWD
MLIR_VERSION=$(git rev-parse --short HEAD)
echo "Building mlir-aie version $MLIR_VERSION"
if ! command -v python${{ matrix.python_version }} &> /dev/null; then
echo "Python ${{ matrix.python_version }} not found, installing..."
apt-get update
apt-get install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update
apt-get install -y python${{ matrix.python_version }} python${{ matrix.python_version }}-venv python${{ matrix.python_version }}-dev
fi
python${{ matrix.python_version }} -m venv ${{ github.workspace }}/aie-venv
source ${{ github.workspace }}/aie-venv/bin/activate
echo "Installing vitis_aie_essentials ..."
pushd /opt
tar xfz /workspace/vaie.tgz
popd
pip install --upgrade pip
pip install -r python/requirements_ml.txt
pip install -r python/requirements_dev.txt
export ENABLE_RTTI=${{ matrix.ENABLE_RTTI }}
NO_RTTI="" # Set a default value
NO_RTTI_UNDERSCORE="" # Set a default value
if [ x"$ENABLE_RTTI" == x"OFF" ]; then
NO_RTTI="-no-rtti"
NO_RTTI_UNDERSCORE="_no_rtti"
fi
VERSION=$(utils/clone-llvm.sh --get-wheel-version)
for attempt in 1 2 3; do
rm -f mlir*.whl
if pip -q download mlir$NO_RTTI==$VERSION \
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro; then
break
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to download MLIR wheel after ${attempt} attempts" >&2
exit 1
fi
sleep $((attempt * 5))
done
unzip -q mlir*.whl
# I have no clue why but the system clock on GHA containers is like 12 hours ahead.
# That means wheels have file with time stamps in the future which makes ninja loop
# forever when configuring. Set the time to some arbitrary stamp in the past just to be safe.
find mlir$NO_RTTI_UNDERSCORE -exec touch -a -m -t 201108231405.14 {} \;
export PATH=$VITIS/bin:$VITIS/aietools/bin:$PATH
export MLIR_INSTALL_ABS_PATH=$PWD/mlir$NO_RTTI_UNDERSCORE
export MLIR_AIE_SOURCE_DIR=$PWD
export WHEELHOUSE_DIR=$PWD/wheelhouse
export CMAKE_MODULE_PATH=$PWD/cmake/modulesXilinx
export XRT_ROOT=/opt/xilinx/xrt
if [ x"${{ inputs.AIE_COMMIT }}" == x"" ]; then
export AIE_PROJECT_COMMIT=$MLIR_VERSION
else
export AIE_PROJECT_COMMIT="${{ inputs.AIE_COMMIT }}"
export AIE_PROJECT_COMMIT="${AIE_PROJECT_COMMIT:0:7}"
fi
export AIE_VITIS_COMPONENTS='AIE2;AIE2P'
export DATETIME=$(date +"%Y%m%d%H")
export AIE_WHEEL_KEEP_LOCAL=1
pushd utils/mlir_aie_wheels
pip install wheel auditwheel patchelf importlib_metadata
CIBW_ARCHS=x86_64 pip wheel . -v -w $WHEELHOUSE_DIR --no-build-isolation
popd
auditwheel repair -w $WHEELHOUSE_DIR/repaired_wheel $WHEELHOUSE_DIR/mlir_aie*.whl --plat manylinux_2_35_x86_64 --exclude libcdo_driver.so --exclude libmlir_async_runtime.so --exclude libmlir_c_runner_utils.so --exclude libmlir_float16_utils.so --exclude libmlir_runner_utils.so --exclude libmlir_apfloat_wrappers.so
- name: Upload mlir_aie
uses: actions/upload-artifact@v4
with:
path: wheelhouse/repaired_wheel/mlir_aie*whl
name: mlir_aie_rtti_${{ matrix.ENABLE_RTTI }}-${{ matrix.python_version }}
build-windows:
name: Build and upload mlir_aie wheels (Windows)
runs-on: windows-2022
permissions:
id-token: write
contents: write
packages: read
strategy:
fail-fast: false
matrix:
include:
- python_version: "3.11"
ENABLE_RTTI: ON
- python_version: "3.11"
ENABLE_RTTI: OFF
- python_version: "3.12"
ENABLE_RTTI: ON
- python_version: "3.12"
ENABLE_RTTI: OFF
- python_version: "3.13"
ENABLE_RTTI: ON
- python_version: "3.13"
ENABLE_RTTI: OFF
- python_version: "3.14"
ENABLE_RTTI: ON
- python_version: "3.14"
ENABLE_RTTI: OFF
steps:
- uses: actions/checkout@v6
with:
submodules: "true"
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
- name: Compute wheel version on host
id: wheel_version
shell: bash
env:
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
if [[ "${REF_TYPE}" == "tag" && "${REF_NAME}" == v* ]]; then
VERSION="${REF_NAME#v}"
else
VERSION=$(AIE_WHEEL_KEEP_LOCAL=1 python utils/mlir_aie_wheels/_version_helper.py)
fi
if [[ -z "${VERSION}" ]]; then
echo "::error::computed wheel version is empty" >&2
exit 1
fi
if ! [[ "${VERSION}" =~ ^[A-Za-z0-9][A-Za-z0-9.+_-]*$ ]]; then
echo "::error::computed wheel version contains unexpected characters: ${VERSION}" >&2
exit 1
fi
echo "Computed AIE_WHEEL_VERSION=${VERSION}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
- name: Set up MSVC dev environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
# We don't get OpenSSL for free on Windows. Manage the pain.
# Try vcpkg's GHA cache to avoid building OpenSSL for every matrix element.
- name: Enable vcpkg binary caching
uses: actions/github-script@v9
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL)
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN)
- name: Install OpenSSL
shell: pwsh
run: |
$vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT
if ($vcpkgRoot) {
$vcpkg = Join-Path $vcpkgRoot "vcpkg.exe"
} else {
$vcpkg = (Get-Command vcpkg.exe -ErrorAction Stop).Source
$vcpkgRoot = Split-Path -Parent $vcpkg
}
Remove-Item Env:VCPKG_ROOT -ErrorAction SilentlyContinue
$env:VCPKG_BINARY_SOURCES = "clear;x-gha,readwrite"
& $vcpkg install openssl:x64-windows-static
"OPENSSL_ROOT_DIR=$($vcpkgRoot.Replace('\','/'))/installed/x64-windows-static" |
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Stage XRT SDK
shell: pwsh
run: |
$url = 'https://github.com/Xilinx/XRT/releases/download/2.21.75/xrt_windows_sdk.zip'
for ($attempt = 1; $attempt -le 3; $attempt++) {
try {
Invoke-WebRequest -Uri $url -OutFile xrt_windows_sdk.zip
break
} catch {
if ($attempt -eq 3) { throw }
Start-Sleep -Seconds 5
}
}
Expand-Archive -Path xrt_windows_sdk.zip -DestinationPath xrt_windows_sdk -Force
New-Item -ItemType Directory -Path C:\Xilinx -Force | Out-Null
Copy-Item xrt_windows_sdk\xrt_sdk\xrt C:\Xilinx\XRT -Recurse -Force
"XRT_ROOT=C:/Xilinx/XRT" >> $env:GITHUB_ENV
- name: Build mlir-aie wheel
shell: bash
env:
AIE_WHEEL_VERSION: ${{ steps.wheel_version.outputs.version }}
ENABLE_RTTI: ${{ matrix.ENABLE_RTTI }}
CMAKE_GENERATOR: Ninja
CMAKE_ARGS: -DAIE_BUILD_CHESS_CLANG=OFF -DOPENSSL_USE_STATIC_LIBS=TRUE -DAIE_ENABLE_XRT_PYTHON_BINDINGS=OFF
run: |
set -euo pipefail
# No Vitis on Windows!
unset VITIS XILINXD_LICENSE_FILE || true
git config --global --add safe.directory "$PWD"
MLIR_VERSION=$(git rev-parse --short HEAD)
echo "Building mlir-aie version $MLIR_VERSION"
python -m venv aie-venv
source aie-venv/Scripts/activate
python -m pip install --upgrade pip
pip install -r python/requirements_ml.txt
pip install -r python/requirements_dev.txt
export ENABLE_RTTI="${ENABLE_RTTI}"
NO_RTTI="" # Set a default value
NO_RTTI_UNDERSCORE="" # Set a default value
if [ x"$ENABLE_RTTI" == x"OFF" ]; then
NO_RTTI="-no-rtti"
NO_RTTI_UNDERSCORE="_no_rtti"
fi
VERSION=$(utils/clone-llvm.sh --get-wheel-version)
# Grab the MLIR distro wheel and extract
for attempt in 1 2 3; do
rm -f mlir*.whl
if pip -q download "mlir${NO_RTTI}==${VERSION}" -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro; then
break
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to download MLIR wheel after ${attempt} attempts" >&2
exit 1
fi
sleep $((attempt * 5))
done
python -m zipfile -e mlir*.whl .
# Linux-style timestamp magic should work fine on Windows.
find "mlir${NO_RTTI_UNDERSCORE}" -exec touch -a -m -t 201108231405.14 {} \;
# Match Linux wheel version metadata on non-tag builds.
export DATETIME=$(date +"%Y%m%d%H")
if [ x"${{ inputs.AIE_COMMIT }}" == x"" ]; then
export AIE_PROJECT_COMMIT=$MLIR_VERSION
else
export AIE_PROJECT_COMMIT="${{ inputs.AIE_COMMIT }}"
export AIE_PROJECT_COMMIT="${AIE_PROJECT_COMMIT:0:7}"
fi
export AIE_VITIS_COMPONENTS='AIE2;AIE2P'
export AIE_WHEEL_KEEP_LOCAL=1
# Try to always forward slash paths.
ROOT_WIN=$(python -c "import os; print(os.getcwd().replace('\\\\', '/'))")
export MLIR_INSTALL_ABS_PATH="${ROOT_WIN}/mlir${NO_RTTI_UNDERSCORE}"
export MLIR_AIE_SOURCE_DIR="${ROOT_WIN}"
export WHEELHOUSE_DIR="${ROOT_WIN}/wheelhouse"
export CMAKE_MODULE_PATH="${ROOT_WIN}/cmake/modulesXilinx"
mkdir -p "${WHEELHOUSE_DIR}"
pushd utils/mlir_aie_wheels
pip install wheel importlib_metadata "ninja!=1.13.0"
CIBW_ARCHS=AMD64 pip wheel . -v -w "${WHEELHOUSE_DIR}" --no-build-isolation
popd
# Try to repair the wheel on Windows using delvewheel (closest auditwheel equivalent).
pip install delvewheel
python -m delvewheel repair --ignore-existing --analyze-existing-exes -w "${WHEELHOUSE_DIR}/repaired_wheel" "${WHEELHOUSE_DIR}"/mlir_aie*.whl
- name: Upload mlir_aie
uses: actions/upload-artifact@v4
with:
path: wheelhouse/repaired_wheel/mlir_aie*whl
name: mlir_aie_windows_rtti_${{ matrix.ENABLE_RTTI }}-${{ matrix.python_version }}
publish:
name: Publish wheels
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'schedule' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
needs: [build-repo, build-windows]
permissions:
contents: write
actions: read
steps:
- name: Download wheels (RTTI ON)
uses: actions/download-artifact@v4
with:
pattern: mlir_aie*_rtti_ON-*
path: wheels_on
merge-multiple: true
- name: Download wheels (RTTI OFF)
uses: actions/download-artifact@v4
with:
pattern: mlir_aie*_rtti_OFF-*
path: wheels_off
merge-multiple: true
- name: Flatten wheels (RTTI ON)
run: |
set -euo pipefail
mkdir -p wheels_on_flat
find wheels_on -name 'mlir_aie*whl' -exec cp -f {} wheels_on_flat/ \;
- name: Flatten wheels (RTTI OFF)
run: |
set -euo pipefail
mkdir -p wheels_off_flat
find wheels_off -name 'mlir_aie*whl' -exec cp -f {} wheels_off_flat/ \;
- name: Combine wheels
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
set -euo pipefail
mkdir -p wheels_all
cp wheels_on_flat/mlir_aie*whl wheels_all/
cp wheels_off_flat/mlir_aie*whl wheels_all/
- name: Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1.21.0
with:
artifacts: wheels_all/mlir_aie*whl
token: "${{ secrets.GITHUB_TOKEN }}"
tag: ${{ github.ref_name }}
name: ${{ github.ref_name }}
allowUpdates: true
replacesArtifacts: true
omitBodyDuringUpdate: true
makeLatest: true
- name: Release latest wheels (RTTI ON)
if: github.event_name != 'push'
uses: ncipollo/release-action@v1.21.0
with:
artifacts: wheels_on_flat/mlir_aie*whl
token: "${{ secrets.GITHUB_TOKEN }}"
tag: latest-wheels-3
name: latest-wheels-3
allowUpdates: true
replacesArtifacts: false
omitBodyDuringUpdate: true
makeLatest: false
- name: Release latest wheels (RTTI OFF)
if: github.event_name != 'push'
uses: ncipollo/release-action@v1.21.0
with:
artifacts: wheels_off_flat/mlir_aie*whl
token: "${{ secrets.GITHUB_TOKEN }}"
tag: latest-wheels-no-rtti-2
name: latest-wheels-no-rtti-2
allowUpdates: true
replacesArtifacts: false
omitBodyDuringUpdate: true
makeLatest: false