Skip to content

Commit dcfb18a

Browse files
authored
[LoRA] add support for more Qwen LoRAs (#12581)
* fix bug when offload and cache_latents both enabled * fix
1 parent ac5a1e2 commit dcfb18a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/diffusers/loaders/lora_conversion_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,10 @@ def convert_key(key: str) -> str:
22132213

22142214
state_dict = {convert_key(k): v for k, v in state_dict.items()}
22152215

2216+
has_default = any("default." in k for k in state_dict)
2217+
if has_default:
2218+
state_dict = {k.replace("default.", ""): v for k, v in state_dict.items()}
2219+
22162220
converted_state_dict = {}
22172221
all_keys = list(state_dict.keys())
22182222
down_key = ".lora_down.weight"

src/diffusers/loaders/lora_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4940,7 +4940,8 @@ def lora_state_dict(
49404940
has_alphas_in_sd = any(k.endswith(".alpha") for k in state_dict)
49414941
has_lora_unet = any(k.startswith("lora_unet_") for k in state_dict)
49424942
has_diffusion_model = any(k.startswith("diffusion_model.") for k in state_dict)
4943-
if has_alphas_in_sd or has_lora_unet or has_diffusion_model:
4943+
has_default = any("default." in k for k in state_dict)
4944+
if has_alphas_in_sd or has_lora_unet or has_diffusion_model or has_default:
49444945
state_dict = _convert_non_diffusers_qwen_lora_to_diffusers(state_dict)
49454946

49464947
out = (state_dict, metadata) if return_lora_metadata else state_dict

0 commit comments

Comments
 (0)