MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decoding

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Sadhukhan, Ranajoy, Chen, Jian, Chen, Zhuoming, Tiwari, Vashisth, Lai, Ruihang, Shi, Jinyuan, Yen, Ian En-Hsu, May, Avner, Chen, Tianqi, Chen, Beidi
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866912304578166784
author Sadhukhan, Ranajoy
Chen, Jian
Chen, Zhuoming
Tiwari, Vashisth
Lai, Ruihang
Shi, Jinyuan
Yen, Ian En-Hsu
May, Avner
Chen, Tianqi
Chen, Beidi
author_facet Sadhukhan, Ranajoy
Chen, Jian
Chen, Zhuoming
Tiwari, Vashisth
Lai, Ruihang
Shi, Jinyuan
Yen, Ian En-Hsu
May, Avner
Chen, Tianqi
Chen, Beidi
contents Large Language Models (LLMs) have become more prevalent in long-context applications such as interactive chatbots, document analysis, and agent workflows, but it is challenging to serve long-context requests with low latency and high throughput. Speculative decoding (SD) is a widely used technique to reduce latency losslessly, but the conventional wisdom suggests that its efficacy is limited to small batch sizes. In MagicDec, we show that surprisingly SD can achieve speedup even for a high throughput inference regime for moderate to long sequences. More interestingly, an intelligent drafting strategy can achieve better speedup with increasing batch size based on our rigorous analysis. MagicDec first identifies the bottleneck shifts with increasing batch size and sequence length, and uses these insights to deploy SD more effectively for high throughput inference. We leverage draft model with sparse KV cache to address the KV bottleneck, which scales with both sequence length and batch size. Additionally, we propose a theoretical model to select the optimal drafting strategy for maximum speedup. Our work highlights the broad applicability of speculative decoding in long-context serving, as it can enhance throughput and reduce latency without compromising accuracy. For moderate to long sequences, we demonstrate up to 2.51x speedup for Llama3.1-8B when serving batch sizes ranging from 32 to 256 on various types of hardware and tasks.
format Preprint
id arxiv_https___arxiv_org_abs_2408_11049
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decoding
Sadhukhan, Ranajoy
Chen, Jian
Chen, Zhuoming
Tiwari, Vashisth
Lai, Ruihang
Shi, Jinyuan
Yen, Ian En-Hsu
May, Avner
Chen, Tianqi
Chen, Beidi
Computation and Language
Large Language Models (LLMs) have become more prevalent in long-context applications such as interactive chatbots, document analysis, and agent workflows, but it is challenging to serve long-context requests with low latency and high throughput. Speculative decoding (SD) is a widely used technique to reduce latency losslessly, but the conventional wisdom suggests that its efficacy is limited to small batch sizes. In MagicDec, we show that surprisingly SD can achieve speedup even for a high throughput inference regime for moderate to long sequences. More interestingly, an intelligent drafting strategy can achieve better speedup with increasing batch size based on our rigorous analysis. MagicDec first identifies the bottleneck shifts with increasing batch size and sequence length, and uses these insights to deploy SD more effectively for high throughput inference. We leverage draft model with sparse KV cache to address the KV bottleneck, which scales with both sequence length and batch size. Additionally, we propose a theoretical model to select the optimal drafting strategy for maximum speedup. Our work highlights the broad applicability of speculative decoding in long-context serving, as it can enhance throughput and reduce latency without compromising accuracy. For moderate to long sequences, we demonstrate up to 2.51x speedup for Llama3.1-8B when serving batch sizes ranging from 32 to 256 on various types of hardware and tasks.
title MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decoding
topic Computation and Language
url https://arxiv.org/abs/2408.11049