Engineers at Google have incorporated four distinct context-parallelism methods into MaxText, their open-source JAX training framework, which permits training large language models with context spans reaching 14 million tokens utilizing Cloud TPUs. This enhancement directly tackles the constraints related to computation, memory capacity, and inter-chip communication inherent in training models with extensive context windows.
The introduction of these new techniques is significant because, as Google personnel point out, the industry trend is moving toward substantially larger context windows, enabling applications such as processing entire code repositories or ingesting several hours of video data. Over the past three years, context windows have expanded from ranges of 128K-200K tokens to 1M-2M, with models capable of handling 10M tokens now emerging. The practical limitations of the system become apparent when attempting to train at these massive sequence lengths, not merely when serving the resulting models.
Training massive language models at such long sequence lengths presents two primary hurdles: the quadratic scaling associated with the attention mechanism, alongside the linear scaling observed in activations and key-value (KV) caches. To mitigate these difficulties, Google employs context parallelism, a technique that spreads sequences across numerous processing chips and streams the keys and values between them, rather than requiring every chip to hold the entire sequence in memory.
MaxText now features four such context-parallelism approaches: All-Gather, All-to-All (Ulysses), P2P (Ring Attention), and A2A + P2P (USP). These strategies possess variations concerning their demands on high-bandwidth memory (HBM), their capacity to overlap communication operations with computation, and their scalability beyond the quantity of KV heads. For very long-context training, P2P (Ring Attention) functions as the principal mechanism, while All-Gather serves as the standard reference point for most other scenarios where the KV data can be accommodated. These represent the chief CP strategies suitable for real-world application.
When utilizing these novel strategies, Google documented notable performance outcomes using Llama 3.1 8b on its Cloud TPU infrastructure. Specifically, they achieved 70% Model FLOPs Utilization (MFU) when processing sequence lengths up to 4 million tokens on TPU 5p, and supported context lengths up to 14 million tokens on both TPU 5p and TPU 7. Furthermore, they managed to sustain around 50% MFU for sequence lengths under 6 million tokens. In a separate finding, P2P reached 48.7% MFU on TPU 7, contrasting with 37.1% MFU observed on TPU 5p.
Future avenues for advancement were identified by Google. One area involves extending support to accommodate additional architectures, including those that blend global attention layers with sliding-window mechanisms, as well as linear attention methods such as Gated Delta Net (GDN) and Kimi Delta Attention (KDA). The second area focuses on performance refinement through further optimizing Tokamax kernels, making improvements to the P2P backward pass, and creating "recipes by model and context length" tailored for different TPU architectures.
Director Nathan Beach of Google commented on this release, stating: "If you are training models on Google TPUs with multi-million-token context, attention memory -- not compute -- is usually the first wall you hit."
The MaxText version 0.2.4 is presently accessible via PyPi, DockerHub, and GitHub.
The increasing capability to handle vast context windows fundamentally shifts the operational constraints for large model development, moving the primary bottleneck from raw compute power to memory management and communication efficiency across distributed hardware.
Why it matters
This advancement directly addresses critical bottlenecks in training massive models, specifically memory and communication limits related to long context windows. For infrastructure and platform operators, this signals a major step toward practical, large-scale deployment of context-heavy AI applications.






