-
Couldn't load subscription status.
- Fork 6.5k
DPM++ third order fixes #9104
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
DPM++ third order fixes #9104
Conversation
|
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
|
can you take a look here? @hlky |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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 @StAlKeR7779! 🤗
Test
from diffusers import DPMSolverSinglestepScheduler, DPMSolverMultistepScheduler, StableDiffusionXLPipeline
import torch
solver_order = 3
algorithm_type = "sde-dpmsolver++"
model = "stabilityai/stable-diffusion-xl-base-1.0"
dpm_single = DPMSolverSinglestepScheduler.from_pretrained(model, subfolder="scheduler", solver_order=solver_order, algorithm_type=algorithm_type)
dpm_multi = DPMSolverMultistepScheduler.from_pretrained(model, subfolder="scheduler", solver_order=solver_order, algorithm_type=algorithm_type)
pipeline = StableDiffusionXLPipeline.from_pretrained(model, variant="fp16", torch_dtype=torch.float16)
pipeline.enable_vae_tiling()
pipeline = pipeline.to("cuda")
prompt = "a photo of an astronaut riding a horse on mars"
pipeline.scheduler = dpm_single
num_inference_steps = 23
image = pipeline(prompt, num_inference_steps=num_inference_steps, generator=torch.Generator().manual_seed(0)).images[0]
image.save("dpm_single.png")
pipeline.scheduler = dpm_multi
image = pipeline(prompt, num_inference_steps=num_inference_steps, generator=torch.Generator().manual_seed(0)).images[0]
image.save("dpm_multi.png")* Fix wrong output on 3n-1 steps count * Add sde handling to 3 order * make * copies --------- Co-authored-by: hlky <[email protected]>
* Fix wrong output on 3n-1 steps count * Add sde handling to 3 order * make * copies --------- Co-authored-by: hlky <[email protected]>


What does this PR do?
This pull request addresses two issues:
Incorrect output in
DPMSolverSinglestepSchedulerFixed the issue where using
solver_order=3and a step count of 3n-1 resulted in incorrect output. The problem was caused by improper handling offinal_sigmas_type=zero, leading to alog(0)error in thesinglestep_dpm_solver_second_order_updatefunction. The handling has been implemented in the simplest possible way, and I welcome any suggestions how it can done better.Support for
sde-dpmsolver++in third orderAdded support for the
sde-dpmsolver++algorithm to both theDPMSolverSinglestepSchedulerandDPMSolverMultistepScheduler. Previously, usingsolver_order=3would throw an error:UnboundLocalError: local variable 'x_t' referenced before assignmentThis was due to the lack of a branch to handle the
sde-dpmsolver++algorithm in thesinglestep_dpm_solver_third_order_updateandmultistep_dpm_solver_third_order_updatefunctions. My implementation is based on how the sde is already integrated into first and second-order solvers, so please review carefully to ensure correctness.Fixes # (issue)
#9007
Who can review?
@yiyixuxu
@LuChengTHU (sorry if wrongly tag you)