联合子空间稀疏注意力用于高效长上下文解码
研究论文 · 2026/10/15
稀疏注意力减少了主导长上下文LLM解码的KV缓存流量,但实用方法大多在粗粒度上操作。令牌级选择提供了更细的控制,但面临两个挑战:低维评分可能丢失准确排序所需的查询-键结构,而收集分散的选定令牌可能抵消由此产生的延迟收益。我们引入了联合子空间稀疏注意力(JSSA)来解决这两个挑战。对于选择质量,JSSA通过最小化令牌分数保留误差来学习共享的低维查询-键子空间。我们用可处理的边际目标来上界由此产生的非凸目标,该目标允许闭式谱解;在测试设置中,直接细化精确目标没有可测量的改进。对于执行效率,我们开发了一种无收集的令牌级索引注意力内核,在标准分组查询注意力(GQA)KV缓存布局下支持每个KV头的不同选择。在标准GQA、混合滑动窗口/全局注意力和多头潜在注意力(MLA)模型中,JSSA始终接近全KV精度,同时避免了竞争方法中观察到的显著生成长度膨胀和架构相关故障。在NVIDIA B200 GPU上,JSSA在128K上下文下实现了高达6.43倍于全KV注意力的解码吞吐量。JSSA在没有模型训练的情况下实现了与模型原生DSA相当的推理精度,即使在700B规模的大模型上也达到了其解码吞吐量的96-99%。
JSSA在保持接近全KV精度的同时,显著提升长上下文解码效率,且无需训练即可适配多种注意力架构,具有很高的实用价值。
Sparse attention reduces the KV-cache traffic that dominates long-context LLM decoding, but practical methods largely operate at coarse granularity. Token-level selection offers finer control, yet presents two challenges: low-dimensional scoring may lose query--key structure needed for accurate ranking, while gathering scattered selected tokens can offset the resulting latency benefit. We introduce Joint Subspace Sparse Attention (JSSA) to address both challenges. For selection quality, JSSA learns a shared low-dimensional query--key subspace by minimizing token-score preservation error. We upper-bound the resulting non-convex objective with a tractable marginal objective that admits a closed-form spectral solution; direct refinement of the exact objective provides no measurable improvement in the tested settings. For execution efficiency, we develop a gather-free token-level indexed-attention kernel that supports distinct per-KV-head selections under the standard grouped-query attention (GQA) KV-cache layout. Across standard GQA, hybrid sliding-window/global attention, and Multi-head Latent Attention (MLA) models, JSSA consistently remains close to full-KV accuracy while avoiding the substantial generation-length inflation and architecture-dependent failures observed with competing methods. On an NVIDIA B200 GPU, JSSA achieves up to 6.43times the decoding throughput of full-KV attention at 128K context. JSSA achieves reasoning accuracy comparable to model-native DSA without model training and reaches 96--99\% of its decoding throughput even at 700B scale large models.