Change clip workaround for SD3

#186
This commit is contained in:
City
2024-12-22 15:24:14 +01:00
parent 8d1b56c5e2
commit eaffa0a7d3
2 changed files with 6 additions and 10 deletions
-9
View File
@@ -232,15 +232,6 @@ class CLIPLoaderGGUF:
embedding_directory = folder_paths.get_folder_paths("embeddings"),
)
clip.patcher = GGUFModelPatcher.clone(clip.patcher)
# for some reason this is just missing in some SAI checkpoints
if getattr(clip.cond_stage_model, "clip_l", None) is not None:
if getattr(clip.cond_stage_model.clip_l.transformer.text_projection.weight, "tensor_shape", None) is None:
clip.cond_stage_model.clip_l.transformer.text_projection = comfy.ops.manual_cast.Linear(768, 768)
if getattr(clip.cond_stage_model, "clip_g", None) is not None:
if getattr(clip.cond_stage_model.clip_g.transformer.text_projection.weight, "tensor_shape", None) is None:
clip.cond_stage_model.clip_g.transformer.text_projection = comfy.ops.manual_cast.Linear(1280, 1280)
return clip
def load_clip(self, clip_name, type="stable_diffusion"):
+6 -1
View File
@@ -86,7 +86,12 @@ class GGMLLayer(torch.nn.Module):
elif k[prefix_len:] == "bias" and v is not None:
self.bias = torch.nn.Parameter(v, requires_grad=False)
else:
missing_keys.append(k)
unexpected_keys.append(k)
# For Linear layer with missing weight
if self.weight is None and isinstance(self, torch.nn.Linear):
v = torch.zeros(self.in_features, self.out_features)
self.weight = torch.nn.Parameter(v, requires_grad=False)
missing_keys.append(prefix+"weight")
def _save_to_state_dict(self, *args, **kwargs):
if self.is_ggml_quantized():