-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Fix image upcasting #7858
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 image upcasting #7858
Conversation
vae.encode() when using fp16
vae.encode() when using fp16vae.encode() when using fp16 with xformers or torch==2.0 installed
vae.encode() when using fp16 with xformers or torch==2.0 installedvae.encode() when using fp16 with xformers or torch>=2.0 installed
vae.encode() when using fp16 with xformers or torch>=2.0 installed|
the same issue exists in the StableDiffusionPipeline :) would you like to tackle that one too? latents must be cast to vae dtype during decode |
|
I need to understand. Wouldn't this throw an error: import torch
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16, variant='fp16').to("cuda")
image = pipe("a photo of an astronaut riding a horse on mars").images[0]Or, is it a case in MPS? |
|
it's actually something that occurs on ROCm which masquerades as CUDA |
|
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. |
yiyixuxu
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!
|
Thanks for merging! |
Fix image's upcasting before `vae.encode()` when using `fp16` Co-authored-by: YiYi Xu <[email protected]>
|
Thanks @StandardAI ❤️ |
Fix image's upcasting before `vae.encode()` when using `fp16` Co-authored-by: YiYi Xu <[email protected]>
Thanks for the opportunity to fix #7854
What does this PR do?
This PR proposes to fix
imageupcasting beforevae.encode()when usingfp16andvae.config.force_upcast==Truewithxformersortorch>=2.0installed. Casting with.to(next(iter(self.vae.post_quant_conv.parameters())).dtype)is supposed to be preferred beforevae.decode()notvae.encode().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.
@yiyixuxu @kadirnar