Introduction
Speculative Decoding (SD) has emerged as a powerful technique to accelerate Large Language Model (LLM) inference. By employing a smaller "draft" model to predict multiple future tokens which are subsequently verified in parallel by a larger "target" model, SD can significantly reduce latency in memory-bound scenarios. However, in real-world serving environments characterized by high traffic and varying request loads, standard SD implementations often encounter performance bottlenecks.
The Challenges of Static Speculation
The authors identify two primary "traps" that hinder the effectiveness of static SD:
- The Compute Trap: As batch sizes increase, the system transitions from being memory-bound to compute-bound. In this regime, the overhead of verifying draft tokens can exceed the benefits, leading to lower performance than standard autoregressive decoding.
- The Memory Trap: Draft models consume GPU memory that could otherwise be allocated to the Key-Value (KV) cache. In high-concurrency scenarios, this memory overhead limits the maximum batch size, effectively capping system throughput.
The Nightjar Framework
To address these limitations, we present Nightjar, a resource-aware framework that dynamically adapts speculative decoding strategies to real-time system states. Nightjar's architecture consists of three integrated layers: a Request Scheduler, a Nightjar Planner, and an Elastic Memory Manager.
Dynamic Planning and Memory Management
- Contextual Multi-Armed Bandit (MAB) Planner: Nightjar utilizes a modified "ADA-BINGREEDY" algorithm to determine the optimal speculative length ($\gamma$) for a given batch size. By treating batch size as context, the planner learns to maximize "goodput" (tokens per second), including the option to disable SD ($\gamma=0$) when compute-bound.
- Elastic Memory Management: A key innovation of Nightjar is its ability to treat GPU memory as a unified, elastic pool. During periods of high load where speculation is disabled, the framework offloads draft model weights to the CPU. This "Squeeze" operation reclaims GPU memory to expand the KV cache pool, facilitating larger batch sizes and higher throughput. Non-blocking data migration is handled via custom Triton kernels.
- Switching Cost Awareness: Nightjar explicitly models the "switching cost"—the latency incurred when re-enabling speculation due to draft model KV cache re-prefilling. This prevents inefficient "thrashing" between decoding strategies.
Evaluation and Results
Nightjar was evaluated using diverse workloads, including ShareGPT, Alpaca, and SpecBench, with request arrival rates simulated using the Azure LLM Inference Dataset to provide realistic, fluctuating traffic patterns.
The framework demonstrates significant improvements over baselines such as vanilla vLLM and standard speculative decoding:
- Throughput: Nightjar achieves a 27.29% increase in throughput compared to standard autoregressive decoding.
- Latency: Mean end-to-end latency is reduced by up to 20.18% compared to standard speculative decoding.
- Responsiveness: Under high load, Time-To-First-Token (TTFT) improved by 47.2%, as the elastic memory management allowed for earlier admission of new requests.
- Efficiency: The computational overhead of the MAB decision engine is negligible (~10 microseconds), ensuring that the benefits of adaptation are not offset by planning costs.
Conclusion
Nightjar proves that speculative decoding is not a "one-size-fits-all" solution. By dynamically balancing compute and memory resources through an adaptive planner and elastic memory management, Nightjar overcomes the inherent traps of static serving methods. Future work will explore fully autonomous online cost estimation and scaling these dynamic strategies to massive, distributed multi-GPU clusters.
Summary updated