Skip to content

Improve communication overlapping in FP8 distributed optimizer#8221

Merged
timmoon10 merged 14 commits intoNVIDIA-NeMo:mainfrom
timmoon10:distopt-fp8-perf-optim
Feb 8, 2024
Merged

Improve communication overlapping in FP8 distributed optimizer#8221
timmoon10 merged 14 commits intoNVIDIA-NeMo:mainfrom
timmoon10:distopt-fp8-perf-optim

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

Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@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 and others added 2 commits January 22, 2024 17:52
Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
@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 <tmoon@nvidia.com>
@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-NeMo:main Feb 8, 2024
ssh-meister pushed a commit to ssh-meister/NeMo that referenced this pull request Feb 15, 2024
…A-NeMo#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* [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 <tmoon@nvidia.com>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <tmoon@nvidia.com>

---------

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

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* [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 <tmoon@nvidia.com>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <tmoon@nvidia.com>

---------

Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
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-NeMo#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* [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 <tmoon@nvidia.com>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <tmoon@nvidia.com>

---------

Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
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-NeMo#8221)

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* [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 <tmoon@nvidia.com>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <tmoon@nvidia.com>

---------

Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
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 <tmoon@nvidia.com>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* [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 <tmoon@nvidia.com>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <tmoon@nvidia.com>

---------

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

* Only reduce amaxes after fp8 cast for last distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Handle case with FP8 and contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Support distopt buckets with mixed dtypes

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Fix bug where fp8 casts were being skipped

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Separate non-FP8 params into leftover distopt bucket

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* Debug FP8 params with contiguous param buffer

Signed-off-by: Tim Moon <tmoon@nvidia.com>

* [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 <tmoon@nvidia.com>

* Update Apex commit

Avoid unnecessary FP8 weight transposes.

Signed-off-by: Tim Moon <tmoon@nvidia.com>

---------

Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
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

Comments