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

从刚性到动态:面向长上下文LLM的熵引导自适应推理

From Rigid to Dynamic: Entropy-Guided Adaptive Inference for Long-Context LLMs

Department of Computing, PolyU(香港理工大学计算学系);DSA, HKUST(GZ)(香港科技大学(广州)数据科学与分析学域);CSE, HKUST(香港科技大学计算机科学与工程学系)

Zhanchao Xu, Haoyang Li, Qingfa Xiao, Fei Teng, Chen Jason Zhang, Lei Chen, Qing Li

AI总结:

提出EntropyInfer框架,利用注意力熵在预填充阶段自适应分配计算资源,并在解码阶段通过生成令牌压缩KV缓存,实现长上下文LLM的高效推理。

摘要:

现有的用于长上下文LLM推理的稀疏注意力和KV缓存压缩方法通常应用固定的稀疏模式或跨所有注意力头的统一预算,忽略了头和上下文之间注意力行为的显著变化。我们观察到注意力头之间存在两种不同的熵模式:刚性头,其熵在输入段中保持接近零;动态头,其熵显著波动。至关重要的是,这些类型的分布是上下文相关的,无法离线预先确定。因此,我们提出了EntropyInfer,一个无需训练框架,在预填充期间使用注意力熵在单个头和段的粒度上自适应分配计算。对于解码,我们引入了一种潜在KV缓存压缩方案,该方案利用生成的输出令牌(而非仅预填充令牌)来识别和保留最关键的缓存条目。在Llama、Qwen和openPangu模型系列上的大量实验表明,EntropyInfer在包括SnapKV、AdaKV和CritiPrefill在内的基线上持续取得优势,在超过100k令牌的情况下实现了高达2.39倍的端到端加速,同时与全注意力相比质量下降最小。代码已发布在https://github.com/SHA-4096/EntropyInfer。

英文摘要:

Existing sparse attention and KV cache compression methods for long-context LLM inference typically apply fixed sparsity patterns or uniform budgets across all attention heads, overlooking the substantial variation in attention behavior among heads and contexts. We observe two distinct entropy patterns among attention heads: Rigid Heads, whose entropy stays near zero across input segments, and Dynamic Heads, whose entropy fluctuates significantly. Crucially, the distribution of these types is context-dependent and cannot be predetermined offline. We therefore propose EntropyInfer, a training-free framework that uses attention entropy to adaptively allocate compute at the granularity of individual heads and segments during prefilling. For decoding, we introduce a latent KV cache compression scheme that leverages generated output tokens, rather than prefill tokens alone, to identify and retain the most critical cache entries. Extensive experiments on Llama, Qwen and openPangu model series show that EntropyInfer consistently outperforms baselines including SnapKV, AdaKV, and CritiPrefill, achieving up to 2.39$\times$ end-to-end speedup beyond 100k tokens with minimal quality degradation compared to full attention. The code is released in https://github.com/SHA-4096/EntropyInfer.

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

↑