fused attention
**Fused attention** is the **combined-kernel execution of key attention substeps such as score computation, masking, softmax, and value aggregation** - it minimizes intermediate tensor materialization and improves sequence processing efficiency.
**What Is Fused attention?**
- **Definition**: Attention implementation that merges multiple stages of scaled dot-product attention into fewer GPU kernels.
- **Pipeline Scope**: Commonly fuses QK matmul scaling, mask application, softmax normalization, and weighted value accumulation.
- **Memory Objective**: Keeps blocks on-chip where possible instead of writing full score matrices to HBM.
- **Algorithm Family**: Includes FlashAttention-like methods and framework-specific fused kernels.
**Why Fused attention Matters**
- **Long-Sequence Performance**: Attention dominates runtime and memory at larger context lengths.
- **Bandwidth Reduction**: Avoiding score-matrix writes removes major memory bottlenecks.
- **Higher Throughput**: Fewer launches and improved locality increase tokens-per-second.
- **Better Scaling**: Enables larger batch or context settings under the same memory budget.
- **Serving Benefits**: Reduces latency and memory overhead in autoregressive decoding paths.
**How It Is Used in Practice**
- **Kernel Selection**: Dispatch fused kernels based on head dimension, causal mode, and precision.
- **Profile Comparison**: Benchmark fused versus unfused attention under representative sequence lengths.
- **Stability Checks**: Validate numerical parity and masking correctness across edge cases.
Fused attention is **one of the most important optimizations in modern transformer systems** - combining attention stages into efficient kernels is essential for high-context performance.