Sliding-window beats linear attention

Alexia Jolicoeur-Martineau, Rhea Sanjay Sukthanker, Pashmina Cameron, Emy Gervais
8/28/2026
cs.CLcs.LG

No official code found. Best implementation: sachncs/beacon (0 stars, MIT, PyTorch, last commit 2026-09-14).

Abstract

Due to the nature of quadratic attention, Large Language Models (LLMs) consume a lot of memory and energy: every new token costs more than the previous one, and its keys and values must be stored in memory indefinitely, which is unsustainable. Two main lines of work address this: compressing the KV cache, e.g., by evicting or quantizing keys and values, and retrofitting LLMs to use Linear Attention, which replaces the KV cache with a fixed-size state. Retrofitting has attracted a lot of attention, given its promise to solve the quadratic scaling problem with state-of-the-art performance at low cost. However, it has not been properly compared to the simplest form of KV-cache eviction: Sliding Window Attention (SWA) with attention sinks. In this work, we show that SWA with sinks performs as well or better than most retrofitted Linear Attention models across multiple LLMs and downstream tasks, with the largest gains on long-context and generative tasks. On long-context reasoning tasks (Needle-in-a-Haystack and BABILong), SWA achieves massively higher performance (2 to 10 times higher than linear attention). SWA requires no additional training, is extremely fast, and requires little memory, making it an extremely cheap and reliable solution. When the training budget is limited, switching to SWA is a much more effective way to reduce inference memory cost than retrofitting linear attention. Linear attention models have shown promise, but they require training from scratch or extensive retrofitting to reap their architectural benefits and come close to SWA.

View on arXivView PDF

Code Implementations(1)

sachncs/beaconCommunity25%
PyTorchMIT

Training-free Sliding Window Attention with sinks: a reproduction of 'Sliding-window beats linear attention' (Jolicoeur-Martineau et al., 2026) for decoder-only LMs.

00CSS, HTMLSep 3, 20261 months agoMIT
attentioninferencellmlong-contextpython+4 more

Similar Papers

Cite this paper

@article{jolicoeurmartineau2026slidingwindow,
  title  = {Sliding-window beats linear attention},
  author = {Alexia Jolicoeur-Martineau and Rhea Sanjay Sukthanker and Pashmina Cameron and Emy Gervais},
  year   = {2026},
  eprint = {2608.28444},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2608.28444v2}
}

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/2608.28444.svg)](https://codeofpaper.com/paper/2608.28444)

Discussion