FlashAttention is an IO-aware exact attention algorithm that computes the standard attention function without approximation while significantly reducing reads and writes between GPU high-bandwidth memory (HBM) and faster on-chip SRAM. By fusing operations and tiling the computation into blocks that fit entirely within SRAM, it avoids materializing the full N×N attention matrix in HBM, which is the primary bottleneck in standard implementations. This yields wall-clock speedups of 2-4x and reduces memory consumption from quadratic to linear in sequence length.
Glossary
FlashAttention

What is FlashAttention?
FlashAttention is an input/output-aware exact attention algorithm that dramatically accelerates the transformer self-attention mechanism by minimizing data movement between GPU high-bandwidth memory (HBM) and on-chip SRAM.
The algorithm employs two key techniques: tiling to decompose the softmax computation into smaller blocks processed incrementally, and recomputation of the attention matrix during the backward pass rather than storing it from the forward pass. This trades additional FLOPs for drastically reduced I/O, aligning with the reality that modern GPU compute is abundant while memory bandwidth is the binding constraint. FlashAttention-2 and FlashAttention-3 further optimize this by improving work partitioning across thread blocks and exploiting newer hardware features like Hopper architecture TMA and FP8 support.
Key Features of FlashAttention
FlashAttention is an algorithm that accelerates the transformer attention mechanism by minimizing data movement between GPU high-bandwidth memory (HBM) and on-chip SRAM. It computes exact attention, not an approximation, while achieving significant speed and memory efficiency gains.
IO-Aware Tiling
The core innovation of FlashAttention is decomposing the attention computation into small tiles that fit entirely into on-chip SRAM. By fusing the softmax reduction across these tiles using a numerically stable online algorithm, the method avoids materializing the full N×N attention matrix in HBM. This reduces the number of high-latency HBM reads and writes from quadratic O(N²) to sub-quadratic, directly addressing the memory bottleneck that plagues standard attention implementations on long sequences.
Exact Computation, Not Approximation
Unlike sparse or low-rank attention approximations that trade accuracy for speed, FlashAttention computes mathematically exact attention scores. The tiling and online softmax algorithm is numerically equivalent to the standard implementation, producing identical outputs up to floating-point precision. This guarantees no degradation in model quality or perplexity, making it a drop-in replacement that accelerates training and inference without requiring architectural changes or retuning hyperparameters.
Memory Footprint Reduction
Standard attention stores the intermediate N×N attention matrix for the backward pass, causing memory consumption to scale quadratically with sequence length. FlashAttention employs recomputation in the backward pass: it recalculates attention scores on-the-fly from the stored softmax normalization statistics rather than reading the full matrix from HBM. This reduces peak memory usage from O(N²) to O(N), enabling training with sequence lengths up to 8K or 16K tokens on hardware that would otherwise run out of memory.
Kernel Fusion for GPU Efficiency
FlashAttention is implemented as a single, highly optimized CUDA kernel that fuses multiple operations—matrix multiply, softmax, dropout, and masking—into one GPU pass. This eliminates the overhead of launching separate kernels and storing intermediate results in global memory. The fused kernel maximizes occupancy and arithmetic intensity by keeping data in registers and shared memory, achieving up to 7.6x speedup over standard PyTorch attention and approaching the theoretical peak throughput of modern NVIDIA GPUs.
FlashAttention-2: Parallelism Optimizations
The second iteration, FlashAttention-2, introduces critical work partitioning improvements. It parallelizes over the sequence length dimension rather than the batch and head dimensions, achieving higher GPU occupancy. It also reduces non-matmul FLOPs by optimizing the rescaling logic within the online softmax loop. These changes bring utilization closer to theoretical peak and deliver approximately 2x speedup over FlashAttention-1 on modern architectures like the H100 GPU, particularly for the forward pass.
FlashAttention-3: Hopper Architecture Exploitation
FlashAttention-3 is purpose-built for the NVIDIA Hopper GPU architecture (H100/H200). It leverages new hardware features such as WGMMA (Warp Group Matrix Multiply-Accumulate) instructions for asynchronous tensor core operations and TMA (Tensor Memory Accelerator) for hardware-accelerated data copying between global and shared memory. By overlapping computation with data movement using Hopper's asynchronous execution model, FlashAttention-3 achieves up to 1.5-2.0x speedup over FlashAttention-2 and reaches 740 TFLOPS on H100 GPUs, representing 75% of theoretical peak FP16 performance.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about the IO-aware exact attention algorithm that transformed transformer efficiency.
FlashAttention is an IO-aware exact attention algorithm that computes the standard transformer self-attention mechanism without approximation while dramatically reducing reads and writes between GPU high-bandwidth memory (HBM) and on-chip SRAM. It works by tiling the attention computation into blocks that fit entirely within SRAM, computing the softmax in a numerically stable incremental fashion using a running maximum and rescaling technique. Instead of materializing the full N×N attention matrix in HBM—which is quadratic in sequence length—FlashAttention fuses the entire attention operation into a single CUDA kernel, performing all computations on-chip before writing only the final output back to HBM. This reduces HBM access from O(N²) to O(N), yielding 2-4× wall-clock speedups and enabling training on sequences up to 64K tokens without approximation.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts and infrastructure components that interact with or are optimized by IO-aware exact attention algorithms.
KV Cache
A memory mechanism in transformer-based generative models that stores previously computed key and value tensors to avoid redundant computation during autoregressive token generation. FlashAttention's memory efficiency directly reduces the footprint of the KV cache, allowing for larger batch sizes or longer context windows without exhausting GPU high-bandwidth memory.
Mixed Precision Inference
The practice of using lower-precision formats like FP16 or BF16 for compute-intensive operations while retaining FP32 precision for critical parts of the network. FlashAttention is designed to operate efficiently in FP16 and BF16 modes, leveraging tensor core acceleration on modern GPUs to deliver further speedups without numerical instability.
Continuous Batching
An advanced iteration of dynamic batching for generative models that evicts completed sequences from a batch and inserts new requests immediately, preventing idle compute time. FlashAttention's deterministic and fast execution enables predictable kernel launch times, which is critical for the tight scheduling loops required by continuous batching systems.
Speculative Decoding
A latency-reduction technique where a small, fast draft model predicts multiple future tokens that are then verified in parallel by a larger target model. The parallel verification step relies on a single forward pass with an attention mechanism that benefits directly from FlashAttention's speed, making the verification overhead negligible.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us