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

Extend sequence length padding for GPT SFT to account for context parallel #8869

Merged
merged 3 commits into from
May 6, 2024

Conversation

vysarge
Copy link
Contributor

@vysarge vysarge commented Apr 10, 2024

What does this PR do ?

Adds a check for MegatronGPTSFTModel to ensure sequence dimension will be padded to a multiple of 16 after being split over context parallel ranks, which TE requires during fp8 training; this fixes issues like AssertionError: FP8 execution requires 2D input matrices with height divisible by 8 and width divisible by 16, but got tensor with dims=[5504, 184] when using context parallel with datasets that have a variable sequence length.

Collection: nlp

Changelog

  • Alters pad_seq_length_to_mult input to GPT SFT datasets to account for context parallel

Usage

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

Jenkins CI

To run Jenkins, a NeMo User with write access must comment jenkins on the PR.

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)

@ericharper
Copy link
Collaborator

jenkins

@xrennvidia
Copy link
Collaborator

Hi @vysarge , I do not totally understand what the first input dim and the second dim mean, could you please describe it? And how does it work if sequence_parallel=True and context_parallel_size > 1? Thanks.

@vysarge
Copy link
Contributor Author

vysarge commented Apr 16, 2024

Hi @vysarge , I do not totally understand what the first input dim and the second dim mean, could you please describe it? And how does it work if sequence_parallel=True and context_parallel_size > 1? Thanks.

Hm, I thought sequence parallel and context parallel were mutually exclusive. If they're used together, do CP and TP counts split on the same dimension? Making the change you suggested should fix this case too if so, let me test it.

@xrennvidia
Copy link
Collaborator

Hi @vysarge , I do not totally understand what the first input dim and the second dim mean, could you please describe it? And how does it work if sequence_parallel=True and context_parallel_size > 1? Thanks.

Hm, I thought sequence parallel and context parallel were mutually exclusive. If they're used together, do CP and TP counts split on the same dimension? Making the change you suggested should fix this case too if so, let me test it.

Sequence parallel and context parallel can work together. Sequence parallel only split sequence of LayerNorm. In addition, context parallel split sequence of the whole transformer layer. Yeah, you can test my suggested fix, I think it should work for all cases. Thanks.

…quirements when using fp8

Signed-off-by: Valerie Sarge <[email protected]>
Signed-off-by: Valerie Sarge <[email protected]>
@vysarge
Copy link
Contributor Author

vysarge commented Apr 18, 2024

Hi @vysarge , I do not totally understand what the first input dim and the second dim mean, could you please describe it? And how does it work if sequence_parallel=True and context_parallel_size > 1? Thanks.

Hm, I thought sequence parallel and context parallel were mutually exclusive. If they're used together, do CP and TP counts split on the same dimension? Making the change you suggested should fix this case too if so, let me test it.

Sequence parallel and context parallel can work together. Sequence parallel only split sequence of LayerNorm. In addition, context parallel split sequence of the whole transformer layer. Yeah, you can test my suggested fix, I think it should work for all cases. Thanks.

Tested and this fix is working well; PR has been updated, thanks.

@xrennvidia
Copy link
Collaborator

LGTM, thanks.

@xrennvidia
Copy link
Collaborator

jenkins

Copy link
Contributor

github-actions bot commented May 5, 2024

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions bot added the stale label May 5, 2024
@xrennvidia xrennvidia removed the stale label May 5, 2024
@ericharper ericharper merged commit 48a2a6b into NVIDIA:main May 6, 2024
125 checks passed
@vysarge vysarge deleted the vsarge/cp_size_padding branch May 6, 2024 19:42
rohitrango pushed a commit to rohitrango/NeMo that referenced this pull request Jun 25, 2024
…allel (NVIDIA#8869)

* Pad outputs from G GPTSFTDataset / GPTSFTPackedDataset to match TE requirements when using fp8

Signed-off-by: Valerie Sarge <[email protected]>

* Account for SP + CP case

Signed-off-by: Valerie Sarge <[email protected]>

---------

Signed-off-by: Valerie Sarge <[email protected]>
Co-authored-by: Pablo Garay <[email protected]>
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.

None yet

4 participants