动态调整生成长度,让大模型推理更快更省资源。
Nightjar: Dynamic Adaptive Speculative Decoding for Large Language Models Serving
- 根据负载动态选最优生成长度,避免无效推测。
- 高负载时主动关闭推测,降低延迟20.18%。
- 内存紧张时把辅助模型搬至CPU,提升吞吐量14.76%。
推测解码(SD)通过并行验证草案令牌加速大语言模型推理,但存在关键权衡:在低负载、内存受限场景下提升吞吐量,而在高负载、计算密集场景中因验证开销导致性能下降。现有方法采用固定推测长度,无法随工作负载变化调整,也缺乏何时停止推测的判断机制,且重启推测的代价未被量化。高负载下推测收益递减,同时保留草案模型会占用KV缓存空间,限制批处理规模,降低吞吐量。为此,我们提出Nightjar,一种资源感知的自适应推测框架。它首先根据请求负载动态选择不同批大小下的最优推测长度;关键在于,当多臂赌博机规划器判定推测不再有益时,主动禁用推测,并在禁用阶段仅在GPU内存压力下将草案模型卸载至CPU,从而释放内存用于KV缓存,支持更大批处理规模,最大化整体系统吞吐量。实验表明,在动态请求到达率的真实大模型服务场景中,Nightjar相比标准推测解码实现最高14.76%的吞吐量提升,主基准测试集延迟降低最高达20.18%。
原文摘要 · Abstract (English)
Speculative decoding (SD) accelerates LLM inference by verifying draft tokens in parallel. However, this method presents a critical trade-off: it improves throughput in low-load, memory-bound systems but degrades performance in high-load, compute-bound environments due to verification overhead. Existing speculative decoding methods use fixed lengths and cannot adapt to workload changes or decide when to stop speculation. The cost of restarting speculative inference also remains unquantified. Under high load, the benefit of speculation diminishes, while retaining the draft model reduces KV cache capacity, limiting batch size and degrading throughput. To overcome this, we propose Nightjar, a resource-aware adaptive speculative framework. It first adjusts to the request load by dynamically selecting the optimal speculative length for different batch sizes. Crucially, Nightjar proactively disables speculative decoding when the MAB planner determines that speculation is no longer beneficial, and during the disabled phase, offloads the draft model to the CPU only under GPU memory pressure. This reclaims memory for the KV cache, thereby facilitating larger batch sizes and maximizing overall system throughput. Experiments show that Nightjar achieves up to 14.76% higher throughput than standard speculative decoding and up to 20.18% lower latency in the main benchmark suite under dynamic request arrival rates for real-time LLM serving scenarios.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。