-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Phi] Support kps backend and kernel registry #39941
[Phi] Support kps backend and kernel registry #39941
Conversation
// on GPU and XPU at the same time, so we need KPSContext when registering | ||
// KPS Kernel. Note: XPU and GPU cannot be compiled at the same time! | ||
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) | ||
using KPSContext = GPUContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
其它硬件是不是加一个 elif 就可以?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里没有可以elif的对象?我的想法是同质化的context放在同一个文件中,便于include,这里是在gpu_context.h中的
cmake/phi.cmake
Outdated
@@ -137,6 +140,11 @@ function(kernel_library TARGET) | |||
list(APPEND xpu_srcs ${CMAKE_CURRENT_SOURCE_DIR}/xpu/${TARGET}.cc) | |||
endif() | |||
endif() | |||
if (WITH_GPU OR WITH_ROCM OR WITH_XPU_KP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前要求kps目录下文件是.cu后缀是吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,按那天晚上讨论的结论是这样;而且,使用cu的话,其实不需要再额外支持kps拷贝成cu了
cmake/xpu_kp.cmake
Outdated
cp ${kernel_path}/${kernel_name}.kps kernel_build/${kernel_name}.xpu | ||
[[ -e ${kernel_path}/${kernel_name}.kps ]] && cp ${kernel_path}/${kernel_name}.kps kernel_build/${kernel_name}.xpu | ||
COMMAND | ||
[[ -e ${kernel_path}/${kernel_name}.cu ]] && cp ${kernel_path}/${kernel_name}.cu kernel_build/${kernel_name}.xpu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是支持.cu 和 .kps两种吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只是暂时没删掉原来的,这个需要你们确认一下,如果可以的话,我也可以将kps删除
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只是暂时没删掉原来的,这个需要你们确认一下,如果可以的话,我也可以将kps删除
这个还是先别删。
cmake/phi.cmake
Outdated
@@ -137,6 +140,11 @@ function(kernel_library TARGET) | |||
list(APPEND xpu_srcs ${CMAKE_CURRENT_SOURCE_DIR}/xpu/${TARGET}.cc) | |||
endif() | |||
endif() | |||
if (WITH_GPU OR WITH_ROCM OR WITH_XPU_KP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.cu->.xpu文件这种重命名规则,这个目前只会影响phi/kernel/里面的.cu文件吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xpu_library才会改,但是xpu_library只会处理kps目录下的cu文件
|
||
} // namespace phi | ||
|
||
PD_REGISTER_KERNEL( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前XPU2 KP的CI还没有建起来,这个注册逻辑是否在XPU2硬件上开with_xpu_kp进行验证了呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmake/xpu_kp.cmake
Outdated
cp ${kernel_path}/${kernel_name}.kps kernel_build/${kernel_name}.xpu | ||
[[ -e ${kernel_path}/${kernel_name}.kps ]] && cp ${kernel_path}/${kernel_name}.kps kernel_build/${kernel_name}.xpu | ||
COMMAND | ||
[[ -e ${kernel_path}/${kernel_name}.cu ]] && cp ${kernel_path}/${kernel_name}.cu kernel_build/${kernel_name}.xpu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只是暂时没删掉原来的,这个需要你们确认一下,如果可以的话,我也可以将kps删除
这个还是先别删。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
New features
PR changes
Others
Describe
[Phi] Support kps backend and kernel registry
本PR支持基于kernel primitives api实现的kernel能够在phi中实现并被正确调度:
kernels/kps
子目录:phi中基础kernel的管理根据backend不同,通过不同子目录管理,因此基于kps实现的kernel均放置于kps中,整体kernel实现方式规范与cpu、gpu、gpudnn等其他backend一致,同时增加了相应的自动化编译支持。kps注册kernel写法为:
注意,第二个参数为
KPS