Skip to content

Commit dae34b1

Browse files
committed
fix z-image non-diffusers lora loading.
1 parent 897aed7 commit dae34b1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/diffusers/loaders/lora_conversion_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,8 +2538,12 @@ def normalize_out_key(k: str) -> str:
25382538

25392539
def get_alpha_scales(down_weight, alpha_key):
25402540
rank = down_weight.shape[0]
2541-
alpha = state_dict.pop(alpha_key).item()
2542-
scale = alpha / rank # LoRA is scaled by 'alpha / rank' in forward pass, so we need to scale it back here
2541+
alpha_tensor = state_dict.pop(alpha_key, None)
2542+
if alpha_tensor is None:
2543+
return 1.0, 1.0
2544+
scale = (
2545+
alpha_tensor.item() / rank
2546+
) # LoRA is scaled by 'alpha / rank' in forward pass, so we need to scale it back here
25432547
scale_down = scale
25442548
scale_up = 1.0
25452549
while scale_down * 2 < scale_up:

0 commit comments

Comments
 (0)