Repository navigation
Fix LoRA loading for flattened CLIP text encoders - #14872
Conversation
| "text_encoder.text_model.encoder.layers.0.self_attn.q_proj.lora_B.weight": lora_b, | ||
| } | ||
|
|
||
| StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder( |
There was a problem hiding this comment.
IMO, a test should be closer to how a user would load such a checkpoint via a pipeline, using the mixin class directly is not normally done. If the maintainers are fine with this, I won't object though.
There was a problem hiding this comment.
Yes, I agree with you, @BenjaminBossan. However, internally, the call gets dispatched to load_lora_into_text_encoder from load_lora_weights(). So, seems okay to me as a minimal and self-contained use case.
There was a problem hiding this comment.
Yeah, I kept the test at the loader level since load_lora_weights() ends up calling the same path anyway.
There was a problem hiding this comment.
However, internally, the call gets dispatched to
load_lora_into_text_encoderfromload_lora_weights(). So, seems okay to me as a minimal and self-contained use case.
Your call, Sayak, so if you're fine with this, I have no complaint. Personally, I'd prefer the tests not to rely on implementation details and go through the same motions as the user, but I can't tell how much more complex it would require to make the test to achieve the same coverage, so the tradeoff might be worthwhile.
BenjaminBossan
left a comment
There was a problem hiding this comment.
No blockers from my side, thanks for the PR.
|
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. |
What does this PR do?
Fixes #14860
CLIPTextModelis flattened in newer transformers versions, so its module names no longer start withtext_model.. Older LoRA checkpoints can still contain this prefix.Because of that, the text encoder rank lookup does not find the LoRA keys, leaving
rankempty and causing anIndexError.This strips the
text_model.prefix when loading into a flattened text encoder.Added a regression test for this case. I also tested the fix with the LoRA checkpoint shared in #14860.
No new dependencies.
Tests
Before submitting
self-reviewskill on the diff?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.
@sayakpaul @BenjaminBossan