What problem does it solve?
This Skill helps you reduce transformer attention compute time and GPU memory pressure by switching attention implementations to Flash Attention, especially when sequence lengths are long or you hit CUDA out-of-memory errors.
Core Features & Use Cases
- Faster, memory-efficient attention: Achieves 2–4x speedups and 10–20x memory reductions by avoiding materializing the full attention matrix through IO-aware tiling and recomputation.
- Multiple integration paths: Uses PyTorch native scaled_dot_product_attention (SDPA) for easy enablement, or the flash-attn library for advanced features and more control.
- Long-context and GPU optimization: Supports scenarios like training/inference with >512 tokens, sliding-window attention, multi-query attention, and FlashAttention-3 optimizations such as H100 FP8 acceleration.
Example Use Case
If your training or inference run OOMs when pushing context to thousands of tokens, enable Flash Attention to fit larger batches or longer sequences while improving throughput.
Quick Start
Use the optimizing-attention-flash skill to enable Flash Attention in your PyTorch model (or switch to flash-attn) for transformer attention on long sequences and then verify performance with a short benchmark.