A Systematic Study of Cross-Layer KV Sharing for Efficient LLM Inference

You Wu, Haoyi Wu, Kewei Tu
10/18/2024
cs.CL

No official code found. Best implementation: whyNLP/LCKV (156 stars, last commit 2025-04-07).

Abstract

Recently, sharing key-value (KV) cache across layers has been found effective in efficient inference of large language models (LLMs). To systematically investigate different techniques of cross-layer KV sharing, we propose a unified framework that covers several recent methods and their novel variants. We conduct comprehensive experiments on all the configurations of the framework, evaluating their generation throughput and performance in language modeling and downstream tasks. We find that when reducing the size of the KV cache by 2$\times$, most configurations can achieve higher throughput than standard transformers while maintaining competitive performance. When further reducing the size of the KV cache, however, pairing queries of all layers with KVs of upper layers performs better, at the expense of additional training cost and prefilling latency. We hope that this work will help users make more informed choices of cross-layer KV sharing approaches and facilitate future research on efficient LLM inference.

View on arXivView PDF

Code Implementations(1)

whyNLP/LCKVCommunity100%

Layer-Condensed KV cache w/ 10 times larger batch size, fewer params and less computation. Dramatic speed up with better task performance. Accepted to ACL 2024.

15614Shell, PythonMar 9, 20241 years ago

Cite this paper

@article{wu2024systematic,
  title  = {A Systematic Study of Cross-Layer KV Sharing for Efficient LLM Inference},
  author = {You Wu and Haoyi Wu and Kewei Tu},
  year   = {2024},
  eprint = {2410.14442},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.14442v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.14442.svg)](https://codeofpaper.com/paper/2410.14442)

Discussion