Skip to content

Commit 3c84a3c

Browse files
committed
support non-diffusers hidream loras
1 parent 599c887 commit 3c84a3c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/diffusers/loaders/lora_conversion_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,3 +1704,11 @@ def get_alpha_scales(down_weight, key):
17041704
converted_state_dict[f"transformer.{key}"] = converted_state_dict.pop(key)
17051705

17061706
return converted_state_dict
1707+
1708+
1709+
def _convert_non_diffusers_hidream_lora_to_diffusers(state_dict, non_diffusers_prefix="diffusion_model"):
1710+
if not all(k.startswith(non_diffusers_prefix) for k in state_dict):
1711+
raise ValueError("Invalid LoRA state dict for HiDream.")
1712+
converted_state_dict = {k.removeprefix(f"{non_diffusers_prefix}."): v for k, v in state_dict.items()}
1713+
converted_state_dict = {f"transformer.{k}": v for k, v in converted_state_dict.items()}
1714+
return converted_state_dict

src/diffusers/loaders/lora_pipeline.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
_convert_hunyuan_video_lora_to_diffusers,
4444
_convert_kohya_flux_lora_to_diffusers,
4545
_convert_musubi_wan_lora_to_diffusers,
46+
_convert_non_diffusers_hidream_lora_to_diffusers,
4647
_convert_non_diffusers_lora_to_diffusers,
4748
_convert_non_diffusers_lumina2_lora_to_diffusers,
4849
_convert_non_diffusers_wan_lora_to_diffusers,
@@ -5465,6 +5466,10 @@ def lora_state_dict(
54655466
logger.warning(warn_msg)
54665467
state_dict = {k: v for k, v in state_dict.items() if "dora_scale" not in k}
54675468

5469+
is_non_diffusers_format = any("diffusion_model" in k for k in state_dict)
5470+
if is_non_diffusers_format:
5471+
state_dict = _convert_non_diffusers_hidream_lora_to_diffusers(state_dict)
5472+
54685473
return state_dict
54695474

54705475
# Copied from diffusers.loaders.lora_pipeline.CogVideoXLoraLoaderMixin.load_lora_weights

0 commit comments

Comments
 (0)