Fix CFG denoising: use unconditional sample for unconditional branch#387
Open
hobostay wants to merge 1 commit into
Open
Fix CFG denoising: use unconditional sample for unconditional branch#387hobostay wants to merge 1 commit into
hobostay wants to merge 1 commit into
Conversation
In sample_speech_tokens, the unconditional half of the speech tensor was being replaced with a copy of the conditional half before being passed to the prediction head. This means the unconditional noise prediction was computed from the conditional sample, not the actual unconditional sample, making CFG mathematically incorrect. Use the actual unconditional sample (other_half) in the combined input to the prediction head so that both conditional and unconditional predictions use their respective samples. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
sample_speech_tokensto use the actual unconditional sample instead of duplicating the conditional sampleDetails
Affected file:
vibevoice/modular/modeling_vibevoice_streaming_inference.py(lines 887-899)The original code:
The fix:
In standard CFG, the model receives both the conditional sample (with the conditioning) and the unconditional sample (without). By duplicating the conditional half for both inputs, the unconditional noise prediction was computed from the wrong sample, producing incorrect CFG scaling. Only the conditional half is returned as output, but the unconditional branch still needs proper evolution through the denoising steps for CFG to work correctly.
Test plan
🤖 Generated with Claude Code