-
Notifications
You must be signed in to change notification settings - Fork 451
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
New activation checkpointing #343
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b67e92c
Do activation checkpointing in a different way
dirkgr c8c6c68
Forgot the X
dirkgr 1e2c7e0
Python imports are weird
dirkgr c527ff4
Productivity through formatting
dirkgr 3326f93
Make activation checkpointing enablable on the fly
dirkgr 09f0e44
Merge remote-tracking branch 'origin/main' into ActivationCheckpointing
dirkgr 5dde774
Makes checkpointing work with block groups
dirkgr c366e42
I'd rather be sailing.
dirkgr 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 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 |
---|---|---|
|
@@ -404,6 +404,12 @@ class ModelConfig(BaseConfig): | |
See :data:`TrainConfig.precision` instead. | ||
""" | ||
|
||
activation_checkpointing: bool = False | ||
""" | ||
Use activation checkpointing on transformer blocks. You shouldn't set this directly. | ||
See :data:`TrainConfig.activation_checkpointing` instead. | ||
""" | ||
|
||
|
||
class OptimizerType(StrEnum): | ||
lionw = "lionw" | ||
|
@@ -808,11 +814,6 @@ class TrainConfig(BaseConfig): | |
Settings for compiling the model with ``torch.compile()``. | ||
""" | ||
|
||
activation_checkpointing: bool = False | ||
""" | ||
Use activation checkpointing on transformer blocks. | ||
""" | ||
|
||
fsdp: FSDPConfig = field(default_factory=FSDPConfig) | ||
""" | ||
Fully sharded data parallel settings. | ||
|
@@ -853,6 +854,11 @@ class TrainConfig(BaseConfig): | |
Stop at a specific step. | ||
""" | ||
|
||
activation_checkpointing: bool = False | ||
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. We already have this field |
||
""" | ||
Use activation checkpointing on transformer blocks. | ||
""" | ||
|
||
@property | ||
def autocast_precision(self) -> torch.dtype: | ||
if self.precision == "amp_bf16": | ||
|
This file contains 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 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.
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.
When this gets set to true during training this could cause issues later when loading the model for inference since. Instead maybe we have a method on the model like
Olmo.enable_activation_checkpointing()
? The trainer calls that whenTrainConfig.activation_checkpointing
is true, so we don't need to add a configuration option to
ModelConfig`.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 don't see why it would cause issues for inference, as the resulting checkpoint files should be 100% identical.
But I like this other design anyways.
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.
3326f93
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.
What I mean is that it would enable activation checkpointing when the model is loaded for inference