-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Add Custom Timesteps Support to LCMScheduler and Supported Pipelines #5874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Custom Timesteps Support to LCMScheduler and Supported Pipelines #5874
Conversation
…which support LCMScheduler (img2img, inpaint).
…es which support LCMScheduler (img2img, inpaint).
…ince make fix-copies doesn't appear to work correctly (it deletes the whole pipeline).
|
The documentation is not available anymore as the PR was closed or merged. |
| # 4. Prepare timesteps | ||
| self.scheduler.set_timesteps(num_inference_steps, device=device) | ||
| timesteps = self.scheduler.timesteps | ||
| if timesteps is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice!
Could we maybe factor this out into a function:
timesteps = retrieve_timesteps(self.scheduler, timesteps)and then use #copied from for all pipelines?
patrickvonplaten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for opening this PR - I think that's a good idea! Could we maybe try to make use of # Copied from by factoring out the function (similarly to:
diffusers/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py
Line 162 in 6fac136
| # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.retrieve_latents |
|
@patrickvonplaten I have refactored the timestep handling logic into a |
This looks great - very nice job! Merging! |
…uggingface#5874) * Add custom timesteps support to LCMScheduler. * Add custom timesteps support to StableDiffusionPipeline. * Add custom timesteps support to StableDiffusionXLPipeline. * Add custom timesteps support to remaining Stable Diffusion pipelines which support LCMScheduler (img2img, inpaint). * Add custom timesteps support to remaining Stable Diffusion XL pipelines which support LCMScheduler (img2img, inpaint). * Add custom timesteps support to StableDiffusionControlNetPipeline. * Add custom timesteps support to T21 Stable Diffusion (XL) Adapters. * Clean up Stable Diffusion inpaint tests. * Manually add support for custom timesteps to AltDiffusion pipelines since make fix-copies doesn't appear to work correctly (it deletes the whole pipeline). * make style * Refactor pipeline timestep handling into the retrieve_timesteps function.
…uggingface#5874) * Add custom timesteps support to LCMScheduler. * Add custom timesteps support to StableDiffusionPipeline. * Add custom timesteps support to StableDiffusionXLPipeline. * Add custom timesteps support to remaining Stable Diffusion pipelines which support LCMScheduler (img2img, inpaint). * Add custom timesteps support to remaining Stable Diffusion XL pipelines which support LCMScheduler (img2img, inpaint). * Add custom timesteps support to StableDiffusionControlNetPipeline. * Add custom timesteps support to T21 Stable Diffusion (XL) Adapters. * Clean up Stable Diffusion inpaint tests. * Manually add support for custom timesteps to AltDiffusion pipelines since make fix-copies doesn't appear to work correctly (it deletes the whole pipeline). * make style * Refactor pipeline timestep handling into the retrieve_timesteps function.
What does this PR do?
This PR adds custom
timestepssupport toLCMScheduler.set_timestepsand pipelines which supportLCMScheduler(e.g.LatentConsistencyModelPipeline,StableDiffusionPipeline,StableDiffusionXLPipeline). This gives users the flexibility to try out timestep schedules beyond the "standard" LCM inference schedule (as calculated whennum_inference_stepsis given toLCMScheduler.set_timesteps).Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@patrickvonplaten
@patil-suraj
@luosiallen