- β‘ open-xdna
- π Proven on silicon (every row measured, on a real Ryzen 7 8845HS)
- π Why this exists
- π§ The four fixes nobody documented together
- π Quick start
- 𧬠The flex: you can hand-write AIE kernels like AltiVec
- π Full benchmark log (by model)
- π The honest part
- πΊοΈ Does my chip have an XDNA1 NPU?
- π Related work β Elyan Labs
- πΌοΈ Multimodal: vision front-end on the NPU
- π License
- π Proven on silicon (every row measured, on a real Ryzen 7 8845HS)
Source snapshot of github.com/Scottcjn/open-xdna, also on GitLab with full history. Code only: nothing here runs on Hugging Face infrastructure.
β‘ open-xdna
Running AI on the AMD NPU that AMD says you can't.
The first-generation XDNA1 NPU β "Phoenix" / "Hawk Point" β in millions of Ryzen laptops, brought up on Linux with 100% open source. Models running on the silicon. Custom vector kernels hand-authored in the AIE ISA.
FastFlowLM and AMD Lemonade β the stacks everyone points to for "LLMs on the Ryzen AI NPU" β support XDNA2 only. If you own a Ryzen 7040 / 8040 laptop, AMD's answer for your NPU on Linux is "not available β use the GPU."
open-xdnais the answer that says "here's how."
$ xrt-smi examine
[0000:06:00.1] RyzenAI-npu1 aie2 6x5 β the chip they left behind, alive on Linux
π Proven on silicon (every row measured, on a real Ryzen 7 8845HS)
| Milestone | Result |
|---|---|
| π Gen-1 NPU driven by fully open-source XRT + driver + firmware | β |
| β»οΈ Survives reboot + kernel updates (DKMS) | β |
βοΈ 512Β³ int16 matmul on the NPU |
β ~68 GFLOPS |
| π§ A real model's forward pass (2-layer MLP) on the NPU | β bit-exact |
| βοΈ Non-bijunctive collapse (keep-strong / prune-weak) | β prune 50β92% |
π οΈ Hand-authored AIE vector kernel (aie::ge+aie::select) |
β first compile |
π Fused reduce_maxβdynamic-Ο collapse in one kernel |
β data-adaptive |
π aie::reverse (vec_perm / shuffle) on the NPU |
β |
| π― Full collapse (reduce+threshold+compact) in one AIE kernel | β |
| π Measured FFN net-win (NPU prune β dense down_proj) | β 1.6Γ @ cos 0.998 |
| π² Attention KV-prune (NPU evicts low-mass keys) | β 4Γ @ cos 0.976 |
| πΌοΈ Vision pipeline (rgba2grayβ3Γ3 convβthreshold) on the NPU | β PASS β the NPU's native CNN strength |
| π§© SigLIP/ViT patch-embed wired on the NPU | β bit-exact (offload play; ~3.2Γ slower than CPU at base size β honest) |
π Why this exists
Hardware vendors retire silicon with software, not screwdrivers. AMD moved on to XDNA2 and told gen-1 owners the NPU "isn't available" for LLMs on Linux. The chip is fine. The driver's in the kernel. The compiler exists. What was missing was a recipe β so here's one, end to end, with receipts.
π§ The four fixes nobody documented together
Getting a kernel onto an XDNA1 NPU on a current Linux needs four non-obvious moves (full detail: docs/BRINGUP.md, error-string fixes in the FAQ):
- Install
libxrt_driver_xdna.so(not justlibvxdna.so) β elsexrt-smireports "0 devices found". - Load the matched staging
amdxdna.koβ mainline (β€6.17) lacks ioctls the SHIM needs. - Put
llvm-objcopyonPATHβ GNU objcopy can't parse the AIE2 ELF. - Match the NPU firmware β stale firmware aborts commands (
ERT_CMD_STATE_ABORT).
Upstream gap writeup:
docs/UPSTREAM_amdxdna_ioctls.mdβ mainlineamdxdna(β€6.17) is missing theGET_ARRAY/telemetry ioctls the current XRT SHIM expects (why fix #2 is needed).
π Quick start
bash scripts/setup_iron.sh # IRON/mlir-aie + Peano
sudo bash scripts/swap_driver.sh # matched staging driver
sudo bash scripts/install_firmware.sh 1.5.5.391 # matching NPU firmware
sudo bash scripts/run_example.sh basic/matrix_multiplication/single_core # 68 GFLOPS on the NPU
Run the hand-authored kernels:
python3 examples/npu_tiny_mlp.py # a model's matmuls on the NPU
python3 examples/npu_collapse_fused.py # fused reduce_max -> dynamic-tau collapse
python3 examples/npu_collapse_runtime.py # runtime-tau collapse (on-NPU aie::sub shift)
python3 examples/npu_shuffle_demo.py # aie::reverse (vec_perm) on the NPU
python3 examples/npu_pse_collapse.py # FULL collapse (reduce+threshold+compact) in ONE kernel
python3 examples/npu_ffn_prune.py # MEASURED FFN net-win + accuracy tradeoff
python3 examples/npu_attention_prune.py # MEASURED attention KV-prune (both GEMMs shrink)
python3 mlir-aie/programming_examples/vision/edge_detect/edge_detect.py -W 512 -H 512 # 2D conv vision pipeline on NPU
python3 examples/npu_patch_embed.py # SigLIP/ViT patch-embed on the NPU (measured, honest)
𧬠The flex: you can hand-write AIE kernels like AltiVec
The AIE2 vector ISA is the same primitive class as PowerPC AltiVec/VSX β just new mnemonics. The non-bijunctive collapse, hand-authored (examples/kernels/collapse.cc):
aie::vector<bfloat16,32> x = aie::load_v<32>(a + i); // vec_ld
aie::mask<32> keep = aie::ge(x, tau_v); // vec_cmpge β mask
aie::vector<bfloat16,32> out = aie::select(zero_v, x, keep); // vec_sel: keep ? x : 0
aie::store_v(c + i, out); // vec_st
Porting your own SIMD kernels? docs/ALTIVEC_TO_AIE.md maps the whole vocabulary.
π Full benchmark log (by model)
Every measurement, organized by model/architecture β what was tested, the result, measured-vs-projected: BENCHMARKS.md. Includes the honest negatives (gemma4 layer-prune net loss, vision offload-not-speed).
π The honest part
This is not a turnkey LLM server, and the NPU is not a fast matmul engine β measured, it's 6Γ slower than the integrated Radeon 780M at dense GEMM and loses on energy-per-GFLOP for dense work (6.6 W power floor** and cheap pruning/selection that lets a stronger device do less work. A prune-then-shrink FFN nets ~1.3β1.6Γ less work (not the naive 4Γ β you still pay the producer projection), gated on accuracy. We measure before we claim, and we mark every frontier.RESULTS.md). Its real value is a **
πΊοΈ Does my chip have an XDNA1 NPU?
lspci -d 1022:1502 β "AMD IPU Device" = yes. 7840HS/U Β· 8840HS/U Β· 8845HS Β· 7940HS Β· 8945HS Β· 7640HS/U Β· 8640HS Β· 8645HS Β· 8600G/8700G. (Desktop 8500G/8300G have no NPU β Zen4c die.)
π Related work β Elyan Labs
Heterogeneous-compute research (PSE non-bijunctive collapse, RAM coffers / NUMA weight banking, neuromorphic device routing) by Elyan Labs. See also ram-coffers Β· pse-vcipher-collapse.
πΌοΈ Multimodal: vision front-end on the NPU
The NPU was built for vision/CNN inference β a multimodal model's image tower (patch-embed convs, preprocessing) is a far better NPU fit than text decode. A full conv pipeline already runs on the NPU; see docs/VISION_OFFLOAD.md for the offload, and docs/MULTIMODAL_3WAY.md for the full 3-processor picture (incl gemma4:26b @ 16.5 tok/s on the 780M via 96 GB β a 17 GB model the 8 GB discrete can't hold).
π License
AGPLv3 (this repo's original work) β see LICENSE. A commercial / proprietary license (no copyleft) is available for closed-source or SaaS use: COMMERCIAL.md. AMD's XDNA/XRT and IRON/mlir-aie toolchains are Apache-2.0 WITH LLVM-exception and installed, not redistributed.