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

[cherry-pick-2.2]Fix fused_attention_op and fused_feedforward_op bug when pre_layer_norm is false. #36816

Conversation

limin2021
Copy link
Contributor

PR types

Bug fixes

PR changes

OPs

Describe

问题描述:
fused_attention_op中,当pre_layer_norm为false时,fused_attention_op.cc的GradOpMaker将与pre layer_norm相关的张量也作为了输入和输出(比如,将d_scale,d_bias和d_ln_out作为输出)。此时,模型中调用该op时,梯度更新阶段会更新d_scale, d_bias和d_ln_out。由于这几个张量的值是没有初始化的,会偶发性的引发nan,inf的错误。
同理,fused_feedforwad_op也有类似的问题。

解决:
1.当pre_layer_norm为false时,反向的输入输出中去掉与pre layer_norm相关的张量;
2.为fused_attention_op增加单测,测试pre_layer_norm为true和false的情形。

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@lanxianghit lanxianghit merged commit ae59223 into PaddlePaddle:release/2.2 Oct 28, 2021
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.

4 participants