diff --git a/nodes.py b/nodes.py index bea5a04..a743297 100644 --- a/nodes.py +++ b/nodes.py @@ -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"): diff --git a/ops.py b/ops.py index 378d21e..22342a0 100644 --- a/ops.py +++ b/ops.py @@ -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():