Contributing to Megatron-LM
This document outlines the processes and policies for issues and pull requests by non-NVIDIA contributors to the Megatron-LM GitHub repository.
Everyone is welcome to contribute. The project recently migrated from an internal repository to doing all development directly on GitHub.
When contributing, it is important to ensure that changes are in line with the project direction. Small bug fixes are always welcome. If proposing large architectural changes or changes for stylistic reasons, open an issue first for discussion.
Issue Policy
File any bugs you find, keeping the following in mind:
- If filing a bug, that is, you have found something that does not work as expected, use the
BUGtemplate. - If you’ve found a regression in speed or accuracy, use the
REGRESSIONtemplate. - If you are requesting a new feature or modification of an existing feature, use the
ENHANCEMENTtemplate. - If opening an issue to ask a question, you do not need a template, but make your question as clear and concise as possible.
- One issue per bug. Putting multiple things in the same issue makes both discussion and completion unnecessarily complicated.
- Reproducible bugs get the fastest attention from the development team.
- Use proper spelling, grammar, and punctuation.
- Write in an authoritative and technical tone.
Code Submission Policy
Do
- Follow the repository style guide. The guide is newly introduced; older code may not conform and can remain as-is if unmodified.
- Run the configured formatting and lint checks using tools/autoformat.sh.
- Use the docstring style and format the documentation generator is configured for: Google style with MyST format.
- Split your changes into separate, atomic commits, that is, a commit per feature or fix.
- Make sure your commits are rebased on the
mainbranch. - Write the commit message subject line in the imperative mood (“Change the default argument for X”, not “Changed the default argument for X”).
- Write your commit messages in proper English, with care and punctuation.
- Check the spelling of your code, comments, and commit messages.
- Put new operation implementations and kernel backends under
megatron/core/ops, following the operations guide (how to add an operation, how to add a backend kernel to an existing one).
Don’t
- Submit code that’s incompatible with the project license.
- Touch anything outside the stated scope of the PR. This includes formatting changes to code not relevant to the PR.
- Iterate excessively on your design across multiple commits.
- Include commented-out code.
- Attempt large architectural changes without first opening an issue to discuss.
Process groups in megatron/core
megatron.core.parallel_state is being deprecated. It holds the process groups for a single,
global parallel grid; Megatron-Core is moving to explicit passing via ProcessGroupCollection.
- New features must not call
parallel_state.get_*_group(),get_*_rank(), orget_*_world_size()inmegatron/core. Accept aProcessGroupCollectionor an explicittorch.distributed.ProcessGroupfrom the caller and pass it through. - Do not introduce global-state fallbacks for new features. A
Nonedefault that readsparallel_statecan select a different model’s grid or fail if the globals are uninitialized. ProcessGroupCollection.use_mpu_process_groups()is not a migration target. It reads the same global state. Bootstrap code and explicitly commented compatibility fallbacks may use it while existing callers migrate.- Bug fixes may leave existing calls alone. Process-group plumbing changes belong in their own PR.
Full guidance, including the tier breakdown and reviewer notes: parallel-state-deprecation.md.
Signing Your Work
-
We require that all contributors “sign-off” on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
- Any contribution which contains commits that are not Signed-Off will not be accepted.
-
To sign off on a commit you simply use the
--signoff(or-s) option when committing your changes:This will append the following to your commit message:
-
Full text of the DCO:
Issue and Pull Request Q&A
Response Time for Issues and PRs
You should receive a response within two business days.
Getting Help
Use @NVIDIA/mcore-oncall.
Escalating Unresponsive Issues or PRs
After two business days, tag @NVIDIA/mcore-oncall.
Stale Issue and PR Policy
A bot marks untouched PRs as “stale” after 60 days.
A long backlog of issues and PRs dates back years, and triage works backwards through it. Older issues that may still be relevant receive a request to re-test with the latest code. Without a response, the issue may be closed. To request reopening, respond with a comment.
Thank you.