# 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.

- URL: https://dmxsf.com/en/blog/mistral-7b/
- [DMXSF](https://dmxsf.com/en/about/)
- Published: 2023-10-20
- Updated: 2026-11-13
- Paper notes
- Paper: [Mistral 7B](https://arxiv.org/abs/2310.06825) (Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch, et al. · arXiv, 2023)

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.

```python
layers, window = 32, 4096
print("direct window =", window)
print("upper bound of layered receptive field =", layers*window)
print("cache positions per sequence =", window)
```

```text
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

- [Mistral 7B](https://arxiv.org/abs/2310.06825)
- [GQA](https://dmxsf.com/en/blog/gqa-grouped-query-attention/)
- [StreamingLLM](https://dmxsf.com/en/blog/efficient-streaming-language-models-with-attention-sinks/)

## 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.
