arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2511.04686cs.LGcs.AIcs.CL
收藏

面向大语言模型的有状态KV缓存管理:平衡空间、时间、准确性与位置保真度

Stateful KV Cache Management for LLMs: Balancing Space, Time, Accuracy, and Positional Fidelity

Florida International University(佛罗里达国际大学)

Pratik Poudel

AI总结:

本文研究有状态多轮场景下大语言模型KV缓存管理,发现缓存接近或超过训练上下文窗口及破坏位置编码连贯性会导致生成质量急剧下降,并提出保留连续上下文块的简单策略比复杂逐出策略更有效。

摘要:

键值(KV)缓存对于大语言模型(LLMs)中高效的自回归推理至关重要,然而其在有状态多轮场景下的无界增长带来了重大挑战。本文考察了KV缓存管理策略、meta-llama/Meta-Llama-3-8b-instruct等模型的架构上下文限制,以及常被忽视的位置编码完整性之间的相互作用。通过使用有状态基准测试框架进行实证分析,我们表明当累积的KV缓存接近或超过模型训练时的上下文窗口(例如Llama 3的8192个token)时,LLM生成质量会急剧下降,这是一种不同于GPU内存耗尽的失效模式。常见的逐出策略,即使是高保留率的策略(例如通过AttentionTop保留99%),如果破坏了位置连贯性,也可能使性能恶化。由于LLM依赖一致的位置信号(例如RoPE),通过移除非连续token来压缩缓存会扰乱这些信号并导致退化输出。我们进一步表明,保留连续上下文块的简单策略(例如保留初始“要点”)可以产生比复杂或破坏位置结构的策略更连贯的生成结果。我们主张采用尊重架构限制、保留位置结构并从整体上而不仅仅是大小角度看待“缓存健康”的逐出技术。

英文摘要:

The Key-Value (KV) cache is integral to efficient autoregressive inference in large language models (LLMs), yet its unbounded growth in stateful multi-turn scenarios presents major challenges. This paper examines the interplay between KV cache management strategies, the architectural context limits of models like meta-llama/Meta-Llama-3-8b-instruct, and the often-overlooked integrity of positional encodings. Through empirical analysis using a stateful benchmarking framework, we show that LLM generation quality degrades sharply when the accumulated KV cache approaches or exceeds the model's trained context window (e.g., 8192 tokens for Llama 3), a failure mode distinct from GPU memory exhaustion. Common eviction strategies, even high-retention ones (e.g., 99% via AttentionTop), can worsen performance if they disrupt positional coherence. Because LLMs rely on consistent positional signals (e.g., RoPE), compacting a cache by removing non-contiguous tokens can scramble these signals and lead to degenerative outputs. We further show that simple strategies preserving contiguous context blocks (e.g., keeping an initial "gist") can yield more coherent generations than complex or positionally disruptive ones. We advocate for eviction techniques that respect architectural limits, preserve positional structure, and view "cache health" holistically beyond mere size.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑