Skip to content

[RL] [KVCache] let cache transfer managers update key prefix after weight update and add unit tests#7083

Merged
Jiang-Jia-Jun merged 4 commits intoPaddlePaddle:developfrom
liyonghua0910:develop+20260326_add_tests
Apr 2, 2026
Merged

[RL] [KVCache] let cache transfer managers update key prefix after weight update and add unit tests#7083
Jiang-Jia-Jun merged 4 commits intoPaddlePaddle:developfrom
liyonghua0910:develop+20260326_add_tests

Conversation

@liyonghua0910
Copy link
Copy Markdown
Collaborator

@liyonghua0910 liyonghua0910 commented Mar 30, 2026

Motivation

This PR updates the mooncake key_prefix during update_weights.

Previously, key_prefix was only refreshed in resume. To make cache metadata align with the new model version earlier, this PR adds one more refresh in update_weights, while keeping the existing refresh in resume.

Modifications

  • Add cache-transfer control handling in EngineService._control_update_weights()
  • Add update_weights handler in CacheTransferManager
  • Keep resume refreshing key_prefix
  • Add unit tests for both update_weights and resume paths

Usage or Command

No new API.

Behavior after this PR:

  • update_weights refreshes key_prefix
  • resume also refreshes key_prefix
pytest -q tests/engine/test_common_engine.py -k "control_update_weights"
pytest -q tests/cache_manager/test_cache_transfer_manager.py -k "handle_resume or handle_update_weights"

Accuracy Tests

N/A

Checklist

  • Add at least a tag in the PR title.
  • Format your code, run pre-commit before commit.
  • Add 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 Mar 30, 2026

Thanks for your contribution!

@liyonghua0910 liyonghua0910 changed the title [CI] add unit tests for sleep/wakeup control method [RL] [KVCache] let cache transfer managers update key prefix after weight update and add unit tests Mar 30, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@3651113). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/engine/common_engine.py 27.27% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7083   +/-   ##
==========================================
  Coverage           ?   74.15%           
==========================================
  Files              ?      376           
  Lines              ?    52873           
  Branches           ?     8251           
==========================================
  Hits               ?    39207           
  Misses             ?    10908           
  Partials           ?     2758           
Flag Coverage Δ
GPU 74.15% <52.94%> (?)

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

@fastdeploy-bot fastdeploy-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 | {{TIMESTAMP}}

📋 Review 摘要

PR 概述:在 update_weights 操作中添加缓存 key_prefix 的更新,使缓存元数据与新模型版本更早保持一致
变更范围cache_manager/engine/、测试文件
影响面 TagKVCache Engine

问题

未发现阻塞性问题。

代码亮点

  1. request_id 改进:将硬编码的 pause_transfer/resume_transfer 改为基于父请求 ID 的命名方式(如 {control_request.request_id}_pause_transfer),提升了请求追踪的可调试性。

  2. 一致的条件检查_handle_update_weights_handle_resume 都正确检查了 storage_backend_type is not None 才调用 _update_key_prefix()

  3. 测试覆盖充分:新增测试覆盖了正常路径(有 storage backend)和跳过路径(无 storage backend),以及相关的控制方法行为。

总体评价

代码实现清晰,逻辑正确,测试覆盖充分。PR 标题和描述均符合规范,可以合入。

@Jiang-Jia-Jun Jiang-Jia-Jun merged commit 98f3fc9 into PaddlePaddle:develop Apr 2, 2026
3 of 9 checks passed
cloudforge1 added a commit to CloudForge-Solutions/FastDeploy that referenced this pull request Apr 2, 2026
Merge with upstream test_engine.py (PR PaddlePaddle#7083) and add comprehensive
coverage for LLMEngine: lifecycle, worker signals, requests, utils,
stop_profile, and start error handling.
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.

5 participants