arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.00777cs.CL
收藏

HyLRA:混合层重用注意力用于高效长上下文推理

HyLRA: Hybrid Layer Reuse Attention for Efficient Long-Context Inference

City University of Hong Kong(香港城市大学);Theory Lab, Huawei Technologies(华为技术理论实验室)

Xuan Ai, Qingqing Yang, Peng Wang, Lei Deng, Lin Zhang, Renhai Chen, Gong Zhang

AI总结:

HyLRA通过混合层重用注意力机制,高效解决LLM长上下文推理中的二次计算瓶颈问题,提升吞吐量并保持性能。

摘要:

大型语言模型(LLMs)的长上下文推理受到注意力计算的二次计算复杂性和键值(KV)缓存的大量内存占用的限制。尽管现有的稀疏注意力机制试图通过利用固有的稀疏性来缓解这一问题,但它们通常依赖于刚性的模式或激进的剪枝,无法在效率和准确性之间实现最佳平衡。在本文中,我们引入了HyLRA(混合层重用注意力),这是一种由层间稀疏性分析驱动的新框架。我们的实证分析揭示了注意力机制的双重特性:内在层敏感性,即特定层需要完全的注意力以防止特征失真,以及层间相似性,即连续层共享大量关键令牌。基于这些观察,HyLRA采用离线动态规划方法来推导最优的层间策略。这种混合策略在敏感层上保留完整的注意力以确保鲁棒性,同时使容忍层能够通过直接重用前一层的前k个索引来避免二次计算。这种方法使LLMs能够将计算限制在最关键的令牌上,从而有效克服了密集注意力的二次瓶颈。广泛的评估显示,HyLRA在保持性能(精度下降小于1%)的同时,将推理吞吐量提高了6%至46%,始终优于最先进的稀疏注意力方法。HyLRA在https://anonymous.4open.science/r/unified-cache-management-CF80/上开源。

英文摘要:

Long-context inference in Large Language Models (LLMs) is bottlenecked by the quadratic computation complexity of attention and the substantial memory footprint of Key-Value (KV) caches. While existing sparse attention mechanisms attempt to mitigate this by exploiting inherent sparsity, they often rely on rigid patterns or aggressive pruning, failing to achieve an optimal balance between efficiency and accuracy. In this paper, we introduce {\bf HyLRA} ({\bf Hy}brid {\bf L}ayer {\bf R}euse {\bf A}ttention), a novel framework driven by layer-wise sparsity profiling. Our empirical analysis uncovers a dual characteristic in attention mechanics: \textit{intra-layer sensitivity}, where specific layers necessitate full attention to prevent feature distortion, and \textit{inter-layer similarity}, where consecutive layers share substantial critical tokens. Based on these observations, HyLRA employs an offline dynamic programming approach to derive an optimal layer-wise policy. This hybrid strategy retains full attention for sensitive layers to ensure robustness, while enabling tolerant layers to bypass quadratic calculations by directly reusing top-$k$ indices from preceding layers. This approach allows LLMs to restrict computation to the most critical tokens, effectively overcoming the quadratic bottleneck of dense attention. Extensive evaluations demonstrate that HyLRA improves inference throughput by 6\%--46\% while maintaining comparable performance (with $<1\%$ accuracy degradation), consistently outperforming state-of-the-art sparse attention methods. HyLRA is open source at \href{https://anonymous.4open.science/r/unified-cache-management-CF80/}{\texttt{/r/unified-cache-management-CF80/}}

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

↑