Set self._hf_peft_config_loaded to True when LoRA is loaded using load_lora_adapter in PeftAdapterMixin class
#11155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR changes the behavior of the PeftAdapterMixin interface class so that LoRA modules loaded with
load_lora_adapterset theself._hf_peft_config_loadedflag to True after successful injection. This change fixes issue #11148.Previously, the
self._hf_peft_config_loadedflag was not set inload_lora_adapter(), only inadd_adapter()andadd_adapters(). Some functions within the PEFT code such as{enable,disable}_adapters()depend on this flag being set before they will function properly. I believe this change should bring parity between theadd_adapter()/add_adapters()andload_lora_adapter()functions.Since the PeftAdapterMixin class is used by many classes, such as SD3Transformer2DModel (which I was using when I encountered the original issue), this could potentially fix LoRA loading/enabling/disabling issues in many classes across the diffusers library.
Small note: in
add_adapter()/add_adapters(), the flag is set before the module is actually injected. In my proposed PR, I end up doing it afterwards, in case there is an issue with the injection process. If there is a good reason to set the flag earlier, I can alter the PR accordingly.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul