GMSWA: Constant-Cache Long-Context Memory

2 minute read

Published:

GMSWA (Gated-Memory Sliding-Window Attention) studies a practical long-context question:

Can a model keep the language quality of local/softmax attention, recover useful long-range recall, and avoid a growing KV cache?

The problem is the core of the story: full attention has strong quality but its KV cache grows linearly with context; sliding-window attention keeps cache bounded but forgets beyond the window; recurrent memory is compact and recall-friendly but can trail softmax attention on base language quality. GMSWA tests whether a window-memory hybrid can keep the best parts.

The layer runs two branches: exact sliding-window attention for recent local evidence, and a gated-delta recurrent matrix memory for long-range information. A learned per-head gate mixes the two.

GMSWA architecture

The latest paper draft frames the contribution as a controlled characterization rather than an overclaim. The headline findings are:

  • Base quality is preserved. GMSWA is on par with softmax baselines on a 10-task zero-shot suite and above a pure recurrent baseline.
  • Real semantic recall improves over local-only attention. On real recall-intensive tasks, GMSWA is comparable to the recurrent baseline: it wins on SQuAD and FDA, while trailing on SWDE.
  • The cache is constant. At 128K context, GMSWA’s KV cache is about 16.3MB, versus about 12.9GB for full attention — roughly 790× smaller cache.
  • Synthetic needle retrieval is the limitation. On NIAH, GMSWA tracks local-window attention and trails the pure recurrent model.
  • The negative result is informative. Memory-directed controls — normalization, pathway dropout, memory-first curriculum, and memory-only training — all hurt or collapse recall, suggesting the issue is limited sharp addressing rather than simply “the model ignored memory.”

Core benchmark snapshot:

ModelZero-shot avg ↑NLL 1–2K ↓NLL 2–4K ↓NLL 4–8K ↓
Transformer0.5003.625.747.21
SWA0.4983.874.144.21
GMSWA0.4993.784.024.08
GDN0.4863.894.154.24

Detailed zero-shot suite:

ModelAvg ↑LAMBADAPIQAHellaSwagWinoGrandeARC-eARC-cBoolQCOPAOBQASciQ
Transformer0.5000.3170.6600.3300.5230.5690.2530.6150.7000.2060.822
SWA0.4980.3150.6580.3260.5100.5770.2410.6080.7000.2400.803
GMSWA0.4990.3240.6550.3300.5300.5660.2580.6110.6700.2020.849
GDN0.4860.2910.6560.3240.5090.5610.2410.5880.6500.2180.819

MMLU is not shown because it was not part of this controlled run’s completed result set; the available standard suite includes HellaSwag, PIQA, ARC, BoolQ, COPA, OpenBookQA, SciQ, WinoGrande, and LAMBADA.

ModelSWDE ↑FDA ↑SQuAD ↑KV cache @128K
SWA0.0720.0400.07250MB
GMSWA0.0880.0940.28416.3MB
GDN0.1100.0260.2743.4MB
Transformer0.4380.1560.06612.9GB

The short version: GMSWA is a practical constant-cache long-context model and a clean map of where window–memory hybrid recall works — and where it stops.

View the visual project showcase →