Resident KV Claims: A Conformance Contract for Future Reuse under Active KV Pressure

framework 2605.24259
kv-cacheprefix-cachingserving-contractmemory-managementresident-claimconformance-testing

§1 TL;DR #

当 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。


§2 Q1 / Q2 / Q3 #

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 原型上验证:


§3 架构 / 方法图 #

Figure 1: Resident claim thesis — making active/resident infeasibility observable

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

Figure 2: Resident claim lifecycle state machine

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

Figure 3: Active/resident KV arbitration flow

Figure 3 展示当 feasibility boundary 被违反时的仲裁流程。运行时必须从 13 种 contract outcomes(Table 5)中选择显式 action:evict residents / refuse active / defer / offload / route elsewhere / relax claim 等。

三资源分解模型:

graph TD subgraph "KV Pool (usable_kv blocks)" R["Resident Reusable KV
已计算前缀,待复用"] A["Active Live KV
在飞请求占用"] end F["Future Reusable Admission
新 KV 是否入 cache"] REQ[New Request] --> FCHECK{feasibility check
R + A ≤ pool?} FCHECK -->|feasible| SERVE[Serve & preserve] FCHECK -->|infeasible| ARB[Arbiter] ARB --> ACT1[Evict/demote resident] ARB --> ACT2[Refuse/defer active] ARB --> ACT3[Offload/route/recompute] F -.->|write no-admit| BLOCK[Block future reuse admission
不影响 active allocation]

§4 作者证明 #

符号表 #

符号含义
$\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。

6 项验证 #

  1. 不等式可违反性: 60 + 70 = 130 > 80,数值上确认在受控场景中边界被违反。
  2. Write no-admit 不等价 resident protection: no-admit 控制 future reusable admission(第三资源),不控制 active live allocation(第二资源)。Active 请求仍从共享 pool 分配 block,可驱逐 resident。Table 7 实证确认。
  3. Chunking ≠ bounding live KV: 4-chunk schedule (20/20/20/10) 在 full attention 下累积到 70 live blocks。Table 8 实证确认。
  4. Hard protection 改变失败模式而非消除约束: protection 将 resident loss 转为 active allocation failure;不会让 130 blocks 装入 80-block pool。Table 9 实证确认。
  5. Block count ≠ useful value: naive fair share 保留 1104 tokens 但 thresholded value = 0;complete-prefix 保留较少 total blocks 但 value = 18。Table 6 实证确认。
  6. Claim harm 语义唯一性: 同一 block loss 在无 claim / demotion 后 / expiry 后 / accepted claim 未 release 四种情况下产生不同 telemetry 语义。Table 4 定义确认。

  7. §5 实验与数据 #

    5.1 Retained tokens vs. materialization value #

    Table 6: Retained tokens versus thresholded materialization value

    核心发现: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。

    5.2 Write no-admit boundary #

    Table 7: Effect of write no-admit on active reuse and resident survival

    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"。

    5.3 Capacity sweep (核心实验) #

    Figure 4: Capacity sweep for 60-block resident claim and 70-block active request

    容量 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 共存,三种策略行为一致。

    5.4 Live scheduler pressure path #

    指标观测值
    模型SmolLM2-135M-Instruct
    Protected resident materialized events40
    Active deferred events1
    Active refused events1
    Stop reasonprotected_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。

    5.5 TTFT motivation (非 arbiter 性能声明) #

    请求Cached tokensTTFT
    First0~0.345s
    Repeat 1464~0.042s
    Repeat 2464~0.035s

    Qwen2.5-Coder-7B-Instruct 运行表明 prefix reuse 有 serving-visible 价值(8-10× TTFT 降低)。Paper 明确声明这仅为 motivation,不是 arbiter performance gain 的证据。


    §6 论证链 #

    Step论证节点支撑证据前置依赖
    1KV 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 KVStep 1, 2
    4需要一个 typed claim 生命周期来区分 ordinary eviction / policy relaxation / true harm§3.2 Table 4 claim-harm semantics + §5.4 conformance suite L1-L7Step 2, 3
    5Hard 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

    §7 实现 cross-reference #

    公开代码仓库 #

    • MicroRuntime: gustavgauge/kv-residency-microruntime@0dca404
    • vLLM arbiter patch: gustavgauge/kv-residency-vllm-arbiter@816541d

    关键实现细节 #

    1. Write no-admit 与 active allocation 的解耦:vLLM 原型通过 env-gated 机制对 selected request_ids 设置 write no-admit flag,但 active allocation 路径仍走标准 BlockPool allocator。这意味着 no-admit 只影响请求完成后 KV 是否被标记为 reusable,不影响请求服务期间的 block 分配路径——这一实现细节是 Table 7 负面结果的直接原因。
      1. Hard protected-resident victim exclusion:在 vLLM BlockPool 的 eviction victim selection 中加入 claim metadata 检查——标记为 hard_protected 的 blocks 不进入 free-queue candidate list。当 active 请求找不到足够 free blocks 时,分配失败信号沿 allocator → scheduler 路径传播为 active_request_refused 事件,附带 blocking_claim_ids 归因。
      2. 可复现命令 #

        实验命令
        Q1 materializationmake materialization-fidelity
        Q2 no-admit probemake no-admit-probe
        Q3 capacity sweepmake capacity-sweep
        Q4 conformance suitemake conformance
        Live scheduler pressuremake live-scheduler-pressure
        TTFT motivationmake live-scheduler

        Deployment context #

        • Serving stage: 本合约面向 prefill + decode 共享 KV pool 的场景;disaggregated prefill-decode 架构中 resident claims 主要作用在 decode worker 侧
        • Hardware affinity: 与具体 GPU 代际无关——合约是逻辑层抽象;但 HBM 容量直接决定 usable_kv 值,故 KV pressure 在 24GB/48GB 卡上比 80GB+ 卡更频繁触发
        • Ecosystem integration: 以 vLLM 0.19.1 为原型 base commit (b1388b1);patch-level implementation,非 upstream API;SGLang / TRT-LLM 的 existing primitives 为合约的 plausible lowering targets
        • Concurrency regime: 在高并发(≥64 concurrent requests)+ agentic multi-turn workload 下 resident/active 冲突最频繁