Fix 0.6B fine-tuning crash: project text embedding before adding to c…#336
Open
kru2710shna wants to merge 1 commit into
Open
Fix 0.6B fine-tuning crash: project text embedding before adding to c…#336kru2710shna wants to merge 1 commit into
kru2710shna wants to merge 1 commit into
Conversation
1 task
4 tasks
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.
CAUSE
In finetuning/sft_12hz.py, the text and codec embeddings are added element-wise:
But they are defined at different widths in the talker model (modeling_qwen3_tts.py):
So text_embedding has width text_hidden_size and codec_embedding has width hidden_size. These differ for 0.6B Base (text_hidden_size=2048, hidden_size=1024), so the add fails with:
FIX
The talker already defines text_projection (Qwen3TTSTalkerResizeMLP, mapping text_hidden_size to hidden_size) and applies it on the inference path before combining text and codec embeddings. The fine-tuning script omitted it. This PR projects the text embedding through text_projection before the add, matching inference.
Because text_projection uses bias=True, the mask is re-applied after projection so padded positions remain zero:
Verification
Reproduced the crash on Qwen3-TTS-12Hz-0.6B-Base with training data prepared via prepare_data.py:
Before: RuntimeError: tensor a (2048) must match tensor b (1024) at the embedding add.
After: training proceeds and the step completes with finite loss (Epoch 0 | Step 0 | Loss: 11.82).
Fixes #335