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

Refactored forward step #12370

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

Conversation

maanug-nv
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 ?

Enable the forward step to take global state, so that GlobalState need not be a singleton.

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)

@maanug-nv maanug-nv marked this pull request as draft February 25, 2025 20:17
@maanug-nv maanug-nv changed the base branch from main to mlm-pretrain-loop February 25, 2025 20:17
@maanug-nv maanug-nv changed the base branch from mlm-pretrain-loop to maanug/custom-pretrain-api February 25, 2025 20:17
nemo/tron/api.py Outdated
@@ -42,6 +44,11 @@
test_data_iterator = setup_output.test_data_iterator
ckpt_context = setup_output.checkpointing_context

if "state" in inspect.getfullargspec(forward_step_func).args:
mcore_forward_step = partial(forward_step_func, state=state)

Check warning

Code scanning / CodeQL

Variable defined multiple times

This assignment to 'mcore_forward_step' is unnecessary as it is [redefined](1) before this value is used.
nemo/tron/api.py Outdated
if "state" in inspect.getfullargspec(forward_step_func).args:
mcore_forward_step = partial(forward_step_func, state=state)
if "cfg" in inspect.getfullargspec(forward_step_func).args:
mcore_forward_step = partial(forward_step_func, cfg=full_config)

Check notice

Code scanning / CodeQL

Unused local variable

Variable mcore_forward_step is not used.

Copilot Autofix AI 5 days ago

To fix the problem, we should remove the assignment to the variable mcore_forward_step on line 50. This will eliminate the unused variable and clean up the code. Since the variable is not used anywhere else in the function, this change will not affect the existing functionality.

Suggested changeset 1
nemo/tron/api.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/nemo/tron/api.py b/nemo/tron/api.py
--- a/nemo/tron/api.py
+++ b/nemo/tron/api.py
@@ -49,3 +49,3 @@
     if "cfg" in inspect.getfullargspec(forward_step_func).args:
-        mcore_forward_step = partial(forward_step_func, cfg=full_config)
+        partial(forward_step_func, cfg=full_config)
 
EOF
@@ -49,3 +49,3 @@
if "cfg" in inspect.getfullargspec(forward_step_func).args:
mcore_forward_step = partial(forward_step_func, cfg=full_config)
partial(forward_step_func, cfg=full_config)

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
# See the License for the specific language governing permissions and
# limitations under the License.

import contextlib

Check notice

Code scanning / CodeQL

Unused import

Import of 'contextlib' is not used.

Copilot Autofix AI 5 days ago

To fix the problem, we need to remove the unused import statement for contextlib. This will clean up the code and remove the unnecessary dependency, making the code easier to read and maintain.

  • Locate the import statement for contextlib in the file nemo/tron/llm/gpt.py.
  • Remove the line that imports contextlib.
Suggested changeset 1
nemo/tron/llm/gpt.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/nemo/tron/llm/gpt.py b/nemo/tron/llm/gpt.py
--- a/nemo/tron/llm/gpt.py
+++ b/nemo/tron/llm/gpt.py
@@ -14,3 +14,2 @@
 
-import contextlib
 from functools import partial
EOF
@@ -14,3 +14,2 @@

import contextlib
from functools import partial
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Base automatically changed from maanug/custom-pretrain-api to mlm-pretrain-loop February 26, 2025 23:50
@maanug-nv maanug-nv force-pushed the maanug/modified-forward-step branch from 33fa8b7 to a291837 Compare February 27, 2025 00:10
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
@maanug-nv maanug-nv force-pushed the maanug/modified-forward-step branch from a291837 to 27f3f40 Compare February 27, 2025 00:24
Signed-off-by: Maanu Grover <[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 common
nemo/tron/llm/common.py:21:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module gpt
nemo/tron/llm/gpt.py:15:0: W0611: Unused import contextlib (unused-import)
************* Module nemo.tron.api
nemo/tron/api.py:28: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:266:0: C0301: Line too long (179/119) (line-too-long)
nemo/tron/config.py:275:0: C0301: Line too long (158/119) (line-too-long)
nemo/tron/config.py:281:0: C0301: Line too long (376/119) (line-too-long)
nemo/tron/config.py:284:0: C0301: Line too long (158/119) (line-too-long)
nemo/tron/config.py:287:0: C0301: Line too long (123/119) (line-too-long)
nemo/tron/config.py:320:0: C0301: Line too long (124/119) (line-too-long)
nemo/tron/config.py:323:0: C0301: Line too long (121/119) (line-too-long)
nemo/tron/config.py:350:0: C0301: Line too long (225/119) (line-too-long)
nemo/tron/config.py:353:0: C0301: Line too long (142/119) (line-too-long)
nemo/tron/config.py:365:0: C0301: Line too long (143/119) (line-too-long)
nemo/tron/config.py:371:0: C0301: Line too long (160/119) (line-too-long)
nemo/tron/config.py:377:0: C0301: Line too long (195/119) (line-too-long)
nemo/tron/config.py:380:0: C0301: Line too long (176/119) (line-too-long)
nemo/tron/config.py:386:0: C0301: Line too long (200/119) (line-too-long)
nemo/tron/config.py:392:0: C0301: Line too long (316/119) (line-too-long)
nemo/tron/config.py:395:0: C0301: Line too long (234/119) (line-too-long)
nemo/tron/config.py:398:0: C0301: Line too long (147/119) (line-too-long)
nemo/tron/config.py:414:0: C0301: Line too long (438/119) (line-too-long)
nemo/tron/config.py:420:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/config.py:429:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/config.py:626:0: C0301: Line too long (265/119) (line-too-long)
nemo/tron/config.py:651:0: C0301: Line too long (148/119) (line-too-long)
nemo/tron/config.py:654:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/config.py:665:0: C0301: Line too long (122/119) (line-too-long)
nemo/tron/config.py:670:0: C0301: Line too long (240/119) (line-too-long)
nemo/tron/config.py:702:0: C0301: Line too long (306/119) (line-too-long)
nemo/tron/config.py:711:0: C0301: Line too long (334/119) (line-too-long)
nemo/tron/config.py:739:0: C0301: Line too long (157/119) (line-too-long)
nemo/tron/config.py:742:0: C0301: Line too long (483/119) (line-too-long)
nemo/tron/config.py:745:0: C0301: Line too long (170/119) (line-too-long)
nemo/tron/config.py:754:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/config.py:821:0: C0301: Line too long (250/119) (line-too-long)
nemo/tron/config.py:824:0: C0301: Line too long (207/119) (line-too-long)
nemo/tron/config.py:880:0: C0301: Line too long (378/119) (line-too-long)
nemo/tron/config.py:892:0: C0301: Line too long (154/119) (line-too-long)
nemo/tron/config.py:901:0: C0301: Line too long (126/119) (line-too-long)
nemo/tron/config.py:907:0: C0301: Line too long (120/119) (line-too-long)
nemo/tron/config.py:910:0: C0301: Line too long (210/119) (line-too-long)
nemo/tron/config.py:922:0: C0301: Line too long (223/119) (line-too-long)
nemo/tron/config.py:925:0: C0301: Line too long (225/119) (line-too-long)
nemo/tron/config.py:934:0: C0301: Line too long (170/119) (line-too-long)
nemo/tron/config.py:946:0: C0301: Line too long (224/119) (line-too-long)
nemo/tron/config.py:952:0: C0301: Line too long (268/119) (line-too-long)
nemo/tron/config.py:964:0: C0301: Line too long (128/119) (line-too-long)
nemo/tron/config.py:1031: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:726:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:788:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:852:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:959:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:980:0: C0115: Missing class docstring (missing-class-docstring)
nemo/tron/config.py:999:0: C0115: Missing class docstring (missing-class-docstring)

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