[Cherry-Pick][BugFix] Fix Async D2H copy bug & flash mash atten cache V out of bound bug(#7221)#7296
Merged
Jiang-Jia-Jun merged 1 commit intoApr 10, 2026
Conversation
5 tasks
|
Thanks for your contribution! |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review | 2026-04-10
📋 Review 摘要
PR 概述:Cherry-pick 修复两个 GPU 算子 bug - 异步 D2H 拷贝竞态问题和 Flash Mask Attention 共享内存越界问题
变更范围:custom_ops/gpu_ops/
影响面 Tag:[OP]
📝 PR 规范检查
标题拼写错误:"flash mash atten" 应改为 "flash mask attention"
标题建议(可直接复制):
[Cherry-Pick][BugFix] Fix Async D2H copy bug & flash mask attention cache V out of bound bug(#7221)
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | 代码库系统性问题 | 发现大量其他文件存在同样的异步拷贝后立即访问 CPU 数据的问题 |
总体评价
当前 PR 的两个 bug 修复逻辑正确:
- Async D2H copy bug:将异步拷贝改为同步拷贝,确保数据在读取前已完成,所有相关位置都已正确修改
- Flash Mask Attention out of bound bug:正确处理了最后一个 block 的共享内存边界条件,清零越界部分并使用
fence_view_async_shared()确保内存一致性
系统性建议:代码库中存在大量类似的异步拷贝问题(20+ 处),以下文件也存在同样模式:
step.cu:375save_output_msg_with_topk.cc:48-52step_system_cache.cu:160step_reschedule.cu:262,264speculate_decoding/目录下多处- 等等...
建议后续系统性排查并修复这些潜在的数据竞态问题。
未发现阻塞性问题。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/2.6 #7296 +/- ##
==============================================
Coverage ? 74.21%
==============================================
Files ? 376
Lines ? 52915
Branches ? 8255
==============================================
Hits ? 39270
Misses ? 10900
Partials ? 2745
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dd0863b
into
PaddlePaddle:release/2.6
33 of 37 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #7221 (authored by @ming1753) to
release/2.6.devPR:#7221
Motivation
Modifications
copy_和copy_to的最后一个参数从false改为true,将异步拷贝改为同步拷贝,确保数据在读取前已完成Usage or Command
Accuracy Tests
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.