[BugFix] Check optional params before .get() call in gqa_rope_write_cache#7311
Conversation
|
Thanks for your contribution! |
|
K11OntheBoat 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/2.5 #7311 +/- ##
==============================================
Coverage ? 69.62%
==============================================
Files ? 390
Lines ? 54376
Branches ? 8577
==============================================
Hits ? 37859
Misses ? 13805
Partials ? 2712
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:
|
f2af58e to
02b8783
Compare
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-13
📋 Review 摘要
PR 概述:修复 gqa_rope_write_cache 中 optional tensor 为空时调用 .get() 导致的断言错误,将参数从引用改为指针方式处理。
变更范围:custom_ops/gpu_ops/append_attn/
影响面 Tag:[BugFix] [OP]
📝 PR 规范检查
✅ PR 标题包含有效的 [BugFix] 标签
✅ PR 描述完整,包含 Motivation 和 Modifications
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🔴 Bug | custom_ops/gpu_ops/append_attn/gqa_rope_write_cache.cu:1240 |
cache_int8/fp8 分支缺少空指针检查 |
| 🔴 Bug | custom_ops/gpu_ops/append_attn/gqa_rope_write_cache.cu:1276 |
cache_int4_zp 分支缺少空指针检查 |
总体评价
PR 的修复方向正确,将参数类型改为指针允许传递 nullptr。但 AppendCacheKV 函数内部在解引用指针前缺少防御性检查,如果 cache_quant_type 需要某参数但传入的是 nullptr,会导致空指针解引用崩溃而非清晰的错误提示。建议添加断言或参数有效性检查。
10a5e1c
into
PaddlePaddle:release/2.5
Motivation
在gqa_rope_write_cache中, 存在针对 为空的optional tensor 使用.get()方法的情况;导致Paddle框架Assert错误:
python: paddle/include/paddle/utils/optional.h:563: paddle::optional::reference_const_type paddle::optional::get() const [with T = paddle::Tensor; reference_const_type = const paddle::Tensor&]: Assertion `this->is_initialized()' failed.”
Modifications
此PR采用更标准的C++写法,用指针表示可选参数, 不存在的Optional不使用 .get()方法,参数用nullptr向下传入的方法,可以修复此Assertion报错.
Note:
K11OntheBoat@2eea6fa 此PR給dev和2.6提了,规避了本PR处理的bug,但是那个PR并没提给2.5; 所以本PR专給2.5修复Bug使用