Skip to content

Init the actual tensor, not a copy#46030

Merged
ArthurZucker merged 2 commits into
mainfrom
fix_broken_linear_weight_init
May 19, 2026
Merged

Init the actual tensor, not a copy#46030
ArthurZucker merged 2 commits into
mainfrom
fix_broken_linear_weight_init

Conversation

@Rocketknight1
Copy link
Copy Markdown
Member

Our weight init code did init.normal_(module.weight.float()) which is broken because it makes a float32 copy of the tensor and then initializes that. It worked when the model was float32 already, because then the dtype conversion was a no-op.

cc @ArthurZucker since this snuck in during #45643!

Hopefully fixes #46002

@Rocketknight1 Rocketknight1 marked this pull request as ready for review May 18, 2026 11:54
@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.

Copy link
Copy Markdown
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

@ArthurZucker ArthurZucker merged commit d673e12 into main May 19, 2026
94 of 95 checks passed
@ArthurZucker ArthurZucker deleted the fix_broken_linear_weight_init branch May 19, 2026 02:00
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.

NaNs in classification heads upon checkout + init

3 participants