Repository navigation
fix(gtp): clear dummy gradients before DDP readiness - #7467
Merged
Merged
Conversation
|
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. |
JF-D
marked this pull request as ready for review
September 18, 2026 05:07
JF-D
force-pushed
the
fix/gtp-clear-dummy-before-ddp
branch
from
September 18, 2026 06:28
af3cf8f to
2c48c5f
Compare
GTP has already accumulated its reduced gradient into main_grad when it invokes the manual DDP callback. A stale autograd placeholder can still be added when zero_out_wgrad overrides grad_added_to_main_grad. Capturing that redundant add can retain a warmup allocation after it is released. Clear the placeholder at the GTP notification boundary while preserving the dummy returned to autograd and generic DDP accumulation semantics. Add regression coverage for ordinary DDP accumulation, repeated GTP backward uses, and replay after releasing the warmup dummy. Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com>
JF-D
force-pushed
the
fix/gtp-clear-dummy-before-ddp
branch
from
September 18, 2026 06:41
2c48c5f to
2b8404f
Compare
5 of 7 tasks
Contributor
Author
|
/review |
svcnvidia-nemo-ci
approved these changes
Oct 1, 2026
svcnvidia-nemo-ci
left a comment
Contributor
There was a problem hiding this comment.
LGTM. The GTP-specific change preserves DDP readiness notifications and ordinary gradient accumulation, with regression coverage for stale placeholders, repeated backward use, and CUDA graph replay. Tests were not executed in this read-only review.
Review generated by codex
fanshiqing
approved these changes
Oct 9, 2026
kvareddy
approved these changes
Oct 9, 2026
ericharper
approved these changes
Oct 9, 2026
ericharper
enabled auto-merge
October 9, 2026 21:57
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/38044729560 |
xuwchen
pushed a commit
to xuwchen/Megatron-LM
that referenced
this pull request
Oct 14, 2026
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com> (cherry picked from commit 6cad8f6) Signed-off-by: xuwenc <xuwenc@nvidia.com>
xuwchen
pushed a commit
to xuwchen/Megatron-LM
that referenced
this pull request
Oct 14, 2026
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com> (cherry picked from commit 6cad8f6) Signed-off-by: xuwenc <xuwenc@nvidia.com>
fanshiqing
pushed a commit
to fanshiqing/Megatron-LM
that referenced
this pull request
Oct 27, 2026
Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com> Upstream: NVIDIA#7467 Adapt the manual-hook call context to this support branch; retain its existing captured-gradient readiness implementation. Include the upstream regression tests unchanged. (cherry picked from commit 6cad8f6) Signed-off-by: Shiqing Fan <shiqingf@nvidia.com>
This branch was previously deployed
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.
What does this PR do?
Clear GTP's autograd placeholder before invoking its manual DDP readiness callback.
GTP has already accumulated the reduced gradient into
main_grad. However, whenzero_out_wgrad=True(for example, on an MTP embedding), DDP can still add an oldparam.gradeven thoughgrad_added_to_main_grad=True. Under CUDA graph capture,that redundant addition can record the address of a warmup allocation that is
released before replay.
Set
param.grad = Noneat the GTP notification boundary. Preserve thezero_out_wgradconvention, the placeholder returned to autograd, capturebookkeeping, readiness notifications, and generic DDP accumulation behavior.
Issue tracking
Linked issue: None; regression reproduced by the included tests.
Contribution process
Pre-checks
jit_fuser/torch.compile, CUDA extension, TE or external-library dispatch, or a scatter/index accumulation), I have added or updated its bit-exact determinism test and registered it intests/unit_tests/determinism/kernels/manifest.py(guide)Code review
The production change is confined to GTP. No GPU kernels or public APIs are added.