Skip to content
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

Chore checkpointing #417

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions olmo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,29 @@ class ShardedCheckpointerType(StrEnum):

class ActivationCheckpointingStrategy(StrEnum):
whole_layer = "whole_layer"
"""
Checkpoint every transformer layer.
"""

one_in_two = "one_in_two"
"""
Checkpoint one in two transformer layers.
"""

one_in_three = "one_in_three"
"""
Checkpoint one in three transformer layers.
"""

one_in_four = "one_in_four"
"""
Checkpoint one in four transformer layers.
"""

fine_grained = "fine_grained"
"""
Focus checkpointing on where it is cheap to recompute and saves most memory.
"""


@dataclass
Expand Down
3 changes: 0 additions & 3 deletions olmo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,9 +1077,6 @@ def __init__(self, config: ModelConfig, init_params: bool = True):
get_causal_attention_bias(self.__cache, config.max_sequence_length, _non_meta_init_device(config))
self.get_alibi_attention_bias(config.max_sequence_length, _non_meta_init_device(config))

def enable_activation_checkpointing(self, enable: bool = True):
self.set_activation_checkpointing(ActivationCheckpointingStrategy.whole_layer if enable else None)

def set_activation_checkpointing(self, strategy: Optional[ActivationCheckpointingStrategy]):
self.activation_checkpointing_strategy = strategy
if self.config.block_group_size != 1:
Expand Down
Loading