Repository navigation
fix: preserve repeated GTP parameter uses - #6862
Conversation
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/claude strict-review |
c7a5d9f to
d98515d
Compare
|
/claude review |
|
Light review — the core change (record actual finalization occurrences at the hook site instead of inferring them from 1. Everywhere else in self.finalized_during_bwd_capture = (
list(capture_comms.finalized_params) if self.gtp_remat else []
)The old self.finalized_during_bwd_capture = (
[
p
for p in capture_comms.finalized_params
if getattr(p, "chain_id", None) == GTPChain.GRAPHED.value
]
if self.gtp_remat
else []
)2. The new test does not cover the bug that was fixed.
|
|
/ok to test e3b9bfe |
|
/claude strict-review |
e3b9bfe to
07a1f2d
Compare
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com>
Record replay notifications only for graphed-chain hook occurrences and preserve repeated parameters when grouping the replay hook plan. Add focused coverage for hook-site registration and downstream multiplicity. Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com>
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com>
07a1f2d to
a33f14a
Compare
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/33423225640 |
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com>
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com> (cherry picked from commit b89dd94)
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com> (cherry picked from commit b89dd94)
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com> (cherry picked from commit b89dd94)
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com> (cherry picked from commit b89dd94) Signed-off-by: xuwenc <xuwenc@nvidia.com>
What does this PR do?
Problem
MTP can use the same GTP parameter multiple times in one forward/backward pass. Each completed GTP wgrad reduction contributes to main_grad and produces one DDP grad-ready
occurrence. DDP learns this per-parameter occurrence count during eager execution and waits for the same count in later iterations before dispatching the bucket reduction.
Local CUDA graph replay does not execute the Python GTP finalization path directly. Previously, it inferred finalized parameters from the captured graph structure and
deduplicated them by parameter identity. If a parameter was finalized twice, replay reported it ready only once, leaving DDP waiting for the second occurrence and
preventing the bucket reduction from being dispatched.
Solution
Record every actual GTP wgrad-finalization occurrence during backward graph capture, at the point where GTP invokes the DDP grad-ready hook.
The captured occurrence list intentionally preserves duplicate parameters. After graph replay, the hook plan reproduces the same number of grad-ready notifications as
eager execution, allowing DDP’s per-parameter ready counts to reach their expected values.
This also removes the previous graph-structure-based inference, so replay bookkeeping reflects the finalizations that actually occurred during capture.
Validation
Contribution process
Pre-checks