Skip to content

Don't modify tied_weight_keys in-place#43619

Merged
vasqu merged 8 commits intohuggingface:mainfrom
zucchini-nlp:cls-attr-updated-in-place
Jan 30, 2026
Merged

Don't modify tied_weight_keys in-place#43619
vasqu merged 8 commits intohuggingface:mainfrom
zucchini-nlp:cls-attr-updated-in-place

Conversation

@zucchini-nlp
Copy link
Member

What does this PR do?

As per title, some models add or delete entries in tied weights depending on configuration. If we load two models consecutively with different configs, it fails to tie weights correctly

I am copying it in __init__ same way as keep_in_fp32. We could also simply copy the cls attribute in these two models, where in-place modification happens. WDYT?

@zucchini-nlp zucchini-nlp requested a review from vasqu January 30, 2026 10:43
@HuggingFaceDocBuilderDev

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.

Copy link
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit confused about the test since we check for the same keys? Does it work as intended

Copy link
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifiying, my bad didn't properly see the second case

@zucchini-nlp zucchini-nlp enabled auto-merge (squash) January 30, 2026 12:36
@zucchini-nlp zucchini-nlp disabled auto-merge January 30, 2026 12:36
@vasqu vasqu added the for patch Tag issues / labels that should be included in the next patch label Jan 30, 2026
Comment on lines +330 to +333
# Ignore copy
def test_tie_weights_is_not_modified(self):
# this model doesn't need a test
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just passing through, why doesn't this need a test? (wrt comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the model definition is slightly different from GroundingDino but the tests are Copied from. I don't see tied_weights_keys being modified for MMGroundingDino

@zucchini-nlp
Copy link
Member Author

CI is still super flaky :(

@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: deformable_detr, grounding_dino, mm_grounding_dino

@vasqu
Copy link
Contributor

vasqu commented Jan 30, 2026

As discussed CI is still flaky, merging as the test that fails is unrelated - can you write something internally in slack

@vasqu vasqu merged commit 11b9b0f into huggingface:main Jan 30, 2026
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for patch Tag issues / labels that should be included in the next patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants