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

[XPU] Add XPU plugin support #55101

Merged

Conversation

hong19860320
Copy link
Contributor

@hong19860320 hong19860320 commented Jul 3, 2023

PR types

Function optimization

PR changes

Others

Description

Add XPU plugin to support the customized ops and improve the performance of the fusion ops based on hand-written xpu micro kernels.
Pcard-72642

…ce of the fusion ops based on hand-written xpu micro kernels.
@paddle-bot
Copy link

paddle-bot bot commented Jul 3, 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.

@hong19860320 hong19860320 reopened this Jul 3, 2023
@PaddlePaddle PaddlePaddle locked as off-topic and limited conversation to collaborators Jul 3, 2023
@PaddlePaddle PaddlePaddle unlocked this conversation Jul 3, 2023
Copy link
Contributor

@qili93 qili93 left a comment

Choose a reason for hiding this comment

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

LGTM


#pragma once
#include "xpu/xdnn.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

这个东西和XFT等加速库怎么区分?

Copy link
Contributor Author

@hong19860320 hong19860320 Jul 4, 2023

Choose a reason for hiding this comment

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

XFT 作为昆仑独立的加速库,用于支持 transformer 类大模型的融合算子,而 plugin 是作为 Paddle 内置的库,是对 XDNN 和 XFT 的补充,主要用于支持 Paddle 模型的特殊算子(例如各业务的自定义算子),并改变目前只有图优化一种手段且核函数依赖昆仑排期的现状,Paddle 可自行开发适合模型的简单融合算子的核函数,例如多个 eltwise XDNN API 合并成一个核函数的调用可减少访存开销,降低带宽需求提升模型整体性能。

Copy link
Contributor

Choose a reason for hiding this comment

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

这种业务定制的融合放入paddle开源仓中是否合适?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

业务模型在非保密情况下,对于通用子结构的融合及融合算子放在开源repo没问题;对于保密情况,可通过paddle自定义算子由业务方或paddle内部管理。

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tianshuo78520a tianshuo78520a left a comment

Choose a reason for hiding this comment

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

LGTM for printf

@@ -0,0 +1,379 @@
cmake_minimum_required(VERSION 3.16)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是3.16,但是api无论是2.6产出还是master主干上,都是要求3.20,是否会有影响呢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

不影响的,测试过没有问题的,我们不是编译 XDNN,只是编译 plugin 哈~

Copy link
Contributor

Choose a reason for hiding this comment

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

嗯嗯这里确实没有编译xdnn的逻辑,抱歉我刚才没有说清楚,就是plugin是xdnn其中的一个小模块,这个小模块在xdnn中要求cmake3.20,如果测试没问题就ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

plugin是xdnn可独立编译的模块,它的CMakeLists.txt部分代码引用了XDNN的CMakeLists.txt,目前我们测试下来,cmake 3.16是没问题的。

mkdir build
cd build
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_STANDALONE=ON ..
make
Copy link
Contributor

Choose a reason for hiding this comment

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

编译逻辑转移到cmakelist里,确实更符合paddle语法规范。
但是后续api plugin仍会有升级,这样较大的改动,会使得后续升级花费更多时间
请问是不再有后续升级计划呢,还是打算后续升级后再比对着改写?

Copy link
Contributor Author

@hong19860320 hong19860320 Jul 4, 2023

Choose a reason for hiding this comment

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

这个是 standalone 编译脚本,与 Paddle 联编是走下面的逻辑,不走这个脚本的。
image

Copy link
Contributor

Choose a reason for hiding this comment

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

嗯嗯联编走cmake。是这样的,我不确定我观察的这里的代码对不对,就是原本的xdnn中plugin是通过一个脚本+cmake一起编译的,但是我看这里把xdnn plugin中脚本的编译逻辑改到cmakelist里了,编译直接走cmake,也就意味着和xdnn中plugin代码有了较大区别,在后续xdnn plugin升级中,估计还是保持脚本+ cmakelist这样的编译方式,后续如果那边plugin有升级,则需要比对着那边的脚本+cmakelist改着加到这里cmakelist里,使得升级花更多时间。所以想问一下以后是否是没有升级的打算了呢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

xdnn中的plugin的编译确实是bash脚本+CMakeLists.txt,但是bash脚本只是下载和配置xtdk、xre等工具链和依赖库,最终编译还是依赖 plugin/CMakeLists.txt,我这次提交的CMakeLists.txt是基于它做了一些小的修改。

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@hong19860320 hong19860320 merged commit 6d5d9f2 into PaddlePaddle:develop Jul 4, 2023
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.

6 participants