Skip to content

Commit 3c0531b

Browse files
Beinseziisayakpaul
andauthored
lora_conversion_utils: replace lora up/down with a/b even if transformer. in key (#12101)
lora_conversion_utils: replace lora up/down with a/b even if transformer. in key Co-authored-by: Sayak Paul <[email protected]>
1 parent a8e4797 commit 3c0531b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/diffusers/loaders/lora_conversion_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,11 @@ def _convert(original_key, diffusers_key, state_dict, new_state_dict):
817817
# has both `peft` and non-peft state dict.
818818
has_peft_state_dict = any(k.startswith("transformer.") for k in state_dict)
819819
if has_peft_state_dict:
820-
state_dict = {k: v for k, v in state_dict.items() if k.startswith("transformer.")}
820+
state_dict = {
821+
k.replace("lora_down.weight", "lora_A.weight").replace("lora_up.weight", "lora_B.weight"): v
822+
for k, v in state_dict.items()
823+
if k.startswith("transformer.")
824+
}
821825
return state_dict
822826

823827
# Another weird one.

0 commit comments

Comments
 (0)