[PyTorch] Reduce CUDA graph memory retention - #3427
Open
buptzyb wants to merge 3 commits into
Open
Conversation
Signed-off-by: Robin Zhang <robinz@nvidia.com>
Signed-off-by: Robin Zhang <robinz@nvidia.com>
Contributor
Greptile SummaryThe PR reduces CUDA graph memory retention by releasing warmup outputs promptly, dropping capture-local tensor references, and clearing each callable’s replay state during reset.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
F[Captured callable forward] --> A[Autograd replay state]
A --> R[reset called]
R --> G[Reset CUDA graphs]
G --> C[Clear per-callable tensors and graph references]
C --> T[Mark callable terminal]
T --> E[Later replay entry point]
E --> X[Raise controlled RuntimeError]
Reviews (3): Last reviewed commit: "[PyTorch] Release per-callable state on ..." | Re-trigger Greptile |
buptzyb
force-pushed
the
codex/te-warmup-output-lifetime
branch
from
August 26, 2026 14:47
38f14e4 to
6103b27
Compare
Signed-off-by: Robin Zhang <robinz@nvidia.com>
buptzyb
force-pushed
the
codex/te-warmup-output-lifetime
branch
from
August 27, 2026 01:59
6103b27 to
a3f1d52
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Reduce avoidable GPU-memory retention across CUDA graph construction and teardown.
make_graphed_attribute_functionswhile snapshotting only per-callable graph state, and clear replay closure state whenreset()is called.The changes preserve warmup/capture order and public APIs.
Testing
python -m pytest -q tests/pytorch/test_cuda_graphs.py -k "warmup_releases_consumed_outputs or inference_warmup_does_not_retain_outputs or reused_capture_buffers_release_outputs_after_backward or reset_releases_only_the_selected_callable or capture_time_hooks or interleaved_pipeline_parallelism"Signed-off-by: Robin Zhang robinz@nvidia.com