Skip to content

Commit 936ab65

Browse files
authored
Build air wheels (#1230)
* Bump mlir-aie version to match a valid wheel * Initial commit of mlir-air wheel building workflow * Switch to using a ubuntu ryzenai docker image * Switch to using a generic manylinux imange for building the air wheels * Fixup undeclared variable BUILD_DIR * Fixup no-rtti wheel naming format
1 parent 4823625 commit 936ab65

File tree

6 files changed

+512
-1
lines changed

6 files changed

+512
-1
lines changed
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Copyright (C) 2025, Advanced Micro Devices, Inc.
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Build mlir-air Wheels
5+
6+
on:
7+
pull_request:
8+
workflow_dispatch:
9+
inputs:
10+
AIR_COMMIT:
11+
description: 'AIR commit to build'
12+
type: string
13+
required: false
14+
default: ''
15+
push:
16+
tags:
17+
- 'v*.*.*'
18+
schedule:
19+
- cron: '0 4 * * *' # Daily at 4 AM
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
25+
concurrency:
26+
group: ci-build-air-wheels-${{ github.event.number || github.sha }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
build-repo:
31+
name: Build and upload mlir_air wheels
32+
33+
runs-on: ubuntu-latest
34+
35+
permissions:
36+
id-token: write
37+
contents: write
38+
packages: read
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
- python_version: "3.10"
45+
ENABLE_RTTI: ON
46+
47+
- python_version: "3.10"
48+
ENABLE_RTTI: OFF
49+
50+
- python_version: "3.11"
51+
ENABLE_RTTI: ON
52+
53+
- python_version: "3.11"
54+
ENABLE_RTTI: OFF
55+
56+
- python_version: "3.12"
57+
ENABLE_RTTI: ON
58+
59+
- python_version: "3.12"
60+
ENABLE_RTTI: OFF
61+
62+
- python_version: "3.13"
63+
ENABLE_RTTI: ON
64+
65+
- python_version: "3.13"
66+
ENABLE_RTTI: OFF
67+
68+
- python_version: "3.14"
69+
ENABLE_RTTI: ON
70+
71+
- python_version: "3.14"
72+
ENABLE_RTTI: OFF
73+
74+
steps:
75+
- name: Free disk space
76+
uses: descriptinc/free-disk-space@main
77+
with:
78+
tool-cache: true
79+
android: true
80+
dotnet: true
81+
haskell: true
82+
large-packages: true
83+
swap-storage: false
84+
85+
- uses: actions/checkout@v4
86+
with:
87+
submodules: "true"
88+
89+
- uses: uraimo/[email protected]
90+
name: Build mlir-air
91+
id: runcmd
92+
with:
93+
distro: none
94+
arch: none
95+
base_image: quay.io/pypa/manylinux_2_34_x86_64:latest
96+
githubToken: ${{ github.token }}
97+
env: |
98+
AIR_WHEEL_VERSION: ${{ (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) && github.ref_name || '""' }}
99+
run: |
100+
git config --global --add safe.directory $PWD
101+
AIR_VERSION=$(git rev-parse --short HEAD)
102+
echo "Building mlir-air version $AIR_VERSION"
103+
104+
if ! command -v python${{ matrix.python_version }} &> /dev/null; then
105+
echo "Python ${{ matrix.python_version }} not found, installing..."
106+
yum update -y
107+
yum install -y yum-utils
108+
yum install -y python${{ matrix.python_version }} python${{ matrix.python_version }}-devel
109+
fi
110+
111+
yum install -y ninja-build clang lld zip unzip binutils
112+
113+
python${{ matrix.python_version }} -m venv ${{ github.workspace }}/air-venv
114+
source ${{ github.workspace }}/air-venv/bin/activate
115+
116+
pip install -r utils/requirements.txt
117+
EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX=aie pip install -r utils/requirements_extras.txt
118+
119+
export ENABLE_RTTI=${{ matrix.ENABLE_RTTI }}
120+
121+
NO_RTTI=""
122+
NO_RTTI_UNDERSCORE=""
123+
NO_RTTI_DOT=""
124+
if [ x"$ENABLE_RTTI" == x"OFF" ]; then
125+
NO_RTTI="-no-rtti"
126+
NO_RTTI_UNDERSCORE="_no_rtti"
127+
NO_RTTI_DOT=".no.rtti"
128+
MLIR_AIE_WHEELS_URL="https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-no-rtti"
129+
else
130+
MLIR_AIE_WHEELS_URL="https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-2/"
131+
fi
132+
133+
VERSION=$(utils/clone-llvm.sh --get-wheel-version)
134+
pip -q download --no-deps "mlir$NO_RTTI==$VERSION" \
135+
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro
136+
unzip -q mlir*.whl
137+
find mlir$NO_RTTI_UNDERSCORE -exec touch -a -m -t 201108231405.14 {} \;
138+
export MLIR_INSTALL_ABS_PATH=$PWD/mlir$NO_RTTI_UNDERSCORE
139+
140+
MLIR_AIE_VERSION=$(utils/clone-mlir-aie.sh --get-wheel-version)
141+
pip -q download --no-deps --platform manylinux_2_35_x86_64 "mlir_aie==${MLIR_AIE_VERSION}${NO_RTTI_DOT}" \
142+
-f "$MLIR_AIE_WHEELS_URL"
143+
unzip -q mlir_aie*.whl
144+
export MLIR_AIE_INSTALL_PATH=$PWD/mlir_aie
145+
146+
export MLIR_AIR_SOURCE_DIR=$PWD
147+
export WHEELHOUSE_DIR=$PWD/wheelhouse
148+
if [ x"${{ inputs.AIR_COMMIT }}" == x"" ]; then
149+
export AIR_PROJECT_COMMIT=$AIR_VERSION
150+
else
151+
AIR_VERSION="${{ inputs.AIR_COMMIT }}"
152+
export AIR_PROJECT_COMMIT=${AIR_VERSION:0:7}
153+
fi
154+
export DATETIME=$(date +"%Y%m%d%H")
155+
156+
rm -rf $WHEELHOUSE_DIR/mlir_air*.whl
157+
rm -rf $WHEELHOUSE_DIR/repaired_wheel/*
158+
159+
pushd utils/mlir_air_wheels
160+
161+
pip install setuptools wheel auditwheel patchelf importlib_metadata
162+
CIBW_ARCHS=x86_64 pip wheel . -v -w $WHEELHOUSE_DIR --no-build-isolation
163+
164+
popd
165+
166+
auditwheel repair -w $WHEELHOUSE_DIR/repaired_wheel $WHEELHOUSE_DIR/mlir_air*.whl --plat manylinux_2_35_x86_64 --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
167+
168+
- name: Upload mlir_air
169+
uses: actions/upload-artifact@v4
170+
with:
171+
path: wheelhouse/mlir_air*whl
172+
name: mlir_air_rtti_${{ matrix.ENABLE_RTTI }}-${{ matrix.python_version }}
173+
174+
- name: Release
175+
if: |
176+
github.event_name == 'workflow_dispatch' ||
177+
github.event_name == 'schedule' ||
178+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
179+
uses: ncipollo/[email protected]
180+
with:
181+
artifacts: wheelhouse/mlir_air*whl
182+
token: "${{ secrets.GITHUB_TOKEN }}"
183+
tag: ${{ github.event_name == 'push' && github.ref_name || (matrix.ENABLE_RTTI == 'ON' && 'latest-air-wheels' || 'latest-air-wheels-no-rtti') }}
184+
name: ${{ github.event_name == 'push' && github.ref_name || (matrix.ENABLE_RTTI == 'ON' && 'latest-air-wheels' || 'latest-air-wheels-no-rtti') }}
185+
allowUpdates: true
186+
replacesArtifacts: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
187+
makeLatest: ${{ github.event_name == 'push' }}

utils/clone-mlir-aie.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
##===----------------------------------------------------------------------===##
1616

1717
export HASH=e952e58d8c1ec7c2759696318731527de8dcc0b5
18-
DATETIME=2025122104
18+
DATETIME=2025122304
1919
WHEEL_VERSION=0.0.1.$DATETIME+${HASH:0:7}
2020

2121
if [ x"$1" == x--get-wheel-version ]; then

utils/mlir_air_wheels/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build artifacts
2+
build/
3+
dist/
4+
wheelhouse/
5+
*.egg-info/
6+
7+
# Downloaded dependencies
8+
mlir/
9+
mlir_no_rtti/
10+
mlir_aie/
11+
mlir-*.whl
12+
mlir_aie*.whl
13+
14+
# Python cache
15+
__pycache__/
16+
*.pyc
17+
*.pyo
18+
19+
# ccache
20+
.ccache/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[project]
2+
name = "mlir-air"
3+
description = "MLIR-based toolchain for spatial accelerators"
4+
readme = { text = """MLIR AIR provides MLIR-based infrastructure for
5+
programming spatial accelerators.""", content-type = "text/markdown" }
6+
dynamic = ["dependencies", "requires-python", "version", "license"]
7+
authors = [
8+
{ name="AMD Inc." },
9+
]
10+
11+
[project.urls]
12+
"Homepage" = "https://github.com/Xilinx/mlir-air"
13+
14+
[build-system]
15+
requires = ["setuptools>=61.0", "nanobind>=2.9"]
16+
build-backend = "setuptools.build_meta"
17+
18+
[project.scripts]
19+
air-opt = "air.tools:air_opt"
20+
air-translate = "air.tools:air_translate"
21+
aircc = "air.compiler.aircc.main:main"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
PyYAML>=6.0.2
2+
aiofiles
3+
filelock==3.13.1
4+
lit
5+
joblib
6+
ipykernel
7+
psutil
8+
rich
9+
pybind11
10+
nanobind>=2.9
11+
numpy
12+
cmake>=3.30
13+
ml_dtypes

0 commit comments

Comments
 (0)