Abstract
Effective attention modules are central to the success of Transformer-based large language models (LLMs), yet their quadratic time and memory complexities ($O(N^2)$) create significant hurdles for processing long sequences. While distributed clusters can parallelize these computations, they often introduce substantial memory overhead and communication costs. This paper introduces BurstAttention, a distributed framework that optimizes memory access and communication at both global and local levels. Experimental results show that BurstAttention reduces communication overhead by 40% and achieves a 1.37× speedup during training for 128K sequence lengths on 32× A100 GPUs compared to competitive baselines.
Introduction
As LLMs evolve to handle "infinite context" tasks like processing entire codebases or books, the standard Attention Mechanism becomes a primary bottleneck. Single-GPU optimizations like FlashAttention mitigate I/O overhead by managing data between SRAM and HBM, but they cannot overcome the physical memory limits of a single device. Existing distributed solutions, such as Tensor Parallelism (TP) or RingAttention, often struggle with high communication latency or fail to fully integrate local memory optimizations. BurstAttention addresses this gap by combining distributed sequence-level parallelism with low-level I/O efficiency.
Methodology
BurstAttention employs a two-step partitioning strategy to optimize the attention mechanism across a cluster:
- Global Attention Optimization (GAO): The input sequence is partitioned across devices organized in a ring. As Key ($K$) and Value ($V$) blocks circulate, each device computes local attention. By using online softmax, the system updates results incrementally, avoiding the storage of the massive $N imes N$ intermediate attention matrix.
- Local Attention Optimization (LAO): Within each device, sub-sequences are divided into "tiles" small enough to fit into the GPU's fast SRAM. This minimizes slow accesses to High-Bandwidth Memory (HBM), effectively implementing a distributed-aware version of FlashAttention logic.
- Communication-Computation Overlapping: To hide data transfer costs, BurstAttention utilizes a double-buffering technique. While the GPU computes attention for the current data block, it simultaneously receives the next block from its neighbor in the ring.
Experimental Evaluation
The framework was evaluated using LLaMA-7b and LLaMA-13b architectures. Correctness was verified using 100 examples from the C4 (Colossal Clean Crawled Corpus) dataset to ensure no loss in perplexity (PPL). Performance benchmarks were conducted on clusters of 8× and 32× A100 GPUs with sequence lengths ranging from 1K to 262K.
Key Results
BurstAttention demonstrates superior performance and scalability compared to RingAttention and Megatron-V3 (with FlashAttention):
- Speedup: On a 32× A100 cluster at 128K sequence length, BurstAttention achieved a 1.37× speedup over Megatron-V3. In 8× A100 configurations, the speedup reached 2×.
- Communication Efficiency: The ring-style communication reduced overhead by 40% compared to standard Tensor Parallelism.
- Scalability: BurstAttention successfully processed sequence lengths up to 256K, while baseline methods frequently encountered Out-of-Memory (OOM) errors at these scales.
- Numerical Accuracy: Perplexity tests confirmed that the optimizations produce results identical to standard attention, incurring no "optimization tax" on model quality.
Conclusion
BurstAttention effectively breaks the "quadratic wall" of Transformer attention by optimizing the interplay between global communication and local memory access. While its performance is dependent on high-speed interconnects like NVLink, it remains a highly scalable and orthogonal solution that can be combined with other parallelism strategies (Data, ZeRO, Pipeline) to train the next generation of long-context LLMs. Future work may explore the integration of sparse attention to push sequence lengths into the millions.
Summary updated