FIX LoRA tests warning about unexpected keys (#14476)
Resolves https://github.com/huggingface/peft/issues/3548.
The issue appeared after merging
https://github.com/huggingface/peft/pull/3490 in PEFT. As part of a
side effect of that refactor, the adapter name is not part of the
state dict keys in the reported mismatches. The warning logic did,
however, check for the adapter name, resulting in the warning not
being emitted.
The fix simply drops the adapter name from the check for unexpected
keys. This should be safe, because we only load one adapter at a time,
so unexpected keys should not report on other adapters anyway.
While working on this function, I also changed the "lora_" in k check
to ".lora_" in k. This should be strictly more precise, but it's not
related to the fix. I also added some type annotations for good
measure.
The tests now pass with both PEFT from source and the latest PEFT
release (i.e. before the refactor merge).
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>