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

【快乐开源】PIR SaveLoad 体系单测适配 #64098

Open
xiaoguoguo626807 opened this issue May 8, 2024 · 5 comments
Open

【快乐开源】PIR SaveLoad 体系单测适配 #64098

xiaoguoguo626807 opened this issue May 8, 2024 · 5 comments
Assignees
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/new-issue 新建 type/others 其他问题

Comments

@xiaoguoguo626807
Copy link
Contributor

xiaoguoguo626807 commented May 8, 2024

问题描述 Please describe your issue

一、BackGround 📚

飞桨新IR(PIR)save load 功能建设已经基本完成,涉及到2组API的相关单测开启适配。分别是动转静api paddle.jit.save / paddle.jit.load;以及推理api paddle.static.save_inference_model / paddle.static.load_inference_model.

二、Task Introduction📚

任务分为多期进行:首先发布动转静API相关的第一期任务,此任务需要为指定单测文件中涉及到paddle.jit.save / paddle.jit.load的单测增加装饰器test_with_dygraph_pir,进行旧ir +pir 下的测试。此装饰器可以保证动转静运行在动态图模式下,转静后运行在pir 模式下。参考test_jit_save_load.py 中相关样例。

dygraph_to_static 目录下相关单测装饰器为@test_legacy_and_pt_and_pir, 大部分单测已增加装饰器,只需将pir 分支下的jit.save,jit.load 内容打开进行调试。

P0, P1 单测常见的调试问题如下:参考https://github.com/PaddlePaddle/Paddle/pull/63958/files

问题1: 动转静to_static的参数需要增加 full_graph=True 确保动转静运行在AST整图模式下。

image

问题2:动转静to_static 如果在layer 的class 中以装饰器实现,会在装饰器外完成动转静,导致模式错误,InputSpec数据类型错误,需要将to_static写在测试的函数内。

image
image

问题3: 动转静输入输出的shape 在pir 模式下是list [], 旧ir模式下是tuple () 。需要在单测中加分支处理。

image

问题4: paddle.jit.save 中如需传递output_spec, output_spec 需要从动转静的layer中获取(value),不能是执行结果(tensor)

image

注意事项:

确保jit.save 和 jit.load 在同一模式下,有些样例save在整个测试类的启动位置,无法使用装饰器进行测试,此时需要单独写一个新类只在pir模式下测试。例如TestTranslatedLayer

如遇到原始单测跑不通的情况,可以单独执行pir 模式测试,(if not paddle.framework.use_pir_api())仍有相同报错的可@SigureMo 协助修复。

P2 单测常见的调试问题如下:参考https://github.com/PaddlePaddle/Paddle/pull/64151/files

问题1. pir 的model 存储后缀为.json 与旧ir 的pdmodel 不同, 因此需要单独适配文件后缀

image

问题2. 目前推理的predictor 未开发完成 predict_analysis_inference 函数需要在pir模式下跳过。

Task Submit📚

1. 单测验证

修复完成后,可以在本地执行验证:
ctest -R 单测名称python 单测名称

2. 认领方式

请大家以 comment 的形式认领任务,如:
【报名】:1、3、12-13
多个任务之间需要使用中文顿号分隔,报名多个连续任务可用横线表示,如 2-5

3. PR提交

  • PR名称需要加前缀 【Fix PIR JIT SaveLoad Unittest No.XXX】
  • PR描述中需要附上本issue
  • 评论里或者 review request @xiaoguoguo626807 进行review

看板信息

任务方向 任务数量 提交作品 / 任务认领 提交率 完成 完成率
【快乐开源】PIR SaveLoad 体系单测适配 23 21 / 22 91.3% 21 91.3%

四、Task List📚

序号 单测 优先级 PR
1 dygraph_to_static/test_container.py P0 @xiaoguoguo626807
2 dygraph_to_static/test_declarative.py P0 @xiaoguoguo626807 #64400
3 dygraph_to_static/test_for_enumerate.py P0 @xiaoguoguo626807 #64400
4 dygraph_to_static/test_grad.py P0 @xiaoguoguo626807 #64400
5 dygraph_to_static/test_layer_hook.py P0 @xiaoguoguo626807 #64400
6 dygraph_to_static/test_loop.py P0 @xiaoguoguo626807 #64400
7 dygraph_to_static/test_lstm.py P0 @xiaoguoguo626807 #64458
8 dygraph_to_static/test_save_inference_model.py P0 @xiaoguoguo626807 #64400
9 dygraph_to_static/test_slice.py P0 @xiaoguoguo626807 #64400
10 dygraph_to_static/test_typing.py P0 @xiaoguoguo626807 #64400
11 rnn/test_rnn_nets.py P0 @xiaoguoguo626807 #64458
12 test_input_spec.py P0 @xiaoguoguo626807 #64362
13 test_ops_nms.py P0 @xiaoguoguo626807 #64400
14 dygraph_to_static/test_pylayer.py P1
15 dygraph_to_static/test_layer_hook.py P1 @xiaoguoguo626807 #64400
16 dygraph_to_static/test_error.py P1 @xiaoguoguo626807 #64475
17 test_translated_layer.py P1 @xiaoguoguo626807 #64475
18 test_bert.py P2 @xiaoguoguo626807 #64151
19 test_bmn.py P2 @enkilee #64184
20 test_mobile_net.py P2 @xiaoguoguo626807 #64315
21 test_resnet.py P2 @xiaoguoguo626807 #64315
22 test_build_strategy.py P2 @xiaoguoguo626807 #64362
23 test_se_resnet.py P2 @xiaoguoguo626807 #64362

统计信息

排名不分先后 @xiaoguoguo626807 (20) @enkilee (1)

@xiaoguoguo626807
Copy link
Contributor Author

【报名】:18

@enkilee
Copy link
Contributor

enkilee commented May 9, 2024

【报名】:19

@paddle-bot paddle-bot bot added the PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc label May 9, 2024
@xiaoguoguo626807
Copy link
Contributor Author

xiaoguoguo626807 commented May 14, 2024

【报名】 20-21

@xiaoguoguo626807
Copy link
Contributor Author

xiaoguoguo626807 commented May 16, 2024

【报名】 12, 22-23

@xiaoguoguo626807
Copy link
Contributor Author

【报名】 1-6, 8-10, 13, 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/new-issue 新建 type/others 其他问题
Projects
Status: In Progress
Development

No branches or pull requests

4 participants