Skip to content

【PaddleNLP No.27】update infer.py to support pir #10379

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

Merged
merged 1 commit into from
Apr 11, 2025
Merged
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
9 changes: 3 additions & 6 deletions llm/server/server/server/engine/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
)
from paddlenlp.trl import llm_utils
from paddlenlp.trl.llm_utils import get_rotary_position_embedding
from paddlenlp.utils.env import PADDLE_INFERENCE_MODEL_SUFFIX, PADDLE_INFERENCE_WEIGHTS_SUFFIX

File_Path = os.path.realpath(sys.argv[0])
Dir_Path = os.path.dirname(File_Path)
Expand Down Expand Up @@ -726,12 +727,8 @@ def _init_predictor(self):
predictor init
"""
device_id = self.rank % self.config.mp_num_per_node
if use_pir_api():
self.model_file = os.path.join(self.model_dir, "model.json")
self.param_file = os.path.join(self.model_dir, "model.pdiparams")
else:
self.model_file = os.path.join(self.model_dir, "model.pdmodel")
self.param_file = os.path.join(self.model_dir, "model.pdiparams")
self.model_file = os.path.join(self.model_dir, f"model{PADDLE_INFERENCE_MODEL_SUFFIX}")
self.param_file = os.path.join(self.model_dir, f"model{PADDLE_INFERENCE_WEIGHTS_SUFFIX}")
config = paddle.inference.Config(self.model_file, self.param_file)

if paddle.is_compiled_with_xpu():
Expand Down