-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Feature] Comprehensive Hybrid Parallelism Support #6389
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
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
52b050d
implement gather before attn
ch-wan abe5c79
Merge branch 'main' into cheng/gather_before_attn
zhyncs d9a745a
wip: --enable-ep-moe drops accuracy
ch-wan bdbd802
Merge branch 'main' into cheng/fix-6297
ch-wan 2f34132
Merge branch 'main' into cheng/gather_before_attn
zhyncs 824254c
Merge branch 'main' into cheng/gather_before_attn
ch-wan b324ca0
Merge branch 'main' into cheng/fix-6297
ch-wan 35267c3
Merge commit 'eb8f02dd87acd8689c41d15a7c0f11f5eff914d0' into cheng/ga…
ch-wan 7845798
update communicator
ch-wan 95df400
Merge branch 'cheng/gather_before_attn' into cheng/fix-6297
ch-wan f6fc191
Merge commit 'b18416fbf869fd2d150937d3efcf9e75ee3fb278' into cheng/ga…
ch-wan eed7ce3
fmt
ch-wan cdd6e9b
Merge branch 'cheng/gather_before_attn' into cheng/fix-6297
ch-wan 81c53e0
Merge branch 'main' into cheng/gather_before_attn
zhyncs 75773aa
fix
ch-wan 8b138a1
fix
ch-wan fcaaeaf
fmt
ch-wan 8c09414
Merge branch 'main' into cheng/gather_before_attn
ch-wan c15836b
Merge commit '8c09414e29636629f0c0544591f12933073ce5c5' into cheng/fi…
ch-wan cd6d94c
Merge commit 'b1c8d4e9f31953560f2db45a3b6e68099ef00c13' into cheng/fi…
ch-wan 1870255
format
ch-wan f8d152c
fix
ch-wan e170745
Update communicator.py
ch-wan c80f333
Update communicator.py
ch-wan 0c92871
fix
ch-wan a269c5b
Merge branch 'main' into cheng/gather_before_attn
ch-wan 7a3131e
format
ch-wan fe98477
Merge commit '7a3131e6868ec903d03156d1765c6722b9fbcaad' into cheng/fi…
ch-wan 260bbef
multiple fixes
ch-wan 8cc1fea
format
ch-wan e78fa2c
Merge commit '4f723edd3baf3823eddfb9d6426548daba17c687' into cheng/fi…
ch-wan 2bc64aa
Merge branch 'main' into cheng/gather_before_attn
ch-wan e596568
Merge branch 'main' into cheng/gather_before_attn
zhyncs bfdec93
Merge branch 'main' into cheng/gather_before_attn
ch-wan 80d2f03
Merge remote-tracking branch 'origin/cheng/gather_before_attn' into c…
ch-wan dd99fb9
Merge commit '80d2f03ecde5992184f6128538126691ee89f04b' into cheng/fi…
ch-wan ca887b8
refactor
ch-wan ead7d9f
revert dp attention test
ch-wan 0397727
add a hybrid test
ch-wan 33fb878
format
ch-wan 8c1789d
Merge commit '0ae1e9a75573b5159afb9149b8c80ae76f239ff7' into cheng/fi…
ch-wan e061123
Update test_hybrid_dp_ep_tp.py
ch-wan d887f77
update tests
ch-wan 713f87b
update test
ch-wan d39549d
fix
ch-wan dcf58ee
Merge commit 'e56685ac1bb881e58043fe5f2c4ae055905332ba' into cheng/fi…
ch-wan 84c31ff
update tests
ch-wan 57857af
adapt to dp attn with mtp
ch-wan 1e7012e
format
ch-wan 5a1d9bd
fix mlp sync
ch-wan 937451b
Merge commit '09ae5b20f3123487f36097d284a1f535cd267e7b' into cheng/fi…
ch-wan e4aab35
format
ch-wan a14115f
add MTP tests
ch-wan 3c6de24
update file name and intro
ch-wan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,9 +28,9 @@ | |
| attn_tp_reduce_scatter, | ||
| dp_gather_partial, | ||
| dp_scatter, | ||
| get_attention_dp_size, | ||
| get_attention_tp_rank, | ||
| get_attention_tp_size, | ||
| get_local_attention_dp_size, | ||
| ) | ||
| from sglang.srt.managers.schedule_batch import global_server_args_dict | ||
| from sglang.srt.model_executor.forward_batch_info import ForwardBatch | ||
|
|
@@ -229,7 +229,7 @@ class CommunicateContext: | |
| process_group_sizes: Dict[ScatterMode, int] | ||
| attn_tp_rank: int | ||
| attn_tp_size: int | ||
| local_attn_dp_size: int | ||
| attn_dp_size: int | ||
| tp_size: int | ||
|
|
||
| def is_same_group_size(self, a: ScatterMode, b: ScatterMode): | ||
|
|
@@ -239,7 +239,7 @@ def is_same_group_size(self, a: ScatterMode, b: ScatterMode): | |
| def init_new(cls): | ||
| attn_tp_rank = get_attention_tp_rank() | ||
| attn_tp_size = get_attention_tp_size() | ||
| local_attn_dp_size = get_local_attention_dp_size() | ||
| attn_dp_size = get_attention_dp_size() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| tp_size = get_tensor_model_parallel_world_size() | ||
| process_group_sizes = { | ||
| ScatterMode.SCATTERED: 1, | ||
|
|
@@ -251,7 +251,7 @@ def init_new(cls): | |
| process_group_sizes=process_group_sizes, | ||
| attn_tp_rank=attn_tp_rank, | ||
| attn_tp_size=attn_tp_size, | ||
| local_attn_dp_size=local_attn_dp_size, | ||
| attn_dp_size=attn_dp_size, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| tp_size=tp_size, | ||
| ) | ||
|
|
||
|
|
@@ -385,7 +385,7 @@ def _gather_hidden_states_and_residual( | |
| attn_tp_all_gather( | ||
| list(residual.tensor_split(context.attn_tp_size)), local_residual | ||
| ) | ||
| if context.local_attn_dp_size != 1: | ||
| if context.attn_dp_size != 1: | ||
| if context.attn_tp_rank == 0: | ||
| hidden_states += residual | ||
| hidden_states, local_hidden_states = ( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,9 +30,9 @@ | |
| attn_tp_all_gather, | ||
| dp_gather_replicate, | ||
| dp_scatter, | ||
| get_attention_dp_rank, | ||
| get_attention_dp_size, | ||
| get_attention_tp_size, | ||
| get_local_attention_dp_rank, | ||
| get_local_attention_dp_size, | ||
|
Comment on lines
+33
to
36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) | ||
| from sglang.srt.layers.vocab_parallel_embedding import VocabParallelEmbedding | ||
|
|
@@ -171,7 +171,7 @@ def compute_dp_attention_metadata(self, hidden_states: torch.Tensor): | |
| return | ||
|
|
||
| cumtokens = torch.cumsum(self.global_num_tokens_for_logprob_gpu, dim=0) | ||
| dp_rank = get_local_attention_dp_rank() | ||
| dp_rank = get_attention_dp_rank() | ||
| if dp_rank == 0: | ||
| dp_local_start_pos = torch.zeros_like( | ||
| self.global_num_tokens_for_logprob_gpu[0] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing
get_local_attention_dp_sizesince it's no longer used after the change.