Skip to content

docs: update mcore optimizer docstrings to google style#2799

Open
Akshat8510 wants to merge 1 commit intoNVIDIA:mainfrom
Akshat8510:docstring-optimizer
Open

docs: update mcore optimizer docstrings to google style#2799
Akshat8510 wants to merge 1 commit intoNVIDIA:mainfrom
Akshat8510:docstring-optimizer

Conversation

@Akshat8510
Copy link

Description

This PR updates and standardizes the docstrings for the megatron/core/optimizer module to follow the Google Style Guide. This is part of the documentation overhaul tracked in issue #2653.

Changes

  • Updated optimizer.py, distrib_optimizer.py, grad_scaler.py, and clip_grads.py with structured Args, Returns, and Attributes blocks.
  • Formatted OptimizerConfig dataclass attributes for better compatibility with auto-generated API guides.
  • Refined technical descriptions and updated documentation references to use relative paths.

Files Updated:

  • megatron/core/optimizer/clip_grads.py
  • megatron/core/optimizer/distrib_optimizer.py
  • megatron/core/optimizer/grad_scaler.py
  • megatron/core/optimizer/optimizer.py
  • megatron/core/optimizer/optimizer_config.py
  • megatron/core/optimizer/qk_clip.py

Mentions: @Phlip79 @sbhavani

@Akshat8510 Akshat8510 requested review from a team as code owners January 4, 2026 04:41
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jan 4, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Akshat8510
Copy link
Author

Hi @Phlip79, I have submitted a PR for the optimizer and clip_grads modules as part of this docstring update.

@Akshat8510 Akshat8510 marked this pull request as draft January 4, 2026 09:57
@Akshat8510 Akshat8510 marked this pull request as ready for review January 4, 2026 09:57
@Phlip79
Copy link
Member

Phlip79 commented Jan 9, 2026

Thank you Akshat! Could you please ensure that your changes do not reduce verbosity?

@Akshat8510
Copy link
Author

Thank you for the feedback, @Phlip79! I will do a thorough pass over all the changed files to ensure that all technical details and explanations from the original comments are preserved within the new Google Style format. I'll update the PR shortly.

@Akshat8510 Akshat8510 force-pushed the docstring-optimizer branch 2 times, most recently from 7199c88 to 8e80e8f Compare January 9, 2026 05:02
@Akshat8510
Copy link
Author

Akshat8510 commented Jan 9, 2026

Hi @Phlip79, I have updated the docstrings across all 6 files to restore the original technical verbosity and detailed explanations while maintaining the Google Style structure. This includes restoring the core mapping logic in distrib_optimizer.py, the FSDP/filtering details in clip_grads.py, and the in-place modification warnings. Thank you for the feedback!

@chtruong814 chtruong814 added the needs-follow-up Issue needs follow-up label Jan 11, 2026
@Akshat8510
Copy link
Author

Hi @Phlip79 and @chtruong814, I wanted to follow up on this PR. I have addressed the feedback regarding technical verbosity across all 6 files.

@Akshat8510
Copy link
Author

I noticed the needs-follow-up label is still active, please let me know if there are any further changes required on my end to clear this and move toward a merge. Thank you!

@chtruong814 chtruong814 added needs-follow-up Issue needs follow-up and removed needs-follow-up Issue needs follow-up labels Jan 23, 2026
@Akshat8510 Akshat8510 force-pushed the docstring-optimizer branch 2 times, most recently from c97b8cd to 71a045f Compare January 29, 2026 14:02
@Akshat8510
Copy link
Author

Hi @Phlip79 @chtruong814, I've squashed the commits and restored the technical verbosity as requested. Should I update the branch whenever it is out-of-date with main, or only if merge conflicts occur?

@chtruong814 chtruong814 added needs-follow-up Issue needs follow-up and removed needs-follow-up Issue needs follow-up labels Jan 29, 2026
@Akshat8510
Copy link
Author

Hi @Phlip79 and @chtruong814, it's been two weeks since I restored the technical verbosity and squashed the history. The PR is ready for a final look.

@Akshat8510
Copy link
Author

Could you please trigger the internal tests (approve the workflow) so we can see if any further adjustments are needed? Thank you!

@chtruong814 chtruong814 added needs-follow-up Issue needs follow-up and removed needs-follow-up Issue needs follow-up labels Feb 9, 2026
@Akshat8510
Copy link
Author

Hi @Phlip79 and @chtruong814,
I noticed the needs follow-up label was added again. Could you please let me know what specific changes are required from my side? I’m happy to address any feedback to help move this forward. Thank you!

@chtruong814 chtruong814 added needs-follow-up Issue needs follow-up and removed needs-follow-up Issue needs follow-up labels Feb 14, 2026
@Akshat8510
Copy link
Author

Hi @chtruong814,
I noticed the needs follow-up label was added again. Could you please let me know what specific changes are required from my side? I’m happy to address any feedback to help move this forward. Thank you!

@Akshat8510
Copy link
Author

it's been more than 3 weeks since I restored the technical verbosity and squashed the history. The PR is ready for a final look.

@chtruong814 chtruong814 added needs-follow-up Issue needs follow-up and removed needs-follow-up Issue needs follow-up labels Feb 21, 2026
@Akshat8510
Copy link
Author

Hi @chtruong814, I've addressed all the requested changes, restored the technical verbosity

@Akshat8510
Copy link
Author

The PR is ready for review.
Looking forward to your feedback. Thanks!

@chtruong814 chtruong814 removed the needs-follow-up Issue needs follow-up label Feb 24, 2026
@Akshat8510
Copy link
Author

hi @chtruong814 , thank you for removing the follow up label. can you pls review my PR ? It was about improving standardizes the docstrings for the megatron/core/optimizer module to follow the Google Style Guide.

@chtruong814 chtruong814 added the needs-follow-up Issue needs follow-up label Feb 26, 2026
@Akshat8510
Copy link
Author

Hi @chtruong814, I noticed the needs-follow-up label was added again.
Could you please let me know if there are any remaining changes required from my side?

Happy to address them. Thanks!

@chtruong814 chtruong814 added needs-follow-up Issue needs follow-up and removed needs-follow-up Issue needs follow-up labels Feb 26, 2026
@Akshat8510
Copy link
Author

Hi @chtruong814, I noticed the needs-follow-up label was added again.
Could you please let me know if there are any remaining changes required from my side?

Happy to address them. Thanks!

@chtruong814 chtruong814 removed the needs-follow-up Issue needs follow-up label Feb 28, 2026
@Akshat8510
Copy link
Author

Thank you @chtruong814 for removing follow up label, pls review this PR

@chtruong814 chtruong814 added the needs-follow-up Issue needs follow-up label Mar 2, 2026
@Akshat8510
Copy link
Author

Hi @chtruong814, I noticed the needs-follow-up label was added again.
Could you please let me know if there are any remaining changes required from my side?

Happy to address them. Thanks!

@chtruong814 chtruong814 removed the needs-follow-up Issue needs follow-up label Mar 2, 2026
@Akshat8510
Copy link
Author

Thank you @chtruong814 for removing follow up label, pls review this PR

Copy link
Member

@Phlip79 Phlip79 left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to create this PR. I have a few nits.

Apologies it took so long to review, this PR went completely unnoticed because the "Expert Review" label was not added.

We are actually changing the review process moving forward to make the process more clear in #3659.

@Phlip79
Copy link
Member

Phlip79 commented Mar 3, 2026

/ok to test b0aa307

@svcnvidia-nemo-ci svcnvidia-nemo-ci added this to the Core 0.16 milestone Mar 3, 2026
@Phlip79 Phlip79 added Final Review PR is in the "final review" stage docs-only documentation only (docs or docstrings) complexity: medium labels Mar 3, 2026
Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510 Akshat8510 force-pushed the docstring-optimizer branch from b0aa307 to f2c3f3b Compare March 3, 2026 05:41
@Akshat8510
Copy link
Author

Akshat8510 commented Mar 3, 2026

Hi @Phlip79, I have squashed the branch into a single clean commit and restored the technical details in distrib_optimizer.py and optimizer_config.py as requested. I've also ensured that all docstrings follow the Google Style Guide. This PR is ready for final review. Thank you!

@Akshat8510
Copy link
Author

Akshat8510 commented Mar 3, 2026

And I like the new PR review change mention in 3659 with this, PR review become more smoother

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-request complexity: medium docs-only documentation only (docs or docstrings) Final Review PR is in the "final review" stage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants