flash-attn-4
Flash Attention CUTE (CUDA Template Engine) implementation
What it is and what it does
flash-attn-4 is a specialized GPU kernel library that reimplements the attention operation—a core component of transformer neural networks—using CuTeDSL for modern NVIDIA Hopper and Blackwell architectures. It trades general-purpose compatibility for speed and memory efficiency on these specific GPUs by fusing multiple attention computation steps into a single kernel, reducing memory bandwidth and improving cache locality.
The package is designed for researchers and practitioners building or fine-tuning large language models and other transformer-based systems where attention computation dominates runtime. It provides two main entry points: flash_attn_func for standard attention and flash_attn_varlen_func for variable-length sequences. Installation requires torch, nvidia-cutlass-dsl, and a compatible CUDA version; the package is in active development (alpha status) and updated frequently.
Use it for:
- Accelerate training or inference of large language models on Hopper/Blackwell GPUs by replacing standard attention with optimized kernels.
- Reduce memory consumption during transformer model training by fusing attention operations into a single GPU kernel.
- Implement causal attention for autoregressive language generation with lower latency.
- Handle variable-length sequences efficiently in batched transformer inference without padding overhead.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
GPU-accelerated attention mechanism implementation using CuTeDSL for Hopper and Blackwell GPUs, optimizing the core computational bottleneck in transformer models.
Yes, if you are training or running transformer models on Hopper or Blackwell GPUs and want lower latency and memory usage. The package is actively maintained, has no known vulnerabilities, and uses a permissive license. However, it is in alpha status and only useful for specific GPU hardware; it will not benefit users on other GPU architectures or CPU-only setups.
Install
flash-attn-4 on PyPI
pip
pip install flash-attn-4uv
uv add flash-attn-4poetry
poetry add flash-attn-4Installing flash-attn-4
Before you install
Installation is straightforward with low friction. The package is actively maintained with a recent release (2 days old) and high repository engagement (24706 stars). Requires torch and NVIDIA GPU libraries as runtime dependencies.
License in practice
BSD 3-Clause License is permissive, allowing commercial and private use with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
pip install flash-attn-4
# or for CUDA 13:
# pip install "flash-attn-4[cu13]"
from flash_attn.cute import flash_attn_func
out = flash_attn_func(q, k, v, causal=True)
Requires an NVIDIA Hopper or Blackwell GPU and corresponding CUDA toolkit; torch must be installed and configured for your CUDA version.
Verify before relying
- Performance benchmarks compared to standard PyTorch attention or other implementations.
- Supported tensor shapes, dtypes, and edge cases for q, k, v inputs.
- Memory overhead and actual speedup on different model sizes and batch configurations.
- Stability and numerical accuracy guarantees relative to standard attention.
Package facts
| License | BSD 3-Clause License (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — nvidia-cutlass-dsl, torch, einops, typing_extensions, apache-tvm-ffi, torch-c-dlpack-ext, quack-kernels |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,040,273/month — #3,347 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flash_attn_4-4.0.0b26-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
flash-attnProvides optimized GPU implementations of…
permissive · top 15,000 on PyPI
fa3-fwdProvides a lightweight Flash-Attention-3…
permissive · top 15,000 on PyPI
nvidia-cudnn-frontendProvides Python and C++ APIs to NVIDIA's cuDNN…
permissive · top 5,000 on PyPI
ring-flash-attnImplements ring attention with flash attention…
permissive · top 15,000 on PyPI
flashinfer-cubinProvides pre-compiled GPU kernel binaries…
permissive · top 5,000 on PyPI
flashinfer-pythonFlashInfer provides optimized GPU kernels for…
permissive · top 5,000 on PyPI
tokenspeed-mlaProvides optimized MLA (Multi-head Latent…
permissive · top 5,000 on PyPI
transformer-engine-cu12Accelerates Transformer model training and…
unclear · top 15,000 on PyPI
transformer-engineTransformer Engine accelerates Transformer…
unclear · top 15,000 on PyPI
transformer-engine-cu13Accelerates Transformer model training and…
unclear · top 15,000 on PyPI