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

Improve communication overlapping in FP8 distributed optimizer #8221

Merged
merged 14 commits into from
Feb 8, 2024

Conversation

timmoon10
Copy link
Collaborator

What does this PR do ?

When training GPT, the Apex distributed Adam optimizer overlaps its first parameter all-gather with the optimizer step. This optimization has been applied to both FP8 and non-FP8 models.

Collection: NLP

Changelog

  • Wait until all distopt buckets finish optimizer step before updating FP8 scaling factors
  • Support dist opt buckets with multiple dtype configs
  • Put GPT "leftover params" (i.e. embeddings, layer norm params, biases) in same distopt bucket as first layer params

Usage

Run GPT, e.g. with the config at https://github.com/NVIDIA/NeMo/blob/main/examples/nlp/language_modeling/conf/megatron_gpt_config.yaml.

Enable FP8 support with model.fp8=True, FP8 parameters with model.fp8_params=True, the distributed optimizer with model.optim.name=distributed_fused_adam, and overlapped param all-gathers with model.optim.overlap_param_sync=True

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

@timmoon10 timmoon10 added feature request/PR for a new feature NLP labels Jan 23, 2024
@timmoon10 timmoon10 requested a review from ericharper January 23, 2024 01:50
@github-actions github-actions bot added the core Changes to NeMo Core label Jan 23, 2024
@timmoon10
Copy link
Collaborator Author

jenkins

@timmoon10
Copy link
Collaborator Author

jenkins

@timmoon10
Copy link
Collaborator Author

jenkins

@timmoon10 timmoon10 requested a review from erhoo82 February 6, 2024 03:59
@ericharper ericharper requested a review from dimapihtar February 8, 2024 18:01
timmoon10 and others added 2 commits February 8, 2024 10:43
Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>
@github-actions github-actions bot added the CI label Feb 8, 2024
@timmoon10
Copy link
Collaborator Author

jenkins

Copy link
Collaborator

@dimapihtar dimapihtar left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@timmoon10 timmoon10 merged commit c84121a into NVIDIA:main Feb 8, 2024
11 checks passed
biscayan pushed a commit to biscayan/NeMo that referenced this pull request Feb 15, 2024
…A#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <[email protected]>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make sure to update FP8 transpose cache

Signed-off-by: Tim Moon <[email protected]>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>

---------

Signed-off-by: Tim Moon <[email protected]>
Signed-off-by: Tim Moon <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: biscayan <[email protected]>
ssh-meister pushed a commit to ssh-meister/NeMo that referenced this pull request Feb 15, 2024
…A#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <[email protected]>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make sure to update FP8 transpose cache

Signed-off-by: Tim Moon <[email protected]>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>

---------

Signed-off-by: Tim Moon <[email protected]>
Signed-off-by: Tim Moon <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Sasha Meister <[email protected]>
vasunvidia pushed a commit to vasunvidia/NeMo that referenced this pull request Feb 19, 2024
…A#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <[email protected]>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make sure to update FP8 transpose cache

Signed-off-by: Tim Moon <[email protected]>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>

---------

Signed-off-by: Tim Moon <[email protected]>
Signed-off-by: Tim Moon <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
vasunvidia added a commit to vasunvidia/NeMo that referenced this pull request Feb 19, 2024
layalir added a commit to layalir/NeMo that referenced this pull request Feb 28, 2024
layalir added a commit to layalir/NeMo that referenced this pull request Feb 29, 2024
ftxj pushed a commit to ftxj/NeMo that referenced this pull request Feb 29, 2024
…A#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <[email protected]>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make sure to update FP8 transpose cache

Signed-off-by: Tim Moon <[email protected]>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>

---------

Signed-off-by: Tim Moon <[email protected]>
Signed-off-by: Tim Moon <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
minitu pushed a commit to minitu/NeMo that referenced this pull request Mar 7, 2024
…A#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <[email protected]>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make sure to update FP8 transpose cache

Signed-off-by: Tim Moon <[email protected]>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>

---------

Signed-off-by: Tim Moon <[email protected]>
Signed-off-by: Tim Moon <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
pablo-garay pushed a commit that referenced this pull request Mar 19, 2024
* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <[email protected]>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make sure to update FP8 transpose cache

Signed-off-by: Tim Moon <[email protected]>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>

---------

Signed-off-by: Tim Moon <[email protected]>
Signed-off-by: Tim Moon <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Pablo Garay <[email protected]>
rohitrango pushed a commit to rohitrango/NeMo that referenced this pull request Jun 25, 2024
…A#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <[email protected]>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <[email protected]>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make sure to update FP8 transpose cache

Signed-off-by: Tim Moon <[email protected]>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <[email protected]>

---------

Signed-off-by: Tim Moon <[email protected]>
Signed-off-by: Tim Moon <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI core Changes to NeMo Core feature request/PR for a new feature NLP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants