Okapi-dog/iron

Python

0

56 commits

updated Sep 23, 2026

See the code

README

🦾 - IRON: Unlocking the Full Potential of NPUs - 🦾

Discord Latest Release GitHub downloads Iron Tests PRs Welcome license: Apache Code style: black

IRONCLAD Logo

IRON is an open-source & close-to-metal Python API enabling fast and efficient execution on AMD Ryzenβ„’ AI NPUs. It relies on language bindings around the MLIR-AIE dialect.

The IRON Python API for Ryzenβ„’ AI NPUs is described in the following paper:

E. Hunhoff, J. Melber, K. Denolf, A. Bisca, S. Bayliss, S. Neuendorffer, J. Fifield, J. Lo, P. Vasireddy, P. James-Roxby, E. Keller. "Efficiency, Expressivity, and Extensibility in a Close-to-Metal NPU Programming Interface". In 33rd IEEE International Symposium On Field-Programmable Custom Computing Machines, May 2025.

🎯 Operator Dashboard

SectionDescriptionDatatypeAIE2AIE2PStatusDesign Example
Element-wise AddElement-wise addition kernelbfloat16βœ“βœ“πŸŸ’example/elementwise_add/
Element-wise MulElement-wise multiplication kernelbfloat16βœ“βœ“πŸŸ’example/elementwise_mul/
GEMMGeneral Matrix Multiplication kernelbfloat16βœ“βœ“πŸŸ’example/gemm/
GEMVGeneral Matrix-Vector Multiplication kernelbfloat16βœ“βœ“πŸŸ’example/matrix_vector_mul/
GQAGrouped Query Attention kernel (Single pipeline)bfloat16βœ“πŸŸ’example/mha/
MHAMulti-Head Attention kernel & Grouped Query Attentionbfloat16βœ“πŸŸ’example/mha/
RMSNormRMSNorm kernelbfloat16βœ“βœ“πŸŸ’example/rms_norm/
RoPERotary Positional Embedding kernelbfloat16βœ“βœ“πŸŸ’example/rope/
SiLUSigmoid Linear Unit activation kernelbfloat16βœ“βœ“πŸŸ’example/silu/
SoftmaxSoftmax kernelbfloat16βœ“βœ“πŸŸ’example/softmax/
Weighted RMSNormWeighted RMSNorm kernelbfloat16βœ“βœ“πŸŸ’example/rms_norm/
CopyCopybfloat16βœ“βœ“πŸŸ’example/mem_copy/
TransposeTransposebfloat16βœ“βœ“πŸŸ’example/transpose/
AXPYAXPYbfloat16βœ“βœ“πŸŸ’example/axpy/
ReductionReductionbfloat16🟑
DequantDequant Q4NX from AWQ to bfloat16bfloat16βœ“βœ“πŸŸ’example/dequant/
RELURELUbfloat16βœ“βœ“πŸŸ’example/relu/
Leaky RELU (WIP)Leaky RELU kernelbfloat16βœ“βšͺexample/leaky_relu/
GELUGELUbfloat16βœ“βœ“πŸŸ’example/gelu/
LayerNormLayerNormbfloat16βœ“βœ“πŸŸ’example/layer_norm/
ConvolutionConvolutionbfloat16🟑
MaxPoolMaxPoolbfloat16βšͺ
AveragePoolAveragePoolbfloat16βšͺ
TanhTanh kernelbfloat16βœ“βœ“πŸŸ’example/tanh/
SigmoidSigmoid kernelbfloat16βœ“βœ“πŸŸ’example/sigmoid/

Use this dashboard to quickly check the status of each kernel and locate relevant setup, build, and usage information.

πŸ“Œ Legend

StatusMeaning
🟒Done
🟑In Development
βšͺNot Assigned

Installation (Linux)

These instructions will guide you through everything required for building and executing a program on the Ryzenβ„’ AI NPU, starting from a fresh bare-bones Ubuntu 24.04 or Ubuntu 24.10 install.

Initial Setup

Be sure you have the latest BIOS on your laptop or mini-PC that enables the NPU. See here.

If starting from Ubuntu 24.04 you may need to update the Linux kernel to 6.11+ by installing the Hardware Enablement (HWE) stack:

sudo apt update
sudo apt install --install-recommends linux-generic-hwe-24.04
sudo reboot
  1. Install XDNAβ„’ Driver and XRT:

    Instructions from mlir-aie repository

  2. Install the packages needed for IRON and MLIR-AIE:

    # Python versions 3.10, 3.12 and 3.13 are currently supported by our wheels
    sudo apt install \
    build-essential clang clang-14 lld lld-14 python3-venv python3-pip
    
  3. Setup a virtual environment and activate it:

    python3 -m venv ironenv
    source ironenv/bin/activate
    python3 -m pip install --upgrade pip
    
  4. Source XRT (installed in step 1):

    source /opt/xilinx/xrt/setup.sh
    
  5. Install required Python packages (from requirements.txt):

    MLIR_PYTHON_EXTRAS_SET_VERSION="0.0.8.3" HOST_MLIR_PYTHON_PACKAGE_PREFIX="aie" pip install -r requirements.txt
    
  6. To test your installation, you can try to build and run the example below:

    ./operators/axpy/test.py
    

Building/Using & Testing Operators

All available operators can be found in operators. These each contain:

  • op.py: The Python operator interface -- an easy access point to integrate operators into your project that prescribes how to compile the operator (build artifacts) and how to call it at runtime (buffer sizes, etc.)
  • design.py: The implementation of the operator's NPU code. Often references a kernel in aie_kernels for the compute core code and describes the data movement using ObjectFIFOs.
  • reference.py: A reference CPU implementation to validate the correctness of the NPU implementation.
  • test.py: An end-to-end test that instantiates and builds the operator, runs it and verifies its outputs against the reference.

NOTE: Be sure the XRT setup script has been sourced and the Python environment is activated: source /opt/xilinx/xrt/setup.sh source /path/to/ironenv/bin/activate

To build and test all the operators:

pytest operators/ -m "not extensive"

To run the extensive test suite:

pytest operators/

To run a specific operator's tests:

pytest operators/axpy/

To ensure your code passes CI linting checks before pushing, install the pre-push hook:

cp scripts/hooks/pre-push .git/hooks/pre-push
chmod +x .git/hooks/pre-push

The hook will run the same linting checks as CI:

  • License checks (reuse)
  • Python formatting (black)
  • C++ formatting (clang-format)

To bypass the hook if needed: git push --no-verify


CopyrightΒ© 2025 Advanced Micro Devices, Inc

Contributors

Okapi-dog

27 commits

andrej

12 commits

kurtis-b-1

10 commits

hunhoffe

5 commits

Okapi-dog/iron

Python

0

56 commits

updated Sep 23, 2026

See the code

README

🦾 - IRON: Unlocking the Full Potential of NPUs - 🦾

Discord Latest Release GitHub downloads Iron Tests PRs Welcome license: Apache Code style: black

IRONCLAD Logo

IRON is an open-source & close-to-metal Python API enabling fast and efficient execution on AMD Ryzenβ„’ AI NPUs. It relies on language bindings around the MLIR-AIE dialect.

The IRON Python API for Ryzenβ„’ AI NPUs is described in the following paper:

E. Hunhoff, J. Melber, K. Denolf, A. Bisca, S. Bayliss, S. Neuendorffer, J. Fifield, J. Lo, P. Vasireddy, P. James-Roxby, E. Keller. "Efficiency, Expressivity, and Extensibility in a Close-to-Metal NPU Programming Interface". In 33rd IEEE International Symposium On Field-Programmable Custom Computing Machines, May 2025.

🎯 Operator Dashboard

SectionDescriptionDatatypeAIE2AIE2PStatusDesign Example
Element-wise AddElement-wise addition kernelbfloat16βœ“βœ“πŸŸ’example/elementwise_add/
Element-wise MulElement-wise multiplication kernelbfloat16βœ“βœ“πŸŸ’example/elementwise_mul/
GEMMGeneral Matrix Multiplication kernelbfloat16βœ“βœ“πŸŸ’example/gemm/
GEMVGeneral Matrix-Vector Multiplication kernelbfloat16βœ“βœ“πŸŸ’example/matrix_vector_mul/
GQAGrouped Query Attention kernel (Single pipeline)bfloat16βœ“πŸŸ’example/mha/
MHAMulti-Head Attention kernel & Grouped Query Attentionbfloat16βœ“πŸŸ’example/mha/
RMSNormRMSNorm kernelbfloat16βœ“βœ“πŸŸ’example/rms_norm/
RoPERotary Positional Embedding kernelbfloat16βœ“βœ“πŸŸ’example/rope/
SiLUSigmoid Linear Unit activation kernelbfloat16βœ“βœ“πŸŸ’example/silu/
SoftmaxSoftmax kernelbfloat16βœ“βœ“πŸŸ’example/softmax/
Weighted RMSNormWeighted RMSNorm kernelbfloat16βœ“βœ“πŸŸ’example/rms_norm/
CopyCopybfloat16βœ“βœ“πŸŸ’example/mem_copy/
TransposeTransposebfloat16βœ“βœ“πŸŸ’example/transpose/
AXPYAXPYbfloat16βœ“βœ“πŸŸ’example/axpy/
ReductionReductionbfloat16🟑
DequantDequant Q4NX from AWQ to bfloat16bfloat16βœ“βœ“πŸŸ’example/dequant/
RELURELUbfloat16βœ“βœ“πŸŸ’example/relu/
Leaky RELU (WIP)Leaky RELU kernelbfloat16βœ“βšͺexample/leaky_relu/
GELUGELUbfloat16βœ“βœ“πŸŸ’example/gelu/
LayerNormLayerNormbfloat16βœ“βœ“πŸŸ’example/layer_norm/
ConvolutionConvolutionbfloat16🟑
MaxPoolMaxPoolbfloat16βšͺ
AveragePoolAveragePoolbfloat16βšͺ
TanhTanh kernelbfloat16βœ“βœ“πŸŸ’example/tanh/
SigmoidSigmoid kernelbfloat16βœ“βœ“πŸŸ’example/sigmoid/

Use this dashboard to quickly check the status of each kernel and locate relevant setup, build, and usage information.

πŸ“Œ Legend

StatusMeaning
🟒Done
🟑In Development
βšͺNot Assigned

Installation (Linux)

These instructions will guide you through everything required for building and executing a program on the Ryzenβ„’ AI NPU, starting from a fresh bare-bones Ubuntu 24.04 or Ubuntu 24.10 install.

Initial Setup

Be sure you have the latest BIOS on your laptop or mini-PC that enables the NPU. See here.

If starting from Ubuntu 24.04 you may need to update the Linux kernel to 6.11+ by installing the Hardware Enablement (HWE) stack:

sudo apt update
sudo apt install --install-recommends linux-generic-hwe-24.04
sudo reboot
  1. Install XDNAβ„’ Driver and XRT:

    Instructions from mlir-aie repository

  2. Install the packages needed for IRON and MLIR-AIE:

    # Python versions 3.10, 3.12 and 3.13 are currently supported by our wheels
    sudo apt install \
    build-essential clang clang-14 lld lld-14 python3-venv python3-pip
    
  3. Setup a virtual environment and activate it:

    python3 -m venv ironenv
    source ironenv/bin/activate
    python3 -m pip install --upgrade pip
    
  4. Source XRT (installed in step 1):

    source /opt/xilinx/xrt/setup.sh
    
  5. Install required Python packages (from requirements.txt):

    MLIR_PYTHON_EXTRAS_SET_VERSION="0.0.8.3" HOST_MLIR_PYTHON_PACKAGE_PREFIX="aie" pip install -r requirements.txt
    
  6. To test your installation, you can try to build and run the example below:

    ./operators/axpy/test.py
    

Building/Using & Testing Operators

All available operators can be found in operators. These each contain:

  • op.py: The Python operator interface -- an easy access point to integrate operators into your project that prescribes how to compile the operator (build artifacts) and how to call it at runtime (buffer sizes, etc.)
  • design.py: The implementation of the operator's NPU code. Often references a kernel in aie_kernels for the compute core code and describes the data movement using ObjectFIFOs.
  • reference.py: A reference CPU implementation to validate the correctness of the NPU implementation.
  • test.py: An end-to-end test that instantiates and builds the operator, runs it and verifies its outputs against the reference.

NOTE: Be sure the XRT setup script has been sourced and the Python environment is activated: source /opt/xilinx/xrt/setup.sh source /path/to/ironenv/bin/activate

To build and test all the operators:

pytest operators/ -m "not extensive"

To run the extensive test suite:

pytest operators/

To run a specific operator's tests:

pytest operators/axpy/

To ensure your code passes CI linting checks before pushing, install the pre-push hook:

cp scripts/hooks/pre-push .git/hooks/pre-push
chmod +x .git/hooks/pre-push

The hook will run the same linting checks as CI:

  • License checks (reuse)
  • Python formatting (black)
  • C++ formatting (clang-format)

To bypass the hook if needed: git push --no-verify


CopyrightΒ© 2025 Advanced Micro Devices, Inc

Contributors

Okapi-dog

27 commits

andrej

12 commits

kurtis-b-1

10 commits

hunhoffe

5 commits

Languages

Python

72.1%

C++

18.7%

MLIR

7.4%