Skip to main content
QUICK REVIEW

[論文レビュー] MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention

Huiqiang Jiang, Yucheng Li|arXiv (Cornell University)|Jul 2, 2024
Advancements in Photolithography TechniquesEngineering被引用数 3
ひとこと要約

MInference 1.0 は、注意行列の分析を通じて特定された動的スパース注意パターン(A字型、バックスラッシュ型、ブロックスパース型)を活用することで、長文脈 LLM の事前入力推論を高速化する。1枚の A100 GPU で 100万トークンのプロンプトに対して、モデルの微調整なしに最大 10倍の高速化を達成し、Needle In A Haystack や InfiniteBench などのベンチマークで高い精度を維持する。

ABSTRACT

The computational challenges of Large Language Model (LLM) inference remain a significant barrier to their widespread deployment, especially as prompt lengths continue to increase. Due to the quadratic complexity of the attention computation, it takes 30 minutes for an 8B LLM to process a prompt of 1M tokens (i.e., the pre-filling stage) on a single A100 GPU. Existing methods for speeding up prefilling often fail to maintain acceptable accuracy or efficiency when applied to long-context LLMs. To address this gap, we introduce MInference (Milliontokens Inference), a sparse calculation method designed to accelerate pre-filling of long-sequence processing. Specifically, we identify three unique patterns in long-context attention matrices-the A-shape, Vertical-Slash, and Block-Sparsethat can be leveraged for efficient sparse computation on GPUs. We determine the optimal pattern for each attention head offline and dynamically build sparse indices based on the assigned pattern during inference. With the pattern and sparse indices, we perform efficient sparse attention calculations via our optimized GPU kernels to significantly reduce the latency in the pre-filling stage of long-context LLMs. Our proposed technique can be directly applied to existing LLMs without any modifications to the pre-training setup or additional fine-tuning. By evaluating on a wide range of downstream tasks, including InfiniteBench, RULER, PG-19, and Needle In A Haystack, and models including LLaMA-3-1M, GLM4-1M, Yi-200K, Phi-3-128K, and Qwen2-128K, we demonstrate that MInference effectively reduces inference latency by up to 10x for pre-filling on an A100, while maintaining accuracy. Our code is available at https://aka.ms/MInference.

研究の動機と目的

  • 1枚の A100 で 100万トークンのプロンプトに対して最大 30分を要する長文脈 LLM の事前入力における高い計算コストを低減すること。
  • 既存のスパース注意手法が微調整を必要としたり、長文脈環境における動的注意パターンに適応できないという制限を克服すること。
  • 長文脈 LLM における安定的でデータ駆動のスパース注意パターンを同定し、それを活用することで、効率的で低オーバーヘッドの推論高速化を実現すること。
  • 推論時に各注意ヘッドに対して最適なスパースパターンを動的に割り当て、推定オーバーヘッドを最小限に抑えるシステムを設計すること。
  • 多様な長文脈ベンチマークおよびモデルアーキテクチャにおいて、モデル精度を保持したまま顕著な遅延低減を達成すること。

提案手法

  • 長文脈 LLM の注意行列の実証的分析を通じて、A字型、バックスラッシュ型、ブロックスパース型の3つの繰り返し発生するスパース注意パターンを同定する。
  • 注意ダイナミクスのオフライン分析に基づき、キーネルに最適なスパースパターンを各注意ヘッドに割り当てるための、キーネルに配慮した探索を実施する。
  • 入力に依存する軽量な近似を用いて、推論時にスパースインデックスを動的に構築する:バックスラッシュ型では最後のクエリおよびキーのベクトルを用い、ブロックスパース型では64トークンブロックごとの平均プーリングを適用する。
  • PIT、Triton、FlashAttention を基盤とする3つの最適化された GPU カーネルを実装し、3つのスパースパターンに特化した高効率なスパース行列乗算を実現する。
  • 事前学習の変更や微調整を必要とせず、既存の LLM に統合可能であり、プラグアンドプレイでの展開を可能にする。
  • 入力ごとに適応する動的スパースマスクを採用し、パターン推定にかかる計算コストを最小限に抑える。

実験結果

リサーチクエスチョン

  • RQ1長文脈 LLM において、微調整なしに効率的な事前入力を可能にする安定的で一般化可能なスパース注意パターンを同定できるか?
  • RQ2最小限の計算オーバーヘッドで、オンラインでの動的スパース注意をどのように推定できるか?
  • RQ3パターン固有のスパース計算によって、長文脈 LLM における FLOPs と推論遅延をどの程度低減できるか?また、精度は保持できるか?
  • RQ4動的スパース注意は、固定スパースまたは密注意と比較して、多様な長文脈ベンチマークでどの程度の性能を示すか?
  • RQ5本手法は、アーキテクチャの変更なしに、さまざまな LLM アーキテクチャおよび文脈長に普遍的に適用可能か?

主な発見

  • 1枚の A100 GPU で 100万トークンのプロンプトに対して、MInference は事前入力遅延を最大 10倍に短縮し、30分の事前入力処理を3分未満に短縮する。
  • 本手法は、Needle In A Haystack、InfiniteBench、RULER、PG-19 などのベンチマークで高い精度を維持し、ベースラインを上回るか同等の性能を示す。
  • 長文脈 LLM の注意行列は、128K の文脈長で最大 96.8% のスパースリティを示しており、スパース計算の実現可能性を裏付けている。
  • A字型、バックスラッシュ型、ブロックスパース型のパターンは、LLaMA-3-1M、GLM-4-1M、Qwen2-128K など複数のモデルで一貫して観察される。
  • 動的スパースマスクの構築に起因するオーバーヘッドは無視できるほど小さく、遅延にほとんど影響を与えないリアルタイム推論を可能にする。
  • 本手法はモデルに依存せず、微調整やアーキテクチャ変更なしに既存の LLM に適用可能であることが、LLaMA-3-8B-1M、Phi-3-Mini-128K、Qwen-2-7B-128K でも実証された。

この論文を読む

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

Nubintでこの論文を読む

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