Skip to content

Fix EMAModel test_from_pretrained #10325

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
Dec 21, 2024
Merged

Fix EMAModel test_from_pretrained #10325

merged 2 commits into from
Dec 21, 2024

Conversation

hlky
Copy link
Contributor

@hlky hlky commented Dec 20, 2024

What does this PR do?

Torch CUDA Tests (others) has been failing from EMAModel.

FAILED tests/others/test_ema.py::EMAModelTests::test_from_pretrained - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

ema_unet is on the correct device as it's created from unet which is moved to torch_device

unet = UNet2DConditionModel.from_pretrained(self.model_id, subfolder="unet")
unet = unet.to(torch_device)
ema_unet = EMAModel(unet.parameters(), decay=decay, model_cls=UNet2DConditionModel, model_config=unet.config)

loaded_ema_unet is on CPU.

This matches torch.allclose call with original_param, loaded_param and the order of the error cuda:0 and cpu!.

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.

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!

@hlky hlky merged commit bf9a641 into huggingface:main Dec 21, 2024
8 checks passed
Foundsheep pushed a commit to Foundsheep/diffusers that referenced this pull request Dec 23, 2024
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
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.

2 participants