Blockwise Parallel Transformer for Large Context Models
Hao Liu, Pieter Abbeel
TL;DR
The paper tackles the memory bottleneck in long-context Transformers by introducing Blockwise Parallel Transformer (BPT), which fusion-cores self-attention and feedforward computation in a blockwise fashion to avoid full sequence materialization. By processing input in blocks and fusing FFN with attention, BPT achieves up to 32× longer training sequences than vanilla attention and up to 4× memory savings over prior memory-efficient methods, with competitive throughput. Extensive experiments on OpenWebText and ExoRL demonstrate reduced memory usage, longer context lengths, and improved RL performance when conditioning on multiple trajectories. The work shows that blockwise parallelism, coupled with careful normalization and blockwise FFN, enables scalable training of large-context GPT-like models, with practical impact for NLP and reinforcement learning research. Potential future directions include lower-level optimizations (CUDA/Triton) to push runtime speed further while maintaining memory benefits.
Abstract
Transformers have emerged as the cornerstone of state-of-the-art natural language processing models, showcasing exceptional performance across a wide range of AI applications. However, the memory demands posed by the self-attention mechanism and the large feedforward network in Transformers limit their ability to handle long sequences, thereby creating challenges for tasks involving multiple long sequences or long-term dependencies. We present a distinct approach, Blockwise Parallel Transformer (BPT), that leverages blockwise computation of self-attention and feedforward network fusion to minimize memory costs. By processing longer input sequences while maintaining memory efficiency, BPT enables training sequences 32 times longer than vanilla Transformers and up to 4 times longer than previous memory-efficient methods. Extensive experiments on language modeling and reinforcement learning tasks demonstrate the effectiveness of BPT in reducing memory requirements and improving performance.
