Skip to content

MOSS codec decoder drifts from the reference as the input grows (63 dB at 43 frames, 13 dB at 171) #663

Closed

Description

@pnnbao97

The ggml MOSS audio tokenizer decoder agrees with the reference decoder on short inputs and drifts steadily from it as the input grows. What is left over is a roughly constant noise floor, which speech masks and silence does not — so the end of a long chunk, where the model has stopped talking, comes out as an audible rasp.

I am the author of VieNeu-TTS (#647, #658) and found this while embedding vieneu_v3_turbo in an application. The decoder is src/framework/codecs/moss_audio_tokenizer_codec_runtime.cpp, shared by moss_tts_nano, moss_tts_local, moss_tts_v15, moss_voicegen and vieneu_v3_turbo, so this is not a family-specific problem.

Measurement

Same codes, two decoders. The codes come from audio.cpp itself (codes_dump_file=), so nothing upstream of the decoder differs; the reference is the ONNX export of the same MOSS-Audio-Tokenizer-Nano checkpoint.

generated frames audio C++ vs reference
43 3.44 s 63.2 dB
94 7.52 s 34.8 dB
171 13.68 s 13.0 dB

About 25 dB lost per doubling. At 171 frames the last three frames, which the model generated as silence, come out as:

reference : 0.00001  0.00001  0.00001
audio.cpp : 0.00164  0.00126  0.00153     (~ -56 dB)

This is audible. In a blind listening test on six 0.8 s clips (three from each decoder, shuffled, unlabelled) the listener picked all three audio.cpp clips as "buzzy" and none of the reference ones.

Reproducing

# generate, and dump the codes the run decoded
audiocpp_cli --task tts --family vieneu_v3_turbo --backend cpu \
  --model models/VieNeu-TTS-v3-Turbo-GGUF/vieneu-v3-turbo-q8_0.gguf \
  --text "<a paragraph, ~14 s of speech>" \
  --request-option max_tokens=400 --request-option frame_cap=false \
  --request-option seed=1 --request-option codes_dump_file=dump.txt \
  --out cpp.wav

Then decode the generated_codes line from dump.txt with the reference decoder and compare against cpp.wav. A short utterance (~3 s) matches at 63 dB; a 14 s one at 13 dB. return_codes=true (in #658) returns the same codes directly if that is easier.

Ruled out

  • Windowed attention. Rebuilt with kAttentionQueryChunk set high enough to disable the windowed path entirely: output is bit-identical, so the chunked attention is not the source.
  • Decoder graph arena. vieneu_v3_turbo.speech_decoder_graph_arena_mb at 32 (default) and at 1024: also bit-identical.
  • Weight precision as such is not settled: the codec is f16 in the published package, and the shape of the loss (growing with T rather than constant) does not look like plain quantisation noise, but I could not isolate it cleanly — weight_type=f32 changes the sampling too, so the run generates different codes and the comparison stops being like-for-like. A way to decode a fixed set of codes through the C++ decoder alone would settle it in one run.

So the cause is still open, and it is something that accumulates along the time axis inside the decoder.

Meanwhile

#658 adds return_codes=true to vieneu_v3_turbo, which hands the generated codes back and lets the host decode them. That is what my application now does, and it restores the 0.23 s of trailing silence the C++ decoder was burying. It is a way around the problem for a host that has another decoder, not a fix.

Happy to keep digging if you can point me at which part of the decode path you would suspect first — and to test any patch on this end, where the failure is reproducible.

Activity

  1. added a commit that references this issue on Sep 23, 2026
    a2698fb
  2. christopherthompson81 commented on Sep 23, 2026

    @christopherthompson81
    Contributor

    Found it, and there is a fix in #664. Your report was good enough to work from directly — thank you for the ruled-out list in particular, it saved me from two of the wrong paths.

    Cause: the Nano decoder's attention contexts were each exactly doubled

    audio.cpp hardcodes each stage's attention context as a step count. The checkpoint states it as a duration per stage, which the reference turns into steps with int(round(current_frame_rate * context_duration)) — the rate being the one before that transformer, not after its patch.

    Nano's decoder durations are not uniform — 10, 8, 6 and 4 seconds down the stack — where v1's are a flat 10:

     50 Hz × 10 s →  500      ours 1000
    100 Hz ×  8 s →  800      ours 1600
    200 Hz ×  6 s → 1200      ours 2400
    400 Hz ×  4 s → 1600      ours 3200
    

    So the decoder attended over twice the intended window. It matches the reference while a sequence is shorter than the real context, and diverges as soon as it outgrows one — which is exactly your curve: exact at 43 frames, collapsing after.

    frames before after
    43 111.3 dB 111.3 dB
    94 23.9 dB 108.4 dB
    171 12.2 dB 102.1 dB
    500 2.4 dB 91.5 dB

    Your "ruled out" list held up

    • Windowed attention — you were right. I rebuilt with kAttentionQueryChunk at 1e6: the bytes change, but the SNR is identical to a tenth of a dB at every length. Both paths were faithfully implementing the same wrong window.
    • Weight precision — also not it, and now settled rather than suspected: it reproduces at f32. Your instinct that the shape did not look like quantisation noise was correct.

    I also eliminated graph-cache reuse, causality, the mask formula (ours matches the reference's (delta >= 0) & (delta < context)), the RoPE convention, and channel handling. The formula was right all along; the numbers fed into it were not.

    Scope

    It is the Nano decoder alone. tools/check_moss_codec_contexts.py in the PR derives every context from each checkpoint and compares:

    v1     encoder OK  decoder OK     moss_tts_v15, moss_voicegen
    v2     encoder OK  decoder OK     moss_tts_local
    nano   encoder OK  decoder OK     moss_tts_nano, vieneu_v3_turbo   (after the fix)
    

    Nano's encoder was already correct, which is why only decoding was affected. So the families you listed were not all exposed — but the two that were are yours and moss_tts_nano, which is the pair that matters for you.

    The harness you asked for

    tests/moss_tts_delay/codec_decode_length_sweep is the decode-only entry point: a fixed code matrix in, a list of lengths, decoding the same matrix as its own prefix at each, so the reference decodes exactly the same prefixes and nothing upstream differs.

    One thing worth checking on your side: write every channel. An early version of mine compared our channel 0 against the reference's L+R mix and reported 70.6 dB where the truth was 111.4 — a 40 dB error that would have sent me somewhere else entirely.

    What I have not confirmed

    Your audible symptom, the rasp in trailing silence. My source clip is continuous speech with no long silent tail, so its quietest window only moves from 0.000002 to 0.000001 against the reference's 0.000001 — the floor now matches exactly, but that is not the same as reproducing the rasp. If you can run your original reproducer against #664 I would value the confirmation, since yours is the case with real generated silence at the end. It should also mean vieneu_v3_turbo no longer needs return_codes=true to get a clean tail.

  3. added a commit that references this issue on Sep 23, 2026
    68b8068
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