RingAttention with Blockwise Transformers for Near-Infinite Context

Abstract

Transformers have emerged as the architecture of choice for many state-of-the-art AI models, showcasing exceptional performance across a wide range of AI applications. However, the memory demands imposed by Transformers limit their ability to handle long sequences, thereby posing challenges in utilizing videos, actions, and other long-form sequences and modalities in complex environments. We present a novel approach, Blockwise RingAttention, which leverages blockwise computation of self-attention and feedforward to distribute long sequences across multiple devices while fully overlapping the communication of key-value blocks with the computation of blockwise attention. Our approach enables training and inference of sequences that are up to device count times longer than those achievable by prior memory-efficient Transformers, without resorting to approximations or incurring additional communication and computation overheads. Extensive experiments on language modeling and reinforcement learning tasks demonstrate the effectiveness of our approach in allowing millions of tokens context size and improving performance.

Cite

Text

Liu et al. "RingAttention with Blockwise Transformers for Near-Infinite Context." International Conference on Learning Representations, 2024.

Markdown

[Liu et al. "RingAttention with Blockwise Transformers for Near-Infinite Context." International Conference on Learning Representations, 2024.](https://mlanthology.org/iclr/2024/liu2024iclr-ringattention/)

BibTeX

@inproceedings{liu2024iclr-ringattention,
  title     = {{RingAttention with Blockwise Transformers for Near-Infinite Context}},
  author    = {Liu, Hao and Zaharia, Matei and Abbeel, Pieter},
  booktitle = {International Conference on Learning Representations},
  year      = {2024},
  url       = {https://mlanthology.org/iclr/2024/liu2024iclr-ringattention/}
}