-
Notifications
You must be signed in to change notification settings - Fork 6k
[draft] refactor DPMSolverMultistepScheduler using sigmas #4690
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
Conversation
The documentation is not available anymore as the PR was closed or merged. |
Do we really need "sde-dpmsolver" and "dpmsolver" here? We have so many options here, and I think that really confuses people. i.e. we have 4 Can we possibly trim it a little bit as I refactor it? From what I understand, the algorithm type "dpmsolver" and "sde-dpmsolver" (proposed in this paper before the same author came up with dpmsolver+++ https://huggingface.co/papers/2206.00927) are completely obsolete at this point. |
testing "dpmsolver ++"testing the implementation against k-diffusion
use_karras_sigmas=Falseimport torch
from diffusers import StableDiffusionKDiffusionPipeline, DPMSolverMultistepScheduler, StableDiffusionPipeline
import gc
import numpy as np
# test1: use_karras_sigmas=False
seed = 33
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
pipe = pipe.to("cuda")
pipe.scheduler = DPMSolverMultistepScheduler.from_config(
pipe.scheduler.config, use_karras_sigmas=False
)
prompt = "an astronaut riding a horse on mars"
generator = torch.Generator(device="cuda").manual_seed(seed)
image_d = pipe(prompt, generator=generator, num_inference_steps=20, output_type='np').images[0]
seed = 33
pipe = StableDiffusionKDiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4"
).to("cuda")
pipe.set_scheduler("sample_dpmpp_2m")
prompt = "an astronaut riding a horse on mars"
generator = torch.Generator(device="cuda").manual_seed(seed)
image_k = pipe(
prompt, generator=generator, num_inference_steps=20, use_karras_sigmas=False, output_type='np'
).images[0]
print(f"compare: {np.max(np.abs((image_d - image_k)))}") -> 0.0002550482749938965 use_karras_sigmas=Trueseed = 33
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
pipe = pipe.to("cuda")
pipe.scheduler = DPMSolverMultistepScheduler.from_config(
pipe.scheduler.config, use_karras_sigmas=True
)
prompt = "an astronaut riding a horse on mars"
generator = torch.Generator(device="cuda").manual_seed(seed)
image_d = pipe(prompt, generator=generator, num_inference_steps=20, output_type='np').images[0]
seed = 33
pipe = StableDiffusionKDiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4"
).to("cuda")
pipe.set_scheduler("sample_dpmpp_2m")
prompt = "an astronaut riding a horse on mars"
generator = torch.Generator(device="cuda").manual_seed(seed)
image_k = pipe(
prompt, generator=generator, num_inference_steps=20, use_karras_sigmas=True, output_type='np'
).images[0]
print(f"compare: {np.max(np.abs((image_d - image_k)))}") -> 0.000287860631942749 compare against current implementation (
|
think I'm overcomplicating things with this pr - will try a different approach! |
This PR refactor DPMSolverMultistepScheduler: update the computation to use sigmas.
currently, I only refactored "dpmsolver++" and "sde-dpmsolver++"
to-do left:
#4187