Skip to main content
QUICK REVIEW

[논문 리뷰] MiniCache: KV Cache Compression in Depth Dimension for Large Language Models

Akide Liu, Jing Liu|arXiv (Cornell University)|2024. 05. 23.
Topic ModelingComputer Science인용 수 3
한 줄 요약

MiniCache는 깊이 있는 트랜스포머 레이어 간의 레이어 간 유사성을 활용하여 훈련이 필요 없는 다층적 키-값 캐시 압축 기법을 제안한다. 이는 키-값 상태를 크기와 방향 성분으로 분해함으로써 인접 레이어 간 효율적인 병합을 가능하게 한다. 4비트 양자화를 사용할 경우 최대 5.02배의 압축 비율을 달성하며, FP16 기준 대비 5배 높은 처리량과 41% 낮은 메모리 사용량을 기록한다. LLaMA-2 및 기타 모델에서 거의 손실이 없는 성능 유지를 유지한다.

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.

연구 동기 및 목표

  • 자기연쇄적 LLM 추론에서 키-값 캐시의 높은 메모리 점유율 문제를 해결하기 위해, 특히 장문의 컨텍스트 길이에서의 영향을 다루는 것.
  • LLM의 깊이 차원에서 키-값 캐시 상태 간의 상호 레이어 레이턴시를 탐색하고 활용하는 것. 이는 이전에 간과된 방향이다.
  • 기존 기법들(예: 양자화 및 희박성)과 보완할 수 있는 훈련이 필요 없는 일반화된 압축 방법을 설계하는 것.
  • 메모리 사용량을 크게 줄이고 추론 처리량을 향상시키면서도 거의 손실이 없는 성능을 유지하는 것.
  • 벡터 분해 기반의 단순하면서도 효과적인 병합 전략을 통해 장문의 컨텍스트 LLM을 효율적으로 배포할 수 있도록 하는 것.

제안 방법

  • 가중치 정규화와 유사하게 재파rametrization을 사용하여 키-값 캐시 상태를 크기와 방향 성분으로 분해함으로써 안정적인 레이어 간 병합을 가능하게 한다.
  • 인접한 레이어 상태의 방향 성분을 보존하면서 보간하여 유사한 상태 간 정확한 병합을 허용한다.
  • 정보 손실을 방지하기 위해 매우 다름을 보이는 상태 쌍을 식별하고 유지하는 토큰 유지 전략을 도입한다.
  • 레이어 간 유사성이 가장 높은 중간에서 깊은 부분부터 시작하여 다수의 레이어에 걸쳐 이 방법을 적용한다.
  • 4비트 양자화 및 희박성과 같은 기존 압축 기법들과 원활하게 통합되어 전체 메모리 효율성을 향상시킨다.
  • 재훈련이나 피지테이닝이 필요 없이 종단 간 추론 전용으로 작동한다.
Figure 1 : Overview of our MiniCache strategy and example results: (a) shows the observation that the KV cache states between two adjacent layers are highly similar, particularly across the middle to deep layers. The x-axis uses index/2 to represent the similarities for each pair of layers. (b) comp
Figure 1 : Overview of our MiniCache strategy and example results: (a) shows the observation that the KV cache states between two adjacent layers are highly similar, particularly across the middle to deep layers. The x-axis uses index/2 to represent the similarities for each pair of layers. (b) comp

실험 결과

연구 질문

  • RQ1키-값 캐시 상태의 상호 레이어 레이턴시는 LLM 추론에서 메모리 점유율을 줄이기 위해 효과적으로 활용될 수 있는가?
  • RQ2인접한 레이어의 키-값 캐시 상태는 어떻게 정확하게 병합할 수 있으며, 이로 인해 모델 성능이 유지되는가?
  • RQ3깊이 방향으로 키-값 캐시 상태를 병합함으로써 추론 속도와 메모리 소비에 어떤 영향을 미치는가?
  • RQ4MiniCache는 평균 평균화나 전체 FP16 캐싱과 같은 기준 방법에 비해 정확도와 효율성 측면에서 어떻게 비교되는가?
  • RQ5MiniCache는 양자화와 같은 다른 압축 기법과 조합하여 더 큰 성과를 낼 수 있는가?

주요 결과

  • ShareGPT 벤치마크에서 LLaMA-2-7B에 4비트 MiniCache를 적용한 결과, 압축 비율이 5.02배에 달하며, FP16 기준 대비 메모리 점유율이 41% 감소하였다.
  • 동일한 환경에서 MiniCache는 추론 처리량을 약 5배 향상시켰으며, 서빙 효율성 향상에 기여하였다.
  • 다양한 벤치마크인 GSM8K, COQA, TruthfulQA에서 생성 품질에 대한 낮은 손실을 유지하며 거의 손실이 없는 성능을 기록하였다.
  • 성능 향상은 레이어 간 유사성이 가장 높은 더 깊은 레이어에서 가장 두드러지게 나타났으며, 중간에서 깊은 레이어에서 병합을 시작하는 핵심 설계 원칙의 타당성을 입증하였다.
  • 단순한 평균 기반 병합 전략에 비해 MiniCache는 크기-방향 분해와 선택적 유지 메커니즘의 효과를 입증하며 뛰어난 성능을 보였다.
  • LLaMA-2, LLaMA-3, Phi-3, Mistral, Mixtral 등 다양한 모델에 걸쳐 일반화되며 아키텍처 유형에 관계없이 일관된 성과를 보였다.
(a) Simple average baseline vs. full cache on GSM8K
(a) Simple average baseline vs. full cache on GSM8K

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.