Skip to content

[Paddle] Add parallel support - #357

Merged
ksivaman merged 18 commits into
NVIDIA:mainfrom
Tom-Zheng:gh_add_parallel
Aug 26, 2023
Merged

[Paddle] Add parallel support#357
ksivaman merged 18 commits into
NVIDIA:mainfrom
Tom-Zheng:gh_add_parallel

Conversation

@Tom-Zheng

Copy link
Copy Markdown
Contributor

Add the following parallel rules:

  • TP
  • DP
  • PP
  • Group sharding (FSDP)

@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

@jeng1220 Could you take a look?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When using TP, NCCL communication needs to be scheduled before GEMM to guarantee overlap.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Although the NCCL is always invoked first, to ensure that the GEMM isn't scheduled first, the environment variable CUDA_DEVICE_MAX_CONNECTIONS needs to be set to 1 to force using a single channel.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it a PaddlePaddle limitation?

@Tom-ZhengTom-ZhengAug 8, 2023

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Same as here. Need to check if such limitation is necessary for Paddle.

@Tom-ZhengTom-ZhengAug 11, 2023

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I think it is not needed for now. In current implementation, TP collective ops run in the same CUDA stream as compute ops. So there will be no overlapping. We may need this optimization later if we change the implementation to consider overlapping.

@jeng1220jeng1220Aug 11, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider replacing CUDA_DEVICE_MAX_CONNECTIONS with cudaEventWait (or cudaStreamWaitEvent) if overlapping setup is needed.

@zlsh80826

Copy link
Copy Markdown
Collaborator

/te-ci

@jeng1220

Copy link
Copy Markdown
Contributor

This PR needs to wait for #361, and refactoring a bit.

@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

/te-ci

1 similar comment
@mingxu1067

Copy link
Copy Markdown
Collaborator

/te-ci

@ksivaman

Copy link
Copy Markdown
Member

@Tom-Zheng#361 has been merged, could you resolve the conflicts and make the necessary refactors?

Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@Tom-ZhengTom-Zheng changed the title [Paddle] Add parallel support[WIP] [Paddle] Add parallel supportAug 18, 2023
@Tom-Zheng
Tom-Zheng marked this pull request as draft August 18, 2023 06:15
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 79e2e5fd774e67dcdda9aae01a9f31a6479c5d70
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:39:16 2023 +0000
Add TP test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 1d40ad60540490f97ed82ba877cc6eda8902cbf6
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:22:25 2023 +0000
Fix tp_size when disabled
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 6632f735a0c8251862355fc74622af59fae3a509
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 05:52:18 2023 +0000
Add TP for attention and transformer layer
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@Tom-ZhengTom-Zheng changed the title [WIP] [Paddle] Add parallel support[Paddle] Add parallel supportAug 20, 2023
@Tom-Zheng
Tom-Zheng marked this pull request as ready for review August 20, 2023 14:45
@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

@ksivaman@timmoon10 This PR is ready for review. Would you please take a look?

cc: @jeng1220

@jeng1220

Copy link
Copy Markdown
Contributor

@ksivaman@timmoon10 This PR is ready for review. Would you please take a look?

cc: @jeng1220

Check tensor shapes per GPU carefully if sharding is enabled. To ensure that the every tensor shape per GPU meets the expectation.

Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@timmoon10

Copy link
Copy Markdown
Member

/te-ci

@ksivaman

Copy link
Copy Markdown
Member

/te-ci

Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

@ksivaman@timmoon10 This PR is ready for review. Would you please take a look?
cc: @jeng1220

Check tensor shapes per GPU carefully if sharding is enabled. To ensure that the every tensor shape per GPU meets the expectation.

Done

@timmoon10timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall LGTM, although we might see test failures when we add L40S to the CI.

Comment threadtransformer_engine/paddle/distributed.py Outdated
Comment threadtests/paddle/test_parallel.py
@timmoon10
timmoon10 self-requested a review August 24, 2023 17:49
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@jeng1220

Copy link
Copy Markdown
Contributor

LGTM.
@zlsh80826 please help to trigger CI.

@zlsh80826

Copy link
Copy Markdown
Collaborator

/te-ci

@timmoon10timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks reasonable to me, although we're seeing some test failures related to the MNIST example and the Transformer layer. It's strange since I wouldn't expect this PR to have affected them.

Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

It looks reasonable to me, although we're seeing some test failures related to the MNIST example and the Transformer layer. It's strange since I wouldn't expect this PR to have affected them.

It is due to randomness and is fixed now.

@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

/te_ci

@Tom-Zheng

Tom-Zheng commented Aug 26, 2023

Copy link
Copy Markdown
ContributorAuthor

@zlsh80826 Would you please help to rerun CI?

@zlsh80826

Copy link
Copy Markdown
Collaborator

/te-ci

@ksivamanksivaman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving for v0.12 with more work to be done

@ksivaman
ksivaman merged commit b8ba734 into NVIDIA:mainAug 26, 2023
ksivaman added a commit that referenced this pull request Aug 26, 2023
* [Paddle] Add TP, DP, PP, FSDP
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Minor fix
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix CI failure
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Remove set_nccl_overlap_warning_if_tp
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Improve variable naming
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Refactor FP8 Buffer
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Stylic changes
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix FP32 parallel training
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix numel performance issue
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Squashed commit of the following:
commit 79e2e5fd774e67dcdda9aae01a9f31a6479c5d70
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:39:16 2023 +0000
Add TP test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 1d40ad60540490f97ed82ba877cc6eda8902cbf6
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:22:25 2023 +0000
Fix tp_size when disabled
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 6632f735a0c8251862355fc74622af59fae3a509
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 05:52:18 2023 +0000
Add TP for attention and transformer layer
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Add shape check
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Add FSDP check for stage 1,2,3
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Review changes
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix group_sharding test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Support NVTE_FUSE_ATTN
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix CI errors
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
---------
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Co-authored-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
janekb04 pushed a commit to janekb04/TransformerEngine that referenced this pull request Sep 1, 2023
* [Paddle] Add TP, DP, PP, FSDP
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Minor fix
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix CI failure
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Remove set_nccl_overlap_warning_if_tp
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Improve variable naming
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Refactor FP8 Buffer
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Stylic changes
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix FP32 parallel training
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix numel performance issue
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Squashed commit of the following:
commit 79e2e5fd774e67dcdda9aae01a9f31a6479c5d70
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:39:16 2023 +0000
Add TP test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 1d40ad60540490f97ed82ba877cc6eda8902cbf6
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:22:25 2023 +0000
Fix tp_size when disabled
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 6632f735a0c8251862355fc74622af59fae3a509
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 05:52:18 2023 +0000
Add TP for attention and transformer layer
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Add shape check
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Add FSDP check for stage 1,2,3
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Review changes
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix group_sharding test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Support NVTE_FUSE_ATTN
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix CI errors
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
---------
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Co-authored-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
Signed-off-by: Jan Bielak <jbielak@nvidia.com>
RuiWang1998 pushed a commit to RuiWang1998/TransformerEngine that referenced this pull request Sep 11, 2023
* [Paddle] Add TP, DP, PP, FSDP
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Minor fix
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix CI failure
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Remove set_nccl_overlap_warning_if_tp
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Improve variable naming
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Refactor FP8 Buffer
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Stylic changes
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix FP32 parallel training
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix numel performance issue
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Squashed commit of the following:
commit 79e2e5fd774e67dcdda9aae01a9f31a6479c5d70
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:39:16 2023 +0000
Add TP test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 1d40ad60540490f97ed82ba877cc6eda8902cbf6
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 14:22:25 2023 +0000
Fix tp_size when disabled
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
commit 6632f735a0c8251862355fc74622af59fae3a509
Author: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Date: Sun Aug 20 05:52:18 2023 +0000
Add TP for attention and transformer layer
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Add shape check
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Add FSDP check for stage 1,2,3
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Review changes
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix group_sharding test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Support NVTE_FUSE_ATTN
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix CI errors
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
---------
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Co-authored-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
Signed-off-by: Rui Wang <rui@helixon.com>
Sign up for freeto 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.

6 participants

@Tom-Zheng@zlsh80826@jeng1220@mingxu1067@ksivaman@timmoon10