Skip to content

enables default data step in megatron parallel to operate on a wider variety of tensors#9641

Merged
marcromeyn merged 6 commits intoNVIDIA-NeMo:mainfrom
jomitchellnv:jm/default-data-step
Jul 10, 2024
Merged

enables default data step in megatron parallel to operate on a wider variety of tensors#9641
marcromeyn merged 6 commits intoNVIDIA-NeMo:mainfrom
jomitchellnv:jm/default-data-step

Conversation

@jomitchellnv
Copy link
Collaborator

…variety of tensors coming out of the dataloader

Add more flexibility to the default data step inside megatron parallel.

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

Collection: [Note which collection this PR will affect]

Changelog

  • Megatron parallel's default data step can operate on wrapped tuples and unwrapped items coming directly out of the dataloader

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)

…variety of tensors coming out of the dataloader
@jomitchellnv jomitchellnv force-pushed the jm/default-data-step branch from 3f53682 to 70cd4c4 Compare July 8, 2024 18:57
Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
case _:
batch = None

if batch is not None:

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable

Local variable 'batch' may be used before it is initialized.
# Canonical case.
case batch:
pass
# If the dataloader_iter is empty, return None.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is not what happens anymore. Now in your else you say raise ValueError(...):. Are we sure we don't want to pass through a None on the iter? Otherwise we should prob change line 79 or 84 to return None and drop the ValueError piece.

Copy link
Collaborator

@jstjohn jstjohn Jul 8, 2024

Choose a reason for hiding this comment

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

Actually what I hope would happen is that the match(dataloader_iter) would trigger an StopIteration or whatever it is exception rather than returning None. The StopIteration exception ideally would raise through this function (what happens now on the match) and be handled elsewhere. So I think your case _ should never get hit...

Copy link
Collaborator

@jstjohn jstjohn Jul 8, 2024

Choose a reason for hiding this comment

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

Maybe a better error message on line 84 would be "None batch returned at the end of iteration rather than a StopIteration exception being raised, why?"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I only added this to be past the linter. I updated the comment so that its more accurate. My only concern would be how it plays out with drop_last=True since maybe that would dump some None's?

@ericharper ericharper requested a review from marcromeyn July 8, 2024 20:36
marcromeyn
marcromeyn previously approved these changes Jul 9, 2024
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
@jomitchellnv jomitchellnv force-pushed the jm/default-data-step branch from 14c5733 to 5971ff5 Compare July 9, 2024 22:57
@marcromeyn marcromeyn self-requested a review July 10, 2024 08:19
@marcromeyn marcromeyn merged commit f5d5221 into NVIDIA-NeMo:main Jul 10, 2024
marcromeyn added a commit that referenced this pull request Jul 11, 2024
…variety of tensors (#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
marcromeyn added a commit that referenced this pull request Jul 11, 2024
…variety of tensors (#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
maanug-nv pushed a commit that referenced this pull request Jul 14, 2024
…variety of tensors (#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
ertkonuk pushed a commit that referenced this pull request Jul 19, 2024
…variety of tensors (#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: Tugrul Konuk <ertkonuk@gmail.com>
tonyjie pushed a commit to tonyjie/NeMo that referenced this pull request Aug 6, 2024
…variety of tensors (NVIDIA-NeMo#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: tonyjie <jl4257@cornell.edu>
monica-sekoyan pushed a commit that referenced this pull request Oct 14, 2024
…variety of tensors (#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
hainan-xv pushed a commit to hainan-xv/NeMo that referenced this pull request Nov 5, 2024
…variety of tensors (NVIDIA-NeMo#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: Hainan Xu <hainanx@nvidia.com>
XuesongYang pushed a commit to paarthneekhara/NeMo that referenced this pull request Jan 18, 2025
…variety of tensors (NVIDIA-NeMo#9641)

* enables default data step in megatron parallel to operate on a wider variety of tensors coming out of the dataloader

* handles the case where a batch is empty

* Apply isort and black reformatting

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>

* Allows the default data step to operate on more types
than just dictionaries

Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>

---------

Signed-off-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Signed-off-by: Jonathan Mitchell <jomitchell@nvidia.com>
Co-authored-by: jomitchellnv <jomitchellnv@users.noreply.github.com>
Co-authored-by: Marc Romeyn <mromeijn@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants