KnapSpec: Self-Speculative Decoding via Adaptive Layer Selection as a Knapsack Problem
On the map: Efficient LLM inference and serving → Speculative decoding
Abstract (arXiv)
Self-speculative decoding (SSD) accelerates LLM inference by skipping layers to create an efficient draft model, yet existing methods often rely on static heuristics that ignore the dynamic computational overhead of attention in long-context scenarios. We propose KnapSpec, a training-free framework that reformulates draft model selection as a knapsack problem to maximize tokens-per-time throughput. By decoupling Attention and MLP layers and modeling their hardware-specific latencies as functions of context length, KnapSpec adaptively identifies optimal draft configurations on the fly via a parallel dynamic programming algorithm. Furthermore, we provide the first rigorous theoretical analysis establishing cosine similarity between hidden states as a mathematically sound proxy for the token acceptance rate. This foundation allows our method to maintain high drafting faithfulness while navigating the shifting bottlenecks of real-world hardware. Our experiments on Qwen3 and Llama3 demonstrate that KnapSpec consistently outperforms state-of-the-art SSD baselines, achieving up to 1.47x wall-clock speedup across various benchmarks. Our plug-and-play approach ensures high-speed inference for long sequences without requiring additional training or compromising the target model's output distribution.
Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Placed in Speculative decoding, one of 12 directions in Efficient LLM inference and serving. Builds on 26 of its 27 references that are in the map. First posted on arXiv 23 Feb 2026.
Builds on
26 of 27 references.
Closest ancestors · 13
Same direction, newest first
- 2025Mamba Drafters for Speculative Decoding1 Jun
- 2025CLaSp: In-Context Layer Skip for Self-Speculative Decoding30 May
- 2025SpecExtend: A Drop-in Enhancement for Speculative Decoding of Long Sequences27 May
- 2025DEL: Context-Aware Dynamic Exit Layer for Efficient Self-Speculative Decoding8 Apr
- 2024SWIFT: On-the-Fly Self-Speculative Decoding for LLM Inference Acceleration9 Oct
- 2024Draft on the Fly: Adaptive Self-Speculative Decoding using Cosine Similarity1 Oct
- 2024MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decoding20 Aug
- 2024EAGLE-2: Faster Inference of Language Models with Dynamic Draft Trees24 Jun
- 2024Kangaroo: Lossless Self-Speculative Decoding via Double Early Exiting29 Apr
- 2024TriForce: Lossless Acceleration of Long Sequence Generation with Hierarchical Speculative Decoding18 Apr
- 2023Accelerating Large Language Model Decoding with Speculative Sampling2 Feb
- 2022Fast Inference from Transformers via Speculative Decoding30 Nov
1 more
Other references · 13
- 2017Attention Is All You Needcited by 59,932
- 2024The Llama 3 Herd of Modelscited by 14,192
- 2025Qwen3 Technical Reportcited by 8,195
- 2023Generative Agents: Interactive Simulacra of Human Behaviorcited by 3,500
- 2019The Curious Case of Neural Text Degenerationcited by 2,881
- 2022Learn to Explain: Multimodal Reasoning via Thought Chains for Science Question Answeringcited by 1,881
- 2024MMLU-Pro: A More Robust and Challenging Multi-Task Language Understanding Benchmarkcited by 1,758
- 2019Compressive Transformers for Long-Range Sequence Modellingcited by 699
- 2021Efficient Attentions for Long Document Summarizationcited by 342
- 2024LayerSkip: Enabling Early Exit Inference and Self-Speculative Decodingcited by 302
- 2021BookSum: A Collection of Datasets for Long-form Narrative Summarizationcited by 184
- 2025A Survey on Code Generation with LLM-based Agentscited by 104
Built on by
Citing papers per year: 2026: 4.
4 papers.
- 2026LoopSpec: Pipelined Self-Speculative Decoding for Looped Transformerscited by 2
- 2026Component-Aware Self-Speculative Decoding in Hybrid Language Modelscited by 1
- 2026CATS: Cascaded Adaptive Tree Speculation for Memory-Limited LLM Inference Accelerationcited by 0
- 2026Where Activation Sparsity and KV-Cache Sparsity Cross in LLM Decodingcited by 0
- 2026Where Activation Sparsity and KV-Cache Sparsity Cross in LLM Decoding27 Sep 2026
- 2026LoopSpec: Pipelined Self-Speculative Decoding for Looped Transformers15 Sep 2026
- 2026CATS: Cascaded Adaptive Tree Speculation for Memory-Limited LLM Inference Acceleration11 May 2026
- 2026Component-Aware Self-Speculative Decoding in Hybrid Language Models1 May 2026
Similar, not cited
Close in wording, no citation either way
- 2026Margins, Not Windows: Training-Free Per-Step Lossy Speculative Decoding
- 2025KNN-SSD: Enabling Dynamic Self-Speculative Decoding via Nearest Neighbor Layer Set Optimization
- 2025Mirror Speculative Decoding: Breaking the Serial Barrier in LLM Inference
- 2026ASPIRE: Asynchronous Batched Self-Speculative Decoding for Long-Context LLM Inference
- 2026Carryover Drafting: Recycling Rejected States for Speculative Decoding
- 2025CARD: A Cache-Assisted Parallel Speculative Decoding Framework via Query-and-Correct Paradigm for Accelerating LLM Inference
- 2025Yggdrasil: Bridging Dynamic Speculation and Static Runtime for Latency-Optimal Tree-Based LLM Decoding
- 2026FlexDraft: Flexible Speculative Decoding via Attention Tuning and Bonus-Guided Calibration