CLMay 8, 2024

You Only Cache Once: Decoder-Decoder Architectures for Language Models

MicrosoftTsinghua
arXiv:2405.05254v2133 citationsh-index: 63Has CodeNIPS
Originality Highly original
AI Analysis

This addresses memory efficiency issues for users of large language models, offering a novel architectural improvement that is not purely incremental.

The paper tackles the problem of high GPU memory demands in large language models by introducing YOCO, a decoder-decoder architecture that caches key-value pairs only once, reducing memory usage while retaining global attention. It achieves favorable performance compared to Transformer, extends to 1M context length with near-perfect retrieval accuracy, and improves inference memory, prefill latency, and throughput by orders of magnitude.

We introduce a decoder-decoder architecture, YOCO, for large language models, which only caches key-value pairs once. It consists of two components, i.e., a cross-decoder stacked upon a self-decoder. The self-decoder efficiently encodes global key-value (KV) caches that are reused by the cross-decoder via cross-attention. The overall model behaves like a decoder-only Transformer, although YOCO only caches once. The design substantially reduces GPU memory demands, yet retains global attention capability. Additionally, the computation flow enables prefilling to early exit without changing the final output, thereby significantly speeding up the prefill stage. Experimental results demonstrate that YOCO achieves favorable performance compared to Transformer in various settings of scaling up model size and number of training tokens. We also extend YOCO to 1M context length with near-perfect needle retrieval accuracy. The profiling results show that YOCO improves inference memory, prefill latency, and throughput by orders of magnitude across context lengths and model sizes. Code is available at https://aka.ms/YOCO.

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes