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

[checkpoint] Log timings for checkpoint IO save and load #11972

Merged
merged 15 commits into from
Feb 27, 2025

Conversation

ananthsub
Copy link
Collaborator

@ananthsub ananthsub commented Jan 28, 2025

What does this PR do ?

Adds timings around checkpoint save/load IO calls within Nemo1 and Nemo2 Lightning strategies.

To test, sanity checked logs from existing checkpointing tests:

pytest -v --log-cli-level=INFO --capture=no -s tests/core/test_dist_ckpt.py::TestAsyncSave::test_async_save_produces_same_checkpoints_as_sync

Collection: nlp, llm

Changelog

Adds timings around checkpoint save/load IO calls within Nemo1 and Nemo2 Lightning strategies

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)

Copy link
Contributor

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.


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

************* Module nemo.collections.nlp.parts.nlp_overrides
nemo/collections/nlp/parts/nlp_overrides.py:214:0: C0301: Line too long (140/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:219:0: C0301: Line too long (149/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:235:0: C0301: Line too long (123/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:415:0: C0301: Line too long (162/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:433:0: C0301: Line too long (166/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:436:0: C0301: Line too long (136/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:522:0: C0301: Line too long (152/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:584:0: C0301: Line too long (166/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:602:0: C0301: Line too long (162/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:754:0: C0301: Line too long (140/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:759:0: C0301: Line too long (149/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:981:0: C0301: Line too long (166/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:988:0: C0301: Line too long (162/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:1010:0: C0301: Line too long (162/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:1041:0: C0301: Line too long (128/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:1045:0: C0301: Line too long (141/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:1049:0: C0301: Line too long (149/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:1106:0: C0301: Line too long (135/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:1233:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:1815:0: C0301: Line too long (152/119) (line-too-long)
nemo/collections/nlp/parts/nlp_overrides.py:250:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:383:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:437:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:626:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:642:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:661:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:902:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:1037:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:1726:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:1814:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/parts/nlp_overrides.py:18:0: W0611: Unused import re (unused-import)
nemo/collections/nlp/parts/nlp_overrides.py:107:4: W0611: Unused tensorstore imported from megatron.core.dist_checkpointing.strategies (unused-import)
************* Module nemo.lightning.pytorch.strategies.fsdp_strategy
nemo/lightning/pytorch/strategies/fsdp_strategy.py:234:0: C0301: Line too long (165/119) (line-too-long)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:271:0: C0301: Line too long (165/119) (line-too-long)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:88:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:94:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:119:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:145:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:154:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:164:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:172:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:180:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/lightning/pytorch/strategies/fsdp_strategy.py:201:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.lightning.pytorch.strategies.megatron_strategy
nemo/lightning/pytorch/strategies/megatron_strategy.py:760:0: C0301: Line too long (158/119) (line-too-long)
nemo/lightning/pytorch/strategies/megatron_strategy.py:804:0: C0301: Line too long (158/119) (line-too-long)
nemo/lightning/pytorch/strategies/megatron_strategy.py:300:4: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.67/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!

@ashors1
Copy link
Collaborator

ashors1 commented Jan 29, 2025

Overall, changes LGTM. Just one question -- what is the intended behavior when async checkpointing is enabled? Do you think these logs will be misleading in that case?

@ananthsub ananthsub enabled auto-merge (squash) January 29, 2025 16:51
@ananthsub
Copy link
Collaborator Author

what is the intended behavior when async checkpointing is enabled? Do you think these logs will be misleading in that case?

In this case we'd report the time spent blocked while staging the checkpoint. In follow ups I'd like to make the logging more granular so that we can report time spent on staging vs finalization for the async case

@ashors1
Copy link
Collaborator

ashors1 commented Jan 30, 2025

Sorry, one other comment. Do you think we should consider making this logging optional? Or provide the option to log only a single rank? If we're running a job on many GPUs, I wonder if this would clutter the logs.

@maanug-nv
Copy link
Collaborator

maanug-nv commented Jan 30, 2025

What are your thoughts on using a decorator for this? I think one actually already exists here (used on dist ckpt save_checkpoint() here). If we need to start logging runtime of more functions in general, I think using a decorator prevents disrupting readability.

@maanug-nv
Copy link
Collaborator

maanug-nv commented Jan 30, 2025

Sorry, one other comment. Do you think we should consider making this logging optional? Or provide the option to log only a single rank? If we're running a job on many GPUs, I wonder if this would clutter the logs.

Or use logging.debug level?

@apaithankar
Copy link

apaithankar commented Feb 6, 2025

Could you also include the iteration number? Filename is optional.

Here is the doc for requirements from Heimdall: https://docs.google.com/document/d/1J5TVmg4msY1HA0kcR6etb4Ha72gBRC2aPen1Z0rinQI/edit?usp=sharing

As for cluttering logs across many ranks, I agree. Currently MegatronLM only prints the (min, max) across all ranks for each checkpoint. E.g.:

7:     load-checkpoint ................................: (1.45, 1.48)
...
0: saving checkpoint at iteration      40 to /workspace/23_11_torch_ckpt/training/15B/1362932 in torch_dist format
7:     save-checkpoint ................................: (23492.92, 23493.03)
0:   successfully saved checkpoint from iteration      40 to /workspace/23_11_torch_ckpt/training/15B/1362932

Time above is in milliseconds, (min, max) across ranks. Ideally, all logs should have timestamps.

@ananthsub ananthsub force-pushed the ckpt-log-times branch 2 times, most recently from 9c20142 to fff6310 Compare February 12, 2025 00:10
ananthsub and others added 5 commits February 26, 2025 12:56
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: ananthsub <ananthsub@users.noreply.github.com>
ananthsub and others added 9 commits February 26, 2025 12:56
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: ananthsub <ananthsub@users.noreply.github.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: ananthsub <ananthsub@users.noreply.github.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: ananthsub <ananthsub@users.noreply.github.com>
Copy link
Collaborator

@maanug-nv maanug-nv left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@ananthsub ananthsub merged commit b94bff7 into NVIDIA:main Feb 27, 2025
194 checks passed
@ananthsub ananthsub deleted the ckpt-log-times branch February 27, 2025 15:25
ko3n1g pushed a commit that referenced this pull request Mar 6, 2025
* [checkpoint] Log timings for checkpoint IO save and load

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>

* add rank to logline for megatron strategy

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>

---------

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
chtruong814 pushed a commit that referenced this pull request Mar 7, 2025
…2520)

* [checkpoint] Log timings for checkpoint IO save and load



* add rank to logline for megatron strategy



---------

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Co-authored-by: Ananth Subramaniam <ansubramania@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants