[ROCm] Re-enable cudagraph memory profiling, captured on the current stream (#48526)

Signed-off-by: pei.zhang <pei.zhang@amd.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
peizhang56
2026-07-15 10:03:48 -05:00
committed by GitHub
co-authored by Claude Andreas Karatzas
parent 5810e884f1
commit 05eed72aec
3 changed files with 37 additions and 8 deletions
+10 -2
View File
@@ -1427,7 +1427,10 @@ def get_pcp_group() -> GroupCoordinator:
@contextmanager
def graph_capture(device: torch.device):
def graph_capture(
device: torch.device,
graph_capture_context: GraphCaptureContext | None = None,
):
"""
`graph_capture` is a context manager which should surround the code that
is capturing the CUDA graph. Its main purpose is to ensure that some
@@ -1440,8 +1443,13 @@ def graph_capture(device: torch.device):
the graph capture is running on a separate stream from the default stream,
in order to explicitly distinguish the kernels to capture
from other kernels possibly launched on background in the default stream.
A caller may pass an explicit ``graph_capture_context`` to control the
stream used (e.g. to capture on the default stream).
"""
context = GraphCaptureContext(torch.cuda.Stream(device=device))
context = graph_capture_context or GraphCaptureContext(
torch.cuda.Stream(device=device)
)
with get_tp_group().graph_capture(context), get_pp_group().graph_capture(context):
yield context