Skip to content

[XPU] fix bug and teporary fix for rope 3d#7465

Open
RuohengMa wants to merge 1 commit intoPaddlePaddle:developfrom
RuohengMa:fix_bug
Open

[XPU] fix bug and teporary fix for rope 3d#7465
RuohengMa wants to merge 1 commit intoPaddlePaddle:developfrom
RuohengMa:fix_bug

Conversation

@RuohengMa
Copy link
Copy Markdown
Contributor

Motivation

fix bug and teporary fix for rope 3d

Modifications

fix bug and teporary fix for rope 3d

Usage or Command

None

Accuracy Tests

None

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[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]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 17, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the XPU label Apr 17, 2026
PaddlePaddle-bot

This comment was marked as outdated.

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review | 2026-04-17 17:28 CST

📋 Review 摘要

PR 概述:修复 XPU 上 rope_3d 场景下 spliced split kvcache 的崩溃问题,以及 GetInferParam 中 decoder_seq_lod 循环边界 bug。
变更范围custom_ops/xpu_ops/src/ops/
影响面 TagXPU OP

问题

级别 文件 概述
🟡 建议 block_attn_spliced.cc:244 外层已排除 rope_3d,内层 if (rope_3d) 成为死代码,建议清理
🟡 建议 block_attn_spliced.cc:553 同上,decoder 路径相同的死代码问题

总体评价

本次修复逻辑正确:通过在外层条件加入 !rope_3d 使 rope_3d 场景绕过不支持的 splice 路径,get_infer_param.cc 中循环上界修正与 decoder_seq_lod_vec(大小 bsz + 1)一致,消除了遍历不完整的 bug。建议顺手清理内层已不可达的 if (rope_3d) 死代码块。

if (FLAGS_encoder_splice) {
// TODO: spliced split kvcache should support rope3d
if (FLAGS_encoder_splice && !rope_3d) {
if (rope_3d) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 外层条件已加入 !rope_3d,此处 if (rope_3d) 永远为 false,PD_THROW 不可达,建议删除这段死代码。

  // TODO: spliced split kvcache should support rope3d
  if (FLAGS_encoder_splice && !rope_3d) {
-   if (rope_3d) {
-     PD_THROW("split_kvcache_encoder does not support rope_3d == true!");
-   }
    paddle::Place place = qkv.place();

if (FLAGS_decoder_splice && !rope_3d) {
// not yet supported
if (rope_3d) {
PD_THROW("split_kvcache_decoder does not support rope_3d == true!");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 与 encoder 路径相同,外层 !rope_3d 使得内层 if (rope_3d) 不可达,建议一并清理。

  // TODO: spliced split kvcache should support rope3d
  if (FLAGS_decoder_splice && !rope_3d) {
-   // not yet supported
-   if (rope_3d) {
-     PD_THROW("split_kvcache_decoder does not support rope_3d == true!");
-   }
    if (std::is_same<TKV_CACHE, int8_t>::value &&

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@91b8bf2). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7465   +/-   ##
==========================================
  Coverage           ?   73.87%           
==========================================
  Files              ?      398           
  Lines              ?    54977           
  Branches           ?     8613           
==========================================
  Hits               ?    40613           
  Misses             ?    11649           
  Partials           ?     2715           
Flag Coverage Δ
GPU 73.87% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants