Skip to content

[Weight converter] Account for base model prefix in scoped weight conversion#45996

Open
yonigozlan wants to merge 2 commits into
huggingface:mainfrom
yonigozlan:fix-scoped-match-with-base-model-prefix
Open

[Weight converter] Account for base model prefix in scoped weight conversion#45996
yonigozlan wants to merge 2 commits into
huggingface:mainfrom
yonigozlan:fix-scoped-match-with-base-model-prefix

Conversation

@yonigozlan
Copy link
Copy Markdown
Member

What does this PR do?

Now that the weight converter patterns are scoped, we need to account for a potential base_model_prefix in 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_prefix to the scope (not the pattern).

This is not perfect but with the way base_model_prefix and 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.

@yonigozlan yonigozlan force-pushed the fix-scoped-match-with-base-model-prefix branch from 5111663 to 4b47a79 Compare May 15, 2026 14:13
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants