MagicDec: Superare il compromesso tra latenza e throughput per la generazione di contesti lunghi con il decoding speculativo
MagicDec: Breaking the Latency-Throughput Tradeoff for Long Context Generation with Speculative Decoding
August 20, 2024
Autori: Jian Chen, Vashisth Tiwari, Ranajoy Sadhukhan, Zhuoming Chen, Jinyuan Shi, Ian En-Hsu Yen, Beidi Chen
cs.AI
Abstract
I modelli linguistici di grandi dimensioni (LLM) stanno diventando sempre più diffusi in applicazioni a contesto lungo come chatbot interattivi, analisi di documenti e flussi di lavoro di agenti, ma è complesso gestire richieste a contesto lungo con bassa latenza e alto throughput. Il decoding speculativo (SD) è una tecnica ampiamente utilizzata per ridurre la latenza senza sacrificare le prestazioni, ma la saggezza convenzionale suggerisce che la sua efficacia sia limitata a dimensioni ridotte del batch. In MagicDec, dimostriamo che, sorprendentemente, SD può ottenere un'accelerazione anche in un regime di inferenza ad alto throughput per sequenze da moderate a lunghe. Ancora più interessante, una strategia intelligente di drafting può ottenere una maggiore accelerazione all'aumentare della dimensione del batch, come evidenziato dalla nostra rigorosa analisi. MagicDec identifica innanzitutto i colli di bottiglia che si spostano con l'aumento della dimensione del batch e della lunghezza della sequenza, e utilizza queste intuizioni per implementare il decoding speculativo in modo più efficace per l'inferenza ad alto throughput. Successivamente, sfrutta modelli di draft con cache KV sparsa per affrontare il collo di bottiglia KV che scala sia con la lunghezza della sequenza che con la dimensione del batch.
English
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 without sacrificing performance 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 speculative decoding more effectively for high
throughput inference. Then, it leverages draft models with sparse KV cache to
address the KV bottleneck that scales with both sequence length and batch size.