[PyTorch] Remove is_first_microbatch setting after cudagraph warmup#2715
Open
buptzyb wants to merge 1 commit intoNVIDIA:mainfrom
Open
[PyTorch] Remove is_first_microbatch setting after cudagraph warmup#2715buptzyb wants to merge 1 commit intoNVIDIA:mainfrom
buptzyb wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Signed-off-by: Robin Zhang <robinz@nvidia.com>
886f8cb to
25af05a
Compare
Contributor
Greptile SummaryRemoves unnecessary code that was resetting The removed code was originally added for Megatron-Core requirements to prevent warmup from altering control flow. However, this reset is actually unnecessary and potentially harmful:
The two functions of
This fix ensures correct gradient accumulation when one CUDA graph is captured and replayed for multiple microbatches. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 25af05a |
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.
Description
Reset
is_first_microbatchto True is unnecessary, because later we'll set it back to False: https://github.com/NVIDIA/TransformerEngine/blob/release_v2.12/transformer_engine/pytorch/module/layernorm_mlp.py#L2037-L2042is_first_microbatchhas two functions: the first is to control fp8 cast-transpose behavior, which is overtaken by theskip_fp8_weight_updatetensor in graph replay. The second is to control whether the fused wgrad should clearmain_gradbuffer before making the accumulation. We should always capture the no-clear version in case the user captures one graph for all microbatches.Type of change
Changes
Please list the changes introduced in this PR:
Checklist: