Repository navigation
Removing call to init_weights in model's __init__ - #1711
Merged
Merged
Conversation
lkhphuc
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
September 15, 2025 10:42
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 13, 2026
As discussed [here](pytorch#1615 (comment)) and [here](pytorch#1615 (comment)), I create this PR to limit the scope of the other PR pytorch#1615 . When subclassing a torchtitan's model for training, the call to `self.init_weights()` inside model `__init__` could have side effect. Solution is to delete this line because in practice it currently has no effect, we explicitly called `m.init_weights(buffer_device)` in `train.py` already. Flux model already doesn't do it.
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 25, 2026
As discussed [here](pytorch#1615 (comment)) and [here](pytorch#1615 (comment)), I create this PR to limit the scope of the other PR pytorch#1615 . When subclassing a torchtitan's model for training, the call to `self.init_weights()` inside model `__init__` could have side effect. Solution is to delete this line because in practice it currently has no effect, we explicitly called `m.init_weights(buffer_device)` in `train.py` already. Flux model already doesn't do it.
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.
As discussed here and here, I create this PR to limit the scope of the other PR #1615 .
When subclassing a torchtitan's model for training, the call to
self.init_weights()inside model__init__could have side effect.Solution is to delete this line because in practice it currently has no effect, we explicitly called
m.init_weights(buffer_device)intrain.pyalready.Flux model already doesn't do it.