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

Yutao Sun, Li Dong, Yi Zhu, Shaohan Huang, Wenhui Wang, Shuming Ma, Quanlu Zhang, Jianyong Wang, Furu Wei

arXiv:2405.05254 · 2026-07-27 공개 · arXiv · PDF

transformer large-language-models long-context memory-optimization key-value-cache inference-throughput decoder-decoder yoco

Abstract

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.

한국어 요약

한 줄 요약

YOCO는 키-벨류 캐시를 단 한 번만 저장하는 디코더-디코더 아키텍처로, GPU 메모리 소비와 프리필 레이턴시를 대폭 줄인다.

핵심 기여도

핵심 아이디어

기존 디코더-온리 트랜스포머는 토큰 생성 시마다 키-벨류 캐시를 저장하여 메모리 소비가 급증한다. YOCO는 이를 해결하기 위해 **self-decoder**가 전체 입력을 한 번만 처리하여 **글로벌 KV 캐시**를 생성하고, **cross-decoder**가 이를 재사용하는 방식을 도입한다. 이는 KV 캐시를 단 한 번만 저장함으로써 메모리 사용량을 줄이고, **cross-attention**을 통해 글로벌 정보를 유지할 수 있다.

또한, YOCO는 **prefill 단계**에서 **early exit**가 가능하도록 설계되어, 입력 처리 시간을 크게 단축한다. 이는 특히 **1M 길이의 컨텍스트**에서 유용하며, **71.8× 빠른 프리필 속도**를 기록한다.

기술적 접근법

주요 결과

의의 및 한계

YOCO는 대규모 언어 모델에서 **메모리 효율성**과 **추론 속도**를 동시에 향상시키는 아키텍처로, 특히 **1M 길이의 컨텍스트 처리**에 강점을 가진다. **KV 캐시 재사용**과 **early exit 메커니즘**은 기존 디코더-온리 모델의 한계를 극복하며, **멀티모달**, **스트리밍 비디오**, **로봇** 등 실시간 응용 분야에 유용하다.

하지만, YOCO는 **self-decoder의 캐시 크기**가 **상수 크기**로 유지되므로, 매우 짧은 입력에서는 성능 개선 효과가 적을 수 있다. 또한, **gated retention**이나 **KV 캐시 인덱싱** 등의 추가 최적화가 필요하다는 점이 한계로 지적된다.

실용적 활용

YOCO는 **대규모 언어 모델의 실시간 추론**, **멀티모달 언어 모델**, **로봇 및 스트리밍 비디오 처리** 등에서 활용 가능하다. 특히, **Groq와 BitNet**과의 결합을 통해 **SRAM 기반의 저비용 추론 시스템** 구축이 가능하며, **RAG 및 검색 엔진**에도 적용 가능하다.