Skip to content
Merged
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
7 changes: 7 additions & 0 deletions megatron/core/tensor_parallel/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,13 @@ def checkpoint(
) -> _R:
"""Checkpoint a model or part of the model.
This has been directly copied from torch.utils.checkpoint."""
from megatron.core.transformer.cuda_graphs import is_graph_capturing, is_graph_warmup

# Skip checkpointing during CUDA graph warmup and capture, matching the behavior of
# CheckpointWithoutOutput. The graph captures all ops directly; recomputation cannot
# run inside a captured graph.
Comment thread
tdene marked this conversation as resolved.
if is_graph_warmup() or is_graph_capturing():

@jiemingz jiemingz Mar 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt this just disable recomputation during graph capture? is_graph_capturing() is true when capturing. Why cant recomputation work with graphs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this only disables recomputation during graph capture. That's where I'm seeing errors in main right now: the first time we run through a training pass, we error out because we are capturing the graph while also attempting recompute.

Subsequent training passes seem to run fine.

return function(*args)
return CheckpointFunction.apply(function, distribute_saved_activations, *args)


Expand Down
Loading