Kernel Fusion's Memory Bandwidth Gains

FlashAttention uses kernel fusion to combine multiple attention operations (like QKᵀ matmul, softmax, and value multiplication) into a single CUDA kernel, eliminating redundant memory accesses and avoiding writing large intermediate results to HBM.

The top 3

  1. Top Performance Gains from Kernel Fusion: Kernel fusion can reduce memory bandwidth usage by 20-40% and achieve kernel speedups ranging from 1.5x to over 4x for various operations, with advanced libraries showing up to 185x speedups in specific vertical fusions.
  2. How Fusion Elevates On-Chip Data Reuse: Kernel fusion drastically improves memory bandwidth by enabling intermediate computation results to remain in fast on-chip memory (registers or shared memory), eliminating slow global memory round-trips and reducing kernel launch overhead.
  3. FlashAttention: Fusion's Breakthrough for LLMs: FlashAttention is a key innovation for large language models that uses kernel fusion to combine all attention operations into a single CUDA kernel, significantly reducing memory traffic between GPU high bandwidth memory (HBM) and on-chip SRAM.

Sources

Open the full topic