Papers › Efficient Streaming Language Models with Attention Sinks

Efficient Streaming Language Models with Attention Sinks

29 Sep 2023arXiv:2309.17453archive 2025-07-28

Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, Mike Lewis

Deploying Large Language Models (LLMs) in streaming applications such as multi-round dialogue, where long interactions are expected, is urgently needed but poses two major challenges. Firstly, during the decoding stage, caching previous tokens' Key and Value states (KV) consumes extensive memory. Secondly, popular LLMs cannot generalize to longer texts than the training sequence length. Window attention, where only the most recent KVs are cached, is a natural approach -- but we show that it fails when the text length surpasses the cache size. We observe an interesting phenomenon, namely attention sink, that keeping the KV of initial tokens will largely recover the performance of window attention. In this paper, we first demonstrate that the emergence of attention sink is due to the strong attention scores towards initial tokens as a "sink" even if they are not semantically important. Based on the above analysis, we introduce StreamingLLM, an efficient framework that enables LLMs trained with a finite length attention window to generalize to infinite sequence lengths without any fine-tuning. We show that StreamingLLM can enable Llama-2, MPT, Falcon, and Pythia to perform stable and efficient language modeling with up to 4 million tokens and more. In addition, we discover that adding a placeholder token as a dedicated attention sink during pre-training can further improve streaming deployment. In streaming settings, StreamingLLM outperforms the sliding window recomputation baseline by up to 22.2x speedup. Code and datasets are provided at https://github.com/mit-han-lab/streaming-llm.

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="2309.17453")

Code

Syntology Ran 8 of 11 code samples harvested from 5 repositories linked to this paper; 3 have no recorded run. Of those that ran: 2 ran · our draft was wrong; 2 ran · fixture could not drive it; 4 ran with no contract checked.

By repository: official repository: 6 samples from 2 repositories, 6 ran; community (archive-listed): 5 samples from 3 repositories, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

intel/intel-extension-for-transformers officialmentioned in papermentioned on GitHubpytorch report
mit-han-lab/streaming-llm officialmentioned in papermentioned on GitHubpytorch report
answerdotai/cold-compress mentioned on GitHubpytorch report
intel/neural-speed mentioned on GitHubpytorch report
squeezeailab/kvquant mentioned on GitHubjax report
tomaarsen/attention_sinks mentioned on GitHubpytorch 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

11 samples harvested; 8 ran; 0 honoured the contract we drafted; 3 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.

2ran · our draft was wrong
2ran · fixture could not drive it
4ran
3unverified

Licence: 2 of the 11 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 5 repositories linked to this paper, official or community; each sample names its own and says which. “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.

H2OKVCache intel/intel-extension-for-transformers/intel_extension_for_transformers/transformers/kv_cache_compression/prune/h2o.py official repository ran Apache-2.0 (permissive) · c2fd5f6408017e25 · report
StartRecentKVCache mit-han-lab/streaming-llm/streaming_llm/kv_cache.py official repository ran MIT (permissive) · 465929486ee1650b · report
greedy_generate mit-han-lab/streaming-llm/examples/run_streaming_llama.py official repository ran · our draft was wrong MIT (permissive) · 0a11ee057df336ca · report
slice1d mit-han-lab/streaming-llm/streaming_llm/kv_cache.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 2564045c0e65006b · report
slice2d mit-han-lab/streaming-llm/streaming_llm/kv_cache.py official repository ran · fixture could not drive it MIT (permissive) · 19c86edfcb34276c · report
slice3d mit-han-lab/streaming-llm/streaming_llm/kv_cache.py official repository ran · fixture could not drive it MIT (permissive) · 8884022644d5af82 · report
AttentionSinkKVCache tomaarsen/attention_sinks/attention_sinks/attention_sink_kv_cache.py community (archive-listed) ran Apache-2.0 (permissive) · 221a10d8ed175d74 · report
SinkCache squeezeailab/kvquant/gradients/src/transformers/cache_utils.py community (archive-listed) ran no licence file found · pointer only · a71a6943a9cf9d4b · report
Cache squeezeailab/kvquant/gradients/src/transformers/cache_utils.py community (archive-listed) unverified no licence file found · pointer only · 1b72723f50079a16 · report
KVCacheHeadConstant answerdotai/cold-compress/cache.py community (archive-listed) unverified BSD-3-Clause (permissive) · ae661478c5529ea2 · report
KVCacheRecentGlobal answerdotai/cold-compress/cache.py community (archive-listed) unverified BSD-3-Clause (permissive) · 87d089c843ae1768 · report

Tasks

Language ModelingLanguage Modelling

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Introduced by this paper: Attention Sinks

Attention SinksPythia

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