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

【AutoParallel】Update rotary_emb in auto_parallel #8475

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paddlenlp/transformers/llama/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
assert past_key_value is None, "fuse rotary not support cache kv for now"
batch_size, seq_length, num_heads, head_dim = query_states.shape
_, kv_seq_len, num_key_value_heads, _ = key_states.shape
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
cos, sin, _ = self.rotary_emb(value_states, seq_len=kv_seq_len)

Check warning on line 451 in paddlenlp/transformers/llama/modeling_auto.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling_auto.py#L451

Added line #L451 was not covered by tests

paddle_version = float(paddle.__version__[:3])
if ((paddle_version != 0.0) and (paddle_version <= 2.6)) and (num_heads != num_key_value_heads):
Expand Down Expand Up @@ -481,7 +481,7 @@
use_neox_rotary_style=False,
)
else:
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
cos, sin, _ = self.rotary_emb(value_states, seq_len=kv_seq_len)

Check warning on line 484 in paddlenlp/transformers/llama/modeling_auto.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling_auto.py#L484

Added line #L484 was not covered by tests
# hack here, because elementwise infer spmd not support broadcast now
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)

Expand Down
4 changes: 2 additions & 2 deletions paddlenlp/transformers/llama/modeling_auto_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
if self.config.rope:
if self.use_fused_rope:
assert past_key_value is None, "fuse rotary not support cache kv for now"
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
cos, sin, _ = self.rotary_emb(value_states, seq_len=kv_seq_len)

Check warning on line 424 in paddlenlp/transformers/llama/modeling_auto_static.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling_auto_static.py#L424

Added line #L424 was not covered by tests
query_states, key_states, _ = fused_rotary_position_embedding(
query_states,
key_states,
Expand All @@ -432,7 +432,7 @@
use_neox_rotary_style=False,
)
else:
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
cos, sin, _ = self.rotary_emb(value_states, seq_len=kv_seq_len)

Check warning on line 435 in paddlenlp/transformers/llama/modeling_auto_static.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling_auto_static.py#L435

Added line #L435 was not covered by tests
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)

# [bs, seq_len, num_head, head_dim]
Expand Down
1 change: 1 addition & 0 deletions scripts/distribute/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ target_lists_for_llama=(
"paddlenlp/trainer/auto_trainer.py"
"paddlenlp/transformers/llama/modeling_auto_static.py"
"paddlenlp/transformers/llama/modeling_auto.py"
"paddlenlp/transformers/llama/modeling.py"
"scripts/distribute"
)

Expand Down
Loading