Skip to content

[LoRA] make set_adapters() method more robust. #9535

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

Merged
merged 7 commits into from
Sep 27, 2024
Merged

Conversation

sayakpaul
Copy link
Member

What does this PR do?

First caught in #9525 (comment) by @asomoza. But then it turned out to be #9525 (comment).

This PR:

  1. Makes our set_adapters() method more robust by catching errors on adapter names that are wrong (and adds a test for it).
  2. Makes our existing test on set_adapters() more robust.

@cshowley do you wanna give this a try?

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sayakpaul
Copy link
Member Author

Failing tests are completely unrelated.

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this check, I agree it makes sense to prevent typos etc.

I have some comments to potentially improve the code, but no blockers.

check_if_lora_correctly_set(pipe.text_encoder_2), "Lora not correctly set in text encoder 2"
)

with self.assertRaises(ValueError) as err_context:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use self.assertRaisesRegex to directly check the error message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just prefer to do a bit more explicitly across the codebase (which is what I have followed here).

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick adjustments.

Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

Co-authored-by: YiYi Xu <yixu310@gmail.com>
@sayakpaul sayakpaul merged commit 2daedc0 into main Sep 27, 2024
18 checks passed
@sayakpaul sayakpaul deleted the better-set-adapters branch September 27, 2024 02:02
leisuzz pushed a commit to leisuzz/diffusers that referenced this pull request Oct 11, 2024
* make set_adapters() method more robust.

* remove patch

* better and concise code.

* Update src/diffusers/loaders/lora_base.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

---------

Co-authored-by: YiYi Xu <yixu310@gmail.com>
sayakpaul added a commit that referenced this pull request Dec 23, 2024
* make set_adapters() method more robust.

* remove patch

* better and concise code.

* Update src/diffusers/loaders/lora_base.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

---------

Co-authored-by: YiYi Xu <yixu310@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants