Fix: WanVideoToVideoPipeline now handles VACE control tensors safely #12576
+181
−14
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.
What does this PR do?
Fixes: #12574
Summary:
WanVideoToVideoPipeline.__call__currently crashes when the underlyingTransformerWanVACE.forward()expects VACE control arguments but the pipeline doesn’t provide them, and it also doesn’t expose a way for users to pass them. This PR:control_hidden_states: Optional[torch.Tensor] = Nonecontrol_hidden_states_scale: Optional[torch.Tensor] = NoneThis makes Wan V2V robust out-of-the-box while allowing advanced users to supply real control tensors.
Motivation & Context
AttributeError: 'NoneType' object has no attribute 'new_ones'becausecontrol_hidden_states/_scaleare assumed non-None in the model, but the pipeline never provides them.Changes
WanVideoToVideoPipeline.__call__.forward()exposescontrol_hidden_states&control_hidden_states_scale, the pipeline:B,C_ctrl,pt,ph,pw).Bif needed during the denoising loop (future-proof for batch shape changes).tests/pipelines/wan/test_wan_video_to_video.py:test_neutral_control_injection_no_crash_latent: no CFG, latent output, asserts shape preserved.test_neutral_control_injection_with_cfg: with CFG (uncond branch), latent output, asserts shape preserved.Example usage
Backwards compatibility
Performance
B,C_ctrl,pt,ph,pw)); no measurable overhead.Tests
test_neutral_control_injection_no_crash_latenttest_neutral_control_injection_with_cfgoutput_type="latent") for speed, avoid VAE decode.WanTransformer3DModeldoesn’t expose control kwargs.Documentation
Checklist
make style) and quality checks (make quality) on my branchWho can review?
Tagging pipelines maintainers who might be interested: @yiyixuxu @asomoza
Thanks!