Repository navigation
omnivoice: run the generator on the vendor zero-op matmul API (rknn_zeroop) - #1297
Conversation
…eroop) A third generator impl for omnivoice.exec_plan that needs no compiled engine artifacts: the 28-layer diffusion-LM trunk runs on the vendor rknn_matmul_api shipped inside librknnrt.so (zero custom operators, links nothing beyond the runtime), with the geometry built at runtime and the weights packed once into the native tiled B layout (disk-cached under <model dir>/rknn-zeroop-cache). Same front-shard contract as the compiled front-shard ladder: NPU trunk, host fp32 CFG tail. Attention is tile-assembled on the vendor API with a host fp32 softmax, and the self-only dLLM step rows take an exact identity on V. Additive plumbing: OmniVoiceRknnGenerator's public methods become virtual and gain a reset() per-request hook (no-op for the stateless compiled ladder), an empty engine list is inert instead of throwing, the engine layer compiles as a clear-error stub off aarch64, and the -march=armv8.2-a+fp16 flags are scoped to the two sources that need them (RK3562/RK3561-class parts have no FP16 SIMD). RK3588 (librknnrt 2.3.2): 28-layer referee SNR 80.6-132.9 dB against the compiled front-shard ground truth, whisper-clean Russian renders, deterministic output; deep geometry at compiled-ladder parity (22.9 vs 23.2 s/step, 50.1 s prefill).
… 7.5 Measured per-step medians from the twin and deep board logs (32 steps each): twin 8.8-9.1 s median with the first step at 25.8 s (geometry build), deep 22.9 s median with a 50.1 s first step.
|
@wOvAN Serveral potential issues found by Codex:
Could you double check them? |
Four review findings, all real:
- The constant-pack cache key took only the schema tag and warm-load checked
file sizes, so a checkpoint swapped into the same model directory silently
reused the previous pack. The generator now appends a content hash of the
weight set (FNV-1a-64 over sampled windows of every weight view, ~20 ms) to
the tag, so the cache key pins the weight content, not just its shape.
- is_f16 treated every non-F16 store as fp32, so a custom Q8_0/BF16 GGUF would
be reinterpreted as floats (garbage + OOB reads). The views loop throws for
any store outside {F16, F32} at construction.
- One shared mask buffer carried the prefill b1 convention (canvas-target rows
[seq-tgt, seq) over [seq-tgt, seq)) and the step b1 convention (block-local
rows [0, tgt) over [0, tgt)), merged by fills. In the overlap regime (target
block bigger than the prompt canvas) the two fill regions intersect, and the
merged rows got full-row visibility - a third semantics neither pass defines.
Prefill and step now build and pass separate masks (mask_p / mask_s).
- ~Engine() called close() but never deleted Impl, so every session teardown
leaked the per-layer KV caches and all scratch vectors. It now deletes im_.
Board-validated (RK3588): twin geometry (regions disjoint) render byte-identical
to the pre-fix gate; deep and short-ref overlap geometries render whisper-clean
Russian over the full text.
Co-Authored-By: Claude <[email protected]>
Performed-by: Claude-Fable-5
|
Checked all five, four were real, all fixed in 53e43bf:
The PR description gained a "Review round" section with the new board numbers. |
|
@wOvAN Thanks! PR merged! A follow-up PR could check the disk caching and make sure it works as expected, including on a fresh installation where the cache directory doesn’t exist yet. Disk caching is easy to get wrong, especially cache invalidation and handling failed writes. There are two relevant PRs, but neither has been merged yet. |
omnivoice: a generator that runs on the vendor zero-op matmul API (rknn_zeroop)
The RKNN OmniVoice generator today needs a ladder of per-bucket compiled
.rknnengines(
omnivoice_generator_seq<N>_fp16.rknn): every new canvas geometry is a PC-side reconvert withthe toolkit, and the engines come from a sidecar artifact set. This PR adds a third generator
impl,
rknn_zeroop, that needs no artifacts at all: the 28-layer diffusion-LM trunk runs on thevendor
rknn_matmul_apishipped insidelibrknnrt.soitself (zero custom operators, no externalkernel library, links nothing beyond the runtime), with the geometry built at runtime.
Select it through the existing exec-plan seam:
How it works
tail (final norm, audio heads, guided combine) stays in the host fp32 graph.
rknn_matmulcontexts. Weights are packedonce into the native tiled B layout (M-independent, so all buckets share one pack) and cached
on disk under
<model dir>/rknn-zeroop-cache, overridable withAUDIOCPP_RKNN_ZEROOP_CACHE,keyed by a weight-set fingerprint.
host in fp32, PV over the full cache width. The dLLM step canvas masks make every target row
self-only, and for that case the step attention is the exact identity on V (zero NPU work).
core_maskis accepted-then-ignored, so it is neverset), which sets the perf envelope described below.
OmniVoiceRknnGenerator's public methods become virtual and gain areset()per-request hook (no-op for the stateless compiled ladder), an empty engine list isinert instead of throwing (the zero-op generator registers no compiled ladders), and the two
engine sources compile on non-aarch64 as a clear-error stub. Per-source
-march=armv8.2-a+fp16is scoped to the two files that need it (RK3562/RK3561 parts have noFP16 SIMD, so the flags must not be target-wide).
Runtime validation (RK3588, Orange Pi 5 Plus, librknnrt 2.3.2, 2026-11-15)
Board build:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ -DENGINE_ENABLE_RKNN=ON \ -DENGINE_RKNN_INCLUDE_DIR=/usr/local/include -DENGINE_RKNN_LIBRARY=/usr/lib/librknnrt.so \ -DAUDIOCPP_MODEL_SET=custom -DAUDIOCPP_MODELS=omnivoice cmake --build build --parallel 8 --target audiocpp_cliBoard run (32 Russian characters + ElevenLabs-style English reference clip, greedy-free seed,
live guidance 2.0):
Parity against the compiled front-shard ladder (ground truth) on the same text/seed/geometry,
with the debug hidden-state dump (
AUDIOCPP_RKNN_ZEROOP_DEBUG=1,AUDIOCPP_RKNN_ZEROOP_DUMP=...):across all 28 layers (fp16 trunk noise floor; the final-step conditional row, which the
host tail actually consumes, lands at 34.3 dB at step 0 of the twin geometry and decays
smoothly across steps, no cliff).
twin runs produce a byte-identical WAV (
md5 31eaa272118dd19fad97ac326a72f91d).Timings (same board, 4 threads on the host tail, warm weight cache):
(In each run the first step pays the geometry-context build, 25.8 s / 50.1 s respectively;
medians exclude it, means are 9.3 s and 23.8 s.)
At deep geometry that is parity with the compiled front-shard engine (23.2 s/step measured on the
same board and text). First cold run additionally packs the full trunk (~2 min) and writes the
disk cache.
x86: the tree compiles with
-DENGINE_ENABLE_RKNN=ON(the engine layer is an explicit stub thatthrows a clear error at
open()), and the two stub TUs passg++ -fsyntax-only -std=c++17 -DENGINE_HAVE_RKNN=1on x86-64.tools/check_loader_catalog_sync.pypasses.Known limitations
multi-core compiled engines; deep geometry is at parity. The 3-core split (open-source
rknpu2_matmul library) is a separate, license-encumbered engine and deliberately not here.
max_tokens()is 2176: a policy/memory cap, the per-geometry KV caches reserveseq_padrows (~528 MB at 2304 padded rows).Review round (2026-11-15)
Five issues from review, four real, all fixed on this branch:
(FNV-1a-64 over sampled windows of every weight view, ~20 ms) to the schema tag, so a
checkpoint swap in the same model directory repacks instead of reusing the old pack.
reinterpreted as floats.
mask_p/mask_s). The previous single mergedbuffer gave target rows in the overlap regime (target block bigger than the prompt canvas,
target > seq - target) full-row visibility, a semantics neither pass defines. Validated on theboard across three geometries on the fixed binary:
the pre-fix gate (
md5 31eaa272118dd19fad97ac326a72f91d), i.e. the fix is a no-op when theregions do not overlap.
(expected - this regime was the bug), transcribes whisper-clean over the full text, and
re-measures at parity with the compiled engine (32 steps, 25.0 s/step median, 52.7 s
prefill+first-step geometry build).
whisper-clean over the full text.
Engine::~Engine()deletes itsImpl(KV caches leaked per session teardown).