LiteCache: 一种基于查询相似性的、以GPU为中心的KVCache子系统,用于高效的大语言模型推理
LiteCache: A Query Similarity-Driven, GPU-Centric KVCache Subsystem for Efficient LLM Inference
AI总结:
LiteCache通过基于查询相似性的头粒度缓存算法QSAC,减少CPU开销,充分利用PCIe带宽,提升解码吞吐量。
摘要:
在LLM推理过程中,KVCache内存使用量与序列长度和批处理大小成线性增长,常超出GPU容量。最近的提案将KV状态卸载到主机内存并使用top-k注意力减少传输。但其CPU中心化的GPU缓存管理和CPU-GPU数据传输带来了高开销并碎片化了CUDA Graph依赖的批量执行。为填补这一差距,我们观察到同一注意力头内的相邻查询具有强方向相似性,并检索高度重叠的top-k KV状态。这一洞察使我们能够开发一个简单的头粒度缓存算法QSAC,其中每个头在当前查询足够相似于前一个时重用之前缓存的KV状态。QSAC进一步简化了缓存管理原语并几乎消除了CPU参与。我们开发了LiteCache,一个集成了QSAC的KVCache子系统。LiteCache引入了一个以GPU为中心的同步控制器和推测性稀疏预取,使数据传输和计算完全重叠。这些机制产生了一种稳定且可预测的执行模式,仍与CUDA Graph所需的大批量执行模式兼容。在两个广泛使用的LLM上的评估表明,LiteCache在准确性上与基线相当,同时显著减少CPU开销,完全利用PCIe带宽,从而在H100和A40 GPU上将解码吞吐量提高10.7-224.2%,并轻松支持超过1M的序列长度。我们开源LiteCache在https://anonymous.4open.science/r/LiteCache-888D。
英文摘要:
During LLM inference, KVCache memory usage grows linearly with sequence length and batch size and often exceeds GPU capacity. Recent proposals offload KV states to host memory and reduce transfers using top-k attention. But their CPU-centric management of the on-GPU cache and CPU-GPU data movement incurs high overhead and fragments the bulk GPU execution that CUDA Graph relies on. To close this gap, we observe that adjacent queries within the same attention head exhibit strong directional similarity and retrieve highly overlapping top-k KV states. This insight enables a simple head granularity cache algorithm, QSAC, in which each head reuses its previously cached KV states whenever the current query is sufficiently similar to the prior one. QSAC further simplifies cache management primitives and cuts CPU involvement almost entirely. We develop LiteCache, a KVCache subsystem that incorporates QSAC. LiteCache introduces a GPU-centric synchronization controller and speculative sparse prefetching, enabling fully overlapped data movement and computation. These mechanisms produce a stable and predictable execution pattern that remains compatible with the bulk execution mode required by CUDA Graphs. Evaluation on two widely-used LLMs indicates that LiteCache achieves comparable accuracy to baselines, while sharply minimizing CPU overhead, fully utilizing PCIe bandwidth, thus improving decoding throughput by 10.7-224.2% on both H100 and A40 GPUs and easily supporting sequence lengths beyond 1M. We opensource LiteCache at https://anonymous.4open.science/r/LiteCache-888D.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。