Repository navigation
[cudagraph] Reuse graph-owned parameter gradients - #4659
Merged
Merged
Conversation
[ghstack-poisoned]
This was referenced Sep 14, 2026
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
tianyu-l
reviewed
Sep 24, 2026
| tensor_input_indices: Sequence[int] | None = None, | ||
| *, | ||
| num_warmup_iterations: int, | ||
| gradient_state: CUDAGraphGradientState | None = None, |
Contributor
Author
There was a problem hiding this comment.
yes, this wrapper is also used by optimizer which doesn't have the gradient_state.
Comment on lines
+130
to
+131
| self.parameters = tuple(unique_parameters) | ||
| self._gradients: tuple[ |
Contributor
There was a problem hiding this comment.
naming seems not consistent
[ghstack-poisoned]
tianyu-l
approved these changes
Sep 25, 2026
| def wrap_with_cuda_graph( | ||
| fn: Callable[..., Any], | ||
| *, | ||
| gradient_state: CUDAGraphGradientState | None = None, |
Contributor
There was a problem hiding this comment.
I don't feel particularly safe, when something not fwd-bwd can call this function, with this field exposed. But doesn't seem to be worth blocking on this.
[ghstack-poisoned]
fegin
requested review from
SherlockNoMad,
aditvenk and
sanketpurandare
as code owners
September 25, 2026 19:48
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
fegin
added a commit
that referenced
this pull request
Sep 29, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #4662 * #4661 * #4660 * #4659 * __->__ #4658 ---- **Conflict with #4649, need to discuss how to incorporate with #4649 **Depend on pytorch/pytorch#196640 and pytorch/pytorch#196641 - Add `parallelism.fsdp_defer_gradient_reduction` to reduce gradients after the final backward of a gradient accumulation group. - Replay the whole optimizer step during SDC checks. - Use the public FSDP and pipeline finalization APIs.
[ghstack-poisoned]
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):
Why this state can reduce memory use: