Google has integrated four context-parallelism strategies into MaxText, its open-source JAX training framework, to address computational, memory, and communication bottlenecks in long-context LLM training. The company reports that the enhanced framework supports training with context lengths up to 14 million tokens on Cloud TPUs.
According to Google engineers, context windows have expanded rapidly over three years, growing from 128,000-200,000 tokens to 1-2 million tokens, with models trained toward 10 million tokens now emerging. The engineers note that larger context windows enable applications such as processing entire code repositories or ingesting hours of video, but training at these lengths reveals system limitations.
Training at such sequence lengths creates two major bottlenecks: the quadratic growth of attention mechanisms and the linear growth of activations and key-value (KV) caches. Google addresses these challenges through context parallelism, which distributes sequences across multiple chips and streams keys and values between them rather than materializing the entire sequence on every chip.
The four context-parallelism strategies implemented in MaxText are All-Gather, All-to-All (Ulysses), P2P (Ring Attention), and A2A + P2P (USP). These strategies differ in their high-bandwidth memory (HBM) requirements, their ability to overlap communication with computation, and their scalability beyond the number of KV heads. According to Google, P2P (Ring Attention) serves as the primary approach for very long-context training, while All-Gather is the standard baseline for most other cases where the KV can fit.
Using these strategies with Llama 3.1 8b and Cloud TPU infrastructure, Google reports achieving 70% Model FLOPs Utilization (MFU) for sequence lengths up to 4 million tokens on TPU 5p. The company also reports maintaining approximately 50% MFU for sequence lengths below 6 million tokens, and notes that P2P achieved 48.7% MFU on TPU 7, compared with 37.1% on TPU 5p.
Google identifies two areas for future development: adding support for more architectures, including those combining sliding-window and global attention layers and linear attention mechanisms such as Gated Delta Net (GDN) and Kimi Delta Attention (KDA); and improving performance through further optimization of Tokamax kernels and enhancements to the P2P backward pass.