-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[WIP] Add LoRA multihead attention module #1324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BenjaminBossan
merged 61 commits into
huggingface:main
from
BenjaminBossan:feat-add-lora-multihead-attention
Jan 8, 2025
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
49fab86
[WIP] Add LoRA multihead attention module
BenjaminBossan d8e9589
Make style
BenjaminBossan 0e188a3
Remove commented code
BenjaminBossan b409d81
Remove assignment of weight to new module
BenjaminBossan 173062c
Make state_dict and named_parameters work
BenjaminBossan 1e007f5
Extend test coverage a bit
BenjaminBossan 557c4a1
Clean ups after reviewer feedback:
BenjaminBossan add1f51
Reviewer feedback: removed another unnecessary arg
BenjaminBossan e44e030
Make style
BenjaminBossan 8d62579
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan c5d8a6b
Apply LoRA also to the out_proj of MHA
BenjaminBossan 9dc4a4d
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan c3fb2ce
Fix bug with incorrectly set gradient
BenjaminBossan 17d407b
Fix failing tests
BenjaminBossan 4cbf6e9
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan e0cae11
Move to pytest style asserts
BenjaminBossan 52c8d9b
Fix safe merging code
BenjaminBossan 977c84b
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 96d376d
No need to set bias for MHA anymore, see #1530
BenjaminBossan 0c17476
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 4b8db0c
Fix style
BenjaminBossan 7e91712
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan e12070b
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 7b6c7cb
Remove duplicate merge
BenjaminBossan e6ab8ed
Raise error for multi adapter batch inference
BenjaminBossan 8ec6c3c
Raise error for DoRA + MHA
BenjaminBossan f6ba465
Fix error when adding multiple adapters to MHA
BenjaminBossan fb18886
Better way of param initialization
BenjaminBossan 4ff2ec3
Add tests for broken loading and workaround
BenjaminBossan d1f6ab2
make style
BenjaminBossan 65363be
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 7ba2e68
Fix wrong merge conflict resolution in test
BenjaminBossan 6ef04b0
Ensure that base weights have requires_grad False
BenjaminBossan 07c7240
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan cc3ac3d
Remove xpass-ing test
BenjaminBossan 03c466f
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan e558caa
MAINT: Give stale bot permissions for PRs too (#2064)
BenjaminBossan 38f4a98
ENH BOFT don't save boft_P buffer (#2050)
sywangyi 7e5c61d
FIX Command line args in PiSSA preprocess (#2053)
keakon 183bf52
MNT Update deprecated evaluation_strategy (#1664)
muellerzr b970607
ENH Multi adapters in same batch: modules_to_save (#1990)
saeid93 732e8e7
FIX Bug that prevents BOFT from loading 2 adapters (#2068)
BenjaminBossan 79e2b38
TST Skip some quantization tests on XPU (#2074)
faaany 61e6934
Improve test coverage for initialization of MHA
BenjaminBossan ced2f15
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 4c31bbc
Fix bug with unloading multihead attention layer
BenjaminBossan 1dbb9a5
Fix bug in unloading
BenjaminBossan e094234
Fix for low_cpu_mem_usage
BenjaminBossan e90af48
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 30a08e7
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 09f5ea6
Add tests for init_empty_weights
BenjaminBossan 6a83bd7
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 3b0471a
Merge branch 'main' into feat-add-lora-multihead-attention
BenjaminBossan 465a85e
Add MHA to modules unsupported by EVA
BenjaminBossan 266f9da
Add comment on why/how empty init works
BenjaminBossan 39e755e
Expose attributes of underlying MHA module
BenjaminBossan 4857858
Apply suggestions from code review
BenjaminBossan 74cbba6
Remove trailing whitespace
BenjaminBossan 14deb9f
Linting..
BenjaminBossan ba2a8dd
Reviewer comment: Add comments for clarification
BenjaminBossan ac10b18
Reviewer feedback: Remove q_proj_weight
BenjaminBossan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this has been removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forgot to put this into the description of the PR.
These lines are obsolete for some time now. They only apply when we unload the model (otherwise, the
if
does not match). Remember when we made thebase_layer
switch, we ensured that when unloading, we simply return thebase_layer
, no more need to create a new layer (say, a newnn.Linear
when usinglora.Linear
) and replace the new layer'sweight
by the parent layer'sweight
. Thebase_layer
already has the originalweight
. Therefore, these lines are unnecessary.I removed them now because they were annoying with
MultiheadAttention
, because that layer has noweight
attribute, so this line would fail.