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

LLM Forward Step #12673

Merged
merged 18 commits into from
Mar 20, 2025
Merged

LLM Forward Step #12673

merged 18 commits into from
Mar 20, 2025

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 ?

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: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
maanug-nv and others added 6 commits March 18, 2025 15:52
Signed-off-by: Maanu Grover <[email protected]>
Co-authored-by: Ananth Subramaniam <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
@maanug-nv maanug-nv marked this pull request as ready for review March 19, 2025 00:46
from nemo.tron.state import GlobalState


def get_batch(data_iterator, cfg: ConfigContainer):
Copy link
Collaborator

Choose a reason for hiding this comment

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

would be good to add typehint + docs for the return value

return batch.values()


def forward_step(state: GlobalState, data_iterator: Iterable, model: GPTModel):
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, the return type will be helpful

@@ -509,3 +512,12 @@ def reduce_aux_losses_tracker_across_ranks():
torch.distributed.all_reduce(values, group=tracker[name].get("reduce_group"))
if tracker[name].get("avg_group") is not None:
torch.distributed.all_reduce(values, group=tracker[name]["avg_group"], op=torch.distributed.ReduceOp.AVG)


def maybe_inject_state(forward_step_func: Callable, state: GlobalState) -> Callable:
Copy link
Collaborator

Choose a reason for hiding this comment

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

in some types.py file please define the typehint for forward_step_func since this will serve as additional docs

Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
@maanug-nv maanug-nv merged commit d1d1f7c into mlm-pretrain-loop Mar 20, 2025
11 checks passed
@maanug-nv maanug-nv deleted the maanug/loss-and-fwd branch March 20, 2025 21:10
hemildesai pushed a commit that referenced this pull request Mar 20, 2025
* pretrain loss func

Signed-off-by: Maanu Grover <[email protected]>

* get batch and forward

Signed-off-by: Maanu Grover <[email protected]>

* add rerun functionality to loss

Signed-off-by: Maanu Grover <[email protected]>

* formatting

Signed-off-by: Maanu Grover <[email protected]>

* injection of state

Signed-off-by: Maanu Grover <[email protected]>

* remove globalstate singleton functionality

Signed-off-by: Maanu Grover <[email protected]>

* update example

Signed-off-by: Maanu Grover <[email protected]>

* missing copyright

Signed-off-by: Maanu Grover <[email protected]>

* fix for latest mcore

Signed-off-by: Maanu Grover <[email protected]>

* syntax

Co-authored-by: Ananth Subramaniam <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>

* move assertion

Signed-off-by: Maanu Grover <[email protected]>

* refactor for eval

Signed-off-by: Maanu Grover <[email protected]>

* move to avoid circular import

Signed-off-by: Maanu Grover <[email protected]>

* fix

Signed-off-by: Maanu Grover <[email protected]>

* unused

Signed-off-by: Maanu Grover <[email protected]>

* cache num fw args in train and eval

Signed-off-by: Maanu Grover <[email protected]>

* docstring fix

Signed-off-by: Maanu Grover <[email protected]>

* remove duplicate

Signed-off-by: Maanu Grover <[email protected]>

---------

Signed-off-by: Maanu Grover <[email protected]>
Signed-off-by: Maanu Grover <[email protected]>
Co-authored-by: Ananth Subramaniam <[email protected]>
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.

4 participants