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

【Hackathon No.52】为 Paddle dist 算子实现 float16 数据类型支持 #51753

Closed
wants to merge 0 commits into from

Conversation

yangguohao
Copy link
Contributor

@yangguohao yangguohao commented Mar 16, 2023

PR types

New features

PR changes

OPs

Describe

add the fp16 for dist op

GPU时间

shape p fp32 fp16
[1000, 1000] 2 0.030720976 s 0.028909594 s
[1000, 1000] inf 0.019454569 s 0.016277044 s
[1000, 1000] 0 0.019905371 s 0.01616769 s

@yangguohao
Copy link
Contributor Author

@zhangting2020 您好,麻烦能否 review 一下~

@zhangting2020
Copy link
Contributor

感谢贡献。PR中存在一些问题,可以参考 #50915 中的交流

@yangguohao
Copy link
Contributor Author

yangguohao commented Apr 7, 2023

好的,我想请问一下,这个 dist_kernel.cu 的代码中如果维度不同的时候调用的 PNorm_Kernel 是不需要优化的吧,只需要优化 same shape 的情况。同时,我看到 #50915 中提到

这个OP原始的实现是比较累赘的。其实这里我建议可以看看框架已有的ReduceKernel接口,学习下它的用法,在求和之前的计算过程都可以放到ReduceKernel的TransformOp中去实现,代码和性能都会有优化。最后1个else分支也是一样可以这么处理的。

需要根据这段进行修改吗。

@zhangting2020
Copy link
Contributor

zhangting2020 commented Apr 13, 2023

好的,我想请问一下,这个 dist_kernel.cu 的代码中如果维度不同的时候调用的 PNorm_Kernel 是不需要优化的吧,只需要优化 same shape 的情况。同时,我看到 #50915 中提到

这个OP原始的实现是比较累赘的。其实这里我建议可以看看框架已有的ReduceKernel接口,学习下它的用法,在求和之前的计算过程都可以放到ReduceKernel的TransformOp中去实现,代码和性能都会有优化。最后1个else分支也是一样可以这么处理的。

需要根据这段进行修改吗。

dist和p_norm确实有差异可能无法完全借鉴,只是或许可以看看实现上还有没有可能优化呢?我大概忘记了还有广播的这种情况,不见得能完全依照p_norm去改。

主要的问题是需要去看在计算的流程里面,是否有一些过程会损失精度,那么就需要考虑提升到fp32精度去计算,算子输入输出保持fp16,这是基本的改写原则。像abs、max这种过程就可以保持fp16。

@paddle-bot
Copy link

paddle-bot bot commented Apr 15, 2023

很抱歉,经过我们的反复讨论,你的PR暂未达到合入标准,请阅读飞桨原生算子开发规范,你可以重新提交新的PR,我们先将此PR关闭,感谢你的贡献。
Sorry to inform you that through our discussion, your PR fails to meet the merging standard (Reference: Paddle Custom Operator Design Doc). You can also submit an new one. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants