LongSpec: Long-Context Lossless Speculative Decoding with Efficient Drafting and Verification
On the map: LLM agents and tool use → Software engineering coding agents
also in 1 more
Abstract (arXiv)
As Large Language Models (LLMs) can now process extremely long contexts, efficient inference over these extended inputs has become increasingly important, especially for emerging applications like LLM agents that highly depend on this capability. Speculative decoding (SD) offers a promising lossless acceleration technique compared to lossy alternatives such as quantization and model cascades. However, most state-of-the-art SD methods are trained on short texts (typically fewer than 4k tokens), making them unsuitable for long-context scenarios. Specifically, adapting these methods to long contexts presents three key challenges: (1) the excessive memory demands posed by draft models due to large Key-Value (KV) cache; (2) performance degradation resulting from the mismatch between short-context training and long-context inference; and (3) inefficiencies in tree attention mechanisms when managing long token sequences. This work introduces LongSpec, a framework that addresses these challenges through three core innovations: a memory-efficient draft model with a constant-sized KV cache; novel position indices that mitigate the training-inference mismatch; and an attention aggregation strategy that combines fast prefix computation with standard tree attention to enable efficient decoding. Experimental results confirm the effectiveness of LongSpec, achieving up to a 3.26x speedup over strong Flash Attention baselines across five long-context understanding datasets, as well as a 2.25x reduction in wall-clock time on the AIME24 long reasoning task with the QwQ model, demonstrating significant latency improvements for long-context applications. The code is available at https://github.com/sail-sg/LongSpec.
Key facts. Cited by 19 papers in the map (data through 13 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 54 of its 75 references that are in the map. First posted on arXiv 24 Feb 2025.
Builds on
54 of 75 references.
References · 54
- 2023GPT-4 Technical Reportcited by 18,278
- 2024The Llama 3 Herd of Modelscited by 14,486
- 2025DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learningcited by 6,247
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,831
- 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,270
- 2016SGDR: Stochastic Gradient Descent with Warm Restartscited by 5,021
- 2024Qwen2.5 Technical Reportcited by 4,840
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,628
- 2020Longformer: The Long-Document Transformercited by 3,393
- 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,197
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,137
- 2022Fast Inference from Transformers via Speculative Decodingcited by 1,625
38 more
- 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understandingcited by 1,386
- 2022Solving Quantitative Reasoning Problems with Language Modelscited by 1,369
- 2023AWQ: Activation-aware Weight Quantization for LLM Compression and Accelerationcited by 1,272
- 2024SnapKV: LLM Knows What You are Looking for Before Generationcited by 856
- 2024Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Headscited by 829
- 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 589
- 2024EAGLE: Speculative Sampling Requires Rethinking Feature Uncertaintycited by 569
- 2019Multi-News: a Large-Scale Multi-Document Summarization Dataset and Abstractive Hierarchical Modelcited by 429
- 2021QMSum: A New Benchmark for Query-based Multi-domain Meeting Summarizationcited by 363
- 2023SpecInfer: Accelerating Generative Large Language Model Serving with Tree-based Speculative Inference and Verificationcited by 361
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 350
- 2021Efficient Attentions for Long Document Summarizationcited by 342
- 2024LayerSkip: Enabling Early Exit Inference and Self-Speculative Decodingcited by 301
- 2024Break the Sequential Dependency of LLM Inference Using Lookahead Decodingcited by 295
- 2022Speculative Decoding: Exploiting Speculative Execution for Accelerating Seq2seq Generationcited by 169
- 2023Speculative Decoding with Big Little Decodercited by 162
- 2023REST: Retrieval-Based Speculative Decodingcited by 148
- 2024How to Train Long-Context Language Models (Effectively)cited by 144
- 2023SpecTr: Fast Speculative Decoding via Optimal Transportcited by 129
- 2024Liger Kernel: Efficient Triton Kernels for LLM Trainingcited by 127
- 2023Scaling Laws of RoPE-based Extrapolationcited by 125
- 2024Language Model Cascades: Token-level uncertainty and beyondcited by 117
- 2024Cradle: Empowering Foundation Agents Towards General Computer Controlcited by 115
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 113
- 2023LongCoder: A Long-Range Pre-trained Language Model for Code Completioncited by 111
- 2023Online Speculative Decodingcited by 109
- 2025Reward-Guided Speculative Decoding for Efficient LLM Reasoningcited by 106
- 2024TriForce: Lossless Acceleration of Long Sequence Generation with Hierarchical Speculative Decodingcited by 99
- 2024MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decodingcited by 87
- 2023Cascade Speculative Drafting for Even Faster LLM Inferencecited by 83
- 2024PEARL: Parallel Speculative Decoding with Adaptive Draft Lengthcited by 83
- 2023Fast and Robust Early-Exiting Framework for Autoregressive Language Models with Synchronized Parallel Decodingcited by 80
- 2024GliDe with a CaPE: A Low-Hassle Method to Accelerate Speculative Decodingcited by 74
- 2024SWIFT: On-the-Fly Self-Speculative Decoding for LLM Inference Accelerationcited by 69
- 2024Why Does the Effective Context Length of LLMs Fall Short?cited by 61
- 2025Judge Decoding: Faster Speculative Sampling Requires Going Beyond Model Alignmentcited by 59
- 2024Turning Trash into Treasure: Accelerating Inference of Large Language Models with Token Recyclingcited by 47
- 2024Faster Cascades via Speculative Decodingcited by 38
50 most cited of 54 All 54 (JSON)
Built on by
Citing papers per year: 2025: 2; 2026: 17.
19 papers.
Sort:
By area:
- 2025LogitSpec: Accelerating Retrieval-based Speculative Decoding via Next Next Token Speculationcited by 14
- 2026Speculative Speculative Decodingcited by 14
- 2026SPEED-Bench: A Unified and Diverse Benchmark for Speculative Decodingcited by 8
- 2026Draft Less, Retrieve More: Hybrid Tree Construction for Speculative Decodingcited by 6
- 2026When Hidden States Drift: Can KV Caches Rescue Long-Range Speculative Decoding?cited by 4
- 2026Attention Drift: What Autoregressive Speculative Decoding Models Learncited by 4
- 2026Test-Time Speculationcited by 3
- 2026TailSieve: Partial-Rollout-Guided Tail Routing for LLM Rolloutscited by 2
- 2026Online Draft Co-Training for Speculative Decoding in Large-Scale, Long-Context RL Post-Trainingcited by 2
- 2025SpecMemo: Speculative Decoding is in Your Pocketcited by 1
- 2026Dustin: Draft-Augmented Sparse Verification for Efficient Long-Context Generation with Speculative Decodingcited by 0
- 2026Windowed-MTP: Removing the Full-Context Draft-KV Tax at Million-Token Contextcited by 0
7 more
- 2026KAP: Bridging the Knowledge Selection-Runtime Consumption Gap in LLM Systemscited by 0
- 2026LibraSpec: Dynamic Diffusion-Based Speculative Decoding via Marginal-Gain-Driven Optimizationcited by 0
- 2026Strong Drafts Need Compact Memories: Long-Context Speculative Decoding with Compressed KV Cachecited by 0
- 2026On-Demand Attention: Language Models Know When to Recallcited by 0
- 2026LongSpark: Efficient speculative decoding with a fixed-cost parallel draftercited by 0
- 2026UBTree: Parallel Tree Drafting via Unigram and Bigram Models for Speculative Decodingcited by 0
- 2026SharpDraft: Accelerating Long-Context Speculative Decoding with Cardinality-Aware Query Scalingcited by 0
- 2026SharpDraft: Accelerating Long-Context Speculative Decoding with Cardinality-Aware Query Scaling4 Oct 2026
- 2026UBTree: Parallel Tree Drafting via Unigram and Bigram Models for Speculative Decoding30 Sep 2026
- 2026LongSpark: Efficient speculative decoding with a fixed-cost parallel drafter29 Sep 2026
- 2026On-Demand Attention: Language Models Know When to Recall17 Sep 2026
- 2026Online Draft Co-Training for Speculative Decoding in Large-Scale, Long-Context RL Post-Training7 Sep 2026
- 2026Strong Drafts Need Compact Memories: Long-Context Speculative Decoding with Compressed KV Cache31 Aug 2026
- 2026TailSieve: Partial-Rollout-Guided Tail Routing for LLM Rollouts24 Aug 2026
- 2026LibraSpec: Dynamic Diffusion-Based Speculative Decoding via Marginal-Gain-Driven Optimization9 Aug 2026
- 2026KAP: Bridging the Knowledge Selection-Runtime Consumption Gap in LLM Systems27 Jul 2026
- 2026Windowed-MTP: Removing the Full-Context Draft-KV Tax at Million-Token Context23 Jul 2026
- 2026Dustin: Draft-Augmented Sparse Verification for Efficient Long-Context Generation with Speculative Decoding23 Jun 2026
- 2026Draft Less, Retrieve More: Hybrid Tree Construction for Speculative Decoding19 May 2026
7 more
- 2026Attention Drift: What Autoregressive Speculative Decoding Models Learn11 May 2026
- 2026Test-Time Speculation10 May 2026
- 2026When Hidden States Drift: Can KV Caches Rescue Long-Range Speculative Decoding?29 Apr 2026
- 2026Speculative Speculative Decoding3 Mar 2026
- 2026SPEED-Bench: A Unified and Diverse Benchmark for Speculative Decoding10 Feb 2026
- 2025LogitSpec: Accelerating Retrieval-based Speculative Decoding via Next Next Token Speculation2 Jul 2025
- 2025SpecMemo: Speculative Decoding is in Your Pocket16 May 2025
- 2025LogitSpec: Accelerating Retrieval-based Speculative Decoding via Next Next Token Speculationcited by 14
- 2026Speculative Speculative Decodingcited by 14
- 2026SPEED-Bench: A Unified and Diverse Benchmark for Speculative Decodingcited by 8
- 2026Draft Less, Retrieve More: Hybrid Tree Construction for Speculative Decodingcited by 6
- 2026When Hidden States Drift: Can KV Caches Rescue Long-Range Speculative Decoding?cited by 4
- 2026Attention Drift: What Autoregressive Speculative Decoding Models Learncited by 4
- 2026Test-Time Speculationcited by 3
- 2026Online Draft Co-Training for Speculative Decoding in Large-Scale, Long-Context RL Post-Trainingcited by 2
- 2025SpecMemo: Speculative Decoding is in Your Pocketcited by 1
- 2026Dustin: Draft-Augmented Sparse Verification for Efficient Long-Context Generation with Speculative Decodingcited by 0
- 2026Windowed-MTP: Removing the Full-Context Draft-KV Tax at Million-Token Contextcited by 0
- 2026KAP: Bridging the Knowledge Selection-Runtime Consumption Gap in LLM Systemscited by 0
12 most cited of 17 All 17 (JSON)
- 2026SharpDraft: Accelerating Long-Context Speculative Decoding with Cardinality-Aware Query Scaling4 Oct 2026
- 2026UBTree: Parallel Tree Drafting via Unigram and Bigram Models for Speculative Decoding30 Sep 2026
- 2026LongSpark: Efficient speculative decoding with a fixed-cost parallel drafter29 Sep 2026
- 2026Online Draft Co-Training for Speculative Decoding in Large-Scale, Long-Context RL Post-Training7 Sep 2026
- 2026Strong Drafts Need Compact Memories: Long-Context Speculative Decoding with Compressed KV Cache31 Aug 2026
- 2026LibraSpec: Dynamic Diffusion-Based Speculative Decoding via Marginal-Gain-Driven Optimization9 Aug 2026
- 2026KAP: Bridging the Knowledge Selection-Runtime Consumption Gap in LLM Systems27 Jul 2026
- 2026Windowed-MTP: Removing the Full-Context Draft-KV Tax at Million-Token Context23 Jul 2026
- 2026Dustin: Draft-Augmented Sparse Verification for Efficient Long-Context Generation with Speculative Decoding23 Jun 2026
- 2026Draft Less, Retrieve More: Hybrid Tree Construction for Speculative Decoding19 May 2026
- 2026Attention Drift: What Autoregressive Speculative Decoding Models Learn11 May 2026
- 2026Test-Time Speculation10 May 2026
12 newest of 17 All 17 (JSON)
- 2026On-Demand Attention: Language Models Know When to Recallcited by 0
- 2026On-Demand Attention: Language Models Know When to Recall17 Sep 2026
Similar, not cited
Close in wording, no citation either way
- 2025RAPID: Long-Context Inference with Retrieval-Augmented Speculative Decoding
- 2025OWL: Overcoming Window Length-Dependence in Speculative Decoding for Long-Context Inputs
- 2025DEL: Context-Aware Dynamic Exit Layer for Efficient Self-Speculative Decoding
- 2025SpecExtend: A Drop-in Enhancement for Speculative Decoding of Long Sequences
- 2026TriSpec: Ternary Speculative Decoding via Lightweight Proxy Verification
- 2026A Sparse Glimpse of the Whole: Train-Free Self-Speculative Decoding
- 2025Speculative Decoding: Performance or Illusion?
- 2025DynaSpec: Context-aware Dynamic Speculative Sampling for Large-Vocabulary Language Models