-
Notifications
You must be signed in to change notification settings - Fork 2k
ENH: Extend the regex for rank/alpha pattern #2419
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
ENH: Extend the regex for rank/alpha pattern #2419
Conversation
Supersedes huggingface#2382 Right now, the regex used to match the keys passed for rank_pattern and alpha_pattern requires that either: 1. The module name is identical to the key 2. The module name having a prefix and then ending on the key This is restrictive, since it doesn't allow to disambiguate between all cases. E.g. if we have a model with these attributes: - model.foo - model.bar.foo We cannot currently target just model.foo. (We can already target only model.bar.foo by passing "bar.foo" as a key to the rank_pattern / alpha_pattern dict). This PR makes it possible to pass "^foo" as a key. This way, model.bar.foo is not targeted, as the key does not start with "foo". As a general rule for users, if they intend to have a full match, they should pass the full name of the module preceded by a ^. This is the least ambigious way. When running the test case with the old code, all the test cases with ^ will fail, which is fine, since ^ was not working anyway. At the same time, all test cases not using ^ pass, which means they are backwards compatible.
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. |
Some PEFT methods falsely claimed in docs that they support rank/alpha pattern when they don't, this was just a copy paste error.
For consistency with LoRA
@sayakpaul @hlky After some internal discussion, Marian and I came up with this new solution which would replace the initial proposal of having "fully qualified" keys from #2382. With this suggestion, it should be enough to add the |
@BenjaminBossan thanks! Posted an update here. TL;DR: works like a charm. |
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.
LGTM, thanks for the revision :)
@sayakpaul it's merged. A new PEFT release will be happening soon (we aim for next week). |
Thanks, @BenjaminBossan. Would be nice to get a nudge once that happens. I will get my PR out of DRAFT. |
Supersedes huggingface#2382 Right now, the regex used to match the keys passed for rank_pattern and alpha_pattern requires that either: 1. The module name is identical to the key 2. The module name having a prefix and then ending on the key This is restrictive, since it doesn't allow to disambiguate between all cases. E.g. if we have a model with these attributes: - model.foo - model.bar.foo We cannot currently target just model.foo. (We can already target only model.bar.foo by passing "bar.foo" as a key to the rank_pattern / alpha_pattern dict). This PR makes it possible to pass "^foo" as a key. This way, model.bar.foo is not targeted, as the key does not start with "foo". As a general rule for users, if they intend to have a full match, they should pass the full name of the module preceded by a ^. This is the least ambigious way. When running the test case with the old code, all the test cases with ^ will fail, which is fine, since ^ was not working anyway. At the same time, all test cases not using ^ pass, which means they are backwards compatible.
Supersedes #2382
Right now, the regex used to match the keys passed for
rank_pattern
andalpha_pattern
requires that either:This is restrictive, since it doesn't allow to disambiguate between all cases. E.g. if we have a model with these attributes:
model.foo
model.bar.foo
Then we:
"foo"
to therank_pattern
/alpha_pattern
dictmodel.bar.foo
by passing"bar.foo"
model.foo
This PR makes it possible to pass
"^foo"
as a key. This way, onlymodel.foo
but notmodel.bar.foo
is targeted, as the latter's name does not start with"foo"
.As a general rule for users, if they intend to have a full match, they should pass the full name of the module preceded by a
^
. This is the least ambiguous way.When running the test case with the old code, all the test cases with
^
will fail, which is fine, since^
was not working anyway. At the same time, all test cases not using^
pass, which means they are backwards compatible.Some changes related to this PR:
rank_pattern
/alpha_pattern
to make it easier to findrank_pattern
andalpha_pattern
rank_pattern
/alpha_pattern
even though they are not supported. These are probably just copy-paste errors that slipped through review.rank_pattern
/alpha_pattern
that had syntax errors.rank_pattern
/alpha_pattern
. 8000 li>