In the race for long-context AI, Transformers are the reigning champions, but they suffer from $O(N^2)$ complexity. As sequence length $N$ grows, compute requirements explode. Convolutional models (like Hyena or S4) offer a promising alternative with $O(N \log N)$ scaling via the Fast Fourier Transform (FFT). However, despite their theoretical efficiency, these models often lag behind Transformers in actual wall-clock time.
FlashFFTConv is a new system that dramatically speeds up long-sequence convolutions by rewriting the FFT to leverage GPU Tensor Cores. By using a "Monarch" matrix decomposition and clever kernel fusion, it achieves up to an 8.7× speedup over standard PyTorch implementations, enabling models to process sequences millions of tokens long—including the first DNA model capable of embedding the longest human genes.
The Hardware Bottleneck
The authors identify two primary hardware-level bottlenecks that hold back standard FFT implementations on modern GPUs:
- Tensor Core Underutilization: Modern GPUs feature specialized "Tensor Cores" designed for massive matrix multiplications. Standard FFT algorithms do not use these units, relying instead on slower, general-purpose arithmetic.
- The Memory Wall: FFTs require multiple passes over the data. For long sequences, the data is too large to stay in the fast on-chip memory (SRAM), forcing the GPU to constantly move data to and from the slower main memory (HBM). This creates a massive I/O bottleneck.
FlashFFTConv Methodology
The core innovation of FlashFFTConv optimizes the FFT convolution through three main pillars:
1. Monarch Decomposition
The authors rewrite the FFT as a series of matrix-matrix multiplications using "Monarch" matrices. This mathematical reframing allows the FFT to be computed natively using the GPU's high-throughput Tensor Cores.
2. Kernel Fusion for Long Sequences
Traditionally, fusing kernels for long sequences is difficult because the data doesn't fit in SRAM. FlashFFTConv changes the "direction" of parallelization by broadcasting operations across the sequence length rather than the batch dimension. This allows the system to keep a single sequence in SRAM, performing the FFT, the element-wise multiplication, and the inverse FFT all in one fused step, drastically reducing memory I/O.
3. Algorithmic Sparsity
Because the FFT is now viewed as a matrix decomposition, the authors introduce two new sparse variants that are trivial to implement:
- Partial Convolutions: Zeroing out parts of the filter in the time domain (similar to local attention).
- Frequency-Sparse Convolutions: Zeroing out specific frequency components.
Both are implemented simply by skipping blocks in the Monarch decomposition, saving both memory and compute without complex sparse indexing.
Key Results and Capabilities
The authors evaluated FlashFFTConv across several domains, including language modeling (The PILE, C4), vision (Long Range Arena), genomics (Ensembl), and audio (SaShiMi).
- Massive Speedups: FlashFFTConv is up to 8.7× faster than PyTorch's FFT and provides up to a 4.4× end-to-end speedup for models like HyenaDNA.
- Better Quality for Less Compute: Given the same compute budget, FlashFFTConv allowed Hyena-GPT to improve perplexity by 2.3 points and M2-BERT to boost GLUE scores by 3.3 points—effectively matching the performance of models with twice the parameter count.
- Solving the "Unsolvable": On the Path-512 task (a 256K sequence length vision challenge), previous models couldn't beat 50% accuracy (random guessing). FlashFFTConv achieved 96.1% accuracy.
- Biological Scale: It enabled the first DNA model to process 2.3 million base pairs in a single pass, covering the longest known human genes (like dystrophin).
Limitations and Future Work
While highly effective, FlashFFTConv has a few limitations. The current implementation is heavily optimized for NVIDIA A100 and H100 GPUs; older architectures with different Tensor Core configurations are not yet fully supported. Additionally, the FFT still operates on complex numbers, which doubles the memory footprint compared to purely real-valued operations. Future work will likely focus on deeper integration into low-level libraries like NVIDIA's Cutlass to support a wider variety of hardware and further maximize performance.
Summary updated