Repository navigation
cudagraph trees - #89146
cudagraph trees#89146eellison wants to merge 25 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/89146
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 5c9cd25: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
What's the inputs (?) You want inputs in the pool. In conventional usage, we'll be copying in the training data to the cuda graph to kick off the run. |
For correctness, don't you have to do the "wait until all the incoming refcounts are dead". Doesn't have to be weak-ref, IIRC? |
Uh, this is a bit outdated, check PR. |
cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen chunyuan-w XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire This is a first PR implementing the following plan of POR: - We will use a single Memory Pool across all cudagraphs. The memory pool will contain inputs (?), intermediates, and outputs. CUDAGraphs memory pool ensures that memory allocated within graph capture is not allocated outside of the memory pool, so that memory addresses remain static during graph replay. However, within the memory pool, normal storage allocation occurs, so there is no memory overhead. So long as we invoke separate CUDAGraphs in a consistent order as they are recorded, and do not retain extraneous references to Tensors, there should be no overhead. We will keep a global tape of the initial graph recordings and subsequent usages. Enforcing consistent CUDAGraph usage will also allow us to avoid copying over inputs to a CUDAGraph that are the outputs of a prior one. - To avoid “static outputs” being permanently allocated, which interferes with both memory being reclaimed within CUDAGraphs and [gradient stealing](https://github.com/pytorch/pytorch/blob/master/torch/csrc/autograd/functions/accumulate_grad.h#L52), we will reconstruct output tensors Tensors with the appropriate fixed storage data pointers and other metadata on each cudagraph invocation. - When a CUDAGraph usage diverges from the existing tape we can 1. free the memory pool to the rest of the cuda allocator, invalidating the CUDAGraphs of our tape but keeping the existing Tensors alive or 2. Run torch inductor without cudagraphs for the remainder of the tape. The latter would have some memory penalty because it would not use memory from the memory pool - Because cudagraphs freeze memory addresses, the invocation of a cudagraph will replace whatever values the memory had previously. To avoid overwriting the live output values of a previous invocation, we can either check that the backward has been run for a cudagraph forward (not clear to me this is sufficient ?). We potentially could also do weak-ref ref counting. Not everything is implemented yet, and I will not land this pr without subsequent follow ups. Follows ups, for correctness/minimal viable product in terms of priority include : - Registering the cudagraphs as thread local state that needs to be copied over in autograd - Ensuring clean up works successfully - Adding tests for all the edge cases provided reviewers are okay with approach - Handling subsequent usage when a graph invariant is broken, i.e. moving cuda graph allocations from the private memory pool to eager And then further work would be: - Allowing multiple, separate cudagraph paths by making the cuda caching allocator resumable and doing new recordings. - Adding configs to weaken some of the correctness conditions (for power user who can verify correctness) [ghstack-poisoned]
cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen chunyuan-w XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire This is a first PR implementing the following plan of POR: - We will use a single Memory Pool across all cudagraphs. The memory pool will contain inputs (?), intermediates, and outputs. CUDAGraphs memory pool ensures that memory allocated within graph capture is not allocated outside of the memory pool, so that memory addresses remain static during graph replay. However, within the memory pool, normal storage allocation occurs, so there is no memory overhead. So long as we invoke separate CUDAGraphs in a consistent order as they are recorded, and do not retain extraneous references to Tensors, there should be no overhead. We will keep a global tape of the initial graph recordings and subsequent usages. Enforcing consistent CUDAGraph usage will also allow us to avoid copying over inputs to a CUDAGraph that are the outputs of a prior one. - To avoid “static outputs” being permanently allocated, which interferes with both memory being reclaimed within CUDAGraphs and [gradient stealing](https://github.com/pytorch/pytorch/blob/master/torch/csrc/autograd/functions/accumulate_grad.h#L52), we will reconstruct output tensors Tensors with the appropriate fixed storage data pointers and other metadata on each cudagraph invocation. - When a CUDAGraph usage diverges from the existing tape we can 1. free the memory pool to the rest of the cuda allocator, invalidating the CUDAGraphs of our tape but keeping the existing Tensors alive or 2. Run torch inductor without cudagraphs for the remainder of the tape. The latter would have some memory penalty because it would not use memory from the memory pool - Because cudagraphs freeze memory addresses, the invocation of a cudagraph will replace whatever values the memory had previously. To avoid overwriting the live output values of a previous invocation, we can either check that the backward has been run for a cudagraph forward (not clear to me this is sufficient ?). We potentially could also do weak-ref ref counting. Not everything is implemented yet, and I will not land this pr without subsequent follow ups. Follows ups, for correctness/minimal viable product in terms of priority include : - Registering the cudagraphs as thread local state that needs to be copied over in autograd - Ensuring clean up works successfully - Adding tests for all the edge cases provided reviewers are okay with approach - Handling subsequent usage when a graph invariant is broken, i.e. moving cuda graph allocations from the private memory pool to eager And then further work would be: - Allowing multiple, separate cudagraph paths by making the cuda caching allocator resumable and doing new recordings. - Adding configs to weaken some of the correctness conditions (for power user who can verify correctness) [ghstack-poisoned]
cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen chunyuan-w XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire This is a first PR implementing the following plan of POR: - We will use a single Memory Pool across all cudagraphs. The memory pool will contain inputs (?), intermediates, and outputs. CUDAGraphs memory pool ensures that memory allocated within graph capture is not allocated outside of the memory pool, so that memory addresses remain static during graph replay. However, within the memory pool, normal storage allocation occurs, so there is no memory overhead. So long as we invoke separate CUDAGraphs in a consistent order as they are recorded, and do not retain extraneous references to Tensors, there should be no overhead. We will keep a global tape of the initial graph recordings and subsequent usages. Enforcing consistent CUDAGraph usage will also allow us to avoid copying over inputs to a CUDAGraph that are the outputs of a prior one. - To avoid “static outputs” being permanently allocated, which interferes with both memory being reclaimed within CUDAGraphs and [gradient stealing](https://github.com/pytorch/pytorch/blob/master/torch/csrc/autograd/functions/accumulate_grad.h#L52), we will reconstruct output tensors Tensors with the appropriate fixed storage data pointers and other metadata on each cudagraph invocation. - When a CUDAGraph usage diverges from the existing tape we can 1. free the memory pool to the rest of the cuda allocator, invalidating the CUDAGraphs of our tape but keeping the existing Tensors alive or 2. Run torch inductor without cudagraphs for the remainder of the tape. The latter would have some memory penalty because it would not use memory from the memory pool - Because cudagraphs freeze memory addresses, the invocation of a cudagraph will replace whatever values the memory had previously. To avoid overwriting the live output values of a previous invocation, we can either check that the backward has been run for a cudagraph forward (not clear to me this is sufficient ?). We potentially could also do weak-ref ref counting. Not everything is implemented yet, and I will not land this pr without subsequent follow ups. Follows ups, for correctness/minimal viable product in terms of priority include : - Registering the cudagraphs as thread local state that needs to be copied over in autograd - Ensuring clean up works successfully - Adding tests for all the edge cases provided reviewers are okay with approach - Handling subsequent usage when a graph invariant is broken, i.e. moving cuda graph allocations from the private memory pool to eager And then further work would be: - Allowing multiple, separate cudagraph paths by making the cuda caching allocator resumable and doing new recordings. - Adding configs to weaken some of the correctness conditions (for power user who can verify correctness) [ghstack-poisoned]
| assert isinstance(inputs, (list, tuple)) | ||
| self.graph = torch.cuda.CUDAGraph() | ||
| self.model = model | ||
| static_input_idxs = remove_unaligned_input_idxs(inputs, static_input_idxs) |
There was a problem hiding this comment.
I know this is old code, but it occurs to me we should probably warn when an unaligned parameter induces copies into cuda graphs
|
@davidberard98 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
| id: GraphID, | ||
| parent: Optional[CUDAGraphNode], | ||
| inputs: List[Tensor], | ||
| cuda_graphs_pool: Tuple[int, int], |
There was a problem hiding this comment.
lol I was surprised by that too, it's an Opaque token (returned by a call to [graph_pool_handle()] or [other_Graph_instance.pool()]) according to the doc, but it looks like an (int, int)
There was a problem hiding this comment.
If this is derivable from Graph, then I guess this is purely for caching?
There was a problem hiding this comment.
This is the memory pool handle to use a single pool across separate recordings
| ) | ||
|
|
||
| # we preserve a single reference to executed outputs that is then referenced | ||
| # in children to avoid children having to chase parent pointers in the hot path |
There was a problem hiding this comment.
There seems to be some invariant here, it would be nice if it was explicitly written out
There was a problem hiding this comment.
In particular, according to the comment, it should be possible to recompute the output weakrefs by chasing parent pointers. We should implement this and have a debug mode to actually check that this is consistent.
There was a problem hiding this comment.
Can implement this. I dont think there is any invariant here besides what is commented.
| # the cudagraphify_fns. Reference to the Graph is needed to keep the private pool from | ||
| # deallocation. | ||
| self.live_tensors_count = 0 | ||
| self.graph: Optional[torch.cuda.CUDAGraph] = None |
There was a problem hiding this comment.
"Reference to the Graph is needed to keep the private pool from deallocation."
All the cudagraphify_fns are dead, but we keep graph around to prevent deallocation. i simplify this in a later PR.. can merge that change back here.
| id: GraphID, | ||
| parent: Optional[CUDAGraphNode], | ||
| inputs: List[Tensor], | ||
| cuda_graphs_pool: Tuple[int, int], |
There was a problem hiding this comment.
If this is derivable from Graph, then I guess this is purely for caching?
|
|
||
| self.device: int = next( | ||
| (x.device.index for x in inputs if is_cuda_tensor), None | ||
| ) |
There was a problem hiding this comment.
Can't cuda graphs be multi device?
There was a problem hiding this comment.
Is it an error if we can't infer the device?
There was a problem hiding this comment.
this is cleaned up in the last pr of the stack.. hard to iterate on the stack but also keep things separate and applied to all applicable prs :/
There was a problem hiding this comment.
I'm OK with squashing all of the PRs past this.
| # in children to avoid children having to chase parent pointers in the hot path | ||
| # DO NOT reassign output_weakrefs, only call `clear()` | ||
| self.outputs_weakrefs: List[Optional[TensorWeakRef]] = [] | ||
| self.path_weakrefs: List[List[Optional[TensorWeakRef]]] = [ |
There was a problem hiding this comment.
I don't understand what the graph index means here
| self.recorded_liveness_before_graph: List[List[bool]] = [] | ||
| self.recorded_liveness_after_graph: List[List[bool]] = [] | ||
|
|
||
| # indices into node at level i for output j |
There was a problem hiding this comment.
I have no idea, at thisnpoint, what a "level" is
There was a problem hiding this comment.
lol took that terminology from wikipedia. the level of the tree is distance from the root. maybe depth is more idiomatic. or i'll just spell out with the full description..
There was a problem hiding this comment.
I agree level is unambiguous for this. It's surprising though because you don't have a root, you would traverse parent pointers to populate this.
There was a problem hiding this comment.
It might be cleaner for me to pass in a root, instead of a parent. it doesn't matter perf wise (dont traverse on hot path) but it would be cleaner perhaps. Edit i dont really think so, since that complicates finding the right path. Could pass in parent and root I guess
| self.live_indices_after_graph: List[Tuple[int, int]] = [] | ||
|
|
||
| if self.parent is not None: | ||
| previous_liveness = self.parent.recorded_liveness_after_graph |
There was a problem hiding this comment.
Paradoxically, I think the names here are a bit too long, and shorter names would have helped me for clarity here
There was a problem hiding this comment.
what do you think would be better ?
|
|
||
| if self.parent is not None: | ||
| previous_liveness = self.parent.recorded_liveness_after_graph | ||
| curr_liveness = self._get_liveness(self.path_weakrefs) |
There was a problem hiding this comment.
If these methods don't actually depend on entries in self, I might suggest declaring them as top level functions to make it clear they don't access self in an unrestricted way.
| previous_liveness = self.parent.recorded_liveness_after_graph | ||
| curr_liveness = self._get_liveness(self.path_weakrefs) | ||
|
|
||
| different_indices = self._get_different_indices( |
There was a problem hiding this comment.
A small data structure for indices might help with code organization here
|
|
||
| # graph needs to be kept alive for the duration of the model | ||
| # otherwise the memory pool would be freed on the first recording | ||
| inps_alloc_graph = torch.cuda.CUDAGraph() |
There was a problem hiding this comment.
Needing two cuda graphs is surprising
There was a problem hiding this comment.
this is cleaned up in a later pr
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
|
|
||
| @dynamo_utils.dynamo_timed | ||
| def cudagraphify(model, inputs, static_input_idxs=()): | ||
| from torch._inductor.cudagraph_trees import ( |
There was a problem hiding this comment.
Perhaps move all the cudagraphs related stuff (including this function) to the same file so we don't need to workaround circular imports like this.
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either #91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) [ghstack-poisoned]
ghstack-source-id: c2aa27e Pull Request resolved: #89146 Use Storages for Cudagraph liveness ghstack-source-id: c2aa27e Pull Request resolved: #96154 Do warmup in cudagraph pool ghstack-source-id: c2aa27e Pull Request resolved: #96433 Comments for cuda graph trees Signed-off-by: Edward Z. Yang <ezyangmeta.com> ghstack-source-id: c2aa27e Pull Request resolved: #96932
|
@pytorchbot merge |
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 |
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either pytorch/pytorch#91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) Pull Request resolved: pytorch/pytorch#89146 Approved by: https://github.com/ezyang
CUDA Graph Trees Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit Not currently implemented : - Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either pytorch/pytorch#91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr. - Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr. - Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking Differential Revision: [D43999887](https://our.internmc.facebook.com/intern/diff/D43999887) Pull Request resolved: pytorch/pytorch#89146 Approved by: https://github.com/ezyang
Stack from ghstack (oldest at bottom):
CUDA Graph Trees
Design doc: https://docs.google.com/document/d/1ZrxLGWz7T45MSX6gPsL6Ln4t0eZCSfWewtJ_qLd_D0E/edit
Not currently implemented :
Right now, we are using weak tensor refs from outputs to check if a tensor has dies. This doesn't work because a) aliasing, and b) aot_autograd detaches tensors (see note [Detaching saved tensors in AOTAutograd]). Would need either PyObject preservation and resurrection for
StorageImpl#91395 to land to use storage weak refs or manually add a deleter fn that does what I want. This is doable but theres some interactions with the caching allocator checkpointing so saving for a stacked pr.Reclaiming memory from the inputs during model recording. This isn't terribly difficult but deferring to another PR. You would need to write over the input memory during warmup, and therefore copy the inputs to cpu. Saving for a stacked pr.
Warning on overwriting previous generation outputs. and handling nested torch.compile() calls in generation tracking
Differential Revision: D43999887
cc @soumith @voznesenskym @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @desertfire