Mistral 7B: Sliding-window attention, GQA and a rolling KV cache
Mistral 7B combines grouped-query and sliding-window attention with a rolling KV cache. It delivers strong 7B results while bounding direct cache cost and propagating information across layers.
On this page
Mistral 7B’s 2023 report centers on GQA, SWA and matching inference support through a rolling cache, prefill and chunking.
How it works
GQA shares KV heads among query heads. SWA attends to the previous 4096 positions and overwrites older cache entries. Across 32 layers, information can travel beyond one window even though each layer directly reads only its window.
What the evidence shows
The paper reports wins over Llama 2 13B on several benchmarks. Cross-paper comparisons require caution, and a sliding window is not automatically reliable infinite memory.
A reproducible check
This snippet checks a public formula or configuration; it does not reproduce full training.
layers, window = 32, 4096
print("direct window =", window)
print("upper bound of layered receptive field =", layers*window)
print("cache positions per sequence =", window)
direct window = 4096
upper bound of layered receptive field = 131072
cache positions per sequence = 4096
The arithmetic is reproducible, but model quality still depends on the full experiments in the paper.
Limitations and common misreadings
Information outside the window must propagate indirectly, which can hurt exact retrieval. Cache savings do not remove prefill cost or the need for long-context adaptation.
The key takeaway
Mistral 7B co-designs architecture and serving: GQA shrinks heads, SWA limits the window and the rolling cache realizes the savings.
Further reading
FAQ
- Which two attention designs does it use?
- Grouped-query attention and sliding-window attention.
- How large is the window?
- The paper uses 4096 tokens.
- Is information outside the window entirely inaccessible?
- It cannot be read directly but may propagate through layers; exact retrieval needs empirical testing.