Conversation
Both SD3 ControlNet pipelines called `retrieve_timesteps()` without any `mu` handling and exposed no `mu` argument, so any scheduler configured with `use_dynamic_shifting=True` — the SD3.5-style configs — raised "`mu` must be passed when `use_dynamic_shifting` is set to be `True`" before inference. This made ControlNet inconsistent with the rest of the SD3 family. Port the `calculate_shift()` helper, the `mu` argument and the `scheduler_kwargs["mu"]` handling from the base SD3 pipelines. `mu` is derived from the latents, so latent preparation now runs before timestep preparation, matching the base SD3 ordering. Neither step depends on the other, and the existing expected slices are unchanged, confirming the reorder preserves behaviour. Add regression tests for the derived and explicitly passed `mu` paths in both pipelines. Ref huggingface#13611 (Issue 2) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBYeq5vB4DNZDEaqUsroKR
|
Hi @Devam0311, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an issue (or gets the |
|
This PR has been automatically closed because it does not link an issue and the reminder above was not addressed within 10 days. If this PR is still relevant, please link the issue it fixes (e.g. We are experimenting with this process to keep the review queue manageable, and it will sometimes get it wrong. If you think this PR should stay open, please just say so here and we will reopen it — no need to justify it at length. Thanks again for contributing, and sorry for the noise if we closed this by mistake! |
What does this PR do?
Fixes Issue 2 of #13611.
Both SD3 ControlNet pipelines call
retrieve_timesteps()with nomuhandling and expose nomuargument, so any scheduler withuse_dynamic_shifting=True— the SD3.5-style configs — fails before inference:The base
StableDiffusion3PipelineandStableDiffusion3InpaintPipelinealready compute and passmu, so ControlNet was the odd one out in the SD3 family.Solution
Ports the
calculate_shift()helper, themuargument, and thescheduler_kwargs["mu"]handling from the base SD3 pipelines into both ControlNet pipelines.One ordering change worth calling out.
muis derived from the latents' shape, but these pipelines prepared timesteps (step 4) before latents (step 5) — the reverse of the base SD3 pipelines. So latent preparation now runs first, and the steps are renumbered to match.That reorder is safe here:
prepare_latentsonly draws from the generator and never touches the scheduler, andretrieve_timestepsnever touches the latents. The strongest evidence is that every existing expected slice intests/pipelines/controlnet_sd3/still passes unchanged — I ran the suite after the reorder and before adding any new tests.The alternative was deriving
image_seq_lenfromheight/widthto avoid moving anything, but that re-derives whatprepare_latentsalready computed and would get the user-supplied-latentscase wrong.Testing
Two tests per pipeline (four total):
test_dynamic_shifting_scheduler—use_dynamic_shifting=Truenow runs, exercising the derived-mupathtest_dynamic_shifting_scheduler_accepts_explicit_mu— covers theelif mu is not NonebranchVerified all four catch the bug: with the fix reverted, all four fail with the
ValueErrorabove.Before submitting
self-reviewskill on the diff?Self-review notes
Reviewed against
.ai/references/review-rules.mdandpipelines.md. No blocking issues.For the reviewer:
image_seq_lenfromheight/widthinstead if you'd rather nothing moved.latent_height/latent_widthrather than shadowingheight/widthaspipeline_stable_diffusion_3.pydoes, since those names are still live later in these pipelines.max_shiftdefault of1.16for consistency with them, even thoughcalculate_shift's own signature defaults to1.15. That discrepancy already exists inpipeline_stable_diffusion_3.py; I did not want to silently change it here.Who can review?
@yiyixuxu @asomoza @hlky