support graph-by-graph benchmarking for PyTorch native checkpointing #1437
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting
What does this PR do?
The converter replaces the Torch operators in the checkpoint function with Thunder operators in-place, and also the compiled thunder/inductor module is replaced in-place, but the ThunderCompilerGraphBenchmarking/saving reproduction script needs the original GraphModule to compile/save.
Previously, the deepcopy of GraphModule is blocked by a pytorch/pytorch#139275. Thanks to @kshitij12345 for helping to fix it, we can use it to support the graph-by-graph benchmarking for PyTorch native checkpointing starting from Torch 2.6
Note:
test_thundercompiler_optim_step
, so it's skippedtag_activation_checkpoint
Before 2.6, in order to get the input tensor of
submod_1
we need to calculate thewrap_body_0
ourselves (wrap_body_0
is a placeholder node insubmod_1
module, and there's noexample_value
innode.meta
); In 2.6, thewrap_body_0
is aget_attr
node insubmod_1
module, not an input. Since the latest Torch is much cleaner, we don't currently support benchmark checkpointing in Torch<2.6.Fixes #1381.