Repository navigation
moss_ttsd: hold the encoder at its stored type and widen to f32 in the graph - #690
Merged
0xShug0 merged 1 commit intoSep 25, 2026
Merged
Conversation
…e graph 0xShug0#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 0xShug0#687 thread. The widening is exact, so the output is bit-identical to 0xShug0#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. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KR9AUMpJhbrWijVoDacUDx
Owner
|
@christopherthompson81 Thanks for the follow-up! PR merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Applies @0xShug0's experiment from the #687 thread to MOSS-TTSD. The encoder's projection weights stay resident at their stored type and are
ggml_castto f32 where the graph consumes them. The graph allocator can then reuse the widened buffers instead of keeping every expanded weight in VRAM.Why the output doesn't change at all
#687 kept the encoder at f32 because this model continues directly from the reference's codes and is sensitive to them. But the published packages store the codec at f16, so those f32 weights are just f16 values widened, and f16→f32 is exact. Widening inside the graph gives the matmuls the same operands, so the result is bit-identical, not just close.
One deliberate difference from the experiment as described: the encoder is loaded
Nativerather than as f16. A fixed f16 would round an f32 safetensors source, which is exactly the change to the codes that #687 avoided. WithNative, an f16 GGUF stays f16 in VRAM, and an f32 source stays f32 and skips the cast (projection_weightreturns F32 weights unchanged).Changes
MossAudioTokenizerCodecRuntimeOptions::widen_encoder_transformer_weights_to_f32, appended last, defaultfalse. The other callers are unchanged.projection_weight()applies the cast at the six projections (input_proj,output_proj,in_proj,out_proj,fc1,fc2). The decoder never sets the flag, so its graph is unchanged.moss_ttsdon CUDA/Vulkan/Metal: encoderNative+ widen. On CPU: F32, no widening, as before.Verification
RTX 3090, compared with a build of
mainat #687:That's close to your numbers (q8 15,434 → 13,766, bf16 22,266 → 20,592 on your setup). It also closes #687's one caveat: bf16 cloning now has about 2.5 GiB of headroom on a 24 GiB card instead of about 0.8 GiB.
A one-shot clone also gets 1.3 s faster: q8_0
session.wall_mswent from 3,942–3,965 ms to 2,623–2,642 ms over six interleaved runs each. The encoder is prepared lazily on the first clone, so its upload counts toward the session. It now uploads 1.65 GiB of f16 instead of widening to 3.3 GiB of f32 on the host first. I didn't re-measure warm steady state; your table shows it as neutral, which fits the mechanism.🤖 Generated with Claude Code
https://claude.ai/code/session_01KR9AUMpJhbrWijVoDacUDx