Unverified Commit de6a88c2 authored by kentdan3msu's avatar kentdan3msu Committed by GitHub
Browse files

Set self._hf_peft_config_loaded to True when LoRA is loaded using...


Set self._hf_peft_config_loaded to True when LoRA is loaded using `load_lora_adapter` in PeftAdapterMixin class (#11155)

set self._hf_peft_config_loaded to True on successful lora load

Sets the `_hf_peft_config_loaded` flag if a LoRA is successfully loaded in `load_lora_adapter`. Fixes bug huggingface/diffusers/issues/11148
Co-authored-by: default avatarSayak Paul <spsayakpaul@gmail.com>
parent 7dc52ea7
...@@ -307,6 +307,9 @@ class PeftAdapterMixin: ...@@ -307,6 +307,9 @@ class PeftAdapterMixin:
try: try:
inject_adapter_in_model(lora_config, self, adapter_name=adapter_name, **peft_kwargs) inject_adapter_in_model(lora_config, self, adapter_name=adapter_name, **peft_kwargs)
incompatible_keys = set_peft_model_state_dict(self, state_dict, adapter_name, **peft_kwargs) incompatible_keys = set_peft_model_state_dict(self, state_dict, adapter_name, **peft_kwargs)
# Set peft config loaded flag to True if module has been successfully injected and incompatible keys retrieved
if not self._hf_peft_config_loaded:
self._hf_peft_config_loaded = True
except Exception as e: except Exception as e:
# In case `inject_adapter_in_model()` was unsuccessful even before injecting the `peft_config`. # In case `inject_adapter_in_model()` was unsuccessful even before injecting the `peft_config`.
if hasattr(self, "peft_config"): if hasattr(self, "peft_config"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment