Shared KV Heads, Sliding Windows, and Vocabulary Size: Measured Memory and Retrieval Trade-offs in LLaMA 7B, Mistral 7B, and Qwen2.5-7B
No concrete benchmark grounding is available yet. Treat the page as context or an implementation starting point only.
Abstract
Domain fit: AI-core · Core AI workload signals detected from paper context and implementation/artifact evidence.
Three 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). We measure the consequences of each choice on one 16 GB T4 GPU. (1) Passkey retrieval in Mistral stops at the window. In 134 trials with the key placed 3,600 to 4,600 tokens from the end of the prompt, Mistral retrieved it in all 72 trials where it lay within 4,089 tokens and in none of the 62 trials where it lay 4,098 or more tokens away. With the same weights and the window turned off, retrieval succeeds at every tested position in 8K-token prompts, so the mask causes the limit; at 16K and 32K tokens the window-free model fails completely, while the windowed model still retrieves nearby keys. Qwen2.5 retrieves the key in all 60 trials up to 32K tokens. (2) KV-cache memory per token is 512, 128, and 56 KiB. LLaMA runs out of memory at 32K tokens, Qwen2.5 holds 64K tokens in 3.5 GiB, and Mistral's cache stops at 512 MiB. (3) On 1,997 parallel sentences in 15 languages, Qwen2.5's tokenizer removes 38-58% of tokens for five languages and 3-11% for the other ten; combined with KV sharing, LLaMA needs 9.5-22.0 times more cache memory than Qwen2.5 for the same sentence. (4) Decode latency in a common runtime grows with cache size, and copying the cache, measured on its own, costs about as much as that growth. Code and results are public.
Results and benchmarks
Three 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).
Implementation
No direct implementation yet
Maintained implementation evidence is not confirmed for this paper yet.
Use the implementation status and reproduction sections for the current action plan.
No verified maintained repo yet
There is no verified maintained implementation yet. Use this baseline plan to decide whether to prototype now or defer.
- No direct maintained implementation was found. Use the paper PDF and citation graph to design a baseline reproduction.
- Track assumptions and missing details in an experiment log before coding.
Time to first repro: a few days
Recommendation evidence is currently too limited for a maintained-repo choice. Use Implementation Status and Reproduction Path for a practical baseline plan.
- Estimate is based on paper-only reproduction flow
Reproduction readiness
No repo
No verified implementation available
- No maintained repository has been identified for this paper. Check adjacent implementations or HF artifacts below.
Hardware requirements
- Expect multi-day setup/compute for meaningful reproduction based on current guidance.
Validation caveat
Framework baselines
- Hugging Face Transformers training guide
Modern transformer training baseline.
- PyTorch nn.Transformer docs
Reference transformer building block implementation.
Hugging Face artifacts
No trustworthy direct or curated related Hugging Face artifacts were found yet. Use targeted searches to quickly locate candidate models, datasets, and demos.
Tip: start with models, then check datasets and spaces if you need evaluation data or demos.
Research context
Tasks
Retrieval / indexing
Methods
Transformer
Domains
Natural Language Processing, Information Retrieval
Open this paper in HFEPX to review benchmark signals, evaluation modes, and human-feedback protocol context.
Open in HFEPXJump to Paper2Code search queries derived from this paper's research context.