---
title: "We reverse-engineered Flash Attention 4"
description: "Flash Attention 4, Tri Dao's attention kernel for Nvidia Blackwell GPUs, reportedly runs about 20% faster than cuDNN's closed-source attention kernels."
url: "https://swe.quest/articles/we-reverse-engineered-flash-attention-4-e0ddc41706e090a5"
canonical: "https://modal.com/blog/reverse-engineer-flash-attention-4"
source: "Modal"
published: "2025-09-26"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 18
tags: ["inference","hardware","performance","concurrency","llms"]
---

# We reverse-engineered Flash Attention 4

A post on [Modal](https://swe.quest/sources/modal.md), published 2025-09-26, 18 min read, Deep dive. Original: [https://modal.com/blog/reverse-engineer-flash-attention-4](https://modal.com/blog/reverse-engineer-flash-attention-4)

## Summary

Flash Attention 4, Tri Dao's attention kernel for Nvidia Blackwell GPUs, reportedly runs about 20% faster than cuDNN's closed-source attention kernels. Its main change is a far more complex warp-specialized asynchronous pipeline: Load, MMA, Softmax, Correction and Epilogue warps hand tiles through shared and Tensor Memory, synchronized by producer/consumer barriers. Two math tricks add to the gain. A cubic polynomial exponential runs on CUDA Cores to avoid queueing on the scarce Special Function Units, and a smarter online softmax rescales only when the running max changes enough to matter, reportedly cutting rescaling work by 10x. The authors read the released source and argue that programmer-managed asynchrony is pushing GPU programming toward tile-based DSLs such as CuTe, CUTLASS, Gluon and CuTile.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- Transformer attention
- CUDA programming model
- GPU memory hierarchy ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))
- asynchronous programming

## Keywords

Flash Attention 4, Nvidia Blackwell, CUDA, Tensor Cores, cuDNN, CuTe DSL, CUTLASS, Tensor Memory Accelerator

## Related posts

- [FlashAttention-4: Algorithm and Kernel Pipelining Co-Design for Asymmetric Hardware Scaling](https://swe.quest/articles/flashattention-4-algorithm-and-kernel-pipelining-co-design-for-asymmetric-67fe95e5005d9861.md): Together AI · 2026-03-05 · Hard · 11 min read · Inference & serving, Performance engineering, Hardware, Model training, LLMs
  FlashAttention-4 is an attention kernel co-designed for Blackwell GPUs, where tensor core throughput grew much faster than the exponential (SFU) units and shared memory bandwidth.
- [Making FlashAttention-4 faster for inference](https://swe.quest/articles/making-flashattention-4-faster-for-inference-dc917e70c20e0f22.md): Modal · 2026-06-11 · Hard · 14 min read · Inference & serving, Hardware, Performance engineering, LLMs
  Modal engineers extended the FlashAttention-4 kernel for decode-heavy LLM inference on Blackwell GPUs through two kinds of change: new parallelism strategies, such as split-KV parallelism across the key/value dimension, and support for irregular memory access via cp.async in place of TMA bulk loads.
- [Key research and product announcements at the AI Native Conf](https://swe.quest/articles/key-research-and-product-announcements-at-the-ai-native-conf-07f3b657efde83f0.md): Together AI · 2026-03-05 · Hard · 7 min read · Inference & serving, Hardware, Model training, AI agents, Performance engineering
  Together AI announced seven research and product releases spanning GPU kernels, reinforcement learning infrastructure and inference optimization.
- [Profiling in PyTorch (Part 3): Attention is all you profile](https://swe.quest/articles/profiling-in-pytorch-part-3-attention-is-all-you-profile-44c4f73b7586bec2.md): Hugging Face · 2026-07-10 · Medium · 21 min read · Performance engineering, Inference & serving, Python, Hardware, LLMs
  Profiling attention variants in PyTorch on an A100 shows how each implementation appears in profiler traces.
- [Profiling in PyTorch (Part 2): From nn.Linear to a Fused MLP](https://swe.quest/articles/profiling-in-pytorch-part-2-from-nn-linear-to-a-fused-mlp-9b220b5d3b1f868e.md): Hugging Face · 2026-06-11 · Hard · 19 min read · Performance engineering, Python, Machine learning, Compilers
  Profiling an nn.Linear on an A100 shows a single cuBLAS/CUTLASS GEMM kernel with the bias folded in as an epilogue via aten::addmm, while aten::t only rewrites strides on the CPU and launches nothing.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
