MiniCache: KV Cache Compression in Depth Dimension for Large Language Models

Akide Liu, Jing Liu, Zizheng Pan, Yefei He, Gholamreza Haffari, Bohan Zhuang

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

kv-cache llm-inference memory-optimization llama-2 compression llama-3 mixtral token-retention

Abstract

A critical approach for efficiently deploying computationally demanding large language models (LLMs) is Key-Value (KV) caching. The KV cache stores key-value states of previously generated tokens, significantly reducing the need for repetitive computations and thereby lowering latency in autoregressive generation. However, the size of the KV cache grows linearly with sequence length, posing challenges for applications requiring long context input and extensive sequence generation. In this paper, we present a simple yet effective approach, called MiniCache, to compress the KV cache across layers from a novel depth perspective, significantly reducing the memory footprint for LLM inference. Our approach is based on the observation that KV cache states exhibit high similarity between the adjacent layers in the middle-to-deep portion of LLMs. To facilitate merging, we propose disentangling the states into the magnitude and direction components, interpolating the directions of the state vectors while preserving their lengths unchanged. Furthermore, we introduce a token retention strategy to keep highly distinct state pairs unmerged, thus preserving the information with minimal additional storage overhead. Our MiniCache is training-free and general, complementing existing KV cache compression strategies, such as quantization and sparsity. We conduct a comprehensive evaluation of MiniCache utilizing various models including LLaMA-2, LLaMA-3, Phi-3, Mistral, and Mixtral across multiple benchmarks, demonstrating its exceptional performance in achieving superior compression ratios and high throughput. On the ShareGPT dataset, LLaMA-2-7B with 4-bit MiniCache achieves a remarkable compression ratio of up to 5.02x, enhances inference throughput by approximately 5x, and reduces the memory footprint by 41% compared to the FP16 full cache baseline, all while maintaining near-lossless performance.

한국어 요약

한 줄 요약

MiniCache는 LLM의 KV 캐시를 깊이 차원에서 압축하여 메모리 사용량을 41% 감소시키고 추론 속도를 5배 향상시키는 새로운 방법이다.

핵심 기여도

핵심 아이디어

기존 KV 캐시 압축 연구는 주로 **단일 레이어 내부**(intra-layer) 중복성을 탐색했으나, MiniCache는 **연속된 레이어 간**(inter-layer)의 중복성을 활용하는 새로운 관점, 즉 **깊이 차원**(depth dimension)에서의 압축을 제안한다.
LLM의 중간~깊은 레이어에서 **인접 레이어 간의 KV 캐시 상태가 높은 유사도를 보인다는 관찰**을 바탕으로, 상태 벡터를 **크기**(magnitude)와 **방향**(direction)으로 분리하고, 방향 정보만 공유하여 메모리 사용량을 줄인다.
이를 통해 **각 레이어 별로 저장할 필요 없이 공통된 방향 정보만 저장**할 수 있으며, **유사도가 낮은 토큰 쌍은 별도 저장**(token retention)하여 정보 손실을 최소화한다.

기술적 접근법

주요 결과

의의 및 한계

MiniCache는 기존의 **quantization** 및 **sparsity** 기법과 **직교**(orthogonal)하여, **메모리 효율성과 성능을 동시에 개선**할 수 있다.
특히, **깊이 차원에서의 중복성**을 활용한 압축은 기존 연구에서 거의 다루어지지 않았으며, **대규모 모델**(예: 70B 파라미터)에서도 효과적으로 적용 가능하다는 점에서 학술적·실용적 가치가 크다.
하지만, **모든 토큰 쌍이 병합에 적합하지 않다는 한계**가 있으며, **유사도가 낮은 토큰은 별도 저장**해야 하므로, **일정 수준의 추가 메모리 사용이 수반**된다.

실용적 활용

MiniCache는 **LLM 기반 대화형 서비스**, **장문 생성**, **배치 추론** 등 **메모리 효율성과 추론 속도가 중요한 분야**에 적용 가능하다.
특히, **GPU 메모리가 제한된 환경**에서 **LLM 배포 비용을 낮추고, 대규모 배치 처리를 가능하게** 하는데 유용하며, **4-bit 양자화와 결합**하면 **추론 속도와 메모리 절감을 동시에 달성**할 수 있다.