Flash Attention 4 is the next-generation implementation of the Flash Attention algorithm using NVIDIA CUTE (CUDA Template Engine). It provides highly optimized fused attention kernels for modern GPUs, supporting head dimensions up to 256 and various data types including FP8. Version 4.0.0b12 is in beta, with frequent releases.
pip install flash-attn-4No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic forward pass with causal masking.
Update code to unpack the tuple: out, lse = flash_attn_func(...)
Use 'pip install flash-attn-4' and 'import flash_attn_4'.
Check GPU compute capability via torch.cuda.get_device_capability(). Minimum 8.0 required.