Repository navigation
Fix: LCMScheduler advances the generator on the final step of a strength-truncated custom schedule - #15364
Open
SIDDARTHAREDDY8 wants to merge 1 commit into
Open
Fix: LCMScheduler advances the generator on the final step of a strength-truncated custom schedule#15364SIDDARTHAREDDY8 wants to merge 1 commit into
SIDDARTHAREDDY8 wants to merge 1 commit into
Conversation
…schedule Same bug class as huggingface#15288 (fixed for TCDScheduler in huggingface#15301): `strength < 1` truncates a custom timestep schedule, but `num_inference_steps` keeps the pre-truncation count, so the actual final step sampled noise and advanced the generator even though that noise is never used. Guard on the actual schedule length instead. Follow-up to the review on huggingface#15301. Signed-off-by: SIDDARTHA REDDY <75976672+SIDDARTHAREDDY8@users.noreply.github.com> Signed-off-by: Siddartha Reddy Chinthala <siddarthareddychinthala@gmail.com>
This branch has not been deployed
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.
Same bug class as #15288 (fixed for TCDScheduler in #15301): with a custom timestep schedule and
strength < 1,set_timestepstruncates the schedule butnum_inference_stepskeeps the pre-truncation count, so the actual final step sampled noise and advanced the generator even though that noise is never used. Guard on the actual schedule length instead.Follow-up to the review on #15301, which suggested applying the same one-line change to
LCMScheduler.step.Changes:
src/diffusers/schedulers/scheduling_lcm.py:step_index != num_inference_steps - 1->step_index != len(self.timesteps) - 1tests/schedulers/test_scheduler_lcm.py: regression testtest_truncated_custom_timesteps_final_step_preserves_generatorcovering single-step ([999, 499, 19], strength 0.5 ->[19]) and multi-step ([999, 899, 799, 699, 599], strength 0.6 ->[799, 699, 599]) truncation forepsilonandv_prediction, asserting the generator state is untouched on the final step only.Verification (CPU, torch 2.14): the new test fails on unpatched code (generator advances on the final step) and passes with the fix; the full
test_scheduler_lcm.pysuite passes, 35 passed. Ruff clean.This contribution was developed with AI assistance.