-
Notifications
You must be signed in to change notification settings - Fork 29
[Fix] Reasonable loss for non-distributed training #242
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
joecummings
merged 2 commits into
meta-pytorch:main
from
joecummings:compare-against-hf-trainer
Sep 26, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ class ReferenceModel(ForgeActor): | |
def __post_init__(self): | ||
"""Initializes config types and env variables.""" | ||
super().__init__() | ||
|
||
# Instantiate dict fields | ||
for f in fields(self): | ||
attr = getattr(self, f.name) | ||
|
@@ -60,13 +61,9 @@ def __post_init__(self): | |
f"{f.name} should be a {f.type} type or a dict like object" | ||
) | ||
|
||
""" | ||
torchrun normally hands env variables, but we need to do it ourselves | ||
in monarch for now. | ||
""" | ||
self.step = 0 | ||
self.rank = current_rank().rank | ||
self.size = math.prod(current_size().values()) | ||
self.step = 0 | ||
|
||
env = { | ||
"RANK": str(self.rank), | ||
|
@@ -86,6 +83,7 @@ def __post_init__(self): | |
async def setup(self): | ||
engine_config = {f.name: getattr(self, f.name) for f in fields(self)} | ||
self.engine = ForgeEngine(ForgeJobConfig(**engine_config)) | ||
self.engine.checkpointer.load() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙃 |
||
self.model = self.engine.model_parts[0] # No pipeline parallelism yet | ||
self.model.eval() | ||
|
||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually staring at this in the trainer side .. It's unclear at a glance how the
checkpointer.load
is associated with loading the HF model weightsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's not very clear without digging into the TorchTitan checkpointing code here: https://github.com/pytorch/torchtitan/blob/5b5d46856b400c8550989415bee91473aab4f921/torchtitan/components/checkpoint.py#L523
All the information is taken from the config and instantiated into the CheckpointManager. Then the load call only takes a "step", which in our case isn't needed b/c it should be a static model every time.