-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Core] Harmonize single file ckpt model loading #6971
Conversation
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. |
for pat in vae._keys_to_ignore_on_load_unexpected: | ||
unexpected_keys = [k for k in unexpected_keys if re.search(pat, k) is None] | ||
|
||
if len(unexpected_keys) > 0: |
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.
Small nit. Since unexpected_keys
is always of type list
we can just use
if unexpected_keys:
...
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.
Oh, I followed what's done in modeling_utils.py
to be consistent.
@@ -48,6 +48,7 @@ def build_sub_model_components( | |||
load_safety_checker=False, | |||
model_type=None, | |||
image_size=None, | |||
torch_dtype=None, |
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.
Nice catch!
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.
LGTM 👍🏽
What does this PR do?
Currently, we make use of
set_module_tensor_to_device
in the single file loading utilities to speed up model loading time. However, insrc/models/modeling_utils.py
, we already have a utility calledload_model_dict_into_meta()
that abstracts the boilerplate code.diffusers/src/diffusers/models/modeling_utils.py
Line 133 in 0ca7b68
This PR updates the single file utilities to use
load_model_dict_into_meta()
as well.I have run the single-file SLOW tests, but @DN6, feel free to do so on your end, too, just to be sure.