Skip to content

Commit

Permalink
Build mlir-aie wheels with python versions (#2054)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgmelber authored Feb 20, 2025
1 parent b89b5d6 commit 4b3f3ac
Showing 1 changed file with 126 additions and 119 deletions.
245 changes: 126 additions & 119 deletions .github/workflows/buildRyzenWheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ jobs:
contents: write
packages: read

strategy:
fail-fast: false
matrix:
python_version: [
"3.10", "3.12",
]

steps:
- name: Free disk space
uses: descriptinc/free-disk-space@main
Expand Down Expand Up @@ -69,7 +76,7 @@ jobs:
MLIR_VERSION=$(git rev-parse --short HEAD)
echo "Building mlir-aie version $MLIR_VERSION"
python -m venv ${{ github.workspace }}/aie-venv
python${{ matrix.python_version }} -m venv ${{ github.workspace }}/aie-venv
source ${{ github.workspace }}/aie-venv/bin/activate
echo "Installing vitis_aie_essentials ..."
Expand Down Expand Up @@ -108,14 +115,14 @@ jobs:
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_float16_utils.so
WHL_FN=$(ls $WHEELHOUSE_DIR/repaired_wheel/mlir_aie*whl)
mv "$WHL_FN" "`echo $WHL_FN | sed "s/cp310-cp310/py3-none/"`"
# WHL_FN=$(ls $WHEELHOUSE_DIR/repaired_wheel/mlir_aie*whl)
# mv "$WHL_FN" "`echo $WHL_FN | sed "s/cp310-cp310/py3-none/"`"
- name: Upload mlir_aie
uses: actions/upload-artifact@v4
with:
path: wheelhouse/repaired_wheel/mlir_aie*whl
name: mlir_aie
name: mlir_aie-${{ matrix.python_version }}

- name: Release current commit
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
Expand All @@ -130,118 +137,118 @@ jobs:
replacesArtifacts: true
makeLatest: true

build-wheel:
name: Build wheel
runs-on: ubuntu-latest
needs: build-repo

permissions:
id-token: write
contents: write
packages: read

strategy:
fail-fast: false
matrix:
python_version: [
"3.10", "3.12",
]

steps:
- name: Get the project repository
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: "true"

- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: mlir_aie
path: .

- uses: uraimo/[email protected]
name: Build mlir-aie python bindings
id: runcmd
with:
distro: none
arch: none
base_image: ghcr.io/xilinx/mlir-aie/ubuntu22-ryzenai-1.3.0ea:1.1
githubToken: ${{ github.token }}
dockerRunArgs: |
--mac-address 02:42:ac:11:00:02
env: |
VITIS: ${{ env.VITIS }}
XILINXD_LICENSE_FILE: ${{ env.XILINXD_LICENSE_FILE }}
run: |
git config --global --add safe.directory $PWD
MLIR_VERSION=$(git rev-parse --short HEAD)
echo "Building mlir-aie version $MLIR_VERSION ..."
# faster to do this twice instead of upload the directory with ~4000 files in it...
VERSION=$(utils/clone-llvm.sh --get-wheel-version)
pip -q download mlir==$VERSION \
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro
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 -exec touch -a -m -t 201108231405.14 {} \;
unzip -q mlir_aie-*.whl
find mlir_aie -exec touch -a -m -t 201108231405.14 {} \;
python${{ matrix.python_version }} -m venv aie-venv
source aie-venv/bin/activate
pip install -r python/requirements.txt
HOST_MLIR_PYTHON_PACKAGE_PREFIX=aie pip install -r python/requirements_extras.txt
source aie-venv/bin/activate
export MLIR_INSTALL_ABS_PATH=$PWD/mlir
export MLIR_AIE_INSTALL_ABS_PATH=$PWD/mlir_aie
export WHEELHOUSE_DIR=$PWD/wheelhouse
export CMAKE_MODULE_PATH=$PWD/cmake/modulesXilinx
export PATH=$VITIS/bin:$VITIS/aietools/bin:$PATH
export XRT_ROOT=/opt/xilinx/xrt
export AIE_PROJECT_COMMIT=$MLIR_VERSION
export DATETIME=$(date +"%Y%m%d%H")
cp python/requirements.txt utils/mlir_aie_wheels/python_bindings
pushd utils/mlir_aie_wheels/python_bindings
pip install wheel auditwheel patchelf
CIBW_ARCHS=x86_64 pip wheel . -v -w $WHEELHOUSE_DIR --no-build-isolation
DEBUG=1 CIBW_ARCHS=x86_64 pip wheel . -v -w $WHEELHOUSE_DIR --no-build-isolation
popd
auditwheel repair -w $WHEELHOUSE_DIR/repaired_wheel $WHEELHOUSE_DIR/aie_python_bindings*whl --plat manylinux_2_35_x86_64
- uses: geekyeggo/delete-artifact@v5
if: github.event_name == 'pull_request'
with:
name: mlir_aie

- name: Upload wheels
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
uses: actions/upload-artifact@v4
with:
path: wheelhouse/repaired_wheel/aie_python_bindings*.whl
name: ryzen_ai_wheel-python-${{ matrix.python_version }}

- name: Release current commit
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
uses: ncipollo/[email protected]
with:
artifacts: wheelhouse/repaired_wheel/aie_python_bindings*.whl
token: "${{ secrets.GITHUB_TOKEN }}"
tag: 'latest-wheels'
name: 'latest-wheels'
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true
# build-wheel:
# name: Build wheel
# runs-on: ubuntu-latest
# needs: build-repo
#
# permissions:
# id-token: write
# contents: write
# packages: read
#
# strategy:
# fail-fast: false
# matrix:
# python_version: [
# "3.10", "3.12",
# ]
#
# steps:
# - name: Get the project repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 2
# submodules: "true"
#
# - uses: actions/download-artifact@v4
# with:
# # unpacks default artifact into dist/
# # if `name: artifact` is omitted, the action will create extra parent dir
# name: mlir_aie
# path: .
#
# - uses: uraimo/[email protected]
# name: Build mlir-aie python bindings
# id: runcmd
# with:
# distro: none
# arch: none
# base_image: ghcr.io/xilinx/mlir-aie/ubuntu22-ryzenai-1.3.0ea:1.1
# githubToken: ${{ github.token }}
# dockerRunArgs: |
# --mac-address 02:42:ac:11:00:02
# env: |
# VITIS: ${{ env.VITIS }}
# XILINXD_LICENSE_FILE: ${{ env.XILINXD_LICENSE_FILE }}
# run: |
# git config --global --add safe.directory $PWD
# MLIR_VERSION=$(git rev-parse --short HEAD)
# echo "Building mlir-aie version $MLIR_VERSION ..."
#
# # faster to do this twice instead of upload the directory with ~4000 files in it...
# VERSION=$(utils/clone-llvm.sh --get-wheel-version)
# pip -q download mlir==$VERSION \
# -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro
# 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 -exec touch -a -m -t 201108231405.14 {} \;
#
# unzip -q mlir_aie-*.whl
# find mlir_aie -exec touch -a -m -t 201108231405.14 {} \;
#
# python${{ matrix.python_version }} -m venv aie-venv
# source aie-venv/bin/activate
#
# pip install -r python/requirements.txt
# HOST_MLIR_PYTHON_PACKAGE_PREFIX=aie pip install -r python/requirements_extras.txt
# source aie-venv/bin/activate
#
# export MLIR_INSTALL_ABS_PATH=$PWD/mlir
# export MLIR_AIE_INSTALL_ABS_PATH=$PWD/mlir_aie
# export WHEELHOUSE_DIR=$PWD/wheelhouse
# export CMAKE_MODULE_PATH=$PWD/cmake/modulesXilinx
#
# export PATH=$VITIS/bin:$VITIS/aietools/bin:$PATH
# export XRT_ROOT=/opt/xilinx/xrt
# export AIE_PROJECT_COMMIT=$MLIR_VERSION
# export DATETIME=$(date +"%Y%m%d%H")
#
# cp python/requirements.txt utils/mlir_aie_wheels/python_bindings
#
# pushd utils/mlir_aie_wheels/python_bindings
#
# pip install wheel auditwheel patchelf
# CIBW_ARCHS=x86_64 pip wheel . -v -w $WHEELHOUSE_DIR --no-build-isolation
# DEBUG=1 CIBW_ARCHS=x86_64 pip wheel . -v -w $WHEELHOUSE_DIR --no-build-isolation
#
# popd
#
# auditwheel repair -w $WHEELHOUSE_DIR/repaired_wheel $WHEELHOUSE_DIR/aie_python_bindings*whl --plat manylinux_2_35_x86_64
#
# - uses: geekyeggo/delete-artifact@v5
# if: github.event_name == 'pull_request'
# with:
# name: mlir_aie
#
# - name: Upload wheels
# if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
# uses: actions/upload-artifact@v4
# with:
# path: wheelhouse/repaired_wheel/aie_python_bindings*.whl
# name: ryzen_ai_wheel-python-${{ matrix.python_version }}
#
# - name: Release current commit
# if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
# uses: ncipollo/[email protected]
# with:
# artifacts: wheelhouse/repaired_wheel/aie_python_bindings*.whl
# token: "${{ secrets.GITHUB_TOKEN }}"
# tag: 'latest-wheels'
# name: 'latest-wheels'
# removeArtifacts: false
# allowUpdates: true
# replacesArtifacts: true
# makeLatest: true

0 comments on commit 4b3f3ac

Please sign in to comment.