Layer-Condensed KV Cache for Efficient Inference of Large Language Models

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Wu, Haoyi, Tu, Kewei
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916272328933376
author Wu, Haoyi
Tu, Kewei
author_facet Wu, Haoyi
Tu, Kewei
contents Huge memory consumption has been a major bottleneck for deploying high-throughput large language models in real-world applications. In addition to the large number of parameters, the key-value (KV) cache for the attention mechanism in the transformer architecture consumes a significant amount of memory, especially when the number of layers is large for deep language models. In this paper, we propose a novel method that only computes and caches the KVs of a small number of layers, thus significantly saving memory consumption and improving inference throughput. Our experiments on large language models show that our method achieves up to 26$\times$ higher throughput than standard transformers and competitive performance in language modeling and downstream tasks. In addition, our method is orthogonal to existing transformer memory-saving techniques, so it is straightforward to integrate them with our model, achieving further improvement in inference efficiency. Our code is available at https://github.com/whyNLP/LCKV.
format Preprint
id arxiv_https___arxiv_org_abs_2405_10637
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Layer-Condensed KV Cache for Efficient Inference of Large Language Models
Wu, Haoyi
Tu, Kewei
Computation and Language
Huge memory consumption has been a major bottleneck for deploying high-throughput large language models in real-world applications. In addition to the large number of parameters, the key-value (KV) cache for the attention mechanism in the transformer architecture consumes a significant amount of memory, especially when the number of layers is large for deep language models. In this paper, we propose a novel method that only computes and caches the KVs of a small number of layers, thus significantly saving memory consumption and improving inference throughput. Our experiments on large language models show that our method achieves up to 26$\times$ higher throughput than standard transformers and competitive performance in language modeling and downstream tasks. In addition, our method is orthogonal to existing transformer memory-saving techniques, so it is straightforward to integrate them with our model, achieving further improvement in inference efficiency. Our code is available at https://github.com/whyNLP/LCKV.
title Layer-Condensed KV Cache for Efficient Inference of Large Language Models
topic Computation and Language
url https://arxiv.org/abs/2405.10637