Repository navigation
moss_ttsd: take #674's f16 decoder and KV cache, keep the encoder at f32 - #687
Conversation
…der at f32 moss_tts_v15 loads its codec at f16 and its KV cache at f16 on GPU backends, which is what lets bf16 clone on a 24 GiB card. moss_ttsd shares the codec and backbone, but didn't opt in, so bf16 cloning still failed allocating moss.audio_tokenizer.encoder. The decoder and KV cache come across unchanged. The KV cache is bit-identical on output, and the decoder is 44.5 dB with identical transcripts. The encoder does not come across. This model continues directly from the reference's codes, and an f16 encoder changes 5-14% of the finer codebooks. Over 26 seeds that produced silence or a re-spoken prompt 3 times, against none at f32. Add an optional encoder-only storage type to the codec options for that. It's appended last, so the other callers are untouched. With the encoder at f32, the generated codes match main exactly. Cloning peaks drop by 1.8 GiB and bf16 clones at 21.0 GiB where it failed before. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KR9AUMpJhbrWijVoDacUDx
|
@christopherthompson81 I find one interesting way to reduce peak VRAM
So basically:
This may be a useful pattern for future models. |
|
@0xShug0 Nice, thanks. That's a better fit for TTSD than what I did, so I put it in #690. Since the packages store the codec at f16, the widening is exact, and the encoder's output is bit-identical to #687's f32 path on every package, including the seeds that collapsed with an f16 encoder. That's the property #687 kept f32 for, now for about 1.65 GiB less. bf16 cloning goes from 21.0 to 19.4 GiB, which takes care of the tight headroom I flagged. It also made a one-shot clone 1.3 s faster, because the lazy encoder prepare uploads half the bytes. One thing to watch when reusing the pattern: it's only lossless when the stored type matches the source. From f32 safetensors, holding the weights at f16 is a real rounding step. So #690 loads the encoder |
…e graph (#690) #687 kept the codec encoder at f32 because this model is sensitive to the reference's codes. Those f32 weights are the packages' f16 values widened, so the same numbers can be produced in the graph instead: hold each projection at its stored type and ggml_cast it to f32 where it is consumed. The graph allocator then reuses the widened buffers rather than keeping every expanded weight resident. This is 0xShug0's pattern from the #687 thread. The widening is exact, so the output is bit-identical to #687 for every package, including the seeds that failed with an f16 encoder. The encoder is loaded Native rather than as f16, so an f32 source is never rounded and simply skips the cast. Cloning peaks drop by about 1.65 GiB. A one-shot clone is 1.3 s faster, because the lazily prepared encoder uploads half the bytes.
Follow-up to #674. MOSS-TTSD shares v1.5's codec and backbone, but it didn't opt in to the f16 path, so bf16 cloning on a 24 GiB card still fails:
This applies the same opt-in on CUDA, Vulkan and Metal, with one difference: the codec encoder stays at f32.
Why not the encoder
My first version copied #674 exactly. Peaks and SNR looked fine, but transcribing the output found the problem. At seed 7, the q8_0 and bf16 clones came out near-silent, 11 s long, with empty transcripts.
mainspoke the script.The encoder itself is fine. I dumped the reference codes at f32 and f16: codebook 0 is identical on every clip, and the finer codebooks agree 86–100%. But MOSS-TTSD continues from those codes, and it is sensitive to them. Over 26 seeds of the same two-speaker clone:
[S2]line (4), one misheard wordThe success rate is the same, but only f16 produced the severe failures. 3 of 26 against 0 isn't conclusive, so I kept the encoder at f32 rather than argue about it. v1.5 is unaffected: its clones transcribe exactly at every quantization with the f16 encoder.
That needed one small framework change.
MossAudioTokenizerCodecRuntimeOptionsgains an optionalencoder_transformer_weight_storage_type, which falls back to the shared type when unset. It's appended last, so the six existing positional-brace callers compile unchanged and behave the same.Verification
The decoder only renders finished codes, and the f16 KV cache is bit-identical on output (checked separately: base vs +KV, SNR ∞). So with the encoder at f32, the generated codes match
mainexactly. This is shown directly below rather than argued statistically.RTX 3090, peak VRAM of the process, clone at seed 7, transcribed with
parakeet_tdt:mainmain's length and transcript exactly. Waveform SNR is 15.6–41.2 dB. The low end is seed 7, which is mostly near-silence, where decoder rounding weighs more.main: 44.5 dB, identical transcript, no NaN. The backbone's f16 weight problem noted inparse_weight_typeconcerns activations, and the KV cache stays within range. The output is bit-identical.use_f16is false there, and the encoder was already f32.Caveats
🤖 Generated with Claude Code
https://claude.ai/code/session_01KR9AUMpJhbrWijVoDacUDx