[PyTorch] Reduce CUDA graph memory retention - #3427
Conversation
Signed-off-by: Robin Zhang <robinz@nvidia.com>
Signed-off-by: Robin Zhang <robinz@nvidia.com>
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 |
38f14e4 to
6103b27
Compare
Signed-off-by: Robin Zhang <robinz@nvidia.com>
6103b27 to
a3f1d52
Compare
Validation report: this PR fixes an OOM during deferred CUDA-graph capture at 64-GPU scaleWe hit a reproducible Environment and workload
Because VP=5, the run takes the interleaved Failure without this PRThe run trains normally through iteration 3, then dies as soon as capture begins: Traceback (identical in shape on every failing rank): So the OOM occurs in the warm-up forward inside Result with this PR appliedSame image, same 64-GPU allocation, same recipe, same flags. We applied only this PR's change to
Why this PR appears to address itOn the interleaved The capture-phase Scope and caveats
Validated against this PR at commit This issue was drafted with assistance from the |
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