Dao-AILab/flash-attention

Fast and memory-efficient exact attention

What it solves

FlashAttention은 Transformer의 attention mechanism을 더 빠르고 메모리 효율적으로 만들기 위해 설계되었습니다. 시퀀스 길이에 따라 메모리와 계산 시간이 이차함수적으로 증가하는 문제를 해결하여, LLM의 긴 시퀀스 처리 속도를 늦추는 문제를 해결합니다.

How it works

GPU의 고대역폭 메모리와 온칩 SRAM 사이의 메모리 읽기/쓰기 횟수를 줄이는 IO-aware 정확한 attention 알고리즘을 implement 합니다. 이 프로젝트는 NVIDIA Ampere, Ada, Hopper, and Blackwell를 포함한 다양한 GPU 아키텍처에 대해 최적화가 점차 증가하는 여러 버전 (FlashAttention-2, 3, and 4)을 제공합니다. 또한 Triton과 Composable Kernel 백엔드를 통해 AMD ROCm을 지원합니다.

Who it’s for

현대적 GPU에서 더 높은 처리량과 더 낮은 메모리 사용량을 위해 attention layer를 최적화해야 하는, 대규모 언어 모델을 구축하거나 학습시키는 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)를 지원합니다.
  • Advanced Attention Variants: Multi-Query Attention (MQA) 및 Grouped-Query Attention (GQA heads)를 지원합니다.

관련

  • 프로젝트
  • 프로젝트
  • 프로젝트
  • 프로젝트
  • Dispatch