Skip to content
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

Add checkpointing support to custom pretraining loop #12291

Draft
wants to merge 7 commits into
base: mlm-pretrain-loop
Choose a base branch
from

Conversation

hemildesai
Copy link
Collaborator

Important

The Update branch button must only be pressed in very rare occassions.
An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Collection: [Note which collection this PR will affect]

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

Signed-off-by: Hemil Desai <[email protected]>
Signed-off-by: Hemil Desai <[email protected]>
@hemildesai hemildesai requested a review from maanug-nv February 20, 2025 18:10
hemildesai and others added 4 commits February 20, 2025 18:11
Signed-off-by: Hemil Desai <[email protected]>
Signed-off-by: Hemil Desai <[email protected]>
Signed-off-by: Hemil Desai <[email protected]>
Copy link
Contributor

beep boop 🤖: 🚨 The following files must be fixed before merge!


Your code was analyzed with PyLint. The following annotations have been identified:

************* Module nemo.tron.checkpointing
nemo/tron/checkpointing.py:420:0: C0301: Line too long (124/119) (line-too-long)
nemo/tron/checkpointing.py:649:0: C0301: Line too long (162/119) (line-too-long)
nemo/tron/checkpointing.py:650:0: C0301: Line too long (168/119) (line-too-long)
nemo/tron/checkpointing.py:910:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/checkpointing.py:948:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/checkpointing.py:968:0: C0301: Line too long (124/119) (line-too-long)
nemo/tron/checkpointing.py:1098:0: C0301: Line too long (128/119) (line-too-long)
nemo/tron/checkpointing.py:1176:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/checkpointing.py:1181:0: C0301: Line too long (125/119) (line-too-long)
nemo/tron/checkpointing.py:1190:0: C0301: Line too long (140/119) (line-too-long)
nemo/tron/checkpointing.py:1304:0: C0301: Line too long (130/119) (line-too-long)
nemo/tron/checkpointing.py:85:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/checkpointing.py:92:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/checkpointing.py:190:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/checkpointing.py:280:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/checkpointing.py:377:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/checkpointing.py:694:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/checkpointing.py:765:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.utils.async_utils
nemo/tron/utils/async_utils.py:34:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.utils.flop_utils
nemo/tron/utils/flop_utils.py:6:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.utils.wandb_utils
nemo/tron/utils/wandb_utils.py:30:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/wandb_utils.py:46:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.config
nemo/tron/config.py:152:0: C0301: Line too long (153/119) (line-too-long)
nemo/tron/config.py:158:0: C0301: Line too long (262/119) (line-too-long)
nemo/tron/config.py:161:0: C0301: Line too long (455/119) (line-too-long)
nemo/tron/config.py:164:0: C0301: Line too long (364/119) (line-too-long)
nemo/tron/config.py:170:0: C0301: Line too long (278/119) (line-too-long)
nemo/tron/config.py:215:0: C0301: Line too long (133/119) (line-too-long)
nemo/tron/config.py:218:0: C0301: Line too long (131/119) (line-too-long)
nemo/tron/config.py:230:0: C0301: Line too long (135/119) (line-too-long)
nemo/tron/config.py:233:0: C0301: Line too long (132/119) (line-too-long)
nemo/tron/config.py:263:0: C0301: Line too long (179/119) (line-too-long)
nemo/tron/config.py:272:0: C0301: Line too long (158/119) (line-too-long)
nemo/tron/config.py:278:0: C0301: Line too long (376/119) (line-too-long)
nemo/tron/config.py:281:0: C0301: Line too long (158/119) (line-too-long)
nemo/tron/config.py:284:0: C0301: Line too long (123/119) (line-too-long)
nemo/tron/config.py:317:0: C0301: Line too long (124/119) (line-too-long)
nemo/tron/config.py:320:0: C0301: Line too long (121/119) (line-too-long)
nemo/tron/config.py:347:0: C0301: Line too long (225/119) (line-too-long)
nemo/tron/config.py:350:0: C0301: Line too long (142/119) (line-too-long)
nemo/tron/config.py:362:0: C0301: Line too long (143/119) (line-too-long)
nemo/tron/config.py:368:0: C0301: Line too long (160/119) (line-too-long)
nemo/tron/config.py:374:0: C0301: Line too long (195/119) (line-too-long)
nemo/tron/config.py:377:0: C0301: Line too long (176/119) (line-too-long)
nemo/tron/config.py:383:0: C0301: Line too long (200/119) (line-too-long)
nemo/tron/config.py:389:0: C0301: Line too long (316/119) (line-too-long)
nemo/tron/config.py:392:0: C0301: Line too long (234/119) (line-too-long)
nemo/tron/config.py:395:0: C0301: Line too long (147/119) (line-too-long)
nemo/tron/config.py:411:0: C0301: Line too long (438/119) (line-too-long)
nemo/tron/config.py:417:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/config.py:426:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/config.py:623:0: C0301: Line too long (265/119) (line-too-long)
nemo/tron/config.py:662:0: C0301: Line too long (148/119) (line-too-long)
nemo/tron/config.py:665:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/config.py:676:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/config.py:681:0: C0301: Line too long (240/119) (line-too-long)
nemo/tron/config.py:713:0: C0301: Line too long (306/119) (line-too-long)
nemo/tron/config.py:722:0: C0301: Line too long (334/119) (line-too-long)
nemo/tron/config.py:749:0: C0301: Line too long (157/119) (line-too-long)
nemo/tron/config.py:752:0: C0301: Line too long (483/119) (line-too-long)
nemo/tron/config.py:755:0: C0301: Line too long (170/119) (line-too-long)
nemo/tron/config.py:764:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/config.py:831:0: C0301: Line too long (250/119) (line-too-long)
nemo/tron/config.py:834:0: C0301: Line too long (207/119) (line-too-long)
nemo/tron/config.py:890:0: C0301: Line too long (378/119) (line-too-long)
nemo/tron/config.py:902:0: C0301: Line too long (154/119) (line-too-long)
nemo/tron/config.py:911:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/config.py:917:0: C0301: Line too long (120/119) (line-too-long)
nemo/tron/config.py:920:0: C0301: Line too long (210/119) (line-too-long)
nemo/tron/config.py:932:0: C0301: Line too long (223/119) (line-too-long)
nemo/tron/config.py:935:0: C0301: Line too long (225/119) (line-too-long)
nemo/tron/config.py:944:0: C0301: Line too long (170/119) (line-too-long)
nemo/tron/config.py:956:0: C0301: Line too long (224/119) (line-too-long)
nemo/tron/config.py:991:0: C0301: Line too long (124/119) (line-too-long)
nemo/tron/config.py:30:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:43:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:57:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:736:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:798:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:862:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:961:0: C0115: Missing class docstring (missing-class-docstring)
************* Module nemo.tron.data.dataset
nemo/tron/data/dataset.py:84:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/data/dataset.py:115:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.eval
nemo/tron/eval.py:23:0: W0611: Unused get_model_config imported from megatron.core.utils (unused-import)
************* Module nemo.tron.model
nemo/tron/model.py:34:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.setup
nemo/tron/setup.py:41:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/setup.py:51:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/setup.py:34:4: W0611: Unused TorchFullyShardedDataParallel imported from megatron.core.distributed (unused-import)
************* Module nemo.tron.state
nemo/tron/state.py:53:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/state.py:64:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/state.py:79:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/state.py:92:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/state.py:115:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/state.py:123:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/state.py:129:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/state.py:144:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/state.py:168:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/state.py:175:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.tokenizers.tokenizer
nemo/tron/tokenizers/tokenizer.py:129:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/tokenizers/tokenizer.py:635:0: C0301: Line too long (273/119) (line-too-long)
nemo/tron/tokenizers/tokenizer.py:137:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:151:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:154:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:157:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:160:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:173:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:205:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:212:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:218:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:222:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:226:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:229:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:233:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:241:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:256:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:260:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:264:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:268:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:321:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:325:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:329:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:332:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:335:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:339:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:417:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:421:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:425:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:429:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:433:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:438:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:464:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:477:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:481:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:485:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:489:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:493:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:497:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:501:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:505:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:509:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:638:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/tokenizers/tokenizer.py:702:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:706:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:710:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:714:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:718:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:722:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:725:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:734:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:737:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:741:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:745:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:749:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:759:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:762:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:766:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:774:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:778:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:782:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:786:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:790:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:794:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:798:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/tokenizers/tokenizer.py:802:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.train
nemo/tron/train.py:224:0: C0301: Line too long (121/119) (line-too-long)
nemo/tron/train.py:71:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/train.py:535:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/train.py:541:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/train.py:589:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/train.py:621:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.utils.common_utils
nemo/tron/utils/common_utils.py:32:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/common_utils.py:47:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/common_utils.py:51:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/common_utils.py:60:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/common_utils.py:69:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/common_utils.py:80:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/common_utils.py:152:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.tron.utils.train_utils
nemo/tron/utils/train_utils.py:397:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/utils/train_utils.py:47:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/tron/utils/train_utils.py:184:0: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.40/10

Mitigation guide:

  • Add sensible and useful docstrings to functions and methods
  • For trivial methods like getter/setters, consider adding # pylint: disable=C0116 inside the function itself
  • To disable multiple functions/methods at once, put a # pylint: disable=C0116 before the first and a # pylint: enable=C0116 after the last.

By applying these rules, we reduce the occurance of this message in future.

Thank you for improving NeMo's documentation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant