bridge.training.post_training.checkpointing#
Input/output checkpointing for ModelOpt.
Module Contents#
Functions#
Restore ModelOpt state saved in legacy or current MCore checkpoint layouts. |
|
Reject checkpoint sources whose ModelOpt state cannot be selected consistently. |
|
Get the checkpoint iteration path to use for ModelOpt operations. |
|
Check if ModelOpt state exists inside the checkpoint path. |
|
Load modelopt_state from a checkpoint. |
Data#
API#
- bridge.training.post_training.checkpointing.logger#
βgetLogger(β¦)β
- bridge.training.post_training.checkpointing.restore_sharded_modelopt_state(
- model: list[megatron.core.transformer.module.MegatronModule],
- checkpoint_path: str,
Restore ModelOpt state saved in legacy or current MCore checkpoint layouts.
- Parameters:
model β Unwrapped model chunks to restore.
checkpoint_path β Iteration checkpoint directory containing
modelopt_state.
- Raises:
ValueError β If virtual pipeline parallelism produced multiple model chunks.
- bridge.training.post_training.checkpointing._validate_modelopt_checkpointing(
- non_persistent_ckpt_type: str | None,
Reject checkpoint sources whose ModelOpt state cannot be selected consistently.
- bridge.training.post_training.checkpointing._get_modelopt_checkpoint_path(
- checkpoint_path: str,
- ckpt_step: int | None = None,
Get the checkpoint iteration path to use for ModelOpt operations.
- bridge.training.post_training.checkpointing.has_modelopt_state(
- checkpoint_path: str,
- ckpt_step: int | None = None,
Check if ModelOpt state exists inside the checkpoint path.
Checks for modelopt_state in iteration directories (iter_*) or root directory. NOTE: Ignores distillation state which is deprecated and unused.
- Parameters:
checkpoint_path β Path to the checkpoint directory.
ckpt_step β Specific checkpoint iteration selected for native loading.
- Returns:
True if modelopt_state folder exists and contains nontrivial state, else False.
- bridge.training.post_training.checkpointing.load_modelopt_state(
- model: list[megatron.core.transformer.module.MegatronModule],
- checkpoint_path: str,
- ckpt_step: int | None = None,
Load modelopt_state from a checkpoint.
- Parameters:
model β The model to load the modelopt_state into
checkpoint_path β Path to the checkpoint directory.
ckpt_step β Specific checkpoint iteration selected for native loading.