-
Notifications
You must be signed in to change notification settings - Fork 6.1k
debug EMAModel.from_pretrained()
#9809
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
Conversation
`model_cls.load_config()` is modified to **`model_cls.from_config()`**. When setting `return_unused_kwargs=True`, for `model_cls.load_config()`, the returned unused kwargs are referred to as **unused input args**, instead of unused args for `model_cls` initialization. So the returned `ema_kwargs` are always empty (`{}`). **`model_cls.from_config()`** will return the real **unused args for model initialization**, which are the expected `ema_kwargs`.
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.
Could you add a test for this here? https://github.com/huggingface/diffusers/blob/main/tests/others/test_ema.py
Hi @sayakpaul , how can I add a test here? I'm not familiar with this. |
Add a test case like diffusers/tests/others/test_ema.py Line 146 in 9a92b81
that accounts for the changes you introduced in this PR? |
This PR only affects training and resuming with EMAModel and also requires loading a JSON file, so this bug might not be that obvious and easy to write a test case. Let's say you have a file named {
"decay": 0.9999,
"inv_gamma": 1.0
} You can run: from diffusers import UNet2DConditionModel
model_cls = UNet2DConditionModel
path = "config.json"
_, ema_kwargs = model_cls.from_config(path, return_unused_kwargs=True)
print(ema_kwargs) # Output: {"decay": 0.9999, "inv_gamma": 1.0}: ✅
_, ema_kwargs = model_cls.load_config(path, return_unused_kwargs=True)
print(ema_kwargs) # Output: {}: ❌ |
Okay, we can add this as a test case then maybe? |
OK, thank you 😊. You could consider merging this PR then. I have tested it in my own training process, and this bug has confused me for quite some time. |
Sorry I think you misunderstood. I am suggesting you to add a test case to demonstrate the use case you mentioned in #9809 (comment). |
OK. I tried. But I found it's not that easy to write a |
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. |
i already opened a PR for this #9779 with the test case @sayakpaul @chenguolin |
It looks good :) |
What does this PR do?
model_cls.load_config()
is modified tomodel_cls.from_config()
.When setting
return_unused_kwargs=True
, formodel_cls.load_config()
, the returned unused kwargs are referred to as unused input args, instead of unused args formodel_cls
initialization. So the returnedema_kwargs
are always empty ({}
).model_cls.from_config()
will return the real unused args for model initialization, which are the expectedema_kwargs
.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
General functionalities: @sayakpaul @yiyixuxu @DN6