多层索引器:DeepSeek稀疏注意力中的重叠选择与注意力

·

研究论文 · 2026/11/06

在DeepSeek稀疏注意力(DSA)中,每层前的闪电索引器扫描整个缓存并保留k=2048个最高分token,长上下文解码时该扫描成为瓶颈。由于相邻层选择的token几乎相同,多层索引器(MLI)让每层使用前一层索引器的选择,从而消除依赖,使索引器与注意力并发执行。MLI无需重新训练或新权重,默认实现无需修改内核,在SGLang生产解码图中运行,可选融合内核加速。MLI与IndexCache(GLM-5.2的IndexShare)组合:IndexCache减少索引器层数,MLI隐藏剩余扫描。在DeepSeek-V3.2和GLM-5上,保留率1/2至1/32、上下文10K至195K时,组合解码比IndexCache更快:1/2时分别快14.5%和9.8%,1/4时快7.9%和5.1%,且随上下文增长。保留率1/r时比IndexCache的1/(2r)更快且保留两倍新鲜选择:128K时1/4保留率达未修改模型解码吞吐的1.32倍,高于IndexCache 1/8时的1.28倍。LongBench、RULER和LongBench v2准确率与IndexCache相差几个百分点内。

该文章提出了一种无需训练、即插即用的稀疏注意力加速方法,在多个生产级大模型上显著提升长上下文解码吞吐,同时保持准确率,对高效推理部署有直接价值。

Sparse attention cuts the cost of long-context inference by making the attention matrix sparse: each query attends only a subset of the sequence, chosen by a fixed pattern or, in recent production LLMs, learned per query. In DeepSeek Sparse Attention (DSA), the attention of DeepSeek-V3.2 and the GLM-5 family, every layer is preceded by a lightning indexer that scores the whole cache and keeps the k=2048 highest-scoring tokens for the layer to attend. At long context this indexer scan, not the sparse attention it feeds, is where the decode time goes. But adjacent layers select nearly the same tokens, so a layer can attend the selection of the previous indexer layer instead of its own. This removes the dependency: each indexer then runs concurrently with the attention of its layer. The resulting Multi-layer Indexer (MLI) needs no retraining and no new weights. Its default realization changes no kernel, running inside SGLang's production decode graph; an optional fused decode kernel accelerates it further on DeepSeek-V3.2. MLI composes with IndexCache (the cross-layer reuse GLM-5.2 ships as IndexShare): IndexCache drops the indexer from some layers, and MLI hides the scan on the rest. We serve DeepSeek-V3.2 and GLM-5 under IndexCache's protocol at retentions 1/2 to 1/32 (the fraction of layers that keep an indexer) and contexts 10K to 195K. At equal retention the composition decodes faster than IndexCache: up to 14.5% faster on DeepSeek-V3.2 and 9.8% on GLM-5 at 1/2, and 7.9% and 5.1% at 1/4, largest where IndexCache keeps the most indexers and growing with context. At retention 1/r it is faster still than IndexCache at 1/(2r) while keeping twice the fresh selections: at 128K it reaches 1.32x the unmodified model's decode throughput at 1/4, above IndexCache's 1.28x at 1/8. Its LongBench, RULER and LongBench v2 accuracy stays within a few percentage points of IndexCache's.

阅读原文

参与讨论