[Weight converter] Account for base model prefix in scoped weight conversion#45996
Open
yonigozlan wants to merge 2 commits into
Open
[Weight converter] Account for base model prefix in scoped weight conversion#45996yonigozlan wants to merge 2 commits into
yonigozlan wants to merge 2 commits into
Conversation
5111663 to
4b47a79
Compare
|
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?
Now that the weight converter patterns are scoped, we need to account for a potential
base_model_prefixin the original weight (independently of the conversion patterns). Right now we have regression compared to before with integration tests like OneFormer and Mask2Former failing as they load weights with base_model_prefix into base models, and have a backbone (swin) with conversion patterns.This PR accounts for this by trying to match the source weight first with the default scope, then by adding or removing the
base_model_prefixto the scope (not the pattern).This is not perfect but with the way
base_model_prefixand weight conversions are implemented in the repo, we can never know for sure if source model weights have a base_model_prefix attached or not before converting the weights, so this is the best and lightest heuristic I found which doesn't introduce any regressions compared to before scoped weight conversion.