[KVCache][BugFix] Buffer early layer0 cache signals#7872
Conversation
|
Thanks for your contribution! |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-21 11:20:41
📋 Review 摘要
PR 概述:修复 PD 分离 V1 KVCache 场景下 layer0 prefill signal 可能早于 decode cache info 到达导致信号丢失的竞态问题,引入 pending buffer 机制确保信号不被丢弃。
变更范围:fastdeploy/cache_manager/cache_messager.py、tests/cache_manager/test_cache_messager.py
影响面 Tag:[KVCache] [PD Disaggregation]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 📝 PR 规范 | — | 标题含两个官方 Tag [KVCache][BugFix],§D1 要求仅含一个 |
📝 PR 规范检查
标题 [KVCache][BugFix] Buffer early layer0 cache signals 包含 [KVCache] 和 [BugFix] 两个官方 Tag,违反 checklist §D1「标题必须且仅能包含一个官方 Tag」规则。PR 描述结构完整(Motivation / Modifications / Usage or Command / Accuracy Tests / Checklist 均已覆盖),无需修改描述。
标题建议(可直接复制):
[BugFix] Fix early layer0 signal loss in KVCache PD disaggregation
总体评价
整体实现正确,逻辑清晰:锁顺序全程保持 engine_cache_task_thread_lock → pending_layer0_signal_lock 一致,无死锁风险;del idx_cache_task_dict 与 pop pending_layer0_signals 均在 engine_cache_task_thread_lock 内原子完成,无竞态;tasks_count.item() 修复了 Paddle Tensor 直接用于 range 的类型隐患;单元测试覆盖了 early buffer、pending 恢复、invalid 丢弃、跨 engine 隔离、任务完成清理五个关键场景,质量较高。仅标题双 Tag 规范问题,不阻塞合入。
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览当前 required 任务 9/10 通过,存在 1 个 required 失败任务(Approval),等待处理的 required 任务数 0。该失败为人工审批门禁,需完成 Approval 后再继续。
2 任务状态汇总日志列说明:失败任务直接使用 2.1 Required任务 : 9/10 通过
2.2 可选任务 — 28/32 通过
3 失败详情(仅 required)Approval — 需要人工审批(置信度: 高)根因摘要该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。 修复建议摘要请通过人工审批。 关键信息
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7872 +/- ##
==========================================
Coverage ? 63.61%
==========================================
Files ? 462
Lines ? 64513
Branches ? 9894
==========================================
Hits ? 41038
Misses ? 20697
Partials ? 2778
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:
|
Motivation
修复 PD 分离场景下,layer0 prefill signal 可能早于 decode cache info 到达的问题。此前
consume_signals会在cache_info未 ready 时跳过 signal,或在 cache task 尚未注册时直接投递,可能导致 layerwise cache send 入口丢失或断言失败。Modifications
CacheMessagerV1增加 pending layer0 signal 缓冲。current_id对应的 pending signal,避免误恢复其他 engine 的 signal。tasks_count未调用.item()导致 Paddle Tensor 直接用于range/比较的类型风险。Usage or Command
Accuracy Tests
不涉及模型前向、算子或输出精度变更。
Checklist
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.