Skip to content

【inference】support load or save Llama2-7b in three patterns#8712

Merged
wawltor merged 5 commits into
PaddlePaddle:developfrom
lizexu123:llama2-7b-s
Jul 5, 2024
Merged

【inference】support load or save Llama2-7b in three patterns#8712
wawltor merged 5 commits into
PaddlePaddle:developfrom
lizexu123:llama2-7b-s

Conversation

@lizexu123
Copy link
Copy Markdown
Contributor

@lizexu123 lizexu123 commented Jul 4, 2024

PR types

New features

PR changes

Others

Description

补充:

  • 导出pdmodel:

python ./predict/export_model.py --model_name_or_path meta-llama/Llama-2-7b-chat --output_path ./inference --dtype float16

  • 导出json:

FLAGS_enable_pir_api=1 python ./predict/export_model.py --model_name_or_path meta-llama/Llama-2-7b-chat --output_path ./inference --dtype float16

支持三种模式跑

  • 跑Llama2-7b.pdmodel +旧ir

python ./predict/predictor.py --model_name_or_path ./llama2-7b --dtype float16 --mode static

  • 跑Llama2-7b.pdmodel +pir

FLAGS_enable_pir_in_executor=1 python ./predict/predictor.py --model_name_or_path ./llama2-7b --dtype float16 --mode static

  • 跑Llama2-7b.json +pir

FLAGS_enable_pir_api=1 python ./predict/predictor.py --model_name_or_path ./inference --dtype float16 --mode static
如需测试保存优化后的模型再推理,设置inference_config.use_optimized_model(True),第一次执行会先保存优化后的模型,第二次执行,会直接加载优化后的模型进行推理

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Jul 4, 2024

Thanks for your contribution!

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.73%. Comparing base (6d464bf) to head (de3ae3a).
Report is 219 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8712      +/-   ##
===========================================
- Coverage    55.74%   55.73%   -0.01%     
===========================================
  Files          623      623              
  Lines        97456    97459       +3     
===========================================
  Hits         54323    54323              
- Misses       43133    43136       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread llm/predict/predictor.py Outdated
Comment on lines +360 to +364
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.

哦哦对

Comment thread llm/predict/predictor.py Outdated
inference_config.disable_glog_info()
# inference_config.disable_glog_info()
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.

恢复

Comment thread llm/predict/predictor.py Outdated
Comment on lines +371 to +372
# 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.

删掉

Comment thread llm/predict/predictor.py
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.

恢复

Copy link
Copy Markdown
Contributor

@wawltor wawltor left a comment

Choose a reason for hiding this comment

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

LGTM

@wawltor wawltor merged commit d8ddba9 into PaddlePaddle:develop Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants