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】modify Call vjp interface for controlflow grad #58277

Merged
merged 32 commits into from
Oct 23, 2023

Conversation

xiaoguoguo626807
Copy link
Contributor

PR types

others

PR changes

others

Description

pcard-67164
修改call_vjp增加前向输入输出参数,控制流反向子block无法访问前向block中的输入输出变量,需要访问copy变量,因此在ir_backward中提供

xiaoguoguo626807 and others added 28 commits August 30, 2023 01:44
@paddle-bot
Copy link

paddle-bot bot commented Oct 20, 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.

Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -43,7 +43,13 @@ def test_tanh_vjp1(self):
out_grads = [[fill_constant_op.result(0)]]
stop_gradients = [[False]]
with paddle.pir.core.program_guard(newir_program):
grad_outs = call_vjp(tanh_op, out_grads, stop_gradients)
grad_outs = call_vjp(
Copy link
Contributor

Choose a reason for hiding this comment

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

call_vjp 后续会提供两种形态的API么,一种是对于非控制流,可以不显式地指定inputs和outputs,这样使用起来更方便;也有一种是需要指定inputs和outputs的,扩展支持控制流的?

Copy link
Contributor

Choose a reason for hiding this comment

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

前者的函数实现里是调用后者。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

目前是对非控制流op call_vjp改造;这些op在控制流block中需要修改call_vjp的输入. 控制流的op调用反向的接口使用其他接口,只负责返回反向空op, 复用ir_backward 逻辑填加其他op的反向op

@xiaoguoguo626807 xiaoguoguo626807 merged commit 376ace4 into PaddlePaddle:develop Oct 23, 2023
@xiaoguoguo626807 xiaoguoguo626807 deleted the call_vjp branch October 23, 2023 07:19
hitywt pushed a commit to hitywt/Paddle that referenced this pull request Oct 24, 2023
* tmp

* [PIR]Migrate maximum into pir

* Polish code

* add ir_grad of static_gradient

* add test

* modify bug

* modify

* add mean fill_constant test

* modify cpu int32 test

* get_shape_tensor

* delete

* add default place

* modify grad

* modify call_vjp

* Update python/paddle/autograd/ir_backward.py

* fix name

* new ci

---------

Co-authored-by: 0x45f <wangzhen45@baidu.com>
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Oct 26, 2023
* tmp

* [PIR]Migrate maximum into pir

* Polish code

* add ir_grad of static_gradient

* add test

* modify bug

* modify

* add mean fill_constant test

* modify cpu int32 test

* get_shape_tensor

* delete

* add default place

* modify grad

* modify call_vjp

* Update python/paddle/autograd/ir_backward.py

* fix name

* new ci

---------

Co-authored-by: 0x45f <wangzhen45@baidu.com>
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
* tmp

* [PIR]Migrate maximum into pir

* Polish code

* add ir_grad of static_gradient

* add test

* modify bug

* modify

* add mean fill_constant test

* modify cpu int32 test

* get_shape_tensor

* delete

* add default place

* modify grad

* modify call_vjp

* Update python/paddle/autograd/ir_backward.py

* fix name

* new ci

---------

Co-authored-by: 0x45f <wangzhen45@baidu.com>
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.

2 participants