-
Notifications
You must be signed in to change notification settings - Fork 6.4k
[Enhacne] Support maybe_raise_or_warn for peft #5653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhacne] Support maybe_raise_or_warn for peft #5653
Conversation
The documentation is not available anymore as the PR was closed or merged. |
@sayakpaul could you take a look here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle this looks good! I left one comment, IMO this PR should be agnostic to PEFT integration and fixes issues when users pass a PeftModel
. Not sure also how much this is in the scope of diffusers as we might want users to use the PEFT integration through the low level API rather than using PeftModel
interface
if USE_PEFT_BACKEND: | ||
from peft import PeftModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this condition is needed, I would rather do something like:
if USE_PEFT_BACKEND: | |
from peft import PeftModel | |
if is_peft_available() and isinstance(sub_model, PeftModel): | |
from peft import PeftModel |
As we don't use PeftModel
for the PEFT integration, it should be totally agnostic to the minimum PEFT version we require for the integration.
You could also do something different by exposing a method |
In the training code in the examples, unet is passed to the pipeline when the validation is run. It would be nice to be able to pass the PeftModel directly to the pipeline at that time, eliminating the overhead for the user. |
We'll soon start working on refactoring our training scripts to support that :-) @younesbelkada any other comments on this PR? |
Hmm, I think we always want the users to load the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense thanks! I will let diffusers maintainers give their final approval
As it would be a quite common scenario to unwrap the model I would define an utility method unwrap_model
def unwrap_model(model):
if is_compiled_module(model):
model = model._orig_mod
if is_peft_available() and isinstance(model, PeftModel):
model = model.base_model.model
return model
@okotaku could we maybe create a
|
I have fixed. |
Very nice! |
Follow-up PR: #5789 |
* Support maybe_raise_or_warn for peft * fix by comment * unwrap function
* Support maybe_raise_or_warn for peft * fix by comment * unwrap function
What does this PR do?
Issues #5714
This code raised following error.
I solved it.
With this PR, we can fix the following lines to pass the "unet" directory to the pipeline.
https://github.com/huggingface/peft/blob/main/examples/lora_dreambooth/train_dreambooth.py#L992-L1000
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.