Leyline:用于智能推理的 KV 缓存指令
Leyline: KV Cache Directives for Agentic Inference
AI总结:
针对智能体 LLM 中策略驱动的缓存编辑需求,提出 Leyline 服务端原语,通过声明式指令四元组和架构无关接口实现缓存拼接与截断,提升缓存命中率和求解率。
摘要:
现代 KV 缓存管理假设聊天机器人工作负载:提示一次性到达,缓存仅追加增长,因此前缀缓存和仅向前驱逐在构造上是正确的。智能体 LLM 打破了这一假设。它们的对话通过策略驱动的编辑演变:失败的工具调用被重试,过时的输出被丢弃,轨迹被转向。这导致两个不同的缓存问题。首先,相同的内容在轮次之间移动到新位置,使得精确前缀缓存失效,尽管底层 KV 仍然有效;最近针对 MLA 的位置无关缓存工作解决了这个重用问题。其次,也是本文的重点,策略可能需要指示服务系统主动移除或替换一段缓存内容,并继续而不重新预填充之后的所有内容。没有现有的原语提供此功能。生产智能体框架退回到每次编辑时重新预填充,支付完整的前缀重新计算成本;内核级驱逐方法自行决策,无法接受来自内核外部的策略指令。我们引入 Leyline,一个弥补这一差距的服务端原语。一个声明式指令四元组将编辑内容与保持位置正确性分离。策略声明编辑及其模式(原地拼接或前缀修剪的重新预填充以实现语义遗忘);一个架构无关的接口路由到每个架构的内核,通过闭式 RoPE 旋转校正恢复注意力计算。拼接内核将重放缓存命中率提高 11.2 个百分点,并将延迟降低最多 241 毫秒。通过同一接口路由的十行截断规则将 debug-gym 上的智能体求解率提高 14.3 个百分点。该机制是开放的;它启用的策略空间是未来的议程。
英文摘要:
Modern KV cache management assumes the chatbot workload: prompts arrive once and the cache grows append-only, so prefix caching and forward-only eviction are correct by construction. Agentic LLMs break this assumption. Their conversations evolve through policy-driven editing: failed tool calls are retried, stale outputs dropped, trajectories pivoted. Two distinct cache problems result. First, identical content moves to new positions between turns, invalidating exact-prefix caches even though the underlying KV would still be valid; recent work on position-independent caching for MLA addresses this reuse problem. Second, and this paper's focus, a policy may need to direct the serving system to actively remove or replace a span of cached content and continue without re-prefilling everything that came after. No existing primitive offers this. Production agentic harnesses fall back to re-prefill on every edit, paying full prefix-recomputation cost; kernel-level eviction methods make their own decisions and cannot accept policy directives from outside the kernel. We introduce Leyline, a serving-side primitive that closes this gap. A declarative directive 4-tuple separates what to edit from how to preserve position correctness. The policy declares the edit and its mode (in-place splice or prefix-trimmed re-prefill for semantic forgetting); an architecture-agnostic interface routes to a per-architecture kernel that restores attention math via a closed-form RoPE-rotation correction. The splice kernel lifts replay cache-hit by +11.2 pp and cuts latency by up to 241 ms. A ten-line truncation rule routed through the same interface lifts agentic solve rate by +14.3 pp on debug-gym. The mechanism is open; the policy space it enables is the agenda.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。