[draft] refactor DPMSolverMultistepScheduler using sigmas#4690
Closed
[draft] refactor DPMSolverMultistepScheduler using sigmas#4690
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
added 2 commits
August 22, 2023 00:29
Collaborator
Author
|
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. |
Collaborator
Author
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 (
|
Collaborator
Author
|
think I'm overcomplicating things with this pr - will try a different approach! |
4 tasks
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.




This PR refactor DPMSolverMultistepScheduler: update the computation to use sigmas.
currently, I only refactored "dpmsolver++" and "sde-dpmsolver++"
to-do left:
#4187