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

modify Paddlemix qwen dytostatic #8869

Merged
merged 4 commits into from
Aug 7, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import paddle
import paddle.distributed as dist
from paddle.framework import LayerHelper, core, in_dynamic_mode
from paddle.framework import LayerHelper, core, in_dynamic_mode, in_dynamic_or_pir_mode

Check warning on line 18 in paddlenlp/experimental/transformers/fused_transformer_layers.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/experimental/transformers/fused_transformer_layers.py#L18

Added line #L18 was not covered by tests
from paddle.incubate.nn.functional import (
fused_layer_norm,
fused_rms_norm,
Expand Down Expand Up @@ -88,7 +88,8 @@
quant_max_bound=0,
quant_min_bound=0,
):
if in_dynamic_mode():
if in_dynamic_or_pir_mode():

Check warning on line 91 in paddlenlp/experimental/transformers/fused_transformer_layers.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/experimental/transformers/fused_transformer_layers.py#L91

Added line #L91 was not covered by tests

return paddle._C_ops.fused_bias_act(
x,
bias,
Expand Down
1 change: 1 addition & 0 deletions paddlenlp/experimental/transformers/generation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def generate(
inputs_embeds=inputs_embeds,
**model_kwargs,
)

return ret

def update_model_kwargs_for_generation(self, cache, just_decoder, next_tokens, eos_token_id, model_kwargs):
Expand Down
5 changes: 4 additions & 1 deletion paddlenlp/generation/logits_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ def __call__(self, input_ids, scores):


def TopKProcess(probs: paddle.Tensor, top_k: int, min_tokens_to_keep: int):
top_k = min(max(top_k, min_tokens_to_keep), probs.shape[-1])
top_k = paddle.minimum(
paddle.maximum(paddle.to_tensor(top_k), paddle.to_tensor(min_tokens_to_keep)),
paddle.to_tensor(probs.shape[-1]),
)
# Remove all tokens with a probability less than the last token of the top-k
# cast to float16 to support generation & d2s
if probs.dtype == paddle.bfloat16:
Expand Down
11 changes: 8 additions & 3 deletions tests/transformers/test_modeling_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,10 @@ def test_to_static_use_top_k(self):
use_top_p=False,
),
)

model_path = os.path.join(tempdir, "model.pdmodel")
if paddle.framework.use_pir_api():
model_path = os.path.join(tempdir, "model.json")
else:
model_path = os.path.join(tempdir, "model.pdmodel")
params_path = os.path.join(tempdir, "model.pdiparams")
config = paddle.inference.Config(model_path, params_path)

Expand Down Expand Up @@ -1036,7 +1038,10 @@ def test_to_static_use_top_p(self):
),
)

model_path = os.path.join(tempdir, "model.pdmodel")
if paddle.framework.use_pir_api():
model_path = os.path.join(tempdir, "model.json")
else:
model_path = os.path.join(tempdir, "model.pdmodel")
params_path = os.path.join(tempdir, "model.pdiparams")
config = paddle.inference.Config(model_path, params_path)

Expand Down
Loading