Skip to content

[Random op]optimize CUDA implementaion of uniform/gaussian OP #38611

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

Merged
merged 3 commits into from
Jan 18, 2022

Conversation

zhwesky2010
Copy link
Contributor

@zhwesky2010 zhwesky2010 commented Dec 30, 2021

PR types

New features

PR changes

OPs

Describe

新增 FLAGS_use_curand,默认关闭。

在FLAGS打开的情形下,修改 高斯分布、指数分布 OP 的CUDA随机数生成方式,将thrust库的实现修改为curand库的实现,对OP性能有大幅提升。

  • 性能测试代码

基于Nvidia K40显卡测试

for i in range(0, 100):
    x = paddle.rand([32, 3, 1024, 1024])
    x = paddle.randn([32, 3, 1024, 1024])
  • 性能测试结论:float32下有33倍提升,float64下有17倍提升

infoflow 2022-01-27 19-17-48

这两个OP涉及以下API:

paddle.rand
paddle.randn
paddle.normal
paddle.uniform

paddle.nn.initializer.Uniform
paddle.nn.initializer.Normal
paddle.nn.initializer.XavierNormal
paddle.nn.initializer.XavierUniform
paddle.nn.initializer.KaimingUniform
paddle.nn.initializer.KaimingNormal

默认情形下对当前OP/API无影响。

@paddle-bot-old
Copy link

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

@zhwesky2010 zhwesky2010 force-pushed the uniform_gaussian_v2 branch 3 times, most recently from 9e2c5e0 to 89fdd6e Compare December 30, 2021 13:27
@zhwesky2010 zhwesky2010 changed the title Add uniform/gaussian random V2 op change CUDA implementaion of uniform/gaussian random OP Dec 30, 2021
@zhwesky2010 zhwesky2010 changed the title change CUDA implementaion of uniform/gaussian random OP change CUDA implementaion of uniform/gaussian OP Dec 30, 2021
Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010 zhwesky2010 merged commit bbbd75e into PaddlePaddle:develop Jan 18, 2022
@zhwesky2010 zhwesky2010 changed the title change CUDA implementaion of uniform/gaussian OP optimize CUDA implementaion of uniform/gaussian OP Mar 1, 2022
@zhwesky2010 zhwesky2010 changed the title optimize CUDA implementaion of uniform/gaussian OP [Random op]optimize CUDA implementaion of uniform/gaussian OP Apr 2, 2022
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