Skip to content

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!

@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 <[email protected]>

---------

Co-authored-by: YiYi Xu <[email protected]>
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 <[email protected]>

---------

Co-authored-by: YiYi Xu <[email protected]>
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