KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Cho, Minsik, Rastegari, Mohammad, Naik, Devang
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866913348821450752
author Cho, Minsik
Rastegari, Mohammad
Naik, Devang
author_facet Cho, Minsik
Rastegari, Mohammad
Naik, Devang
contents Large Language Model or LLM inference has two phases, the prompt (or prefill) phase to output the first token and the extension (or decoding) phase to the generate subsequent tokens. In this work, we propose an efficient parallelization scheme, KV-Runahead to accelerate the prompt phase. The key observation is that the extension phase generates tokens faster than the prompt phase because of key-value cache (KV-cache). Hence, KV-Runahead parallelizes the prompt phase by orchestrating multiple processes to populate the KV-cache and minimizes the time-to-first-token (TTFT). Dual-purposing the KV-cache scheme has two main benefits. First, since KV-cache is designed to leverage the causal attention map, we minimize computation and computation automatically. Second, since it already exists for the extension phase, KV-Runahead is easy to implement. We further propose context-level load-balancing to handle uneven KV-cache generation (due to the causal attention) and to optimize TTFT. Compared with an existing parallelization scheme such as tensor or sequential parallelization where keys and values are locally generated and exchanged via all-gather collectives, our experimental results demonstrate that KV-Runahead can offer over 1.4x and 1.6x speedups for Llama 7B and Falcon 7B respectively.
format Preprint
id arxiv_https___arxiv_org_abs_2405_05329
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation
Cho, Minsik
Rastegari, Mohammad
Naik, Devang
Distributed, Parallel, and Cluster Computing
Artificial Intelligence
Computation and Language
Large Language Model or LLM inference has two phases, the prompt (or prefill) phase to output the first token and the extension (or decoding) phase to the generate subsequent tokens. In this work, we propose an efficient parallelization scheme, KV-Runahead to accelerate the prompt phase. The key observation is that the extension phase generates tokens faster than the prompt phase because of key-value cache (KV-cache). Hence, KV-Runahead parallelizes the prompt phase by orchestrating multiple processes to populate the KV-cache and minimizes the time-to-first-token (TTFT). Dual-purposing the KV-cache scheme has two main benefits. First, since KV-cache is designed to leverage the causal attention map, we minimize computation and computation automatically. Second, since it already exists for the extension phase, KV-Runahead is easy to implement. We further propose context-level load-balancing to handle uneven KV-cache generation (due to the causal attention) and to optimize TTFT. Compared with an existing parallelization scheme such as tensor or sequential parallelization where keys and values are locally generated and exchanged via all-gather collectives, our experimental results demonstrate that KV-Runahead can offer over 1.4x and 1.6x speedups for Llama 7B and Falcon 7B respectively.
title KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation
topic Distributed, Parallel, and Cluster Computing
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2405.05329