Skip to content

Add ability to save wgrads and dgrads - #3032

Merged
deepakn94 merged 5 commits into
NVIDIA:mainfrom
deepakn94:dnarayanan/wgrad_and_dgrad_logging
Jan 24, 2026
Merged

Add ability to save wgrads and dgrads#3032
deepakn94 merged 5 commits into
NVIDIA:mainfrom
deepakn94:dnarayanan/wgrad_and_dgrad_logging

Conversation

@deepakn94

Copy link
Copy Markdown
Contributor

wgrad saving requires that the DP collective is an all-reduce instead of reduce-scatter to make it easier to pull wgrads from DP replica 0. Some other gotchas:

  • First gradient reduction (when metadata is being collected about when to launch collectives) should also be an all-reduce if needed
  • start_grad_sync call should be a no-op if in first batch and collective has already been dispatched
  • Don't try calling reduce_scatter_with_fp32_accumulation's .wait() method if using all-reduce in a particular iteration

@erhoo82 erhoo82 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread megatron/core/pipeline_parallel/schedules.py Outdated
Comment thread megatron/training/training.py Outdated
… code

wgrad saving requires that the DP collective is an all-reduce instead of reduce-scatter to make it easier to pull wgrads from DP replica 0. Some other gotchas:
- First gradient reduction (when metadata is being collected about when to launch collectives) should also be an all-reduce if needed
- start_grad_sync call should be a no-op if in first batch and collective has already been dispatched
- Don't try calling reduce_scatter_with_fp32_accumulation's .wait() method if using all-reduce in a particular iteration

Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
@deepakn94
deepakn94 force-pushed the dnarayanan/wgrad_and_dgrad_logging branch from fb63246 to 1dfb8b5 Compare January 24, 2026 04:01
@deepakn94
deepakn94 added this pull request to the merge queue Jan 24, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 24, 2026
Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 24, 2026
@deepakn94
deepakn94 added this pull request to the merge queue Jan 24, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 24, 2026
Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: medium enhancement New feature or request Final Review PR is in the "final review" stage module: distributed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants