CoSA: Accelerating Long-Context Inference via Proxy-Kernel Co-Designed Sparse Attention

Yufei Xue, Lin Niu, Hong Liu, Siran Liu, Hanyong Shao +4 more
7/28/2026
cs.CL

No confident code implementation found for this paper.

Abstract

The quadratic cost of self-attention makes long-context inference prohibitively expensive, and proxy-based block-sparse attention has become a practical remedy. Existing methods typically rely on a proxy to predict a binary sparse mask and a kernel to consume this mask and perform sparse attention computation. Such an approach is effective under moderate budgets. However, as the budget tightens, the estimated proxy inevitably drops some salient blocks, while the kernel can only apply the sparse mask mechanically, leading to an evident drop in model accuracy. We propose CoSA, a two-stage training-free Sparse Attention under proxy-kernel CO-design, which couples a Kernel-Aware Proxy (KAP) with an Ordered-Skipping Kernel (OSK). In the first stage, the KAP selects blocks under a moderate budget and produces an ordered mask that prescribes the order in which KV pages are visited in the kernel inner loop. In the second stage, the OSK applies this mask and skips more blocks under a tightened budget given online-softmax statistics. Across mainstream LLM backbones and long-context benchmarks, CoSA attains higher accuracy at lower budgets. Impressively, CoSA achieves a 4.93$\times$ attention speedup and reduces end-to-end Time-to-First-Token by 2.53$\times$ under a context length of 128K with negligible performance degradation.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{xue2026cosa,
  title  = {CoSA: Accelerating Long-Context Inference via Proxy-Kernel Co-Designed Sparse Attention},
  author = {Yufei Xue and Lin Niu and Hong Liu and Siran Liu and Hanyong Shao and Wei Liu and Guanghua Yu and Jianchen Zhu and Jun Zhang},
  year   = {2026},
  eprint = {2607.25291},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2607.25291v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2607.25291.svg)](https://codeofpaper.com/paper/2607.25291)

Discussion