Skip to content

Commit

Permalink
[XPU] set appropriate mask value for xpu
Browse files Browse the repository at this point in the history
  • Loading branch information
runzhech committed Nov 26, 2024
1 parent 131888e commit 23c9434
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion paddlenlp/transformers/llama/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,9 @@ def _prepare_decoder_attention_mask(attention_mask, input_shape, past_key_values
expanded_attn_mask = expanded_attn_mask.astype("float32")
expanded_attn_mask = paddle.where(expanded_attn_mask, x, y).astype(dtype)
elif get_env_device() in ["xpu", "gcu"]:
min_val = paddle.finfo(dtype).min if get_env_device() == "gcu" else -1e37 # mask value for xpu

Check warning on line 1548 in paddlenlp/transformers/llama/modeling.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling.py#L1548

Added line #L1548 was not covered by tests
x = paddle.to_tensor(0.0, dtype=dtype)
y = paddle.to_tensor(paddle.finfo(dtype).min, dtype=dtype)
y = paddle.to_tensor(min_val, dtype=dtype)

Check warning on line 1550 in paddlenlp/transformers/llama/modeling.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling.py#L1550

Added line #L1550 was not covered by tests
expanded_attn_mask = expanded_attn_mask.astype(dtype)
expanded_attn_mask = paddle.where(expanded_attn_mask, x, y).astype(dtype)
else:
Expand Down

0 comments on commit 23c9434

Please sign in to comment.