unlimitedocr: the decoder plugin, the fused router ops and an h128 MHA attention leg

The text side of Unlimited-OCR: a 12-layer, 1280-wide decoder, 10 query heads over 10 KV
heads at head_dim 128, a dense layer 0 and 64 routed experts (top-6, softmax, no
renormalisation) plus one ungated shared arm in layers 1-11. arch/unlimitedocr_bf16/
carries its own plain-Llama bf16 attention, the shared MoE block in its bf16
external-input mode, and the tied LM head; data/recipes/unlimited-ocr-bf16.recipe is the
bf16 passthrough convert. core/format/checkpoint.cpp learns n_routed_experts, so n_expert
is read from the checkpoint's own key.

The router is issued as one op rather than a selection and a sort: libref gains
router_topk_scatter and router_gemm_topk_scatter (the second with the shared expert's
one-column gate at N = 1), libavx composes both from its router/gemm/scatter kernels, and
both get sweep geometries and the gate-absent/gate-present tests.

libr4d had no head_dim 128 leg at ratio 1, so every attn_paged band of this geometry
resolved to no kernel and the server refused to start on device.
r4d_attn_paged_h128_gqa1.hip instantiates the generic body at GQ 1 for both legs; the
rows and the selftest cases come with it.

Device numbers, one R9700 (gfx1201, HIP 7.16), bf16 weights and KV, no reference-kernel
fallback: a 523-token prompt prefills at 35.0-35.8k tok/s (15 ms) and a 4043-token prompt
at 54.2k tok/s (75 ms); decode is 351-354 tok/s (2.82-2.85 ms/token) at short context and
315 tok/s at 4k. r4d_selftest is 0 failures; the host suite is 86/87, the miss being
mm_test's lossless-webp decode, which fails on this box in code this change does not touch.
This commit is contained in:
Juup committed 2026-10-20 07:03:49 +00:00
1 parent 685ec5bd85
commit 543cba7416
20 files changed
+1179 -5

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
# unlimited-ocr-bf16.recipe -- baidu/Unlimited-OCR from its bf16 checkpoint, served at the
# checkpoint's own precision.
#
# rad-convert <Unlimited-OCR checkpoint> --recipe data/recipes/unlimited-ocr-bf16.recipe \
# -o unlimited-ocr-bf16.rad
#
# No rules: every decoder weight is plain bf16 as the checkpoint ships it, and the bf16 plugin
# (arch/unlimitedocr_bf16) probes the first routed expert, reads the plain encoding and serves the
# experts through the bf16 grouped GEMM. The checkpoint carries no quantization_config.
#
# The container this writes is the P0/P1 decoder only: the plugin's name map covers the 12-layer
# Llama-MoE trunk and its tied head, and the DeepEncoder vision tensors are left out until the P2
# tower is declared (aijuus/plans/UNLIMITED-OCR-PLUGIN.md). Reconvert with the same recipe then.
#
# Quantisation follow-ups (after P5) get their own recipes: the 64-expert MoE is the qwen4exp
# w4/w4nl64 tier's shape (moe_intermediate_size 896 = 7 x 128 scale groups, n_embd 1280 = 10 x 128
# -- whole scale blocks both ways), with the tied 331 MB head and the vision tower kept bf16.