Papers › Squeezed Attention: Accelerating Long Context Length LLM Inference

Squeezed Attention: Accelerating Long Context Length LLM Inference

14 Nov 2024arXiv:2411.09688archive 2025-07-28

Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Monishwaran Maheswaran, June Paik, Michael W. Mahoney, Kurt Keutzer, Amir Gholami

Emerging Large Language Model (LLM) applications require long input prompts to perform complex downstream tasks like document analysis and code generation. For these long context length applications, the length of the input prompt poses a significant challenge in terms of inference efficiency since the inference costs increase linearly with sequence length. However, for many of these applications, much of the context in the prompt is fixed across different user inputs, thereby providing the opportunity to perform offline optimizations to process user inputs quickly, as they are received. In this work, we propose Squeezed Attention as a mechanism to accelerate LLM applications where a large portion of the input prompt is fixed. We first leverage K-means clustering offline to group the keys for the fixed context based on semantic similarity and represent each cluster with a single centroid value. During inference, we compare query tokens from the user input with the centroids to predict which of the keys from the fixed context are semantically relevant and need to be loaded during inference. We then compute exact attention using only these important keys from the fixed context, thereby reducing bandwidth and computational costs. We also extend our method to use a hierarchical centroid lookup to identify important keys, which can reduce the complexity of attention from linear to logarithmic with respect to the context length. We implement optimized Triton kernels for centroid comparison and sparse FlashAttention with important keys, achieving more than 4x speedups during both the prefill and generation phases for long-context inference. Furthermore, we have extensively evaluated our method on various long-context benchmarks including LongBench, where it achieves a 3x reduction in KV cache budget without accuracy loss and up to an 8x reduction with <0.5 point accuracy gap for various models.

PaperPDFCodeCode Syntology ran

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

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2411.09688")

Code

Syntology Ran 4 of 15 code samples harvested from 1 repository linked to this paper; 11 have no recorded run. Of those that ran: 1 ran · honoured contract; 3 ran · our draft was wrong.

By repository: official repository: 15 samples from 1 repository, 4 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

SqueezeAILab/SqueezedAttention officialmentioned in papermentioned on GitHubjax 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

15 samples harvested; 4 ran; 1 honoured the contract we drafted; 11 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
3ran · our draft was wrong
11unverified

Licence: 15 of the 15 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from SqueezeAILab/SqueezedAttention. “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. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (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 from a repository marked official are listed first. 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 four 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; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). 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.

count_score SqueezeAILab/SqueezedAttention/LongBench/metrics.py official repository ran · honoured contract fingerprinted no licence file found · pointer only · b349b79d9cc2934b · report
find_layers SqueezeAILab/SqueezedAttention/utils/modelutils.py official repository ran · our draft was wrong no licence file found · pointer only · a9e7f2cdf016b88b · report
normalize_answer SqueezeAILab/SqueezedAttention/LongBench/metrics.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · e7e75981cb464788 · report
normalize_zh_answer SqueezeAILab/SqueezedAttention/LongBench/metrics.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 8c5c581f9264c810 · report
build_chat SqueezeAILab/SqueezedAttention/squeezedattention/utils.py official repository unverified no licence file found · pointer only · 66d002e5d75a1496 · report
get_architectures_from_config_class SqueezeAILab/SqueezedAttention/transformers/utils/create_dummy_models.py official repository unverified no licence file found · pointer only · b176efb26f72e507 · report
get_config_class_from_processor_class SqueezeAILab/SqueezedAttention/transformers/utils/create_dummy_models.py official repository unverified no licence file found · pointer only · 3d999b95009c7537 · report
get_module_names SqueezeAILab/SqueezedAttention/utils/model_parse.py official repository unverified no licence file found · pointer only · b65e0b634a94c717 · report
get_processor_types_from_config_class SqueezeAILab/SqueezedAttention/transformers/utils/create_dummy_models.py official repository unverified no licence file found · pointer only · 0c0b81b081919d8e · report
load_model SqueezeAILab/SqueezedAttention/utils/model_parse.py official repository unverified no licence file found · pointer only · b66c43d90a1a3a1b · report
load_model_and_tokenizer SqueezeAILab/SqueezedAttention/LongBench/pred.py official repository unverified no licence file found · pointer only · 71856fc92741e6f7 · report
parse_args SqueezeAILab/SqueezedAttention/LongBench/pred.py official repository unverified no licence file found · pointer only · 8c953c2e0af15854 · report
parse_model SqueezeAILab/SqueezedAttention/utils/model_parse.py official repository unverified no licence file found · pointer only · dd982ece7960b018 · report
run_global_threshold SqueezeAILab/SqueezedAttention/squeezedattention/clustering.py official repository unverified no licence file found · pointer only · a521d80a7ee5e568 · report
truncate_fn SqueezeAILab/SqueezedAttention/squeezedattention/utils.py official repository unverified no licence file found · pointer only · 983ad6de59ae59a1 · report

Tasks

Code GenerationLarge Language ModelSemantic SimilaritySemantic Textual Similarity

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionSoftmaxk-Means Clustering

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