Sliding-window beats linear attention

Alexia Jolicoeur-Martineau, Rhea Sanjay Sukthanker, Pashmina Cameron, Emy Gervais

arXiv:2608.28444 · 2026-08-31 공개 · arXiv · PDF

llm long-context memory-efficiency linear-attention sliding-window-attention attention-mechanisms inference-cost needle-in-a-haystack

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. For each additional token, the keys and values must be stored in memory indefinitely, which is unsustainable. Several alternatives have been proposed to fix the quadratic scaling problem, one of which is retrofitting LLMs to use Linear Attention. This idea 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, this line of research has not been properly compared to simpler baselines. In this work, we show that Sliding Window Attention (SWA) with sinks performs as well or better than post-trained Linear Attention models. We observe this across multiple LLMs on various downstream tasks. For 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 post-training, is extremely fast, and requires low memory; therefore, making it an extremely cheap and reliable solution. To reduce inference memory cost, we strongly recommend switching to SWA instead of post-training linear models. Linear attention models may have shown some promise, but they likely require to be trained from scratch or extensive post-training in order to even match SWA.

한국어 요약

한 줄 요약

슬라이딩 윈도우 어텐션(SWA)이 포스트 트레이닝된 라인어 어텐션 모델보다 성능이 우수하며, 추가 학습 없이도 높은 효율성을 보인다.

핵심 기여도

핵심 아이디어

기존의 라인어 어텐션은 메모리 소비를 줄이는 데 유리하지만, 학습 비용이 높고 표현력이 낮아 성능 저하를 유발한다. 반면, **Sliding Window Attention (SWA)** 은 기존 모델의 어텐션 메커니즘을 단순히 마스크를 변경하는 방식으로 교체할 수 있으며, **4개의 sink 토큰**과 **최근 w개 토큰**만 참조함으로써 메모리 사용량을 고정시킨다. 이는 추가 학습 없이도 성능을 유지하거나 향상시킬 수 있다는 점에서 혁신적이다. 특히, **LoLCATs** 가 40M 토큰으로 학습한 라인어 어텐션 모델보다 SWA가 더 높은 성능을 보이는 것은 SWA의 간단한 구조가 오히려 장기 기억을 더 잘 유지할 수 있음을 시사한다.

기술적 접근법

주요 결과

의의 및 한계

실용적 활용