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

Add offloading checkpoint policy #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions praxis/layers/checkpoint_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AutodiffCheckpointType(str, enum.Enum):
SAVE_CONTEXT = 'save_context'
SAVE_CONTEXT_AND_OUT_PROJ = 'save_encoded_and_out_proj'
SAVE_DOT_ONLY = 'save_dot_only'
OFFLOAD_DOT_WITH_NO_BATCH_DIM = 'offload_dot_with_no_batch_dims'
SAVE_DOT_WITH_NO_BATCH_DIM = 'save_dot_with_no_batch_dims'
SAVE_DOT_FOR_MLPERF_200B = 'save_dot_for_mlperf_200b'
SAVE_ITERATION_INPUT = 'save_iteration_input'
Expand All @@ -50,6 +51,10 @@ def custom_policy(checkpoint_policy: AutodiffCheckpointType):
return jax.checkpoint_policies.everything_saveable
if checkpoint_policy == AutodiffCheckpointType.SAVE_DOT_ONLY:
return jax.checkpoint_policies.checkpoint_dots
if checkpoint_policy == AutodiffCheckpointType.OFFLOAD_DOT_WITH_NO_BATCH_DIM:
return jax.checkpoint_policies.offload_dot_with_no_batch_dims(
'device', 'pinned_host'
)
if checkpoint_policy == AutodiffCheckpointType.SAVE_DOT_WITH_NO_BATCH_DIM:
return jax.checkpoint_policies.checkpoint_dots_with_no_batch_dims
if checkpoint_policy == AutodiffCheckpointType.SAVE_QKV_OUT_PROJ:
Expand Down