Skip to content

[BugFix][XPU] Fix kv_cache management bug#7420

Merged
ddchenhao66 merged 1 commit intoPaddlePaddle:developfrom
ddchenhao66:kv_cache
Apr 16, 2026
Merged

[BugFix][XPU] Fix kv_cache management bug#7420
ddchenhao66 merged 1 commit intoPaddlePaddle:developfrom
ddchenhao66:kv_cache

Conversation

@ddchenhao66
Copy link
Copy Markdown
Collaborator

Motivation

当xpu开启attention store时,目前会存在在model runner中重复create kv cache的过程,需要解决重复分配cache问题

Modifications

在xpu model runner里修改create kv cache的条件逻辑

Usage or Command

Accuracy Tests

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 15, 2026

Thanks for your contribution!

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.

📋 Review 摘要

PR 概述:修复 XPU model runner 中 KV cache 重复创建的问题

变更范围:fastdeploy/worker/xpu_model_runner.py

影响面 Tag[XPU] [KVCache]

📝 PR 规范检查

✅ PR 标题和描述符合规范,包含必要的 [BugFix][XPU] 标签。

问题

未发现阻塞性问题。

总体评价

本次修改将 XPU model runner 的 KV cache 创建逻辑与 GPU/Metax 标准实现对齐。原逻辑只检查 splitwise_role == "mixed",忽略了 num_cpu_blockskvcache_storage_backend 两个条件,导致在开启 attention store 时会重复创建 KV cache。修改后的逻辑正确地修复了这个问题,代码简洁且符合项目规范。

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7420   +/-   ##
==========================================
  Coverage           ?   74.14%           
==========================================
  Files              ?      394           
  Lines              ?    54759           
  Branches           ?     8577           
==========================================
  Hits               ?    40599           
  Misses             ?    11423           
  Partials           ?     2737           
Flag Coverage Δ
GPU 74.14% <ø> (?)

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.

Copy link
Copy Markdown
Collaborator

@hong19860320 hong19860320 left a comment

Choose a reason for hiding this comment

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

LGTM

@ddchenhao66 ddchenhao66 merged commit e952720 into PaddlePaddle:develop Apr 16, 2026
34 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants