From f7d8fbe74052e139a3b20b4a4f702bda82fdc23e Mon Sep 17 00:00:00 2001 From: blepping Date: Wed, 28 Aug 2024 11:56:51 -0600 Subject: [PATCH] Workaround for stable-diffusion.cpp SDXL GGUF files --- nodes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nodes.py b/nodes.py index 84c5def..9df2523 100644 --- a/nodes.py +++ b/nodes.py @@ -67,6 +67,11 @@ def gguf_sd_loader(path, handle_prefix="model.diffusion_model.", require_prefix= shape = gguf_sd_loader_get_orig_shape(reader, tensor_name) if shape is None: shape = torch.Size(tuple(int(v) for v in reversed(tensor.shape))) + if arch_str is None and (tensor_name.endswith(".proj_in.weight") or tensor_name.endswith(".proj_out.weight")): + # Workaround for stable-diffusion.cpp SDXL detection. + # Impossible to land here for our own GGUF files as we set architecture. + while len(shape) > 2 and shape[-1] == 1: + shape = shape[:-1] if tensor.tensor_type in {gguf.GGMLQuantizationType.F32, gguf.GGMLQuantizationType.F16}: torch_tensor = torch_tensor.view(*shape) sd[sd_key] = GGMLTensor(