-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 test_Conditional_block.py #61091
Merged
xiaoguoguo626807
merged 9 commits into
PaddlePaddle:develop
from
xiaoguoguo626807:condition
Jan 29, 2024
Merged
【pir】modify test_Conditional_block.py #61091
xiaoguoguo626807
merged 9 commits into
PaddlePaddle:develop
from
xiaoguoguo626807:condition
Jan 29, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
你的PR提交成功,感谢你对开源项目的贡献! |
) | ||
# update_no_grad_set_after_prune( | ||
# total_ops, effective_forward_ops, no_grad_set, inputs, complete_outputs | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是暂时保留的注释还是忘记删掉的?
changeyoung98
approved these changes
Jan 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
others
PR changes
others
Description
pcard-67164
1.修复assign_out_(0%, 1%) 的vjp , 将1 %的梯度作为vjp output_grads 传入, 直接转发作为输入0%的梯度, 1%的梯度修改为zero_like(1%) 因为inplace的输入,其被覆盖的输入值没有被其他op使用,梯度应该为0.
2.
上述网络中,由于3%的梯度在父block 中是11%, 3% 是if的输出,因此子block 构建assign_out_ 的反向时需要用11%, 因此sub_state 中需要维护3% -> 11%的关系; 又由于3%是if的输入,因此子block 中也产生梯度20%, sub_state 将维护3% -> 11% ,20%, 在做反向yield 的输出时 add_n为26% 转发给父block 的15%, 而此时父block 如果不对state 中3%的map置空,则最终3% = 11% + 15% = 11% + 11% + 20%, 计算会错误。因此对于if内的inplace 输入,输出state需要在if 更新前置空。
3由于if 支持了combine 的结果作为cond, vjp 需要的input 是vectype 以构造if_grad的cond输入, 与其他op 的make_input_input_stop_gradient 有冲突,因此考虑将if的cond 置为无梯度语意,在对应分支跳过combine的拆解处理. 相应的对其vjp 处理,默认cond 不传stop_gradient 信息,因此内部与input 对应的索引需要错位。