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 support for XHPC #59895

Merged
merged 16 commits into from
Dec 14, 2023
Merged

[XPU]add support for XHPC #59895

merged 16 commits into from
Dec 14, 2023

Conversation

runzhech
Copy link
Contributor

@runzhech runzhech commented Dec 11, 2023

PR types

New features

PR changes

Others

Description

添加了paddle与XHPC共同编译的相关代码。
XHPC是包含xdnn,xBLAS,flash-attention三个库产出的合集包,提供了一些特定的高性能算子。后续在paddle中使用例如fc_fusion、fc_batched、flash_attention_fwd等算子,都会从这些库里调用。
使用XHPC时需要在cmake时开启-DWITH_XPU_XHPC=ON,由于XHPC依赖于特定版本的XDNN,因此开启该选项后paddle会使用XHPC中的xdnn库进行编译。与xdnn一样,可以在xpu.cmake中通过修改日期拉取不同版本的XHPC产出。
不开-DWITH_XPU_XHPC时编译过程和以前一样,会使用XDNN在bos上的产出编译。

Copy link

paddle-bot bot commented Dec 11, 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.

@CLAassistant
Copy link

CLAassistant commented Dec 11, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


chenrunzhe seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@paddle-bot paddle-bot bot added the contributor External developers label Dec 11, 2023
${CMAKE_SOURCE_DIR}/tools/xpu/get_xpti_dependence.sh ${XPU_XPTI_URL}
${XPU_XPTI_DIR_NAME}
DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XPU_INSTALL_ROOT}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${XPU_INSTALL_ROOT}
BUILD_BYPRODUCTS ${XPU_API_LIB}
BUILD_BYPRODUCTS ${XPU_API_LIB} BUILD_BYPORDUCTS ${XPU_XBLAS_LIB}
Copy link
Contributor

Choose a reason for hiding this comment

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

是格式限定么?每行一个感觉会更清楚一些。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pre-commit格式检查的时候自动改的

@@ -206,6 +237,11 @@ if(WITH_XPTI)
target_link_libraries(xpulib ${XPU_XPTI_LIB})
endif()

if(WITH_XPU_XHPC)
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_XBLAS_LIB})
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_XFA_LIB})
Copy link
Contributor

Choose a reason for hiding this comment

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

241行和242行可以拼接在一起么?

Copy link
Contributor

Choose a reason for hiding this comment

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

另外,和225-234行这一堆可以拼接在一起么?
这么多不同的并且是“正交”的编译选项,看看有没有更优雅的方式进行组合。

cp -r output/${XHPC_DIR_NAME}/xblas/so/* xpu/lib/

cp -r output/${XHPC_DIR_NAME}/xdnn/include/* xpu/include/
cp -r output/${XHPC_DIR_NAME}/xdnn/so/* xpu/lib
Copy link
Contributor

Choose a reason for hiding this comment

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

53-54行的这两个cp,是否依赖下面60-61行的mkdir(对应原版38-39行的mkdir)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

else()
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB})
endif()
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_BKCL_LIB}
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的修改是直接删掉了原版的各种if-else么?
不开xccl以及不开xft的话会有问题么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

不开xccl和xft时,对应的变量${XPU_XFT_LIB}${XPU_BKCL_LIB}直接为空值,不会对编译造成影响

shutil.copy(env_dict.get("XPU_XBLAS_LIB"), libs_path)
package_data['paddle.libs'] += [env_dict.get("XPU_XBLAS_LIB_NAME")]
shutil.copy(env_dict.get("XPU_XFA_LIB"), libs_path)
package_data['paddle.libs'] += [env_dict.get("XPU_XFA_LIB_NAME")]
Copy link
Contributor

Choose a reason for hiding this comment

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

注意看一下,python/setup.py.in以及python/env_dict.py.in是否也有需要改的?

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

@lj970926 lj970926 left a comment

Choose a reason for hiding this comment

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

LGTM

houj04
houj04 previously approved these changes Dec 13, 2023
Copy link
Contributor

@luotao1 luotao1 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 CMakeLists.txt

Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zyfncg zyfncg 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 setup.py.in

@QingshuChen QingshuChen merged commit e945153 into PaddlePaddle:develop Dec 14, 2023
29 checks passed
@houj04 houj04 added the XPU label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers XPU
Projects
None yet
Development

Successfully merging this pull request may close these issues.