Striped Attention: Faster Ring Attention for Causal Transformers
Paper · 2023 · William Brandon, Aniruddha Nrusimha, Kevin Qian et al.
Summary
Ring Attention (Liu et al., 2023) makes very long contexts trainable by splitting queries, keys and values along the sequence across accelerators arranged in a ring. Key/value blocks circulate between devices while compute overlaps communication. The authors show this scheme cannot benefit from causal masking. Each device holds a contiguous chunk, so after the first round some devices have fully masked tiles and others fully unmasked ones. Each round runs at the pace of the slowest device, so a causal run costs as much as a bidirectional one, even though it needs only about half the arithmetic.
Their fix, Striped Attention, reorders tokens so that every device holds positions spread evenly across the sequence (for example, every N-th token). Each device then skips roughly half its work in every round. Because attention is permutation-equivariant, the output stays exact, and the layout is set once before the first layer. Built on the JAX Ring Attention codebase and tested on 1B–7B causal models, it trains up to 1.65× faster on long sequences. This makes very long-context generative models cheaper to train.
Key points
- Imbalance: in causal Ring Attention, the work per round is either fully needed or fully discarded depending on the device. Masking therefore saves no wall-clock time.
- Striped layout: the token permutation is applied once before the model, with no extra per-layer communication, and results remain exact.
- A100 results: on a server with 8 A100 80GB GPUs, end-to-end training throughput improved by up to 1.45× over Ring Attention at a sequence length of 262,144 (3B model).
- TPU results: on 16 TPUv4 chips, speedups reached 1.65× at 786,432 tokens (3B model). On 8 TPUv3 chips, speedups reached up to 1.47×.
- Limitations and release: at short sequences (8,192 tokens on A100), the method is slightly slower than Ring Attention (0.92–0.98×). The code is open source at github.com/exists-forall/striped_attention.
Fields, topics and concepts
📚 Shelves 6The field of science this work belongs to (OpenAlex fields).Computer Science · 19,503 worksArtificial Intelligence · 18,805 worksArts and Humanities · 17,959 worksLanguage and Linguistics · 17,789 worksComputer Vision and Pattern Recognition · 3,621 worksHardware and Architecture · 183 works
Cite
Cite as William Brandon, Aniruddha Nrusimha, Kevin Qian, Zachary Ankner, Tian Jin, Zhiye Song and Jonathan Ragan-Kelley. 2023. Striped Attention: Faster Ring Attention for Causal Transformers. arXiv:2311.09431.
@misc{brandon2023striped,
title = {{Striped Attention: Faster Ring Attention for Causal Transformers}},
author = {William Brandon, Aniruddha Nrusimha, Kevin Qian, Zachary Ankner, Tian Jin, Zhiye Song and Jonathan Ragan-Kelley},
year = {2023},
doi = {10.48550/arxiv.2311.09431},
eprint = {2311.09431},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2311.09431}
}References
- 5.3 System optimizations for very long sequence lengths Bradbury, J., Frostig, R., Hawkins, P., Johnson, M. J., Leary, C., Maclaurin, D., Necula, G., Paszke, A., VanderPlas, J., Wanderman-Milne, S., and Zhang, Q. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/g… ↗
Updated
This page in Markdown → https://md.research.elamur.ai/free/en/papers/brandon-2023-striped-attention-faster-ring-attention/