Commit 0e288b5
[KVCache][Engine] fix has_pending_work and move swap/evict to worker layer
## Motivation
BatchRequest.__len__ 混入了 prefetch/swap/evict 任务数量,导致 engine 调度
逻辑(判断是否有待处理工作)出现误判;同时 swap/evict 提交散落在
gpu_model_runner 和 resource_manager 中,职责不清晰。
## Modifications
- engine/request.py: 新增 has_pending_work 属性,__len__ 恢复只计 requests
数量;has_pending_work 同时感知 prefetch/swap/evict 任务
- engine/common_engine.py: 用 has_pending_work 替换 len(batch_request) > 0
判断,逻辑更准确
- worker/worker_process.py: 将 submit_swap_tasks 调用移至 worker 层处理,
处理后清空 metadata 避免重复提交
- worker/gpu_model_runner.py: 移除重复的 submit_swap_tasks 调用
- engine/sched/resource_manager_v1.py: 调整 check_and_add_pending_backup /
issue_pending_backup / dispatch_pending_prefetches 执行顺序,去掉对
len(batch_request) 的依赖
- cache_manager/v1/cache_manager.py: 恢复 matched_nodes 按 device/host 分类
逻辑(之前被误注释)
## Usage or Command
```bash
# 启动服务(单机)
cd baidu/FastDeploy
bash run.sh
```
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 271d85c commit 0e288b5
6 files changed
Lines changed: 31 additions & 24 deletions
File tree
- fastdeploy
- cache_manager/v1
- engine
- sched
- worker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
524 | 523 | | |
525 | 524 | | |
526 | 525 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1112 | 1112 | | |
1113 | 1113 | | |
1114 | 1114 | | |
1115 | | - | |
| 1115 | + | |
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
| |||
1191 | 1191 | | |
1192 | 1192 | | |
1193 | 1193 | | |
1194 | | - | |
| 1194 | + | |
1195 | 1195 | | |
1196 | 1196 | | |
1197 | 1197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
704 | 711 | | |
705 | 712 | | |
706 | 713 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1276 | 1276 | | |
1277 | 1277 | | |
1278 | 1278 | | |
1279 | | - | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
1280 | 1282 | | |
1281 | 1283 | | |
1282 | 1284 | | |
1283 | 1285 | | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1290 | 1289 | | |
1291 | 1290 | | |
1292 | 1291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | 807 | | |
814 | 808 | | |
815 | 809 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
691 | 699 | | |
692 | 700 | | |
693 | 701 | | |
| |||
0 commit comments