Skip to content

[XPU] update StridedCopyKernel #72030

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
Apr 3, 2025

Conversation

houj04
Copy link
Contributor

@houj04 houj04 commented Apr 2, 2025

PR Category

Custom Device

PR Types

Performance

Description

目前phi::StridedCopyKernel的XPU实现中,会使用xpu::strided_copy函数。该函数有严重的性能问题,因此暂时禁用掉,改成“先拷贝到CPU,按照CPU算子逻辑计算,再拷贝回XPU”的临时方案。

由于有其它一批XPU下面的单测,仅能在export FLAGS_use_stride_kernel=0的时候通过,因此本PR先修改了test_setitem_appendix单个单测的运行时环境变量。

Copy link

paddle-bot bot commented Apr 2, 2025

你的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.

@paddle-bot paddle-bot bot added the XPU label Apr 2, 2025
changeyoung98
changeyoung98 previously approved these changes Apr 2, 2025
Comment on lines 56 to 57
// 下述XPU算子有性能问题,因此暂时禁用掉,改成“先拷贝到CPU,按照CPU算子逻辑计算,再拷贝回XPU”的临时方案
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

目前Paddle repo里暂时没有中文注释,换成英文吧~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


// CPU buffer for out
char* output_on_cpu = new char[out->Holder()->size()];
memory_utils::Copy(CPUPlace(),
Copy link
Contributor

Choose a reason for hiding this comment

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

这里需要Wait一下吗?我看底层用的是xpu_memcpy_async。
一般,在Kernel中我们使用phi::Copy,如果给phi::Copy传入Stream则代表不blocking,如果stream为Nullptr,表示需要Blocking。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

如单独沟通,继续保留使用memory_utils::Copy,并且补充了同步操作。

Copy link
Contributor

@wanghuancoder wanghuancoder 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

@HarperCy HarperCy 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 merged commit f03a429 into PaddlePaddle:develop Apr 3, 2025
32 checks passed
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 2025
* [XPU] update StridedCopyKernel

* fix ut env

* follow comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants