KV heads, windows and vocab size measured on three 7B models
Original title: Shared KV Heads, Sliding Windows, and Vocabulary Size: Measured Memory and Retrieval Trade-offs in LLaMA 7B, Mistral 7B, and Qwen2.5-7B
On a 16 GB T4, Mistral passkey retrieval fails past its 4,096-token window, while Qwen2.5 holds 64K tokens in 3.5 GiB.
A paper measures how KV-head count, sliding-window attention and vocabulary size affect memory and retrieval in original LLaMA 7B, Mistral 7B v0.1 and Qwen2.5-7B on one 16 GB T4 GPU. Mistral retrieved a passkey in all 72 trials inside 4,089 tokens and none of 62 trials at 4,098 or more; turning the window off restored retrieval in 8K prompts. Per-token KV cache was 512, 128 and 56 KiB. Code and results are public.
- LLaMA keeps 32 KV heads, Mistral 8 and Qwen2.5 4.
- LLaMA runs out of memory at 32K tokens; Mistral's cache stops at 512 MiB.
- On 1,997 sentences, LLaMA needs 9.5–22.0 times more cache than Qwen2.5.
- Decode latency grows with cache size; copying the cache costs about as much.
From the original article
1 min read at arxiv.orgThree widely used 7B-class language models, original LLaMA 7B, Mistral 7B v0. 1, and Qwen2. 5-7B, differ in three design choices that decide what fits on a small GPU: how many key-value (KV) heads the attention layers keep (32, 8, and 4), whether attention is limited to a sliding window (4,096 tokens in Mistral), and how large the vocabulary is (32,000 versus 151,643 tokens).
By Kapardhi Kannekanti · arxiv.org
A short excerpt; the article and its images belong to the publisher. Summary, key facts and assessment above are AI-written from the article and can be wrong.