Dao-AILab/flash-attention

Fast and memory-efficient exact attention

What it solves

FlashAttention は、Transformer の Attention 機制をより高速かつメモリ効率よくすることを目的に設計されています。これは、シーケンス長に対してメモリと計算時間が二次関数的に増加する問題に対処し、LLM の長シーケンス処理を遅くする主な原因を解消します。

How it works

GPU の高帯域幅メモリとオンチップ SRAM の間のメモリ読み書き回数を削減する、IO-aware な正確な Attention アルゴリズムを実装しています。このプロジェクトは、NVIDIA Ampere, Ada, Hopper, and Blackwell などの異なる GPU アーキテクチャ向けに最適化が進んだ複数のバージョン (FlashAttention-2, 3, and 4) を提供しています。また、Triton と Composable Kernel バックエンドを介して AMD ROCm もサポートしています。

Who it’s for

主に、現代の GPU で高いスループットと低いメモリ使用量を実現するために、Attention 層を最適化する必要がある、大規模言語モデルを構築または学習させる AI 研究者やエンジニア向けです。

Highlights

  • Multi-GPU Architecture Support: NVIDIA (H100/B200 を含む) および AMD (MI200/MI300) ハードウェア向けに最適化されたカーネル (kernels)。
  • Inference Optimizations: 高効率な増分デコーディングとインプレース (in-place) KV cache 更新を実現するための flash_attn_with_kvcache を含みます。
  • Advanced Attention Variants: Causal masking, sliding window local attention, および ALiBi (attention with linear bias) をサポートしています。
  • Flexible Head Configurations: Multi-Query Attention (MQA) と Grouped-Query Attention (GQA) をサポートしています。

関連

  • プロジェクト
  • プロジェクト
  • プロジェクト
  • プロジェクト
  • Dispatch