-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[AutoParallel] Add sequence parallel for llama #59822
Conversation
… fix_backward_reshard
… fix_backward_reshard
… fix_backward_reshard
… fix_backward_reshard
你的PR提交成功,感谢你对开源项目的贡献! |
5972d6f
to
d6c38d9
Compare
@@ -192,6 +192,26 @@ def forward( | |||
shape=target_key_value_shape | |||
) | |||
|
|||
if self.config.sequence_parallel: | |||
query_states = dist.reshard( |
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.
reshard before projection while tranpose after projection
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.
Done, thx~
@@ -238,6 +250,12 @@ def forward( | |||
else: | |||
attn_output = outputs | |||
|
|||
if self.config.sequence_parallel: | |||
attn_output = paddle.transpose(attn_output, [1, 0, 2]) | |||
attn_output = dist.reshard( |
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.
reshard should after out_projection
@@ -731,6 +772,13 @@ def forward( | |||
|
|||
# if labels is None,means we need full output, instead of tensor_parallel_output | |||
logits = self.lm_head(hidden_states) | |||
if self.config.sequence_parallel: |
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.
# reshard should before lm_head
if self.config.sequence_parallel:
hidden_states = dist.reshard(
hidden_states, get_mesh(-1), [dist.Shard(1), dist.Replicate()]
)
# [S, B, H] -> [B, S, H]
hidden_states = paddle.transpose(hidden_states, [1, 0, 2])
logits = self.lm_head(hidden_states)
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.
LGTM
PR types
Others
PR changes
Others
Description
Pcard-73145
Add sequence parallel for llama.