Skip to content

Add world_size dict getter method for simple integration with W&B #1735

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WoosungMyung
Copy link

Thanks for this amazing distributed learning tool for users!
I have something to propose for integration with W&B.

What

This PR adds two getter methods to megatron.core.parallel_state.py:

  • get_all_world_sizes(): returns a string of world sizes for TP, DP, CP, PP, and EP.
  • get_world_sizes_dict(): returns the same information as a dictionary, e.g. {"tp": 4, "dp": 8, "cp": 1, "pp": 2, "ep": 1}.

Why

When integrating Megatron-LM with logging tools such as Weights & Biases, it is often useful to record the parallelism configuration (world sizes for each parallel group) alongside the training metrics.
Currently, there is a convenient get_all_ranks() method for ranks, but no equivalent for world sizes.

Benefits

  • Simplifies logging of parallelism configuration for distributed training.

Thanks for your time for reviewing this PR.
Thanks.

@WoosungMyung WoosungMyung changed the title Add world-size dict getter method for simple use of Wandb [Enhancement] Add world-size dict getter method for simple use of Wandb Aug 9, 2025
@WoosungMyung WoosungMyung changed the title [Enhancement] Add world-size dict getter method for simple use of Wandb Add world_size dict getter method for simple integration with W&B Aug 9, 2025
@sbhavani sbhavani added the enhancement New feature or request label Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants