FIX Restore LoRA hotswapping functionality#45682
Open
BenjaminBossan wants to merge 1 commit intohuggingface:mainfrom
Open
FIX Restore LoRA hotswapping functionality#45682BenjaminBossan wants to merge 1 commit intohuggingface:mainfrom
BenjaminBossan wants to merge 1 commit intohuggingface:mainfrom
Conversation
LoRA hotswapping was added in huggingface#41297. Due to changes in huggingface#43261, it stopped working. This PR restores the functionality. The tests already cover this and are failing, but probably no one noticed because they're slow tests. On main, they fail with mismatched sizes, which is expected as the padding of the LoRA weights is not being applied. With this PR, I can confirm that the tests pass locally. Since the two PRs were released in together in v5, there was never a Transformers release with working hotswapping functionality. Notes: The hotswap path does not use _load_pretrained_model, which means that loading the state_dict if not present is required. I hoisted that functionality from the TP path, which was already there, to re-use the same logic. I also apply weight renamings for that reason. Moreover, I moved the inference model logic to a local function, again to avoid duplicating the logic.
|
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. |
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.
What does this PR do?
LoRA hotswapping was added in #41297. Due to changes in #43261, it stopped working. This PR restores the functionality.
The tests already cover this and are failing, but probably no one noticed because they're slow tests. On main, they fail with mismatched sizes, which is expected as the padding of the LoRA weights is not being applied. With this PR, I can confirm that the tests pass locally.
Since the two PRs were released in together in v5, there was never a Transformers release with working hotswapping functionality.
Notes
The hotswap path does not use
_load_pretrained_model, which means that loading thestate_dictif not present is required. I hoisted that functionality from the TP path, which was already there, to re-use the same logic. I also apply weight renamings for that reason.Moreover, I moved the inference model logic to a local function, again to avoid duplicating the logic.
Code Agent Policy
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.