Repository navigation
fix: derive text-encoder alpha_pattern keys from the LoRA module name - #14972
akhil9tiet wants to merge 13 commits into
Conversation
|
Thanks for the quick fix, @akhil9tiet! I checked this PR (at e1e02ab) against the reproduction from #14970 on diffusers 0.41.0, transformers 5.16.1 and peft 0.20.0:
|
|
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. |
BenjaminBossan
left a comment
There was a problem hiding this comment.
Thanks for the PR. It seems to be doing what it's supposed to do. It depends on some LoRA checkpoint convention that I'm not familiar with, so I can't comment on whether it solves a real world issue or not.
Regarding the implementation itself, I have suggestion and a question.
BenjaminBossan
left a comment
There was a problem hiding this comment.
it doesn't actually create 4 rank entries. The comprehension {k.replace(".lora_A.", ".lora_B."): 4 for k in peft_state_dict if ".lora_A." in k} filters to the two .lora_A. keys first, so rank_dict ends up with just the two .lora_B. module names. It's a compact way to build a rank_dict whose keys match the state dict's module names, mirroring what the real checkpoint loader passes in.
It feels a bit roundabout to me compared to just spelling out the rank_dict, but it's no blocker for me.
Fixes #14970
In
get_peft_kwargs, the text-encoderalpha_patternkey derivation dropped the LoRA module segment (to_k_lora), producing the parent block (...self_attn) instead of the module (...self_attn.k_proj). Since PEFT matchesalpha_patternkeys against the end of module names, the key never matched and every text-encoder module fell back to the most common alpha. The derivation now translates the diffusers LoRA weight suffix (.to_{q,k,v,out}_lora,.lora_linear_layer) to the PEFT module name, and drops thetext_model.prefix so the key matches whether or not the loader stripped it for flattened text encoders. Adds two regression tests totests/lora/test_peft_utils.py.