Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/171285
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit facd52b with merge base b699fa5 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Dec 25, 2025
guangyey
marked this pull request as draft
December 25, 2025 03:02
This was referenced Dec 29, 2025
guangyey
commented
Mar 4, 2026
| // Dump the captured graph to a file for debugging purposes. The file format | ||
| // and content are backend-specific. | ||
| void debug_dump(const std::string& path) const { | ||
| void debug_dump(const std::string& path) { |
Collaborator
Author
There was a problem hiding this comment.
minor fix: this function should not be defined as const.
EikanWang
approved these changes
Mar 5, 2026
Collaborator
|
@guangyey , test plan? |
Collaborator
Author
|
Hi @eellison, just wanted to check if you have any additional comments or concerns on this PR. |
sandy-gags
pushed a commit
to sandy-gags/pytorch
that referenced
this pull request
Mar 12, 2026
…nterface ghstack-source-id: 9511a89 Pull Request resolved: pytorch/pytorch#171285
eellison
approved these changes
Mar 18, 2026
Collaborator
Author
|
Thanks very much~ |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
ryanzhang22
pushed a commit
to ryanzhang22/pytorch
that referenced
this pull request
Mar 19, 2026
…nterface (pytorch#171285) # Motivation This PR introduces a unified frontend API `torch.accelerator.Graph` which wraps `at::accelerator::Graph` and provides capture and replay functionality. The interface is largely aligned with `torch.cuda.Graph`, and can be extended on demand in the future. Inspired by the design and usage of `torch.Stream`, `torch.accelerator.Graph` is intended to act as a context manager that captures work on the current of the current device. This enables a simple and intuitive usage pattern, for example: ```python s = torch.Stream() g = torch.accelerator.Graph() with s, g: # capture ops pass g.replay() ``` There are, however, some subtle but important differences compared to the existing `torch.cuda.graph` context manager: 1. Stream selection semantics `torch.cuda.graph` implicitly creates and uses a non-default `torch.cuda.Stream` as the capture stream if none is explicitly provided. In contrast, `torch.accelerator.Graph` always captures on the current stream. On CUDA, if no additional stream is set and the current stream is the default stream, this may raise an error such as `CUDA graphs must be captured on a non-default stream.` Refer to https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L212 2. Graph memory pool support `torch.cuda.graph` allows users to specify a graph pool to share memory across graph captures. See https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L190 `torch.accelerator.Graph` currently supports specifying a graph pool at construction time. So, I think we don't provide `torch.accelerator.graph` to align with the behavior of `torch.cuda.graph`, `torch.accelerator.Graph` is enough as the context manager. Pull Request resolved: pytorch#171285 Approved by: https://github.com/EikanWang, https://github.com/eellison
pytorchmergebot
pushed a commit
that referenced
this pull request
Mar 20, 2026
# Motivation This PR introduces a unified API, `torch.accelerator.empty_host_cache`, for releasing unused host (pinned) memory. This API can also be used prior to graph capture. For example, as discussed in #167507, CUDA supports graph capture and replay involving host memory as well. Therefore, it is important to clean up both the device and host memory before starting graph capture to ensure correct and predictable behavior. Pull Request resolved: #171270 Approved by: https://github.com/eellison ghstack dependencies: #171285
EmanueleCoradin
pushed a commit
to EmanueleCoradin/pytorch
that referenced
this pull request
Mar 30, 2026
…nterface (pytorch#171285) # Motivation This PR introduces a unified frontend API `torch.accelerator.Graph` which wraps `at::accelerator::Graph` and provides capture and replay functionality. The interface is largely aligned with `torch.cuda.Graph`, and can be extended on demand in the future. Inspired by the design and usage of `torch.Stream`, `torch.accelerator.Graph` is intended to act as a context manager that captures work on the current of the current device. This enables a simple and intuitive usage pattern, for example: ```python s = torch.Stream() g = torch.accelerator.Graph() with s, g: # capture ops pass g.replay() ``` There are, however, some subtle but important differences compared to the existing `torch.cuda.graph` context manager: 1. Stream selection semantics `torch.cuda.graph` implicitly creates and uses a non-default `torch.cuda.Stream` as the capture stream if none is explicitly provided. In contrast, `torch.accelerator.Graph` always captures on the current stream. On CUDA, if no additional stream is set and the current stream is the default stream, this may raise an error such as `CUDA graphs must be captured on a non-default stream.` Refer to https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L212 2. Graph memory pool support `torch.cuda.graph` allows users to specify a graph pool to share memory across graph captures. See https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L190 `torch.accelerator.Graph` currently supports specifying a graph pool at construction time. So, I think we don't provide `torch.accelerator.graph` to align with the behavior of `torch.cuda.graph`, `torch.accelerator.Graph` is enough as the context manager. Pull Request resolved: pytorch#171285 Approved by: https://github.com/EikanWang, https://github.com/eellison
AaronWang04
pushed a commit
to AaronWang04/pytorch
that referenced
this pull request
Mar 31, 2026
…nterface (pytorch#171285) # Motivation This PR introduces a unified frontend API `torch.accelerator.Graph` which wraps `at::accelerator::Graph` and provides capture and replay functionality. The interface is largely aligned with `torch.cuda.Graph`, and can be extended on demand in the future. Inspired by the design and usage of `torch.Stream`, `torch.accelerator.Graph` is intended to act as a context manager that captures work on the current of the current device. This enables a simple and intuitive usage pattern, for example: ```python s = torch.Stream() g = torch.accelerator.Graph() with s, g: # capture ops pass g.replay() ``` There are, however, some subtle but important differences compared to the existing `torch.cuda.graph` context manager: 1. Stream selection semantics `torch.cuda.graph` implicitly creates and uses a non-default `torch.cuda.Stream` as the capture stream if none is explicitly provided. In contrast, `torch.accelerator.Graph` always captures on the current stream. On CUDA, if no additional stream is set and the current stream is the default stream, this may raise an error such as `CUDA graphs must be captured on a non-default stream.` Refer to https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L212 2. Graph memory pool support `torch.cuda.graph` allows users to specify a graph pool to share memory across graph captures. See https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L190 `torch.accelerator.Graph` currently supports specifying a graph pool at construction time. So, I think we don't provide `torch.accelerator.graph` to align with the behavior of `torch.cuda.graph`, `torch.accelerator.Graph` is enough as the context manager. Pull Request resolved: pytorch#171285 Approved by: https://github.com/EikanWang, https://github.com/eellison
AaronWang04
pushed a commit
to AaronWang04/pytorch
that referenced
this pull request
Mar 31, 2026
# Motivation This PR introduces a unified API, `torch.accelerator.empty_host_cache`, for releasing unused host (pinned) memory. This API can also be used prior to graph capture. For example, as discussed in pytorch#167507, CUDA supports graph capture and replay involving host memory as well. Therefore, it is important to clean up both the device and host memory before starting graph capture to ensure correct and predictable behavior. Pull Request resolved: pytorch#171270 Approved by: https://github.com/eellison ghstack dependencies: pytorch#171285
nklshy-aws
pushed a commit
to nklshy-aws/pytorch
that referenced
this pull request
Apr 7, 2026
# Motivation This PR introduces a unified API, `torch.accelerator.empty_host_cache`, for releasing unused host (pinned) memory. This API can also be used prior to graph capture. For example, as discussed in pytorch#167507, CUDA supports graph capture and replay involving host memory as well. Therefore, it is important to clean up both the device and host memory before starting graph capture to ensure correct and predictable behavior. Pull Request resolved: pytorch#171270 Approved by: https://github.com/eellison ghstack dependencies: pytorch#171285
gplutop7
pushed a commit
to gplutop7/pytorch
that referenced
this pull request
Jul 15, 2026
…nterface (pytorch#171285) # Motivation This PR introduces a unified frontend API `torch.accelerator.Graph` which wraps `at::accelerator::Graph` and provides capture and replay functionality. The interface is largely aligned with `torch.cuda.Graph`, and can be extended on demand in the future. Inspired by the design and usage of `torch.Stream`, `torch.accelerator.Graph` is intended to act as a context manager that captures work on the current of the current device. This enables a simple and intuitive usage pattern, for example: ```python s = torch.Stream() g = torch.accelerator.Graph() with s, g: # capture ops pass g.replay() ``` There are, however, some subtle but important differences compared to the existing `torch.cuda.graph` context manager: 1. Stream selection semantics `torch.cuda.graph` implicitly creates and uses a non-default `torch.cuda.Stream` as the capture stream if none is explicitly provided. In contrast, `torch.accelerator.Graph` always captures on the current stream. On CUDA, if no additional stream is set and the current stream is the default stream, this may raise an error such as `CUDA graphs must be captured on a non-default stream.` Refer to https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L212 2. Graph memory pool support `torch.cuda.graph` allows users to specify a graph pool to share memory across graph captures. See https://github.com/pytorch/pytorch/blob/0db3b1eee4dde4dede75904914fc04cf1f9f65b9/torch/cuda/graphs.py#L190 `torch.accelerator.Graph` currently supports specifying a graph pool at construction time. So, I think we don't provide `torch.accelerator.graph` to align with the behavior of `torch.cuda.graph`, `torch.accelerator.Graph` is enough as the context manager. Pull Request resolved: pytorch#171285 Approved by: https://github.com/EikanWang, https://github.com/eellison
gplutop7
pushed a commit
to gplutop7/pytorch
that referenced
this pull request
Jul 15, 2026
# Motivation This PR introduces a unified API, `torch.accelerator.empty_host_cache`, for releasing unused host (pinned) memory. This API can also be used prior to graph capture. For example, as discussed in pytorch#167507, CUDA supports graph capture and replay involving host memory as well. Therefore, it is important to clean up both the device and host memory before starting graph capture to ensure correct and predictable behavior. Pull Request resolved: pytorch#171270 Approved by: https://github.com/eellison ghstack dependencies: pytorch#171285
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.
Stack from ghstack (oldest at bottom):
Motivation
This PR introduces a unified frontend API
torch.accelerator.Graphwhich wrapsat::accelerator::Graphand provides capture and replay functionality. The interface is largely aligned withtorch.cuda.Graph, and can be extended on demand in the future.Inspired by the design and usage of
torch.Stream,torch.accelerator.Graphis intended to act as a context manager that captures work on the current of the current device. This enables a simple and intuitive usage pattern, for example:There are, however, some subtle but important differences compared to the existing
torch.cuda.graphcontext manager:torch.cuda.graphimplicitly creates and uses a non-defaulttorch.cuda.Streamas the capture stream if none is explicitly provided. In contrast,torch.accelerator.Graphalways captures on the current stream. On CUDA, if no additional stream is set and the current stream is the default stream, this may raise an error such asCUDA graphs must be captured on a non-default stream.Refer topytorch/torch/cuda/graphs.py
Line 212 in 0db3b1e
torch.cuda.graphallows users to specify a graph pool to share memory across graph captures. Seepytorch/torch/cuda/graphs.py
Line 190 in 0db3b1e
torch.accelerator.Graphcurrently supports specifying a graph pool at construction time.So, I think we don't provide
torch.accelerator.graphto align with the behavior oftorch.cuda.graph,torch.accelerator.Graphis enough as the context manager.cc @albanD @eellison @EikanWang