TL;DR
FlashAttention revolutionized Transformers by fusing attention operations to stay inside ultra-fast GPU SRAM, yet the Feed-Forward Network (FFN) still forces GPUs to write massive intermediate tensors out to slow main memory. Why hasn't anyone given the FFN the same "Flash" treatment? Because a standard monolithic FFN is simply too wide to fit on chip—so the authors of FlashFFN redesign the FFN architecture around the physical geometry of GPU silicon, cutting memory usage by up to 2.7× while making models faster and smarter at the exact same compute budget.
What Problem Does This Paper Address?
Every modern LLM is essentially a repeating stack of two components: Attention and the Feed-Forward Network (FFN). To understand why FFNs bottleneck memory, picture a GPU's memory hierarchy: there is tiny, lightning-fast on-chip SRAM (like a workbench right in front of you, ~228 KB per streaming multiprocessor on an NVIDIA H100), and massive, much slower off-chip HBM (like a warehouse down the street).
Standard FFNs (like SwiGLU) take an input of width $d_{\text{model}}$, expand it into a wide intermediate tensor, apply an activation, and project it back down. Because that wide intermediate tensor is written to and read back from the HBM warehouse between matrix multiplications, it dominates activation memory at long sequences.
You might wonder: why not tile and fuse the FFN in one pass on the SRAM workbench, just like FlashAttention does? The authors prove a hardware-geometry constraint: under one-pass tiled execution, the GPU must hold an output accumulator spanning the entire hidden dimension ($d_{\text{model}}$) in SRAM. Once $d_{\text{model}} \ge 2048$, the working set balloons to ~2.3 MB—roughly 10× larger than an H100's SRAM budget. Attention only gets away with FlashAttention because it is already split into small heads!
Methods
Instead of trying to shoehorn an oversized FFN onto tiny silicon, the authors let the SRAM constraint dictate the neural architecture, deriving FlashFFN in three steps:
- Multi-Head Decomposition (R1): To shrink the SRAM footprint, they split the model dimension into $H$ independent FFN heads of width $d_h = d_{\text{model}} / H$ (e.g., $d_h = 128$). Now the per-tile working set depends on $d_h$ instead of $d_{\text{model}}$, fitting comfortably inside the 228 KB SRAM limit regardless of how large the overall model scales.
- Sub-Network Ratio Restoration (R2): Splitting into heads creates a sneaky second-order mathematical bug. Standard SwiGLU works best when its intermediate-to-input expansion ratio is roughly $8/3$. If you shrink a head's input width to $d_h$ while keeping the intermediate dimension big, that ratio explodes as models scale (hitting 45× at 1.3B parameters), degrading model quality. FlashFFN fixes this by dividing each head into $E$ parallel SwiGLU "sub-networks," each calibrated to the sweet-spot width $d_e \approx \frac{8}{3} d_h$. A lightweight router applies dense, per-token sigmoid-normalized gates to weight and sum the sub-networks (unlike sparse Mixture-of-Experts, all sub-networks run every step).
- Fused I/O-Aware Kernel: Written in Triton and ThunderKittens, the custom kernel loops over sub-networks and tiles completely on-chip. The wide intermediate activations live purely in registers and never touch HBM.
Datasets
No new datasets are introduced; the authors rely on standard, well-established benchmarks:
- Training: Models (128M, 370M, and 1.3B parameters) are trained from scratch on The Pile (60B tokens for 128M/370M; 100B tokens for 1.3B).
- Evaluation: Language modeling perplexity (PPL) is evaluated on the PG19 validation split. Downstream zero-shot reasoning and reading comprehension are tested across six benchmarks: HellaSwag, SIQA, PIQA, OpenBookQA (OBQA), WinoGrande, and RACE.
Key Insights and Ideas
- Architecture and kernel are mutually dependent: Neither trick works alone. Without multi-head splitting, a one-pass kernel physically cannot fit in SRAM. Without the fused kernel, multi-head splitting actually increases HBM traffic linearly with $H$ (causing out-of-memory crashes at 16K tokens).
- Architectural synergy beats isolated tweaks: In 370M ablation studies, multi-head splitting alone (MH-FFN) washes out against the baseline because of the warped expansion ratio, while dense sub-networks alone (Dense-MoE) slightly hurt performance due to gating noise. Composing them together produces a strict quality jump—the sub-networks restore the $8/3$ expressivity floor inside each head's local subspace.
- $d_h = 128$ is both a hardware and quality sweet spot: On an H100, the strict SRAM math caps $d_h$ at ~184. Sweeping $d_h \in \{64, 128, 256\}$ reveals that 128 isn't just safe for hardware occupancy—it also yields the best perplexity and downstream accuracy.
Key Results
At strictly matched parameter counts and FLOPs against a Llama-style SwiGLU baseline on H100 GPUs, FlashFFN achieves a true Pareto improvement—simultaneously better, faster, and lighter:
- Peak Memory: Up to 2.74× lower per-layer peak FFN memory than eager SwiGLU and Liger Kernel, and up to 1.93× lower than
torch.compileat 32K context. - Throughput: Up to 1.18× faster end-to-end model prefill (at 32K context) and 1.19× faster CUDA-graphed decode at 1.3B scale.
- Model Quality: At 1.3B parameters, FlashFFN ($d_h=128$) drops PG19 perplexity by 0.84 points (16.33 vs. 17.17)—the largest improvement of all tested scales—and boosts average accuracy across the six downstream tasks by +1.60 points (43.35% vs. 41.75%), with the biggest jumps on reasoning-heavy tasks like HellaSwag (+3.49).
Limitations and Future Work
- Scale of Empirical Validation: Due to compute budgets, pretraining experiments top out at 1.3B parameters and 100B tokens, though the perplexity advantage over SwiGLU widened at the largest scale.
- Dense Regime Only: All sub-networks are evaluated for every token, meaning FlashFFN does not decouple parameter capacity from FLOPs like sparse Mixture-of-Experts (MoE) models do. However, the authors point out a natural sequel (FlashMoE): applying top-$k$ sparse routing across the $H \times E$ sub-network pool to combine MoE scaling with SRAM-feasible execution.
Summary updated