core.transformer.residual_recompute_plan#
Residual recompute planning functions.
Only immutable boundary plans may be cached, such as a plan that keeps a ShortcutMoE producer/consumer pair in the same block. Managers own checkpoints from one forward invocation; callers choose which operations to register.
Module Contents#
Functions#
Mark block ends without splitting disjoint adjacent atomic layer pairs. |
|
Allocate fresh managers for an active plan, sharing one within each block. |
|
Discard registered outputs and attach replay at the block’s live boundary. |
API#
- core.transformer.residual_recompute_plan.build_recompute_block_end_plan(
- num_layers: int,
- block_size: int | None,
- *,
- atomic_layer_pairs: collections.abc.Sequence[tuple[int, int]] = (),
Mark block ends without splitting disjoint adjacent atomic layer pairs.
Indices use the caller’s local layer order. A pair may exceed a block size of one; otherwise blocks contain at most
block_sizelayers.Noneuses the entire local stack. Empty stacks return an empty plan.
- core.transformer.residual_recompute_plan.build_recompute_layer_managers(
- block_ends: collections.abc.Sequence[bool],
Allocate fresh managers for an active plan, sharing one within each block.
- core.transformer.residual_recompute_plan.finalize_recompute_block(
- manager: megatron.core.tensor_parallel.random.CheckpointWithoutOutputManager | None,
- hidden_states: torch.Tensor,
- is_block_end: bool,
Discard registered outputs and attach replay at the block’s live boundary.