From 42a4b82c8e3217982ab68924552da1c067596a7f Mon Sep 17 00:00:00 2001 From: QualiaRain <44004657+QualiaRain@users.noreply.github.com> Date: Sat, 13 Jun 2026 00:19:56 -0400 Subject: [PATCH] fix(lora): guard self.shape for modules without a weight attribute NetworkModule.__init__ set self.shape only inside 'if hasattr(sd_module, weight)' but then used len(self.shape) unconditionally, raising AttributeError when a LoRA targets a weightless module. Default shape to None and skip the dora_norm_dims computation when absent. Co-Authored-By: Claude --- modules/lora/network.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/lora/network.py b/modules/lora/network.py index 576f5831c..5926cd4fa 100644 --- a/modules/lora/network.py +++ b/modules/lora/network.py @@ -166,6 +166,7 @@ class NetworkModule: self.network_key = weights.network_key self.sd_key = weights.sd_key self.sd_module = weights.sd_module + self.shape = None if hasattr(self.sd_module, 'weight'): if hasattr(self.sd_module, "sdnq_dequantizer"): self.shape = self.sd_module.sdnq_dequantizer.original_shape @@ -176,7 +177,7 @@ class NetworkModule: self.alpha = weights.w["alpha"].item() if "alpha" in weights.w else None self.scale = weights.w["scale"].item() if "scale" in weights.w else None self.dora_scale = weights.w.get("dora_scale", None) - self.dora_norm_dims = len(self.shape) - 1 + self.dora_norm_dims = (len(self.shape) - 1) if self.shape is not None else None def multiplier(self): unet_multiplier = 3 * [self.network.unet_multiplier] if not isinstance(self.network.unet_multiplier, list) else self.network.unet_multiplier