Skip to content

fix vae dtype when accelerate config using --mixed_precision="fp16" #9601

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

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

xduzhangjiayu
Copy link
Contributor

What does this PR do?

Issue #9560
Fix vae dtype when accelerate config using --mixed_precision="fp16".

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.
@sayakpaul

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just left a comment.

vae.to(accelerator.device, dtype=torch.float32)
vae.to(accelerator.device, dtype=weight_dtype)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be like:

if args.upcast_vae:
    vae.to(accelerator.device, dtype=torch.float32)
else:
    vae.to(accelerator.device, dtype=weight_dtype)

With upcast_vae being added to the arguments?

@xduzhangjiayu
Copy link
Contributor Author

Thanks for the comment, I have modified the code.

@HuggingFaceDocBuilderDev

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.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sayakpaul sayakpaul merged commit 2cb383f into huggingface:main Oct 7, 2024
8 checks passed
leisuzz pushed a commit to leisuzz/diffusers that referenced this pull request Oct 11, 2024
…uggingface#9601)

* fix vae dtype when accelerate config using --mixed_precision="fp16"

* Add param for upcast vae
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
…9601)

* fix vae dtype when accelerate config using --mixed_precision="fp16"

* Add param for upcast vae
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.

3 participants