Skip to content
Merged
Changes from 3 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
12 changes: 9 additions & 3 deletions llm/predict/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ def __init__(self, config: PredictorArgument, tokenizer: PretrainedTokenizer = N
super().__init__(config, tokenizer)

params_path = os.path.join(self.config.model_name_or_path, self.config.model_prefix + ".pdiparams")
model_path = os.path.join(self.config.model_name_or_path, self.config.model_prefix + ".pdmodel")

if paddle.framework.use_pir_api():
model_path = os.path.join(self.config.model_name_or_path, self.config.model_prefix + ".json")
else:
model_path = os.path.join(self.config.model_name_or_path, self.config.model_prefix + ".pdmodel")
inference_config = paddle.inference.Config(model_path, params_path)

if self.config.device == "gpu":
Expand All @@ -357,12 +361,15 @@ def __init__(self, config: PredictorArgument, tokenizer: PretrainedTokenizer = N
# set CPU configs accordingly,
# such as enable_mkldnn, set_cpu_math_library_num_threads
inference_config.disable_gpu()
inference_config.disable_glog_info()
# inference_config.disable_glog_info()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恢复

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦哦对

inference_config.enable_new_executor()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恢复

if in_pir_executor_mode():
inference_config.enable_new_ir()
if in_cinn_mode():
inference_config.enable_cinn()
# if use optimized_model to inference
# inference_config.use_optimized_model(True)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉


with static_mode_guard():
self.predictor = paddle.inference.create_predictor(inference_config)
Expand All @@ -372,7 +379,6 @@ def __init__(self, config: PredictorArgument, tokenizer: PretrainedTokenizer = N
def _preprocess(self, input_text: str | list[str]):
inputs = super()._preprocess(input_text)
inputs["max_new_tokens"] = np.array(self.config.max_length, dtype="int64")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恢复

inputs["top_p"] = np.array(self.config.top_p, dtype="float32")
inputs["temperature"] = np.array(self.config.temperature, dtype="float32")
inputs["top_k"] = np.array(self.config.top_k, dtype="int64")
Expand Down