Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/196724
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit 9ba63e6 with merge base f239880 ( UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Sep 11, 2026
SherlockNoMad
approved these changes
Sep 24, 2026
SherlockNoMad
left a comment
Contributor
There was a problem hiding this comment.
lgtm, but @weifengpy should take a look.
weifengpy
approved these changes
Sep 25, 2026
Contributor
Author
|
@pytorchbot merge |
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 |
pytorchmergebot
pushed a commit
that referenced
this pull request
Sep 30, 2026
**Split pipeline FSDP gradient reduction into explicit start and wait actions.** `REDUCE_GRAD` starts asynchronous FSDP gradient finalization and stores its public `GradientReductionHandle`. `WAIT_REDUCE_GRAD` waits for that handle and completes gradient scaling. Every reduction has exactly one matching wait, and each pipeline rank may have at most one pending reduction. By default, the wait remains adjacent to its reduction, preserving existing behavior. With `defer_reduce_grad_wait=True`, schedule lowering moves only the wait to immediately before the next local reduction or to the end of the schedule. The reduction remains at its existing causal point, allowing its communication to overlap with the next local stage's backward computation. For pre-lowered compute-comms schedules, the action stream is the source of truth. Their `REDUCE_GRAD` and `WAIT_REDUCE_GRAD` ordering is validated regardless of the constructor option. Non-final outer gradient-accumulation steps skip both actions. Deferred waits reject FSDP stages that share a communication context because another stage cannot safely use that context while a reduction is pending. Pull Request resolved: #196725 Approved by: https://github.com/SherlockNoMad, https://github.com/sanketpurandare ghstack dependencies: #196640, #196724
pytorchmergebot
pushed a commit
that referenced
this pull request
Sep 30, 2026
Store a GradientEdge for each releasable, grad-requiring pipeline output so backward does not require the original tensor object. Track one pending batched send per output slot. When an existing schedule wait completes that send, release the send operations and the stage's output reference. Keep unsupported output types, DDP, custom split backward, and last-stage outputs on their tensor-backed ownership paths. Forward-only schedules do not create unused GradientEdges. **This PR does not change when sends are issued. This PR releases send and stage ownership after the send completes, using the matching backward as the causal retirement point.** Test Plan: ``` python test/distributed/pipelining/test_backward.py python test/distributed/pipelining/test_stage.py OutputSlotReleaseTest ``` Authored with assistance from Codex. Pull Request resolved: #196963 Approved by: https://github.com/SherlockNoMad ghstack dependencies: #196640, #196724, #196725
pytorchmergebot
pushed a commit
that referenced
this pull request
Sep 30, 2026
## Summary Add `WAIT_SEND_F` and `WAIT_SEND_B` as first-class pipeline schedule actions. Each send now has an explicit matching wait. The runtime keeps the P2P operations, work handles, source tensors, and optional output-release callback alive until that wait executes. ## Motivation Pipeline sends are nonblocking. Their work handles and source tensors must remain alive until communication completes. Implicit end-of-step waits cannot express earlier ownership release and are unsuitable for static CUDA graph capture. Explicit actions make send lifetime part of the schedule. This PR is stacked on #196963, which lets forward output ownership be released without breaking backward autograd connectivity. ## Design For generated schedules: - Insert one wait for every send. - Place a forward-send wait after the matching backward action when available. - Place backward-send waits and unmatched forward-send waits at schedule end. For pre-lowered `compute_comms` schedules: - Require one ordered wait for every send. - Reject duplicate sends, missing waits, and waits without a pending send. At runtime: - Track each send by direction, stage, and microbatch. - Retire a send only when its explicit wait executes. - Release forward output ownership after the forward send completes. - Drain pending sends only when action execution fails. - Do not poll for communication completion. The schedule simulator also understands send-wait dependencies and requires he peer receive to be posted before a wait can complete. This PR does not enforce an outstanding-send count. A later PR can move these explicit waits earlier to satisfy a memory budget. Pull Request resolved: #196726 Approved by: https://github.com/SherlockNoMad, https://github.com/sanketpurandare ghstack dependencies: #196640, #196724, #196725, #196963
pytorchmergebot
pushed a commit
that referenced
this pull request
Sep 30, 2026
## Summary Add an optional `max_outstanding_sends` limit to runtime pipeline schedules. The schedule moves existing send waits earlier to keep pending forward and backward sends within the per-rank limit. Waits move only when dependency analysis proves the placement cannot create a cycle. Unsafe limits raise an actionable error. The default behavior remains unchanged. Pull Request resolved: #196727 Approved by: https://github.com/sanketpurandare ghstack dependencies: #196640, #196724, #196725, #196963, #196726
cyyever
pushed a commit
to BakeLab/pytorch
that referenced
this pull request
Oct 11, 2026
## Summary Add an optional `max_outstanding_sends` limit to runtime pipeline schedules. The schedule moves existing send waits earlier to keep pending forward and backward sends within the per-rank limit. Waits move only when dependency analysis proves the placement cannot create a cycle. Unsafe limits raise an actionable error. The default behavior remains unchanged. Pull Request resolved: pytorch#196727 Approved by: https://github.com/sanketpurandare ghstack dependencies: pytorch#196640, pytorch#196724, pytorch#196725, pytorch#196963, pytorch#196726
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):
Add an async option to
finalize_backwardthat returns a public gradient-reduction handle. The handle keeps reduction buffers alive and completes stream synchronization and cleanup when waited.Keep synchronous finalization as the default and implement it through the same handle path.