From 3f84be7fff9c6ce9fcbf74d6c4f7d95d660da73f Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 4 May 2026 21:47:54 +0800 Subject: [PATCH] Fix CFG denoising: use unconditional sample for unconditional branch 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 --- vibevoice/modular/modeling_vibevoice_streaming_inference.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vibevoice/modular/modeling_vibevoice_streaming_inference.py b/vibevoice/modular/modeling_vibevoice_streaming_inference.py index 70a48958..79c662c5 100644 --- a/vibevoice/modular/modeling_vibevoice_streaming_inference.py +++ b/vibevoice/modular/modeling_vibevoice_streaming_inference.py @@ -890,7 +890,8 @@ def sample_speech_tokens(self, condition, neg_condition, cfg_scale=3.0): speech = torch.randn(condition.shape[0], self.config.acoustic_vae_dim).to(condition) for t in self.model.noise_scheduler.timesteps: half = speech[: len(speech) // 2] - combined = torch.cat([half, half], dim=0) + other_half = speech[len(speech) // 2:] + combined = torch.cat([half, other_half], dim=0) eps = self.model.prediction_head(combined, t.repeat(combined.shape[0]).to(combined), condition=condition) cond_eps, uncond_eps = torch.split(eps, len(eps) // 2, dim=0) half_eps = uncond_eps + cfg_scale * (cond_eps - uncond_eps)