-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add statistics logging for params and activations #5492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
philipcmonk
wants to merge
17
commits into
NVIDIA:main
Choose a base branch
from
philipcmonk:pmonk/metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
34f71bc
Add raw moment statistics logging
philipcmonk 27c3516
thread EP groups into per_parameter_stats
philipcmonk daed0da
remove untested support for FSDP in training metrics
philipcmonk 044dd63
change raw moment logging flags to step intervals
philipcmonk 16cdc8c
Add canonical parameter name indexing
philipcmonk 9b2f65b
Use canonical name index for parameter statistics
philipcmonk eb177a7
add nvtx ranges to stats logging
philipcmonk 6197dc6
Merge upstream/main into pmonk/metrics
philipcmonk ec97c56
fix tests
philipcmonk 38af53a
suspend cudagraphs when act/dgrad logging
philipcmonk 49a98e1
Log residual raw moments by layer
philipcmonk 06972ad
Log residual dgrad raw moments by layer
philipcmonk a636fe5
simplify statistics logging machinery
philipcmonk 3c745e2
refactor raw_moment_logging
philipcmonk 03a4fd0
rename training stats flags
philipcmonk d626901
Merge upstream/main into residual-metrics
philipcmonk 5ee0b50
formatting
philipcmonk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
reduce_groups=(None,)passesgroup=Nonetotorch.distributed.all_reduce, which reduces over the default (WORLD) group. This will multiply all raw moments byworld_size— every DP replica holds the same (already-reduced) gradient, and every PP/TP rank's contribution gets summed globally.Compare with the base
MegatronOptimizer.get_raw_moment_buckets_for_grad_norm, which carefully selects the data-parallel group (for DTensor) andget_grad_stats_parallel_group()(model-parallel group). TheLayerWiseOptimizershould assemble equivalent reduce groups from its chained optimizers rather than falling back to WORLD.If
(None,)was intended as "no reduction needed", use an empty tuple()instead —reduce_raw_moments_by_paramiteratesbucket.reduce_groupsand will skip the all-reduce entirely when the tuple is empty.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggled with this one a bit and am not sure I got it right in the end.
Noneas the world group is used based on the similar logic in get_grad_norm and count_zeros.However, I notice in their helper functions that if they're dtensors, they also reduce across that data parallel group. That seems like a double-count to me, since reducing across
Noneshould already include those devices, I believe.