Locret:通过在消费级设备上训练保留头增强长上下文LLM推理中的驱逐机制
Locret: Enhancing Eviction in Long-Context LLM Inference with Trained Retaining Heads on Consumer-Grade Devices
AI总结:
为解决LLM长上下文推理在消费级设备上的内存瓶颈,提出首个兼容分块预填充的Locret框架,利用可学习的保留头精确驱逐KV缓存单元,在性能损失不到10%下实现20倍压缩比,并在单张4090上支持128K+长上下文推理。
摘要:
扩大大型语言模型(LLM)的输入上下文长度会导致计算成本和内存占用显著增加,以维持注意力键值(KV)缓存。现有的KV缓存压缩方法存在压缩策略低效和内存减少效果有限的问题,使得LLM难以在消费级设备上进行长上下文推理,尤其是在推理长上下文流输入时。这些障碍阻碍了消费级设备支持更复杂的应用,对LLM的普及化提出了挑战。为克服此问题,我们提出了Locret,这是首个创建与分块预填充兼容的驱逐策略的框架。通过使用可学习的保留头评估KV缓存单元的因果重要性,Locret能够精确驱逐缓存单元,从而促进高效的长上下文推理。在我们广泛的经验研究中,Locret在内存效率和生成质量方面均优于近期流行且具竞争力的方法——Locret在性能损失不到10%的情况下,实现了高达20倍的KV缓存压缩比。此外,Locret在单个NVIDIA 4090 GPU上实现了128K+长上下文推理,且不妥协生成质量,仅需不到1个GPU小时的额外训练。
英文摘要:
Scaling the input context length of a large language model (LLM) incurs a significant increase in computation cost and memory footprint to maintain the attention key-value (KV) cache. Existing KV cache compression methods suffer from inefficient compression strategies and limited memory reduction effects, making it difficult for LLMs to conduct long-context inference on consumer-grade devices, especially when inferring long-context stream input. Such obstacles prevent consumer-grade devices from supporting more complex applications, creating challenges for the democratization of LLMs. To overcome this, we propose Locret, the first framework to create an eviction policy compatible with chunked prefill. By evaluating the causal importance of KV cache units by learnable retaining heads, Locret enables precise eviction of cache units, facilitating efficient long-context inference. In our extensive empirical studies, Locret outperforms the recent popular and competitive approaches in terms of memory efficiency and generation quality -- Locret achieves up to 20x of KV cache compression ratio within less than 10% performance loss. Furthermore, Locret achieves 128K+ long-context inference on a single NVIDIA 4090 GPU without compromising generation quality and only costs <1 GPU hour of additional training.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。