Uh oh!
There was an error while loading. Please reload this page.
Z-Image-Turbo from_single_file - #12756
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 defforward(self, t):
t_freq=self.timestep_embedding(t, self.frequency_embedding_size)
weight_dtype=self.mlp[0].weight.dtypeifweight_dtype.is_floating_point:
t_freq=t_freq.to(weight_dtype)
t_emb=self.mlp(t_freq)
returnt_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 |
hlky
commented
Dec 1, 2025
Vargol
commented
Dec 1, 2025
That looks like it'll work, I'll give a quick test. |
Vargol
commented
Dec 1, 2025
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.
Just a question. Why the device cast here? Is it to fix something else?
There was a problem hiding this comment.
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.
Just a question. Why the device cast here? Is it to fix something else?
HuggingFaceDocBuilderDev
commented
Dec 3, 2025
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. |
Uh oh!
There was an error while loading. Please reload this page.
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.