atlas

Research map / Architectures and efficiency / Attention and transformers

MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decoding

ICLR 2025 · Architectures and efficiency › Attention and transformers · approach: Sparse attention for long-context LLMs · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

MagicDec shows speculative decoding can speed up high-batch, long-context LLM serving by using a self-speculative draft with a sparse (compressed) KV cache, and gives a theoretical model to pick the best drafting strategy.

Problem

Speculative decoding is believed to help only at small batch sizes because verification becomes compute-bound at large batches; the goal is to improve both latency and throughput for long-context serving at large batch sizes without accuracy loss.

Approach

For moderate-to-long sequences, KV cache loading dominates at large batch, so verification cost is amortized and a draft that uses a sparse KV cache (self-speculation) keeps draft cost low and acceptance high; the speedup grows with batch size beyond a critical sequence length. A theoretical speedup formulation selects the draft model size, KV budget, and KV selection algorithm.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use SnapKV instead of StreamingLLM for self-speculationLlama3.1-8B · PG-19, prefill 32000, batch sizes 16–128speedup: 1.08 vs 1.17; 1.26 vs 1.37; 1.55 vs 1.64; 1.85 vs 2.01Helped
Use a small Llama3.2-1B draft with StreamingLLM KV instead of self-speculation (ablation)Llama3.1-8B · PG-19, prefill 32000, batch sizes 16–32speedup: 1.17 -> 1.27; 1.37 -> 1.46Helped
Use self-speculation instead of a small draft model with StreamingLLM KV (ablation)Llama3.1-8B · PG-19, prefill 32000, batch size 128speedup: 1.81 -> 2.01Helped
Increase batch size with long-context speculative decodingMagicDec, Llama3.1-8B · PG-19, prefill 32000, 8xH100speedup: 1.18 -> 1.37 -> 1.62Helped
Use speculative decoding at prefill length 1024 rather than autoregressive decodingMagicDec · A100, batch 32, prefill 1024speedup: 0.95Hurt
Increase the draft KV budget for large batch sizes and long sequences (ablation)MagicDec self-speculation · Large batch, long sequencespeedupHelped
Replace self-speculation with a smaller draft model when context and batch size are modest (ablation)MagicDec · Shorter sequences and modest batch sizesspeedupHelped
Use SnapKV rather than StreamingLLM for static KV selectionLlama3.1-8B self-speculation · Ruler tasks CWE and QA-1theoretical speedupHelped
Use PQCache rather than SnapKV for draftingLlama3.1-8B self-speculation · Ruler niah-multikeys-3theoretical speedupHelped
Use PQCache rather than SnapKV as batch size increasesLlama3.1-8B self-speculation · Ruler tasks at increasing batch sizetheoretical speedupHurt
Use SnapKV instead of a smaller Qwen draft (ablation)Qwen-2.5-32B · PG-19, prefill 32000, batch sizes 8, 16, 32speedup: 1.19 vs 1.02; 1.18 vs 1.16; 1.19 vs 1.34Mixed

Surprising findings

Limitations

Experimental setup

Datasets: PG-19 RULER

Benchmarks: PG-19 RULER (niah-multikeys-3, cwe, qa-1)

Metrics: speedup acceptance rate tokens per step throughput latency per token

Baselines: autoregressive decoding small draft model speculative decoding (Llama3.2-1B) StreamingLLM self-speculation PQCache MLC-LLM speculative decoding

Builds on: speculative decoding TriForce StreamingLLM SnapKV GPT-Fast

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy