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

Fix the FP16 precision problem of add_n. #50129

Merged
merged 4 commits into from
Feb 2, 2023

Conversation

liuruyan
Copy link
Contributor

@liuruyan liuruyan commented Feb 1, 2023

PR types

Performance optimization

PR changes

Others

Describe

Fix the FP16 precision problem of add_n.

@paddle-bot
Copy link

paddle-bot bot commented Feb 1, 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/phi/kernels/gpu/add_n_kernel.cu Outdated Show resolved Hide resolved
}
}
out[id] = total;
out[id] = static_cast<T>(total);
id += blockDim.x * gridDim.x;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

只改这里应该不够吧?AddNKernel中有一些条件走了其他实现,比如如果是2个tensor,调用eigen库实现的,那里加法也需要提升到fp32计算。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已解决。

Copy link
Contributor

@zhangting2020 zhangting2020 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhangting2020 zhangting2020 merged commit 14dd68e into PaddlePaddle:develop Feb 2, 2023
pangengzheng pushed a commit to pangengzheng/Paddle that referenced this pull request Feb 2, 2023
Xreki pushed a commit to Xreki/Paddle that referenced this pull request Apr 9, 2023
aoyulong pushed a commit that referenced this pull request Apr 11, 2023
* Fix scale kernel for low precision, cherry pick #50998.

* Fix the FP16 precision problem of add_n. (#50129)

* Change squared_l2_norm to reuse ReduceKernel, and register fp16 and bf16 kernel, which is cherry pick #48315.

* Cherry-pick the fix of MPTypeTrait in KP, which is implemented in #50993.

* Cherry-pick the multi-precision support of AdamW for bf16, #48041.

* Fix compiling error.

* Cherry-pick the fix of CubTensorReduceImpl for bfloat16 in #50993.

* Fix unittest.

---------

Co-authored-by: liuruyan <[email protected]>
@liuruyan liuruyan deleted the add_n_develop branch December 2, 2024 07:42
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