SCBench:基于KV缓存视角的长上下文方法分析
SCBench: A KV Cache-Centric Analysis of Long-Context Methods
AI总结:
SCBench从KV缓存生成、压缩、检索和加载四个维度系统评估长上下文方法,揭示亚线性内存方法在多轮场景中表现不佳,而动态稀疏编码和层级稀疏混合架构在保持性能的同时有效降低内存开销。
摘要:
长上下文大语言模型(LLM)已催生大量下游应用,但也带来了与计算和内存效率相关的重大挑战。为应对这些挑战,围绕KV缓存发展出了多种长上下文推理优化方法。然而,现有基准测试通常只评估单次请求场景,忽略了真实使用中KV缓存的完整生命周期。这一疏漏尤为关键,因为KV缓存复用已在vLLM和SGLang等LLM推理框架以及OpenAI、Microsoft、Google和Anthropic等LLM提供商中被广泛采用。为填补这一空白,我们提出了SCBench(SharedContextBench),一个从KV缓存中心视角评估长上下文方法的综合基准,涵盖四个维度:1)KV缓存生成,2)KV缓存压缩,3)KV缓存检索,4)KV缓存加载。具体而言,SCBench使用具有共享上下文的测试样例,涵盖12个任务和两种共享上下文模式,覆盖四类长上下文能力:字符串检索、语义检索、全局信息和多任务。基于此,我们对八类长上下文解决方案进行了广泛的KV缓存中心分析,包括门控线性RNN、Mamba-Attention混合架构,以及稀疏注意力、KV缓存丢弃、量化、检索、加载和提示压缩等高效方法。评估在8个长上下文LLM上进行。我们的发现表明,亚线性(sub-O(n))内存方法在多轮场景中表现不佳,而具有O(n)内存和亚平方(sub-O(n^2))预填充计算量的稀疏编码方法则表现稳健。动态稀疏性比静态模式产生更具表达力的KV缓存,混合架构中的层级稀疏性在降低内存占用的同时保持了强劲性能。此外,我们还识别出长文本生成场景中的注意力分布偏移问题。https://aka.ms/SCBench。
英文摘要:
Long-context LLMs have enabled numerous downstream applications but also introduced significant challenges related to computational and memory efficiency. To address these challenges, optimizations for long-context inference have been developed, centered around the KV cache. However, existing benchmarks often evaluate in single-request, neglecting the full lifecycle of the KV cache in real-world use. This oversight is particularly critical, as KV cache reuse has become widely adopted in LLMs inference frameworks, such as vLLM and SGLang, as well as by LLM providers, including OpenAI, Microsoft, Google, and Anthropic. To address this gap, we introduce SCBench(SharedContextBench), a comprehensive benchmark for evaluating long-context methods from a KV cachecentric perspective: 1) KV cache generation, 2) KV cache compression, 3) KV cache retrieval, 4) KV cache loading. Specifically, SCBench uses test examples with shared context, ranging 12 tasks with two shared context modes, covering four categories of long-context capabilities: string retrieval, semantic retrieval, global information, and multi-task. With it, we provide an extensive KV cache-centric analysis of eight categories long-context solutions, including Gated Linear RNNs, Mamba-Attention hybrids, and efficient methods such as sparse attention, KV cache dropping, quantization, retrieval, loading, and prompt compression. The evaluation is conducted on 8 long-context LLMs. Our findings show that sub-O(n) memory methods suffer in multi-turn scenarios, while sparse encoding with O(n) memory and sub-O(n^2) pre-filling computation perform robustly. Dynamic sparsity yields more expressive KV caches than static patterns, and layer-level sparsity in hybrid architectures reduces memory usage with strong performance. Additionally, we identify attention distribution shift issues in long-generation scenarios. https://aka.ms/SCBench.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。