paper-with-me

홈 › Papers

Reducing Transformer Key-Value Cache Size with Cross-Layer Attention

2024-05-21 · William Brandon, Mayank Mishra, Aniruddha Nrusimha, Rameswar Panda, Jonathan Ragan Kelly

Key-value (KV) caching plays an essential role in accelerating decoding for transformer-based autoregressive large language models (LLMs). However, the amount of memory required to store the KV cache can become prohibitive at long sequence lengths and large batch sizes. Since the invention of the transformer, two of the most effective interventions discovered for reducing the size of the KV cache have been Multi-Query Attention (MQA) and its generalization, Grouped-Query Attention (GQA). MQA and GQA both modify the design of the attention block so that multiple query heads can share a single key/value head, reducing the number of distinct key/value heads by a large factor while only minimally degrading accuracy. In this paper, we show that it is possible to take Multi-Query Attention a step further by also sharing key and value heads between adjacent layers, yielding a new attention design we call Cross-Layer Attention (CLA). With CLA, we find that it is possible to reduce the size of the KV cache by another 2x while maintaining nearly the same accuracy as unmodified MQA. In experiments training 1B- and 3B-parameter models from scratch, we demonstrate that CLA provides a Pareto improvement over the memory/accuracy tradeoffs which are possible with traditional MQA, enabling inference with longer sequence lengths and larger batch sizes than would otherwise be possible

📄 PDF Abstract BibTeX arXiv:2405.12981

Code (2)

ibm/dolomite-engine pytorch
whyNLP/LCKV pytorch

Methods 이 논문이 사용한 방법론

Dense Connections Dense Connections, or Fully Connected Connections, are a type of layer in a deep neural network that use a linear operation where every input is connected to every output…
Softmax The Softmax output function transforms a previous layer's output into a vector of probabilities. It is commonly used for multiclass classification. Given an input vector $x$…
Attention 설명 없음
Feedforward Network A Feedforward Network, or a Multilayer Perceptron (MLP), is a neural network with solely densely connected layers. This is the classic neural network architecture of the…
Multi-Query Attention 설명 없음
Grouped-query attention 설명 없음

Similar Papers 제목 키워드 기반

Improving Model Representation and Reducing KV Cache via Skip Connections with First Value Heads

2025-10-19 · Zhoutong Wu, Yuan Zhang, Yiming Dong, Chenheng Zhang 외 arxiv

Transformer models have driven breakthroughs across various language tasks by their strong capability to learn rich contextual representations. Scaling them to improve representation, however, often demands substantial m…

MLKV: Multi-Layer Key-Value Heads for Memory Efficient Transformer Decoding

2024-06-13 · Zayd Muhammad Kawakibi Zuhri, Muhammad Farid Adilazuarda, Ayu Purwarianti, Alham Fikri Aji

Auto-regressive inference of transformers benefit greatly from Key-Value (KV) caching, but can lead to major memory bottlenecks as model size, batch size, and sequence length grow at scale. We introduce Multi-Layer Key-V…

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

2024-10-18 · You Wu, HaoYi Wu, Kewei Tu

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 propo…

Language ModelingLanguage Modelling

Depth-Attention: Cross-Layer Value Mixing for Language Models

2026-06-03 · Boyi Zeng, Yiqin Hao, Zitong Wang, Shixiang Song 외 arxiv

Self-attention selects information freely across the sequence, but across depth, Transformers merely add each layer's output to the residual stream, so later layers cannot selectively reuse earlier-layer representations.…

A Method for Building Large Language Models with Predefined KV Cache Capacity

2024-11-24 · Zhonghua Yi, Ge Niu, Lei Wang, Wei Tang 외

This paper introduces a novel approach, the Bounded-Cache Transformer (BCT), for building large language models with a predefined Key-Value (KV) cache capacity. The BCT addresses the excessive memory consumption issue in…