feat: auto-detect and fuse QKV for original PEFT adapters#14105
Open
Saurav-Gupta-9741 wants to merge 1 commit into
Open
feat: auto-detect and fuse QKV for original PEFT adapters#14105Saurav-Gupta-9741 wants to merge 1 commit into
Saurav-Gupta-9741 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14002
Hi @dg845 Sir! I saw your comment regarding the lack of support for loading generalized, original-checkpoint PEFT adapters without relying on conversion logic.
To solve this, I added dynamic auto-detection to
PeftAdapterMixin.load_lora_adapter. When an adapter is passed in (like DoRA, IA3, or standard LoRA), the code scans the state dictionary. If it expects a fused projection (e.g.,to_qkv), it intercepts the load, checks if the model supports fusion, and automatically runsself.fuse_qkv_projections().This guarantees that the Diffusers checkpoint weights natively coincide with the PEFT weights, allowing
peftto inject it seamlessly without shape mismatch errors or giant conversion scripts!I ran the
tests/lorasuite and locally tested a mock fused adapter to verify that the PyTorch shapes align perfectly after the interception. Let me know what you think!Looking forward for your Response