FastFlowLM / Q4NX build for AMD XDNA 2 NPU (63.6 tok/s @ 2–4W on Strix Halo & Point)

#5
by julianmb - opened

Hi OpenBMB team & community,

We wanted to share an unofficial native port of openbmb/MiniCPM5-2B running entirely on the AMD XDNA 2 NPU (/dev/accel/accel0) via AMD FastFlowLM.


Performance on AMD Hardware (Ryzen AI Max+ 395 / Strix Halo & Strix Point)

  • Sustained Decode: 63.1 – 63.6 tok/s on XDNA 2 (no GPU/CPU decode required)
  • Prefill Speed (TTFT): 81.5 – 128.1 tok/s (~420 ms TTFT)
  • Active Power: ~2–4 W (leaves the 45–65W iGPU and 16 CPU cores completely idle/free)
  • Footprint: ~1.88 GB in NPU memory (Q4_1 / Q4NX format)
  • Accuracy & Reasoning: Tested across multi-step math reasoning, Python bug fixing, and structured JSON output with zero degradation compared to baseline.

How We Solved the GQA Firmware Incompatibility

MiniCPM5-2B uses 16 Query heads and 2 Key/Value heads (16:2 = 8:1 GQA ratio). AMD FastFlowLM's AIE firmware currently lacks a native 8:1 kernel for d_head=128:

  1. 4x KV Head Replication: We replicated the 2 KV heads 4x along dimension 0 into 8 KV heads (16:8 = 2:1 GQA ratio). Under Grouped Query Attention, this maintains exact bit-for-bit mathematical equivalence while matching the native _gen_mha_seq_d128_q2 AIE kernel.
  2. Qwen3 Runtime Engine Routing: Routed execution through FastFlowLM's Qwen3 engine (libqwen3_npu.so) to dynamically dispatch d_head=128 when intermediate_size == 6144.
  3. Identity QK-Norm Injection: Injected synthetic unit RMSNorm tensors across all 42 layers in model.q4nx, making RMSNorm a transparent identity op.

How to Run Locally

# 1. Clone the NPU weights
mkdir -p ~/.config/flm/models
git clone https://huggingface.co/julianmb/MiniCPM5-2B-NPU2 ~/.config/flm/models/MiniCPM5-2B-NPU2

# 2. Register under ~/.config/flm/model_list.json
# Add under "models":
# "minicpm5:2b": {
#   "path": "~/.config/flm/models/MiniCPM5-2B-NPU2",
#   "model_type": "qwen3",
#   "tokenizer": "~/.config/flm/models/MiniCPM5-2B-NPU2"
# }

# 3. Serve via FastFlowLM
flm serve minicpm5:2b --host 127.0.0.1 --port 8001

Thank you for releasing MiniCPM5-2B β€” its quality-to-size ratio makes it by far the strongest 2B-class model running on AMD NPUs today!

Thanks for sharing this β€” the write-up on the GQA workaround is the part we appreciate most. Replicating the 2 KV heads 4x to hit the native 2:1 kernel is a neat way around the missing 8:1 path, and it's good to see you called out that it's mathematically equivalent rather than an approximation. The identity QK-Norm injection across all 42 layers is a clever trick too.

63 tok/s at 2–4 W is a striking number for a 2B model, especially with the iGPU and CPU left idle. Thanks also for publishing the porting scripts and eval alongside the weights β€” that makes the work reproducible for anyone else targeting XDNA 2.

Nice work, and glad the model is a good fit for that hardware.

Sign up or log in to comment