# FlashAttention

- **Canonical URL:** https://getaimath.com/dictionary/flashattention/
- **Topics:** [Transformer Architecture](https://getaimath.com/dictionary/category/transformer-architecture/)
- **Last updated:** 2026-11-25

## What is FlashAttention?

**In one sentence:** FlashAttention is a clever way to compute attention on GPUs that is much faster and uses much less memory, while giving the same results.

Normal attention writes huge temporary tables to slow GPU memory. FlashAttention breaks the work into small tiles that fit in the GPU's fast on-chip memory, so it moves far less data around. The math is the same; it is just organized smarter.

![Transformers & Attention: The Smart Highlighter — Simple cartoon diagram showing how a Transformer reads a whole sentence at once and shines a bright highlighter beam from the word "IT" back to "trophy" so it knows what "IT" means.](https://getaimath.com/diagrams/transformer-architecture.png)
*Napkin Diagram (Transformer Architecture): Older AI read word-by-word and often lost track of earlier words; a Transformer highlights which words connect to which.*

## What is an example of FlashAttention?

Switching to FlashAttention can make training a model with long context several times faster.

## Why does FlashAttention matter?

It made long context windows practical and is used in almost every modern training and inference system.

## Related Concepts

- [Grouped-Query Attention (GQA)](https://getaimath.com/dictionary/grouped-query-attention-gqa/): Grouped-query attention is a middle ground where groups of heads share keys and values, balancing speed and quality.
- [Attention Mask](https://getaimath.com/dictionary/attention-mask/): An attention mask is a pattern that tells the model which positions it may or may not attend to.
- [Multi-Query Attention (MQA)](https://getaimath.com/dictionary/multi-query-attention-mqa/): Multi-query attention is a faster type of attention where all heads share one set of keys and values but keep separate queries.
- [Positional Encoding](https://getaimath.com/dictionary/positional-encoding/): Positional encoding adds information about word order, so the model knows which word came first, second, and so on.
- [Cross-Attention](https://getaimath.com/dictionary/cross-attention/): Cross-attention lets one part of a model pay attention to a different input, like a decoder looking at an encoder's output.
- [Rotary Positional Embedding (RoPE)](https://getaimath.com/dictionary/rotary-positional-embedding-rope/): RoPE is a popular way to tell a model about word positions by rotating its query and key numbers by an angle based on position.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/flashattention/)
