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

[Dy2St] pir dy2st unittest verification - Part 1 #58630

Merged
merged 3 commits into from
Nov 3, 2023

Conversation

gouzil
Copy link
Member

@gouzil gouzil commented Nov 2, 2023

PR types

Others

PR changes

Others

Description

背景

从流程图的dy2st开始垂直向下为早期 legacy IR 形成的动转静模式。

在现阶段如果想要执行PIR executor需要经过一层ProaramTranslator转写。

我们的目标就是让他使用一套完整的PIR dy2st, 我们也称之为最终态(理想态), 也就是右侧PIR dy2st垂直向下的部分。

graph TB
    A[dy2st] --> B[legacy static APi branch] 
    B --> C[legacy IR]
    C --> D[legacy IR executor]

    E[PIR dy2st] --> F[PIR static API branch]
    F --> G[PIR]
    G --> H[PIR executor]

    C -->|ProaramTranslator| G
Loading

目标

从背景可以看出我们目前需要支持的单测有三种 IR 工作模式, 以及两种 dy2st 模式。

这样组合之后我们就能得到新机制需要运行的单测组合: 2*3=6 (如下图)

graph TB
    A[SOT] --> B[legacy IR] 
    A --> C[PIR EXE]
    A --> D[PIR API]

    E[AST] --> B
    E[AST] --> C
    E[AST] --> D

Loading

修改

  1. 模式修改

原有机制会对ToStaticMode.PIR_ASTIrMode.LEGACY_IR 进行组合, 这明显不合理, 我们不可能在一个执行器中跑两套 IR 模式

所以首先对组合模式进行了修改,将ToStaticMode.PIR_AST 模式下沉至 IrMode.PIR_EXE, 这样我们就能对不同动转静模式和 IR 模式进行组合测试

PIR_EXE对应的就是走的ProaramTranslator达到运行PIR executor模式。
PIR_API对应的就是走的全 PIR 模式, 也就是我们的最终态。

  1. 为新的组合模式添加装饰器

test_legacy_and_pir_apitest_legacy_and_pir_api_and_pir_exe装饰器

  1. pir api 推全

任务列表: #58633

Copy link

paddle-bot bot commented Nov 2, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Nov 2, 2023
@gouzil gouzil requested a review from SigureMo November 2, 2023 15:33
logger.info("[PIR][AST] running pir api")
ir_outs = None
try:
import paddle
Copy link
Member

Choose a reason for hiding this comment

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

import paddle 能不能放在文件顶端呢


with paddle.pir_utils.IrGuard():
paddle.disable_static()
with sot_mode_guard(False):
Copy link
Member

Choose a reason for hiding this comment

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

这个 sot_mode_guard 可以删掉了,因为之前考虑的是 PIR_AST 是与 SOT 互斥的,但修改后放到 IR mode 里两者其实是可以组合的

如果暂时不需要测最终态 + SOT,那么可以在组合的时候 skip 掉这种情况,就 194 行刚删掉的那部分逻辑

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@2742195759 2742195759 left a comment

Choose a reason for hiding this comment

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

LGTM

logger.info("[PIR][AST] running pir api")
ir_outs = None
try:
with paddle.pir_utils.IrGuard():
Copy link
Contributor

Choose a reason for hiding this comment

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

可以试验尝试一下,先使用Program组网,然后使用pir::Program组网,结果是否正确。

}

IR_HANDLER_MAP = {
IrMode.LEGACY_IR: to_legacy_ir_test,
IrMode.PIR: to_pir_test,
IrMode.PIR_EXE: to_pir_test,
Copy link
Contributor

Choose a reason for hiding this comment

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

to_pir_exe_test

}

IR_HANDLER_MAP = {
IrMode.LEGACY_IR: to_legacy_ir_test,
IrMode.PIR: to_pir_test,
IrMode.PIR_EXE: to_pir_test,
IrMode.PIR_API: to_pir_ast_test,
Copy link
Contributor

Choose a reason for hiding this comment

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

to_pir_api_test

@gouzil gouzil changed the title [Dy2St] dy2st pir api push all - Part 1 [Dy2St] pir dy2st unittest verification - Part 1 Nov 3, 2023
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow

@SigureMo SigureMo merged commit 3115636 into PaddlePaddle:develop Nov 3, 2023
28 checks passed
zeroRains pushed a commit to zeroRains/Paddle that referenced this pull request Nov 8, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
@gouzil gouzil deleted the dy2st_pir_api_push_1 branch December 27, 2023 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants