当 resident reusable KV(已计算、待复用的前缀 KV)和 active live KV(在飞请求正使用的 KV)无法同时装入一个物理 KV pool 时,现有运行时(vLLM/SGLang/TRT-LLM)只有 retention primitives 而缺少一个 conformance contract 来定义"被接受的 resident claim 被破坏时运行时必须做什么"。本文提出 Resident KV Claims 合约:定义 claim 生命周期、materialization predicate、active/resident feasibility boundary 和 claim-level telemetry;通过 vLLM 原型和 MicroRuntime 验证 write no-admit ≠ resident 保护、hard protection 能将隐性 resident 损失转为可观测的 active refusal。
Q1 痛点: 现有 KV-cache 复用机制(priority eviction、TTL、offload、radix cache)暴露了 retention 策略,但没有定义 合约——当 accepted future-reuse state 与 active live KV 冲突时,运行时无义务报告 resident 损失或采取显式 action,导致 resident prefix 被当普通 cache victim 静默驱逐,外部观察者无法区分"正常缓存淘汰"和"合约违反"。
Q2 方法: 定义 Resident KV Claim 合约:
核心技术壁垒: 将"KV block 驱逐"从一个扁平的 cache replacement 问题提升为 typed ownership contract——区分 ordinary eviction(无 claim)、policy relaxation(demotion/expiry 后 loss)、和 true claim harm(accepted claim 的 predicate-breaking loss 前无 release event)。这要求运行时实现 claim-scoped lifecycle tracking 而非仅 block-level event logging。
Q3 结果: 在 vLLM 0.19.1 原型上验证:

Figure 1 总结核心论点:resident KV claims 让 active/resident infeasibility 变为 observable event 而非被隐式还原为普通 cache eviction。左侧是现有运行时行为(resident prefix 被静默驱逐),右侧是 contract 行为(infeasibility 触发显式 action + telemetry)。

Figure 2 展示 claim 的最小生命周期状态机。关键路径:submitted → accepted → materialized 是正常流程;accepted 可经 demotion/expiry 显式 release 后 block loss 不构成 harm;未经 release 的 predicate-breaking loss 触发 claim_harmed 事件。

Figure 3 展示当 feasibility boundary 被违反时的仲裁流程。运行时必须从 13 种 contract outcomes(Table 5)中选择显式 action:evict residents / refuse active / defer / offload / route elsewhere / relax claim 等。
三资源分解模型:
| 符号 | 含义 |
|---|---|
| $\text{protected\_resident\_kv}$ | 被 accepted claim 保护的 resident blocks 数 |
| $\text{active\_live\_kv}$ | 当前在飞请求需要的 live KV blocks |
| $\text{usable\_kv}$ | KV pool 可用 block 总数 |
| $B$ | Block size (paper 中 = 16 tokens) |
$$\text{protected\_resident\_kv} + \text{active\_live\_kv} \leq \text{usable\_kv}$$
物理意义: 这是一个硬容量约束——当两侧之和超过物理池大小时,系统物理上不可能同时保持 resident claim 和服务 active request,必须做出显式 trade-off。

核心发现:naive fair share 保留了最多 raw tokens (480+320+304=1104) 但 thresholded value = 0,因为 fragments 没有形成 leading contiguous prefix。Complete-prefix 和 value-density 策略保留较少 total tokens 但 value = 18(40+40 leading blocks × 16 tokens/block 覆盖有效前缀)。这证明 useful resident value 是 materialization shape 的函数,不是 retained block count。

Write no-admit 成功阻止 bulky repeat reuse (1120→0 cached tokens),但 resident small_hot 和 small_warm 均返回 0——residents 仍被 active allocation 驱逐。这是因为 write admission 和 active live allocation 是两个独立资源操作:前者控制"新 KV 能否入 cache",后者控制"active 请求占用 pool 的哪些 blocks"。

容量 sweep 是本文核心实验结果。在 usable_kv < 130 时:native 和 write-no-admit 策略服务 active 但丢失 resident materialization;hard resident exclusion 保留 accepted resident claim 并将 active/resident infeasibility 转为 scheduler-visible refusal。在 usable_kv ≥ 130 时:active 和 resident KV 共存,三种策略行为一致。
| 指标 | 观测值 |
|---|---|
| 模型 | SmolLM2-135M-Instruct |
| Protected resident materialized events | 40 |
| Active deferred events | 1 |
| Active refused events | 1 |
| Stop reason | protected_resident_capacity_refused |
| Blocking claim ids | ["claim:live-resident"] |
| 容量证据 | 40 + 46 = 86 > 68, shortfall 19 blocks |
在真实 vllm.LLM.generate 路径上,protected resident claim 被 accept 后,active request 需要 46 blocks 但仅 28 blocks 可用(68 - 40 = 28),触发 active refusal 并归因到 blocking claim。
| 请求 | Cached tokens | TTFT |
|---|---|---|
| First | 0 | ~0.345s |
| Repeat 1 | 464 | ~0.042s |
| Repeat 2 | 464 | ~0.035s |
Qwen2.5-Coder-7B-Instruct 运行表明 prefix reuse 有 serving-visible 价值(8-10× TTFT 降低)。Paper 明确声明这仅为 motivation,不是 arbiter performance gain 的证据。
| Step | 论证节点 | 支撑证据 | 前置依赖 |
|---|---|---|---|
| 1 | KV cache 应分解为三种独立资源(resident / active / future admission) | §3.1 定义 + §5.2 write no-admit 实验(no-admit 只控制第三资源,不保护第一资源) | — |
| 2 | 当 protected_resident + active_live > usable 时存在物理不可行性 | §3.4 feasibility boundary + §5.3 的 60/70/80 数值反例 | Step 1 |
| 3 | 现有 primitives (priority / TTL / offload / no-admit) 单独均不构成完整合约 | §2.2 Table 1 逐系统审计 + §5.2 no-admit 负面实验 + §5.3 chunking 不绑定 live KV | Step 1, 2 |
| 4 | 需要一个 typed claim 生命周期来区分 ordinary eviction / policy relaxation / true harm | §3.2 Table 4 claim-harm semantics + §5.4 conformance suite L1-L7 | Step 2, 3 |
| 5 | Hard protected-resident exclusion 可将隐性 resident loss 转为显式 active refusal | §5.3 capacity sweep (Fig 4) + §5.4 live scheduler pressure (Table 10) | Step 4 |
| 6 | 合约是 operational 的:最小 vLLM 原型在 allocator-level 和 scheduler-path 两条路径验证 | §4.3 原型描述 + §5.3-5.4 结果 + Appendix A 可复现命令 | Step 5 |
gustavgauge/kv-residency-microruntime@0dca404gustavgauge/kv-residency-vllm-arbiter@816541dactive_request_refused 事件,附带 blocking_claim_ids 归因。| 实验 | 命令 |
|---|---|
| Q1 materialization | make materialization-fidelity |
| Q2 no-admit probe | make no-admit-probe |
| Q3 capacity sweep | make capacity-sweep |
| Q4 conformance suite | make conformance |
| Live scheduler pressure | make live-scheduler-pressure |
| TTFT motivation | make live-scheduler |
b1388b1);patch-level implementation,非 upstream API;SGLang / TRT-LLM 的 existing primitives 为合约的 plausible lowering targets