Skip to content

docs(rockchip-npu): price the vendor zero-op matmul path, record the QuaRot int8 negative - #1266

Merged
0xShug0 merged 2 commits into
0xShug0:mainfrom
wOvAN:rknn-zeroop-poc-fwht
Nov 12, 2026
Merged

0xShug0 merged 2 commits into
0xShug0:mainfrom
wOvAN:rknn-zeroop-poc-fwht

Conversation

@wOvAN

@wOvAN wOvAN commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #1264, which merged with the two commits I pushed after the merge left out.

Vendor zero-op path, priced. The single-core ceiling from #1264 was then measured end to end with a one-layer port on the board: the OmniVoice layer-0 QKV/O/MLP GEMMs and the 32+32 attention tiles on rknn_matmul_api at fp16-to-fp32, with RoPE, softmax, SiLU and the residual adds on the CPU in fp32 (M=1536, CFG-packed). The NPU side runs 137 ms per layer and the stage outputs match the fp32 torch reference at fp16-GEMM noise (q_rope 36 dB, layer output 21 dB), so x28 is a 3.9 s/step NPU-only floor, before host cost. Host cost is real: the NATIVE layout is tiled, not row-major (A [K1,M,subK], B [N1,K1,subN,subK], C perf, the official demo packers), and naive scalar packing plus C unpacking triples the layer wall. A tuned port (prepacked weights, vectorized packing, fp16 C for the big-N GEMMs) lands near 5-6 s/step, about 1.5x over the compiled 8.4 s engine, with the O and down projections (0.32/0.22 TFLOP/s single-core at K>=2048) eating 1.8 s of the floor by themselves. The 2.5x stays locked to the AGPL library: the vendor zero-op path is a real but modest lever.

QuaRot/FWHT int8 probe (negative). The int8 probe bullet said the literature remedy is a randomized Hadamard transform exported into the ONNX graph. That experiment ran: a randomized 1024-dim Hadamard folded into the front-28 export (embeddings, QKV, gate/up by H, o and down by H^T, norm weights absorbed, a final de-rotation matmul that keeps the shard contract; the graph is neutral, 116 dB against the fp32 reference, and an fp16 control build of the rotated graph measures 57-60 dB at argmax 1.0). The w8a8 rebuild of the rotated graph measures 2.1/-0.6 dB, bit for bit the unrotated death. The residual stream was not the binding outlier: the per-tensor scales are set by the unrotated MLP mid (silu(g)*u, 3072-wide SwiGLU tails) and by QK^T/P inside attention, and full QuaRot additionally keeps attention in fp16, which is a per-op dtype the converter cannot express. int8 is closed for this family on the converter path.

Docs-only, no code touched. Board: RK3588, librknnrt 2.3.2, engines built in the 2.3.2 converter venv.

wOvAN added 2 commits November 12, 2026 21:31
…0 POC

One full OmniVoice layer on rknn_matmul_api (fp16->fp32 GEMMs, fp32 CPU
RoPE/softmax/SiLU) runs 137 ms NPU/layer, stage outputs at fp16-GEMM noise,
x28 = 3.9 s/step before host packing. Documents the NATIVE tiled layout contract.
Residual-stream Hadamard folded into the front-28 export (graph neutral at
116 dB, fp16 control 57-60 dB): w8a8 rebuild measures 2.1/-0.6 dB, the same
death as unrotated. Scales bind on unrotated MLP-mid/attention activations;
full QuaRot needs per-op fp16 attention the converter cannot express.
@0xShug0
0xShug0 merged commit 5c3d0d4 into 0xShug0:main Nov 12, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@wOvAN Thanks! PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants