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

[Sigmas] Keep sigmas on CPU #6173

Merged
merged 3 commits into from
Dec 15, 2023
Merged

[Sigmas] Keep sigmas on CPU #6173

merged 3 commits into from
Dec 15, 2023

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Dec 14, 2023

What does this PR do?

After a second round of testing, it seems like keeping the sigmas always on CPU is actually not a bad idea because there is no real slow-down for the "default" mode while the speed-up for torch.compile is significantly higher when leaving sigmas on CPU.
cc @sayakpaul

@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
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

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

thanks!

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.

Thank you!

@sayakpaul sayakpaul merged commit 4836cfa into main Dec 15, 2023
16 checks passed
donhardman pushed a commit to donhardman/diffusers that referenced this pull request Dec 18, 2023
* correct

* Apply suggestions from code review

* make style
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* correct

* Apply suggestions from code review

* make style
@sunhs
Copy link
Contributor

sunhs commented Jan 24, 2024

I'm curious about how it works. self.sigmas.to("cpu") does return a Tensor on cpu but it's not used, whereas self. sigmas is still on gpu. I must have misunderstood something. Could you show me some references to make it clear?

@sayakpaul
Copy link
Member

to is inplace.

@sunhs
Copy link
Contributor

sunhs commented Jan 24, 2024

image

Can this demonstrate my uncertainty?

@sayakpaul
Copy link
Member

Cc: @patrickvonplaten here. This still doesn't affect the results in the PyTorch blog post as it was done from a separate branch with another way of doing the device placement.

@yiyixuxu
Copy link
Collaborator

ahh does this means our pipeline.to() behave differently from the pytorch to()? - ours would modify in place and return a copy

@sunhs
Copy link
Contributor

sunhs commented Jan 24, 2024

ahh does this means our pipeline.to() behave differently from the pytorch to()? - ours would modify in place and return a copy

This should not be a problem, since nn.Module.to indeed is in place while Tensor.to isn't.

@patrickvonplaten
Copy link
Contributor Author

Nice catch @sunhs - correcting it here: #6708

It shouldn't change anything in practice since self.sigmas are always kept on CPU anyways for Euler and DPM. I'll keep an eye on the slow tests though (cc @DN6)

@patrickvonplaten patrickvonplaten deleted the keep_sigmas_on_cpu branch January 29, 2024 14:48
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* correct

* Apply suggestions from code review

* make style
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.

5 participants