IndexCache: 通过跨层索引复用加速稀疏注意力
IndexCache: Accelerating Sparse Attention via Cross-Layer Index Reuse
AI总结:
IndexCache通过跨层索引复用减少75%的计算量,提升预填和解码速度,有效优化稀疏注意力效率。
摘要:
长上下文代理工作流已成为大型语言模型的重要应用场景,使得注意力效率对推理速度和服务成本至关重要。稀疏注意力有效解决了这一挑战,DeepSeek稀疏注意力(DSA)是代表性生产级解决方案:一个轻量级闪电索引器选择每个查询最相关的前k个token,将核心注意力从O(L²)降至O(Lk)。然而,索引器本身仍保持O(L²)的复杂度,并必须在每层独立运行,尽管连续层的top-k选择高度相似。我们提出了IndexCache,通过将层分为少量Full层(运行自身索引器)和多数Shared层(简单复用最近Full层的top-k索引)。我们提出两种互补方法来确定和优化此配置。无训练IndexCache应用一种贪心搜索算法,通过直接最小化校准集上的语言建模损失选择保留索引器的层,无需权重更新。有训练IndexCache引入多层蒸馏损失,训练每个保留的索引器对抗所有它服务层的平均注意力分布,使即使简单的交错模式也能匹配全索引器精度。在30B DSA模型上的实验结果表明,IndexCache可移除75%的索引器计算,质量降解可忽略不计,实现比标准DSA的预填速度提升达1.82倍,解码速度提升达1.48倍。这些积极结果进一步通过我们在生产级GLM-5模型上的初步实验得到验证(图1)。
英文摘要:
Long-context agentic workflows have emerged as a defining use case for large language models, making attention efficiency critical for both inference speed and serving cost. Sparse attention addresses this challenge effectively, and DeepSeek Sparse Attention (DSA) is a representative production-grade solution: a lightweight lightning indexer selects the top-k most relevant tokens per query, reducing core attention from $O(L^2)$ to $O(Lk)$. However, the indexer itself retains $O(L^2)$ complexity and must run independently at every layer, despite the fact that the resulting top-k selections are highly similar across consecutive layers. We present IndexCache, which exploits this cross-layer redundancy by partitioning layers into a small set of Full layers that run their own indexers and a majority of Shared layers that simply reuse the nearest Full layer's top-k indices. We propose two complementary approaches to determine and optimize this configuration. Training-free IndexCache applies a greedy search algorithm that selects which layers to retain indexers by directly minimizing language modeling loss on a calibration set, requiring no weight updates. Training-aware IndexCache introduces a multi-layer distillation loss that trains each retained indexer against the averaged attention distributions of all layers it serves, enabling even simple interleaved patterns to match full-indexer accuracy. Experimental results on a 30B DSA model show that IndexCache can remove 75% of indexer computations with negligible quality degradation, achieving up to 1.82$\times$ prefill speedup and 1.48$\times$ decode speedup compared to standard DSA. These positive results are further confirmed by our preliminary experiments on the production-scale GLM-5 model (Figure 1).
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。