Skip to content
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

Fix bug in half precision for DPMSolverMultistepScheduler #1349

Merged
merged 3 commits into from Nov 29, 2022

Conversation

rtaori
Copy link
Contributor

@rtaori rtaori commented Nov 20, 2022

The following code fails for the new DPMSolverMultistepScheduler when used in half precision due to torch.quantile() expecting inputs to be in full precision. This slight patch fixes this bug and allows for the following use case:

pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", custom_pipeline="stable_diffusion_mega",
                                         scheduler=DPMSolverMultistepScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule='scaled_linear'),
                                         torch_dtype=torch.float16, revision="fp16", safety_checker=None, use_auth_token=True).to('cuda')
pipe.text2img('a picture of a stealth fighter', num_images_per_prompt=10, num_inference_steps=50, output_type='numpy')

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 20, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a 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 the fix! Could you maybe add one test to:

class DPMSolverMultistepSchedulerTest(SchedulerCommonTest):
to showcase your PR fixes a bug? :-)

@rtaori
Copy link
Contributor Author

rtaori commented Nov 23, 2022

Added a test!

@patrickvonplaten
Copy link
Contributor

Thanks a lot @rtaori !

@patrickvonplaten patrickvonplaten merged commit 6a0a312 into huggingface:main Nov 29, 2022
sliard pushed a commit to sliard/diffusers that referenced this pull request Dec 21, 2022
…e#1349)

* cast to float for quantile method

* add fp16 test for DPMSolverMultistepScheduler fix

* formatting update
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
…e#1349)

* cast to float for quantile method

* add fp16 test for DPMSolverMultistepScheduler fix

* formatting update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants