Skip to content

Question: how much CPU<->RKNN divergence is expected on the streaming path? #901

Closed

Description

@wOvAN

Measured on RK3588 (Orange Pi 5 Plus, librknnrt 2.3.2), same checkpoint
(Qwen3-TTS-12Hz-0.6B-Base-GGUF), same voice reference, greedy (--do-sample false --seed 42),
--threads 4, one 185-character Russian utterance, renders compared sample-wise as SNR against the
same-binary ggml render:

mode ggml decoder RKNN decoder (vocoder_stateful_64b_fp16.rknn)
offline reference 24.30 dB (identical length, 549,120 samples)
streaming reference 14.38 dB (identical length, 574,080 samples)
streaming, rknn_decoder_first (16-frame) added — 14.38 dB (same as without it)

For reference, streaming vs offline within one decoder is −2.7 to −3.1 dB, i.e. the two modes are
essentially decorrelated renders, which is what docs/models/qwen3_tts.md says to expect ("Streaming
uses smaller codec windows than offline decoding, so waveform differences are expected").

The part I cannot read off the docs is the first two rows. Swapping the decoder costs 10 dB more on
the streaming path than on the offline path. My reading of the mechanism: the offline path decodes
64-frame windows, which is the compiled batch of the engine, while streaming decodes growing events
of 1, 2, 4, 8, 12 frames, so most steps run the stateful engine far below its compiled batch, with
the convolution/KV cache carried in graph I/O. If the cache layout is batch-independent (as the
first-group model's design assumes), that should be exact, and 14.38 dB says it is not.

So the question is which of these is the intended semantics:

  1. Streaming + RKNN is a different valid synthesis (like streaming vs offline), and 14.38 dB is
    its floor — in which case the number belongs in the docs next to the streaming caveat, so nobody
    debugs it as a regression.
  2. The stateful cache handoff at small batch is lossy, and 14.38 dB is a defect worth a gate — in
    which case I can bisect it (per-step cache dump against the offline decode of the same frames) and
    the producer's stepwise self-check (111.4 dB at B=64, 103.7 dB at B=16) is measuring the wrong
    thing: it checks each batch size in isolation, not the cache continuity across a growing event
    sequence.

Not a blocker for the sidecar PRs — the streaming RKNN path is 2.6× faster than streaming ggml
(57.7 s against 151.2 s, first audio 0.88 s) and the listening verdict on the offline path already
passed. It is a semantics question: what is the streaming engine's contract?

Activity

  1. 0xShug0 commented on Oct 14, 2026

    @0xShug0
    Owner

    @wOvAN Have you tried running ASR on the generated audio and comparing the transcriptions against the input text? It may be fine if the ASR transcriptions of the streaming and offline outputs match exactly.

  2. 0xShug0 commented on Oct 14, 2026

    @0xShug0
    Owner

    @wOvAN I compared offline and streaming output of GGML graphs on CPU, CUDA, Metal and Vulkan using the following text:
    “Сегодня мы проверяем, как работает потоковый синтез речи. Один и тот же голос читает этот текст с одинаковыми настройками, чтобы сравнить обычный и потоковый звук без случайного выбора слов.”

    Backend Diff (SNR) ASR output drift
    CPU −2.92 dB One word: offline omits и (“and”); streaming matches input
    CUDA −2.33 dB Both match input
    Vulkan −3.92 dB Both match input
    Metal -2.78 dB Both match input

    The RKNN divergence looks a bit high. It may be worth investigating further.

  3. wOvAN commented on Oct 14, 2026

    @wOvAN
    ContributorAuthor

    Good suggestion — I ran it. Short answer: the transcriptions do not match exactly, they differ by one word out of 44, and that gap is the same size as the ASR's own error against the reference text, so it reads as ASR variance rather than as a broken streaming path.

    Setup

    Orange Pi 5 Plus (RK3588), native aarch64 build, --backend cpu --threads 6.

    • Audio: the two existing qwen3_tts renders of one 307-character Russian text, voice-clone reference — offline (a_qwen3_cpu.wav, md5 be16c437) and streaming (a_qwen3_stream_cpu.wav, md5 abec2c4c). Resampled 24 kHz → 16 kHz for the ASR.
    • ASR: GigaAM v3 CTC f16 (ai-sage/GigaAM-v3, family gigaam_asr), Russian-native.

    I tried SenseVoice-Small first and it is not usable for this: on Russian speech it returns junk (na., Fnatoman, Itana. This picture previate Vietnam) while transcribing the bundled English sample perfectly, so the model is fine and its Russian is not. GigaAM is Russian-native and transcribes the renders almost verbatim.

    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
      -DAUDIOCPP_MODEL_SET=custom -DAUDIOCPP_MODELS=sense_asr;gigaam_asr
    cmake --build build -j6 --target audiocpp_cli
    ./build/bin/audiocpp_cli --task asr --family gigaam_asr \
      --model /root/asr/models/gigaam-v3-ctc-f16.gguf \
      --backend cpu --threads 6 --audio offline16.wav --text-out offline.txt

    Result

    The two transcriptions differ in exactly one word of 44:

    • offline: ... а стрелочник считает вслух каждый перевод стрелки ...
    • streaming: ... а стрелочник читает вслух каждый перевод стрелки ...

    Normalized (lowercase, ё → е, punctuation stripped):

    comparison CER WER
    streaming vs offline 0.33% 2.27%
    offline vs the input text 0.33% 2.27%
    streaming vs the input text 0.67% 4.55%

    Reading

    The streaming-vs-offline gap (0.33% CER) is the same magnitude as the offline-vs-reference gap (0.33% CER), i.e. the streaming render is as far from the offline render as the offline render is from the text the ASR was handed. If the streaming path were systematically damaged, streaming-vs-input would sit clearly above offline-vs-input; it is 0.33% above, on a single-word ASR substitution.

    So on this evidence the CPU↔RKNN streaming divergence is not audible to the recogniser: one substitution in 44 words, at the ASR's own noise floor. I would read that as "expected divergence is small", not as "the paths agree exactly" — the exact-match test the title asks about is not met, and I do not think it can be met by any two paths that differ in accumulation order at all, because the ASR itself is not stable at that level.

    Artifacts (wavs, transcripts, scoring script) are on the board under /root/asr/ if a follow-up measurement is wanted.

  4. wOvAN commented on Oct 14, 2026

    @wOvAN
    ContributorAuthor

    Ran your text through the board. The two tables are measuring different pairs, and once they are put on one axis the RKNN number is not high — the streaming/offline mode switch is what produces the divergence, and it produces the same amount on the CPU graph path.

    Setup

    One binary (the RKNN-enabled build), one voice reference, --language russian --do-sample false --seed 42 --threads 4 --session-option qwen3_tts.conv_weight_type=f16, your text verbatim. Five renders:

    • cpu_off, cpu_stream — GGML vocoder, offline and --mode streaming
    • rknn_off, rknn_stream — RKNN stateful fp16 vocoder (vocoder_stateful_64b_fp16.rknn), offline and streaming
    • rknn_stream_first — the same plus the B=16 first-chunk engine

    Matrix

    pair what it compares SNR best lag SNR after lag alignment envelope corr
    cpu_stream ↔ cpu_off your metric, on CPU −2.24 dB −120.2 ms −2.13 dB 0.187
    rknn_stream ↔ rknn_off your metric, on RKNN −2.23 dB −120.1 ms −2.11 dB 0.187
    cpu_off ↔ rknn_off backend, offline 25.09 dB 0 25.09 dB 0.9999
    cpu_stream ↔ rknn_stream backend, streaming 16.37 dB 0 16.37 dB 0.9988
    rknn_stream_first ↔ rknn_stream first-chunk engine 58.22 dB 0 58.22 dB 1.0000

    So the row you measured (mode switch, same backend) is −2.24 dB on CPU and −2.23 dB on RKNN — indistinguishable. Your CPU figure on your text is −2.92 dB, the same effect. The row I quoted in the issue title (backend switch, same mode) is 25.09 dB offline and 16.37 dB streaming. The NPU render sits about 70× closer to the CPU render in power (16.37 dB against −2.23 dB) than streaming is to offline on either backend.

    What the −2.2 dB is made of

    Not noise, and not a time shift. Aligning by cross-correlation moves it by 0.1 dB (−2.24 → −2.13) at a −120 ms lag, and the 20 ms RMS envelope correlation is 0.187 — the prosody and timing of the two renders diverge across the whole phrase. That is what a different generation trajectory looks like: streaming and offline are two valid syntheses of the same text, not one signal plus an artifact. The backend rows have envelope correlation 0.9988-0.9999, i.e. the same signal.

    ASR

    GigaAM v3 CTC f16 (gigaam_asr, CPU) over all five renders, normalized (lowercase, ё→е, punctuation stripped):

    render CER WER
    cpu_off 0.00% 0.00%
    cpu_stream 0.00% 0.00%
    rknn_off 0.00% 0.00%
    rknn_stream 0.00% 0.00%
    rknn_stream_first 0.00% 0.00%

    All five transcribe to the input text exactly, so the drift you saw on CPU (offline dropping и) does not reproduce here, and the exact-match test you proposed is met by every path including the NPU one.

    Proposal

    If the intent of the metric is "is the NPU sidecar faithful", the row to publish is the backend row: 25.09 dB offline, 16.37 dB streaming, envelope correlation 0.999. If the intent is "how much does streaming change the utterance", that is −2.2 dB on every backend including CPU, and it belongs in the streaming documentation as expected behaviour, not in the RKNN docs as a sidecar cost. I would document both rows separately for exactly this reason — the current single number invites comparing them.

    Artifacts on the board under /root/snr901/ (wavs, logs, analyze.py, transcripts).

  5. 0xShug0 commented on Oct 14, 2026

    @0xShug0
    Owner

    Thanks for the detailed comparison! It helps clarify the distinction.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions