From 282947d93a64f0530c1b754f8d437c252572571d Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Mon, 18 Aug 2025 16:57:07 +0300 Subject: [PATCH] GGUF fix --- gguf/gguf.py | 2 +- nodes_model_loading.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gguf/gguf.py b/gguf/gguf.py index d21b817..41f37bd 100644 --- a/gguf/gguf.py +++ b/gguf/gguf.py @@ -36,6 +36,7 @@ def _replace_with_gguf_linear(model, compute_dtype, state_dict, prefix="", modul if ( isinstance(module, nn.Linear) + and not isinstance(module, GGUFLinear) and _should_convert_to_gguf(state_dict, module_prefix) and name not in modules_to_not_convert ): @@ -54,7 +55,6 @@ def _replace_with_gguf_linear(model, compute_dtype, state_dict, prefix="", modul model._modules[name].source_cls = type(module) # Force requires_grad to False to avoid unexpected errors model._modules[name].requires_grad_(False) - return model def set_lora_params_gguf(module, patches, module_prefix=""): diff --git a/nodes_model_loading.py b/nodes_model_loading.py index 5c0f719..3d5ed1d 100644 --- a/nodes_model_loading.py +++ b/nodes_model_loading.py @@ -755,6 +755,8 @@ def load_weights(transformer, sd, weight_dtype, base_dtype, transformer_load_dev pbar.update(100) #for name, param in transformer.named_parameters(): # print(name, param.dtype, param.device, param.shape) + #for name, param in transformer.blocks[0].motion_attn.named_parameters(): + # print(name, param.data) pbar.update_absolute(param_count) pbar.update_absolute(0) @@ -782,12 +784,12 @@ def load_weights_gguf(transformer, reader, sd, base_dtype, transformer_load_devi continue #print(name, param.dtype, param.device, param.shape) if isinstance(param, GGUFParameter): - dtype_to_use = torch.uint8 + continue elif "patch_embedding" in name: dtype_to_use = torch.float32 else: dtype_to_use = base_dtype - set_module_tensor_to_device(patcher.model.diffusion_model, name, device=transformer_load_device, dtype=dtype_to_use, value=sd[name]) + set_module_tensor_to_device(patcher.model.diffusion_model, name, device=transformer_load_device, dtype=dtype_to_use, value=sd[name.replace("_orig_mod.", "")]) cnt += 1 if cnt % 100 == 0: pbar.update(100) @@ -1142,6 +1144,7 @@ class WanVideoModelLoader: "add_ref_conv": True if "ref_conv.weight" in sd else False, "in_dim_ref_conv": sd["ref_conv.weight"].shape[1] if "ref_conv.weight" in sd else None, "add_control_adapter": True if "control_adapter.conv.weight" in sd else False, + "use_motion_attn": True if "blocks.0.motion_attn.k.weight" in sd else False } with init_empty_weights():