Error when loading Flow-DPO LoRA with pipeline.load_lora_weights: state_dict should be empty at this point (possible diffusers version mismatch)
#4
by Zebin01 - opened
Hi, thanks for releasing this great work!
I encountered an issue when trying to load the Flow-DPO LoRA using diffusers. I suspect it might be related to a diffusers version mismatch, so I wanted to ask which version of diffusers was used in your environment.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[16], line 14
12 # 2. Load this Flow-DPO LoRA
13 lora_id = "/models/z-image-turbo-flow-dpo"
---> 14 pipeline.load_lora_weights(lora_id, adapter_name="lighting_dpo")
15 # Optional: Adjust LoRA scale (0.6 - 1.0 usually works best)
16 pipeline.set_adapters(["lighting_dpo"], adapter_weights=[1.0])
File /envs/xxx/lib/python3.10/site-packages/diffusers/loaders/lora_pipeline.py:5305, in ZImageLoraLoaderMixin.load_lora_weights(self, pretrained_model_name_or_path_or_dict, adapter_name, hotswap, **kwargs)
5303 # First, ensure that the checkpoint is a compatible one and can be successfully loaded.
5304 kwargs["return_lora_metadata"] = True
-> 5305 state_dict, metadata = self.lora_state_dict(pretrained_model_name_or_path_or_dict, **kwargs)
5307 is_correct_format = all("lora" in key for key in state_dict.keys())
5308 if not is_correct_format:
File /envs/xxx/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
111 if check_use_auth_token:
112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 114 return fn(*args, **kwargs)
File /envs/xxx/lib/python3.10/site-packages/diffusers/loaders/lora_pipeline.py:5274, in ZImageLoraLoaderMixin.lora_state_dict(cls, pretrained_model_name_or_path_or_dict, **kwargs)
5272 has_default = any("default." in k for k in state_dict)
5273 if has_alphas_in_sd or has_lora_unet or has_diffusion_model or has_default:
-> 5274 state_dict = _convert_non_diffusers_z_image_lora_to_diffusers(state_dict)
...
-> 2527 raise ValueError(f"`state_dict` should be empty at this point but has {state_dict.keys()=}")
2529 converted_state_dict = {f"transformer.{k}": v for k, v in converted_state_dict.items()}
2530 return converted_state_dict