What problem does it solve?
Flash Attention reduces transformer attention memory blow-ups and improves throughput so you can train or run long-context models without hitting GPU OOM or slow attention kernels.
Core Features & Use Cases
- Faster, memory-efficient attention: Implements IO-aware tiling/recomputation to avoid materializing the full attention matrix, delivering multi-x speedups on long sequences.
- Drop-in PyTorch SDPA support: Uses PyTorch scaled_dot_product_attention (native backend) for simpler integration (PyTorch 2.2+).
- Advanced kernels via flash-attn: Enables FlashAttention-2 and FlashAttention-3 features such as multi-query attention, sliding window attention, and H100 FP8 acceleration for further gains.
Use case example: You’re running a Llama/Mistral fine-tuning or inference job with 8K–32K tokens and standard attention either OOMs or becomes too slow; applying Flash Attention lets the workload fit and run significantly faster while preserving results closely (typical small numerical differences).
Quick Start
Install flash-attn and switch your model’s attention to FlashAttention-2 (or native SDPA) to benchmark speed and memory on your target sequence length.