Skip to main content
QUICK REVIEW

[論文レビュー] MiniCache: KV Cache Compression in Depth Dimension for Large Language Models

Akide Liu, Jing Liu|arXiv (Cornell University)|May 23, 2024
Topic ModelingComputer Science被引用数 3
ひとこと要約

MiniCacheは、深層Transformer層間の相互類似性を活用して、キーベクトル(KV)キャッシュを訓練不要でクロスレイヤーに圧縮する手法を提案する。キーベクトル状態を大きさと方向成分に分解することで、隣接するレイヤー間での効率的な統合が可能になる。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推論におけるKVキャッシュの高いメモリ使用量、特に長文脈長の状況下での課題に対処すること。
  • LLMの深さ方向におけるKVキャッシュ状態の相互冗長性を探索・活用すること。これは、これまで無視されてきた分野である。
  • 微調整や再訓練を必要とせず、一般化可能な圧縮手法を設計すること。これは、量子化やスパarsityといった既存の戦略と補完的である。
  • メモリ使用量を著しく削減し、推論スループットを向上させながら、ほぼ無損失の性能を維持すること。
  • ベクトル分解に基づくシンプルだが効果的な統合戦略を用いて、長文脈LLMの効率的デプロイを可能にすること。

提案手法

  • 重み正則化に類似した再パrameterizationを用いて、KVキャッシュ状態を大きさと方向成分に分解し、安定したレイヤー間統合を可能にする。
  • 隣接するレイヤー状態の方向成分を補間しながら、大きさを保持することで、類似した状態の正確な統合を実現する。
  • 情報損失を避けるために、顕著に異なる状態ペアを特定・保持するトークン保持戦略を導入する。
  • 相互類似性が最も高い中層〜深層部から始めて、複数のレイヤーにわたってこの手法を適用する。
  • 4ビット量子化やスパarsityといった既存の圧縮技術とシームレスに統合され、全体のメモリ効率を向上させる。
  • 再訓練やファインチューニングを一切必要とせず、エンドツーエンドで推論専用に動作する。
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

実験結果

リサーチクエスチョン

  • RQ1KVキャッシュ状態におけるレイヤー間の冗長性は、LLM推論におけるメモリ使用量削減に有効に活用可能か?
  • RQ2隣接するレイヤーからのKVキャッシュ状態は、モデル性能を維持したまま、どのように正確に統合できるか?
  • RQ3深さ方向にわたるKVキャッシュ状態の統合は、推論速度とメモリ消費量にどのような影響を及えるか?
  • RQ4平均化ベースラインや完全なFP16キャッシュと比較して、MiniCacheは精度と効率の面でどのように優れているか?
  • RQ5量子化などの他の圧縮技術と組み合わせることで、さらに高い性能向上が達成可能か?

主な発見

  • 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

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。