AI 译本 · Equalang
新上架PDF · 2026年11月翻译
加载中…
arXiv · 2026
多层索引器:DeepSeek 稀疏注意力中的重叠选择与注意力
Serdarcan Dilbaz, Arjun Krishna, Kiran Kamble, Daniel M. Bikel
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.
稀疏注意力通过稀疏化注意力矩阵来降低长上下文推理的成本:每个查询只关注序列中的一部分内容,这部分内容由固定模式决定,或像近期投入生产的 LLM 那样,针对每个查询单独学习。在 DeepSeek 稀疏注意力(DSA)中,也就是 DeepSeek-V3.2 和 GLM-5 系列采用的注意力机制中,每一层之前都有一个闪电索引器,它会为整个缓存中的 token 打分,并保留得分最高的 k=2048 个 token,供该层关注。在长上下文场景下,解码时间主要耗在索引器扫描上,而不是它所服务的稀疏注意力上。但相邻层选择的 token 几乎相同,因此某一层可以直接使用前一索引器层选出的内容,而不必使用自己的索引结果。这样便消除了依赖关系:每个索引器都可以与其所在层的注意力计算并行运行。由此得到的多层索引器(MLI)无需重新训练,也无需新增权重。默认实现不改变任何内核,直接运行于 SGLang 的生产解码计算图中;此外,还可选用融合解码内核,进一步加速 DeepSeek-V3.2。MLI 可与 IndexCache(GLM-5.2 以 IndexShare 之名提供的跨层复用机制)结合使用:IndexCache 在部分层中省去索引器,MLI 则隐藏其余层的扫描开销。我们按照 IndexCache 的协议,在保留率为 1/2 至 1/32(即保留索引器的层所占比例)、上下文长度为 10K 至 195K 的设置下,为 DeepSeek-V3.2 和 GLM-5 提供服务。在保留率相同的情况下,这种组合的解码速度快于 IndexCache:保留率为 1/2 时,DeepSeek-V3.2 最多快 14.5%,GLM-5 快 9.8%;保留率为 1/4 时,分别快 7.9% 和 5.1%。IndexCache 保留的索引器越多,提升就越明显;上下文越长,提升也越大。在保留率为 1/r 时,该组合的速度甚至快于保留率为 1/(2r) 的 IndexCache,同时保留两倍数量的新鲜选择结果:在 128K 上下文下,保留率为 1/4 时,其解码吞吐量达到未修改模型的 1.32 倍,高于 IndexCache 在保留率为 1/8 时的 1.28 倍。其 LongBench、RULER 和 LongBench v2 准确率与 IndexCache 相比,仅相差几个百分点。
PDF · 2026年11月翻译