Skip to content

Commit

Permalink
fix the d2s bug in qwen2 modeling (#9603)
Browse files Browse the repository at this point in the history
* fix the d2s bug in qwen2 modeling

* update the code for the predictor
  • Loading branch information
wawltor authored Dec 11, 2024
1 parent b7c6b4e commit cd5468c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion llm/predict/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
from paddle.base.framework import in_cinn_mode, in_pir_executor_mode, use_pir_api
from paddle.distributed import fleet

from paddlenlp.experimental.transformers import InferenceWithReferenceProposer
try:
from paddlenlp.experimental.transformers import InferenceWithReferenceProposer
except:
pass
from paddlenlp.generation import GenerationConfig, TextIteratorStreamer
from paddlenlp.peft import LoRAConfig, LoRAModel, PrefixConfig, PrefixModelForCausalLM
from paddlenlp.taskflow.utils import static_mode_guard
Expand Down
2 changes: 1 addition & 1 deletion paddlenlp/transformers/qwen2/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ def _prepare_decoder_attention_mask(attention_mask, input_shape, past_key_values
y = paddle.to_tensor(-1.7005809656952787e38, dtype="float32")
expanded_attn_mask = paddle.where(expanded_attn_mask, x, y)
else:
expanded_attn_mask = paddle.where(expanded_attn_mask.to("bool"), 0.0, paddle.finfo(dtype).min).astype(
expanded_attn_mask = paddle.where(expanded_attn_mask.cast("bool"), 0.0, paddle.finfo(dtype).min).astype(
dtype
)
return expanded_attn_mask
Expand Down

0 comments on commit cd5468c

Please sign in to comment.