Skip to content

omnivoice: RKNN generator step-graph sidecar (RK3588) - #1259

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
wOvAN:omnivoice-rknn-generator
Nov 11, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
wOvAN:omnivoice-rknn-generator

Conversation

@wOvAN

@wOvAN wOvAN commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

What this is

Routes the OmniVoice diffusion-LM decoding step to the RK3588 NPU through a ladder of fixed-shape engines: the fourth per-stage RKNN sidecar in this tree (qwen3 vocoder, piper vocoder, kokoro generator, now omnivoice generator). The step graph is the stage that board profiling puts at 98.8% of omnivoice runtime: 32 full forwards per utterance over the 28-layer Qwen3 backbone.

Design

  • tools/rknn/prepare_omnivoice_rknn_generator.py (PC) compiles one engine per total-token bucket (256/384/512/768/1024) straight from the safetensors checkpoint, mirroring Qwen3DiffusionForwardGraph's semantics: the packed CFG pair, the additive attention mask (pad rows diagonal-only), RoPE as host-computed cos/sin inputs, and the raw-logit guidance combine. The RoPE tables are inputs because the fp16 DPU quantizes Cos/Sin of raw ~1e3-rad arguments (the qwen3 vocoder's freqs_in precedent); the converter recipe (torch-export constant folding, optimization_level=0, Gather-based GQA) is documented in docs/build/rockchip-npu.md.
  • src/models/omnivoice/rknn_generator.{h,cpp} is the board sidecar: name-parsed ladder, driver-priced residency through the shared ApertureBudget, per-engine TIMING, padded run cropped to the conditional target block. All scoring (log_softmax, layer penalty, gumbel, top-k fill) stays in the host loop, as in the device_scoring=false ggml branch.
  • Selection is the existing exec_plan seam: --session-option 'omnivoice.exec_plan={"generator":{"impl":"rknn","artifacts":{"main":"omnivoice_generator_seq768_fp16.rknn"}}}'. A request longer than the largest rung runs the ggml graph unchanged. The spec declares the omnivoice_generator_rk3588 package entry; the loader prices the ladder for the load guard.

Runtime validation (Orange Pi 5 Plus, RK3588, librknnrt 2.3.2, engine SDK 2.3.2)

Build: native aarch64 cmake -DENGINE_ENABLE_RKNN=ON -DENGINE_BUILD_TESTS=ON -DENGINE_BUILD_MODEL_TESTS=ON -DAUDIOCPP_MODEL_SET=custom -DAUDIOCPP_MODELS=omnivoice.

Quality gate (voice clone, full baseline text, b.wav reference, seed 42, --guidance-scale 0.0, seq768 engine, 32 steps): the NPU render is whisper-clean and ASR-equivalent to the ggml path's own render of the same request:

  • ggml CPU: "Сегодня утром на площадке калибровали речевой синтез на плате с нейропроцессором. Вакадер стоял в памяти ускорителя."
  • NPU: "Сегодня утром на площадке калибровали речевой синтез на платье с нейропроцессором, в кого стоял в память и ускоритель." (faster-whisper small, ru, beam 5)

The seq256 rung renders a short probe clean with the a.wav reference. Determinism: the final clean-tree binary's render is byte-identical to the instrumented run.

Numerics, identical step-0 inputs fed to the compiled engine through a standalone C harness and to the torch fp32 reference: engine vs reference 60.2 dB output SNR / 0.81 argmax (cond row), 26.9 dB / 0.70 (uncond row). PC simulator (fp32 emulation) against the fp32 reference: 61.0 dB / 0.978-0.982. Padded runs of the fp32 graph reproduce the exact run at 398-408 dB per bucket.

Performance, same request: 8.8 s/step NPU vs 26.6 s/step ggml at seq768 (wall 293 s vs 883 s, 3.0x), engine load 2.3-3.2 s, peak RSS 4.9 GiB, resident engine set 2736 MiB (budget 3900 MiB via AUDIOCPP_RKNN_APERTURE_MIB). Engines are 1.25-1.36 GiB per rung, compiled per SoC.

Known limitation, stated in the docs

The guidance-2.0 rollout is not usable on the NPU yet, so the engine ships validated in the conditional mode (--guidance-scale 0.0). The fp16 uncond branch sits at 26.9 dB against the fp32 reference, and this decoding is knife-edged at that scale: the CFG gain doubles the noise and the 32-step rollout leaves the speech basin. The same collapse is reproducible on the ggml path at a much smaller perturbation (its --guidance-scale -1 render of the same request is noise while 0/1/2 are clean), which says the headroom needed is a numerically quieter uncond branch, not a re-tune. Related measurement from the same A/B: the ggml graph's unconditional row reproduces its own conditional logits to within 0.9 logit-rms, so the ggml path's guidance term is currently inert; the engine's own cond-minus-uncond sits at 18.9 logit-rms. Both observations are recorded in docs/build/rockchip-npu.md.

Tested gates

  • python3 tools/check_loader_catalog_sync.py --self-test && python3 tools/check_loader_catalog_sync.py: ok (145 loaders / 142 specs / 450 packages in sync).
  • ctest -R rknn: rknn_sidecar_test self-skips (rc 77) on the board because the driver rejects the synthetic fake engine; the OmniVoice section compiles and links with the real contract (6 inputs, head_dim/rope_theta from config).

Route the diffusion-LM decoding step to the RK3588 NPU through a ladder of
fixed-shape engines, the fourth per-stage RKNN sidecar in this tree. The step
graph is the stage board profiling puts at 98.8% of omnivoice runtime (32
forwards per utterance over the 28-layer Qwen3 backbone).

- tools/rknn/prepare_omnivoice_rknn_generator.py compiles one engine per
  total-token bucket from the safetensors checkpoint: torch-export constant
  folding (the converter's own FoldConstant aborts on the full graph),
  optimization_level=0, fp16 weights, Gather-based GQA. The engine takes the
  packed CFG pair, the additive attention mask, host-computed RoPE cos/sin
  tables (float64 angles reduced mod 2*pi: fp16 Cos/Sin of a raw ~1e3-rad
  argument quantizes the argument and renders noise, the qwen3 vocoder's
  freqs_in precedent) and the guidance scale, and returns the guided
  conditional logits, the same tensor the ggml graph produces after its
  guidance combine; scoring stays on the host. On the PC simulator the fp16
  engine reproduces the fp32 reference at 61.0 dB output SNR with 0.978-0.982
  argmax agreement, and padded runs of the fp32 graph are exact at 398-408 dB.
- src/models/omnivoice/rknn_generator.{h,cpp} is the sidecar: name-parsed
  ladder, driver-priced residency with the shared ApertureBudget, per-engine
  TIMING, and a padded run that crops the conditional target block.
- The session selects it through omnivoice.exec_plan component generator
  (artifacts.main, comma-separated), the loader prices the ladder for the
  load guard, the spec declares the option and an rknn package entry, and the
  board sidecar test gains the OmniVoice fake-engine section.

Measured on the board, the seq768 engine renders the baseline voice-clone
request whisper-clean at guidance 0 in 32 steps at 8.8 s/step against the
ggml graph's 26.6 s at the same length (wall 293 s against 883 s, peak RSS
4.9 GiB), and the seq256 rung renders a short probe clean too. The guidance
2.0 rollout is not usable on the NPU yet: the fp16 uncond branch sits at
26.9 dB against the fp32 reference (cond sits at 60.2 dB), and the diffusion
decoding is knife-edged at that scale, so the engine ships validated in the
conditional mode; docs/build/rockchip-npu.md carries the numbers.

A request longer than the largest rung runs the ggml graph unchanged.
@wOvAN

wOvAN commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

The five compiled RK3588 engines (1.25-1.36 GiB each, rope-in-graph contract, built by the producer in this commit with SDK 2.3.2) are published on the engines bucket the spec's omnivoice_generator_rk3588 package points at: https://huggingface.co/tree/main/rk3588/omnivoice (wOvANAI/rknn-tts-engines, commit edf8b5e6). The seq256 and seq768 rungs are the ones measured on the board in the description; the 384/512/1024 rungs pass the PC-simulator gates (61.0 dB / 0.978-0.982, pads exact at 398-408 dB) and ship for the bucket coverage.

@0xShug0
0xShug0 merged commit be2cc80 into 0xShug0:main Nov 11, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@wOvAN Thanks! The PR is scoped. Merged.

One follow-up: since default CFG currently fails on RKNN, the RKNN path should explicitly reject nonzero guidance.

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