-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Z-Image-Turbo from_single_file
#12756
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
base: main
Are you sure you want to change the base?
Conversation
|
Sorry if this shows as a dupe I though commented this ages ago, but there's no sign of it The code is the TimestepEmbedder forward function def forward(self, t):
t_freq = self.timestep_embedding(t, self.frequency_embedding_size)
weight_dtype = self.mlp[0].weight.dtype
if weight_dtype.is_floating_point:
t_freq = t_freq.to(weight_dtype)
t_emb = self.mlp(t_freq)
return t_emb
This leads to the forward code t_emb = self.mlp(t_freq)eventually calling If I hardcode the right type, I can generate an image without issue t_freq = t_freq.to(self.mlp[0].compute_dtype)Presumably It will need to incorporated properly with a attribute check for compute_dtype as part of the dtype setting code rather than my brute force method |
|
That looks like it'll work, I'll give a quick test. |
|
Yep - that's worked, no errors only images :-) |
| # Match t_embedder output dtype to x for layerwise casting compatibility | ||
| adaln_input = t.type_as(x) | ||
| x[torch.cat(x_inner_pad_mask)] = self.x_pad_token | ||
| x[torch.cat(x_inner_pad_mask).to(x.device)] = self.x_pad_token.to(x.device) |
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.
Just a question. Why the device cast here? Is it to fix something else?
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 meant to remove that, for context this patch was shared in the community to fix layer offloading in one of the training UIs, I was just curious what changes they made and forgot to revert before I started this branch, not sure if it's related to Diffusers offloading or specific to the third party repo. Removed in da06a2c
| cap_feats = torch.cat(cap_feats, dim=0) | ||
| cap_feats = self.cap_embedder(cap_feats) | ||
| cap_feats[torch.cat(cap_inner_pad_mask)] = self.cap_pad_token | ||
| cap_feats[torch.cat(cap_inner_pad_mask).to(cap_feats.device)] = self.cap_pad_token.to(cap_feats.device) |
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.
Just a question. Why the device cast here? Is it to fix something else?
DN6
left a comment
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.
Thanks @hlky 👍🏽
|
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. |
What does this PR do?
See https://huggingface.co/Comfy-Org/z_image_turbo/blob/main/z_image_convert_original_to_comfy.py
Fixes #12748
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.