Skip to content

Tie weights recursively on all submodels #39996

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

Merged
merged 5 commits into from
Aug 8, 2025
Merged

Conversation

Cyrilvallez
Copy link
Member

What does this PR do?

Fixes #39900. Current code calls custom _tie_weights recursively on all modules, but does not recursively ties the embeddings or the encoder/decoder parts

@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
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

LGTM otherwise, but this piece of code if very very... tricky haha

@@ -3015,7 +3016,16 @@ def tie_weights(self):
# Leading to issues on subsequent calls by different tests or subsequent calls.
self._dynamic_tied_weights_keys = tied_weights

def tie_weights(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

bit scared about the recursivity as we call that function 10 times....

Copy link
Contributor

github-actions bot commented Aug 8, 2025

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

run-slow: blip, seamless_m4t, seamless_m4t_v2

@Cyrilvallez Cyrilvallez merged commit a96cccd into main Aug 8, 2025
23 of 25 checks passed
@Cyrilvallez Cyrilvallez deleted the recursive-tie-weights branch August 8, 2025 14:03
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.

Weights not tied when loading from_pretrained with a wrapped model
3 participants