用模型自信度动态管理缓存,大幅降低长文本生成内存占用。
CONF-KV: Confidence-Aware KV Cache Eviction with Mixed-Precision Storage for Long-Horizon LLM

- 根据模型预测置信度动态调整每步缓存预算,不确定时保留更多上下文。
- 在4096 token长度下,内存占用接近固定512窗口,困惑度仅高1.5-2.1点。
- 适合长序列生成任务,尤其对内存敏感的推理场景有显著优势。
长序列大模型推理使键值(KV)缓存成为主要显存消耗项,逐标记注意力开销剧增。现有淘汰策略多依赖静态最近窗口或历史注意力,忽略了每解码步已计算的模型当前不确定性信号。本文提出CONF-KV,将下一个标记分布转化为标量置信度分数,据此动态决定每步缓存预算:模型不确定时保留更多上下文,自信时则激进剔除。在每个预算内,按累积注意力权重与时间近邻性综合排序,同时保留一个受保护的近期窗口以维持局部连贯性。结合块级在线软最大值注意力、混合FP16/INT8存储及分层金字塔式预算变体。在四个模型家族、最长4096标记的生成任务中,CONF-KV保持与固定512标记滑动窗口相近的内存占用,且困惑度仅比全缓存低1.5–2.1点;在32K标记的“针堆找针”任务中,检索准确率达91.4%,远超滑动窗口的53.8%和H2O的80.6%;在75个VisualWebArena任务中,以2.8倍更低的峰值内存实现95.3%的全缓存成功率。
原文摘要 · Abstract (English)
Long-horizon LLM inference turns the key--value (KV) cache into the dominant GPU memory consumer and makes per-token attention increasingly expensive. Many common eviction policies use static recency windows or historical attention, leaving unused a signal computed on every decoding step: the model's current uncertainty. We introduce CONF-KV, a KV-cache manager that converts the next-token distribution into a scalar confidence score and uses it to choose the per-step cache budget, retaining more context when the model is uncertain and pruning aggressively when it is confident. Within each budget, tokens are ranked by a composite of accumulated attention mass and recency, while a protected recent window preserves local coherence. We combine the policy with blockwise online-softmax attention, mixed FP16/INT8 storage, and a pyramidal per-layer budget variant. Across four model families and generated lengths up to 4K, CONF-KV stays near the footprint of a fixed 512-token sliding window while remaining within 1.5--2.1 perplexity points of full KV. On Needle-in-a-Haystack up to 32K tokens, CONF-KV reaches 91.4% retrieval accuracy versus 53.8% for sliding windows and 80.6% for H2O; on 75 VisualWebArena tasks it retains 95.3% of full-KV success at 2.8 times lower peak memory.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。