An open NPU runtime for RK3588 that skips librknnrt.so and runs Qwen about twice as fast
The headline number on this project is that a hand-written NPU runtime beats Rockchip's own RKLLM by roughly 2× on an RK3588. The more interesting claim is buried three sections down: the closed-source user-space library is optional. Everything above the kernel driver can be replaced.
That distinction is worth being precise about, because the project's own README is. open_rknpu2_lm_infer does not need librknnrt.so, does not need RKNN model files, and does not need the RKNN compiler. It does still need the RKNPU2 Linux kernel driver, version 0.9.6 or newer. So this is not a driver-free NPU interface — it is a demonstration that the vendor's user-space layer, not its hardware interface, is what you were paying for.
The published comparison
Qwen3.5-4B, tokens per second, against RKLLM 1.3.1:
| Test | RKLLM 1.3.1 | New runtime, MTP1 | New runtime, dual ubatch |
|---|---|---|---|
| Prefill, 512 tokens | 58.35 | 159.27 | 178.53 |
| Prefill, 1024 tokens | 57.84 | 159.22 | 179.16 |
| Prefill, 3800 tokens | 54.03 | 153.46 | 171.25 |
| Decode, 512 context | 5.54 | 11.45 | 11.47 |
| Decode, 1024 context | 5.42 | 11.41 | 11.44 |
| Decode, 3800 context | 4.57 | 10.66 | 10.67 |
That is about 2.7× on short prefill, 2.8× on long prefill, 2.1× on decode at short context and 2.3× at long context. Vision encoding of a 448 × 448 image drops from 1863 ms to 862.25 ms, a 54% reduction.
Read the columns carefully before quoting any of it. MTP1 is multi-token prediction — speculative decoding with one extra candidate per round — so it is not the same execution mode as token-by-token decode. Dual ubatch is a different axis again: two physical micro-batches pipelined so the CPU prepares batch n+1 while the NPU runs batch n, at a cost of roughly 1.5 GB of additional memory, off by default. Neither column is a drop-in replacement for the baseline, and the README says so: the board model, memory configuration, thermal state, CPU and NPU clocks, OS build, power draw and temperature are not all disclosed, and the numbers are the author's, not an independent replication.
Why it can be faster at all
Four things, roughly in order of how much they matter:
W4A8 weights with mixed-precision split-activation decomposition. Four-bit weights cut weight storage and, more importantly, weight traffic. Decode generates few tokens per step and re-reads the whole model each time, so it is memory-bound, and halving weight bytes attacks the actual bottleneck. The project implements its own W4A8 matmul kernel with fused Gate/Up projection and SwiGLU rather than decomposing them into separate passes.
The NPU is driven from user space through the DRM interface. Operators are submitted as command buffers through the rknpu DRM driver. The CPU packs data, quantizes, and does the Split-K reduction in OpenMP and NEON. This is a heterogeneous split, not a "put everything on the accelerator" design.
Per-shape tuning. Matrix sizes and layouts suit different execution configs, so the runtime benchmarks candidate configurations for a given model and caches the winner. Worth noting: the CPU affinity, NPU core mask and operator config used during tuning must match what you run in production, or the tuned result does not transfer.
Not everything goes to the NPU. Normalisation, RoPE, convolution and GDN stay on the CPU path; matmul, attention and MoE get native operators. Small ops with high CPU↔NPU traffic are cheaper on the CPU, which is the standard argument for heterogeneous scheduling and the opposite of what a naive port does.
The accuracy question
WikiText-2 perplexity, RKLLM W8A8 versus the new runtime's mixed quantization:
| Model | RKLLM W8A8 | New runtime | Change |
|---|---|---|---|
| Qwen3.5-4B | 8.5197 | 8.5744 | +0.64% |
| Qwen3-4B | 12.8709 | 12.5913 | −2.17% |
| Granite-4.2-3B | 15.7448 | 16.0519 | +1.95% |
| MiniCPM5-2B | 14.1293 | 13.8073 | −2.28% |
Two models got worse and two got better. That spread is the honest result: 4-bit weights are not uniformly safe, and the fact that two models improved suggests the baseline was not optimally quantized rather than that the new scheme is magic. Perplexity is also one metric; it does not establish instruction-following or downstream task accuracy.
What to actually take from it
For a C/C++ engineer the rknpu2_matmul_open repository is the valuable artifact — FP16/BF16/TF32 matmul, W8A8, W4A8, W4A4, MoE, GQA/MHA/MQA, MLA and gated MLA, GDN, FP16 KV cache, all submitted through a documented kernel interface. That is a study of how a modern NPU is actually programmed, which almost no vendor documentation provides.
Two practical cautions. The code is AGPL-3.0-only, and model weights carry their own separate licences; integrating either into a commercial product or a network service needs a licence review before anything else. And the runtime is iterating quickly, so an OpenAI-compatible endpoint existing does not make it a production serving stack.
Prebuilt ARM64 Linux binaries and a Qwen3-4B W4A8 model are published, so the entry cost is a board, a kernel driver check at /sys/kernel/debug/rknpu/version, and about 10 GB of model weights. Note that hitting the published numbers requires running the tuning step — downloading and running the binary gets you the defaults, not the table.
Projects: happyme531/open_rknpu2_lm_infer and happyme531/rknpu2_matmul_open.