mlsanityData to 7 Oct 2026

KnapSpec: Self-Speculative Decoding via Adaptive Layer Selection as a Knapsack Problem

arXiv 2602.20217 ↗First posted 23 Feb 2026cs.LG cs.AIcited by 4

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

  1. 2025Mamba Drafters for Speculative Decoding1 Jun
  2. 2025CLaSp: In-Context Layer Skip for Self-Speculative Decoding30 May
  3. 2025SpecExtend: A Drop-in Enhancement for Speculative Decoding of Long Sequences27 May
  4. 2025DEL: Context-Aware Dynamic Exit Layer for Efficient Self-Speculative Decoding8 Apr
  5. 2024SWIFT: On-the-Fly Self-Speculative Decoding for LLM Inference Acceleration9 Oct
  6. 2024Draft on the Fly: Adaptive Self-Speculative Decoding using Cosine Similarity1 Oct
  7. 2024MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decoding20 Aug
  8. 2024EAGLE-2: Faster Inference of Language Models with Dynamic Draft Trees24 Jun
  9. 2024Kangaroo: Lossless Self-Speculative Decoding via Double Early Exiting29 Apr
  10. 2024TriForce: Lossless Acceleration of Long Sequence Generation with Hierarchical Speculative Decoding18 Apr
  11. 2023Accelerating Large Language Model Decoding with Speculative Sampling2 Feb
  12. 2022Fast Inference from Transformers via Speculative Decoding30 Nov
1 more
  1. 2022Speculative Decoding: Exploiting Speculative Execution for Accelerating Seq2seq Generation30 Mar

Other references · 13

  1. 2017Attention Is All You Needcited by 59,932
  2. 2024The Llama 3 Herd of Modelscited by 14,192
  3. 2025Qwen3 Technical Reportcited by 8,195
  4. 2023Generative Agents: Interactive Simulacra of Human Behaviorcited by 3,500
  5. 2019The Curious Case of Neural Text Degenerationcited by 2,881
  6. 2022Learn to Explain: Multimodal Reasoning via Thought Chains for Science Question Answeringcited by 1,881
  7. 2024MMLU-Pro: A More Robust and Challenging Multi-Task Language Understanding Benchmarkcited by 1,758
  8. 2019Compressive Transformers for Long-Range Sequence Modellingcited by 699
  9. 2021Efficient Attentions for Long Document Summarizationcited by 342
  10. 2024LayerSkip: Enabling Early Exit Inference and Self-Speculative Decodingcited by 302
  11. 2021BookSum: A Collection of Datasets for Long-form Narrative Summarizationcited by 184
  12. 2025A Survey on Code Generation with LLM-based Agentscited by 104
1 more
  1. 2024A Survey on LLM-based Code Generation for Low-Resource and Domain-Specific Programming Languagescited by 65

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 4.

4 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Margins, Not Windows: Training-Free Per-Step Lossy Speculative Decoding
  2. 2025KNN-SSD: Enabling Dynamic Self-Speculative Decoding via Nearest Neighbor Layer Set Optimization
  3. 2025Mirror Speculative Decoding: Breaking the Serial Barrier in LLM Inference
  4. 2026ASPIRE: Asynchronous Batched Self-Speculative Decoding for Long-Context LLM Inference
  5. 2026Carryover Drafting: Recycling Rejected States for Speculative Decoding
  6. 2025CARD: A Cache-Assisted Parallel Speculative Decoding Framework via Query-and-Correct Paradigm for Accelerating LLM Inference
  7. 2025Yggdrasil: Bridging Dynamic Speculation and Static Runtime for Latency-Optimal Tree-Based LLM Decoding
  8. 2026FlexDraft: Flexible Speculative Decoding via Attention Tuning and Bonus-Guided Calibration