Papers › Post-Training Sparse Attention with Double Sparsity

Post-Training Sparse Attention with Double Sparsity

11 Aug 2024arXiv:2408.07092archive 2025-07-28

Shuo Yang, Ying Sheng, Joseph E. Gonzalez, Ion Stoica, Lianmin Zheng

The inference process for large language models is slow and memory-intensive, with one of the most critical bottlenecks being excessive Key-Value (KV) cache accesses. This paper introduces "Double Sparsity," a novel post-training sparse attention technique designed to alleviate this bottleneck by reducing KV cache access. Double Sparsity combines token sparsity, which focuses on utilizing only the important tokens for computing self-attention, with channel sparsity, an approach that uses important feature channels for identifying important tokens. Our key insight is that the pattern of channel sparsity is relatively static, allowing us to use offline calibration to make it efficient at runtime, thereby enabling accurate and efficient identification of important tokens. Moreover, this method can be combined with offloading to achieve significant memory usage reduction. Experimental results demonstrate that Double Sparsity can achieve 1/16 token and channel sparsity with minimal impact on accuracy across various tasks, including wiki-2 perplexity, key-value retrieval, and long context benchmarks with models including Llama-2-7B, Llama-2-70B, and Mixtral-8x7B. It brings up to a 14.1× acceleration in attention operations and a 1.9× improvement in end-to-end inference on GPUs. With offloading, it achieves a decoding speed acceleration of 16.3× compared to state-of-the-art solutions at a sequence length of 256K. Our code is publicly available at https://github.com/andy-yang-1/DoubleSparse.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 22 code samples harvested from 1 repository linked to this paper: 15 ran (of which 0 constructed an object rather than computing a result; 8 with no instrument failure: 2 honoured, 1 violated, 5 with no contract checked; 7 where Syntology's instrument failed) · 7 unverified. Where Syntology's instrument failed: 6 where our contract draft was wrong; 1 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: official repository: 22 samples from 1 repository, 15 ran (8 with no instrument failure; 7 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written between 2026-09-22 and 2026-09-26 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed. 3 of the 15 samples that ran have no recorded date.

andy-yang-1/doublesparse officialmentioned in papermentioned on GitHubpytorchMITSyntology: 22 samples, 15 ran (7 instrument-failed) · 7 unverified report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

22 samples harvested: 15 ran (of which 0 constructed an object rather than computing a result; 8 with no instrument failure: 2 honoured, 1 violated, 5 with no contract checked; 7 where Syntology's instrument failed) · 7 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

2ran · honoured contract
1ran · violated contract
6ran · our draft was wrong
1ran; the contract check could not run
5ran
7unverified

Licence: 9 of the 22 samples are pointer only, meaning Syntology does not serve that copy's text. For 9 of them, this paper's copy is under a permissive licence and cleared, but the stored copy of the same code that Syntology serves is not; the licence label's tooltip gives Syntology's recorded reason. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from andy-yang-1/doublesparse. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of six reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity. A census tag appears when Syntology's census ran implementations with that name on one shared input per bucket: it gives how many were compared, from how many papers, and how many distinct outputs they produced, and names this sample's bucket when this sample was one of them.

andy-yang-1/doublesparse official repository 22 samples, 15 ran (7 instrument-failed) · 7 unverified
build_chat in 29 papers LongBench/pred.py ran MIT (permissive) · c9d682400f2b2384 · report fixture: signature tokenizer:ChatGLM3Tokenizer/0/?, prompt:str/0/str, model_name:str/0/str · returned str · level recorded 2026-09-24
count_score in 27 papers LongBench/metrics.py ran · honoured contract fingerprinted MIT (permissive) here; the stored copy is pointer only · b349b79d9cc2934b · report fixture: signature prediction:str/0/str, ground_truth:int/0/int · returned float · level recorded, date not recorded
dynamically_quantize_per_channel in 5 papers models/quantize.py ran MIT (permissive) here; the stored copy is pointer only · 55ec8fea60e1d7e7 · report fixture: signature x:Tensor/2/float, quant_min:int/0/int, quant_max:int/0/int, target_dtype:dtype/0/? · returned tuple · level recorded 2026-09-26
find_multiple in 31 papers models/model.py ran · honoured contract fingerprinted MIT (permissive) · aba86ffbed27ba65 · report fixture: signature n:int/0/int, k:int/0/int · returned int · level recorded 2026-09-22
get_group_qparams models/quantize.py ran MIT (permissive) here; the stored copy is pointer only · dbabfb89a4b530ac · report fixture: signature w:Tensor/2/float, n_bit:int/0/int, groupsize:int/0/int · returned tuple · level recorded 2026-09-26
logits_to_probs in 18 papers models/generate.py ran; the contract check could not run (RAISES) fingerprinted MIT (permissive) here; the stored copy is pointer only · fd0cfe048b12c6f2 · report fixture: signature logits:Tensor/2/float, temperature:float/0/float, top_k:int/0/int · returned Tensor · level recorded 2026-09-26
multinomial_sample_one_no_sync in 10 papers models/generate.py ran · our draft was wrong fingerprinted MIT (permissive) · 968f7cbd56cd3206 · report fixture: signature probs_sort:Tensor/2/float · returned Tensor · level recorded 2026-09-24
normalize_answer in 304 papers LongBench/metrics.py ran · our draft was wrong fingerprinted MIT (permissive) here; the stored copy is pointer only · e7e75981cb464788 · report fixture: signature s:str/0/str · returned str · level recorded, date not recorded
normalize_zh_answer in 32 papers LongBench/metrics.py ran · our draft was wrong fingerprinted MIT (permissive) here; the stored copy is pointer only · 8c5c581f9264c810 · report fixture: signature s:str/0/str · returned str · level recorded, date not recorded
pack_scales_and_zeros in 5 papers models/quantize.py ran · our draft was wrong MIT (permissive) here; the stored copy is pointer only · 146cdcef0c195fd7 · report fixture: signature scales:Tensor/2/float, zeros:Tensor/2/float · returned Tensor · level recorded 2026-09-26
parse_args in 355 papers LongBench/pred.py ran · our draft was wrong MIT (permissive) · 4b9ff9b601e07731 · report fixture: signature args:list/1/str · returned Namespace · level recorded 2026-09-24
post_process in 56 papers LongBench/pred.py ran · violated contract fingerprinted MIT (permissive) · 4489113b536ca6eb · report fixture: signature response:str/0/str, model_name:str/0/str · returned str · level recorded 2026-09-22
precompute_freqs_cis in 112 papers models/model.py ran fingerprinted MIT (permissive) here; the stored copy is pointer only · 26cf476e99a51b14 · report fixture: signature seq_len:int/0/int, n_elem:int/0/int, base:int/0/int · returned Tensor · level recorded 2026-09-26
pseudo_quantize AIME/modify_llama.py ran · our draft was wrong fingerprinted MIT (permissive) · 6c58a3a856b83402 · report fixture: signature tensor:Tensor/2/float, q_bit:int/0/int · returned Tensor · level recorded 2026-09-24
sample in 167 papers
census: 8 implementations from 9 papers, 7 distinct outputs across 5 buckets, one shared input per bucket
models/generate.py ran MIT (permissive) here; the stored copy is pointer only · b0856105fbfe6f4f · report fixture: signature logits:Tensor/3/float, temperature:float/0/float, top_k:int/0/int · returned tuple · level recorded 2026-09-26
apply_rotary_emb in 121 papers models/model.py unverified MIT (permissive) · 1102ffb719fa5cde · report
convert_h2o LongBench/h2o_llama.py unverified MIT (permissive) · 1bc3eae58a3d0167 · report
convert_kvcache_llama_heavy_recent AIME/modify_llama.py unverified MIT (permissive) · 423b6b0a2a7a06fb · report
convert_kvcache_qwen2_heavy_recent AIME/modify_qwen2.py unverified MIT (permissive) · 18842172af05afe4 · report
convert_llama_channel_config AIME/modify_llama.py unverified MIT (permissive) · 39e907bab1c70346 · report
convert_qwen2_channel_config AIME/modify_qwen2.py unverified MIT (permissive) · 1ced27a7a4ec46b8 · report
reset_h2o LongBench/h2o_llama.py unverified MIT (permissive) · 0166832f476ba7ea · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionSPEEDSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections