· AI dev tools

Google MaxText framework enables LLM training up to 14 million tokens on Cloud TPUs

Training large language models at extremely long sequence lengths presents significant hurdles, particularly concerning the quadratic growth inherent in attention mechanisms and the linear expansion…


Training large language models at extremely long sequence lengths presents significant hurdles, particularly concerning the quadratic growth inherent in attention mechanisms and the linear expansion of activations and key-value (KV) caches. To tackle these substantial challenges, Google has incorporated four distinct context-parallelism approaches into MaxText, its open-source JAX training framework. This enhancement allows for the training of LLMs utilizing context lengths reaching as high as 14 million tokens when running on Cloud TPUs.

The push toward larger context windows is a notable industry trend, with context capacities expanding from the 128K-200K token range three years ago to the current 1M-2M scale, while models targeting 10M tokens are now emerging. While serving these massive models is one aspect, the actual process of training them is where system limitations become apparent.

Context parallelism functions by distributing sequences across various chips and streaming the necessary keys and values between them, circumventing the need to store the entire sequence on every single chip. Google has implemented four specific context-parallelism methods within MaxText: All-Gather, All-to-All (Ulysses), P2P (Ring Attention), and A2A + P2P (USP). These techniques possess variations concerning their demands on high-bandwidth memory (HBM), their capacity to overlap computation with communication, and their scalability beyond the count of KV heads.

In practical applications, P2P (Ring Attention) serves as the primary mechanism for training with very long contexts, whereas All-Gather remains the standard baseline for most other scenarios where the KV data can fit within memory.

Leveraging these newly integrated strategies, Google documented impressive performance metrics using the Llama 3.1 8b model 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. Furthermore, the framework supports context lengths up to 14 million tokens on both TPU 5p and TPU 7, while sustaining around 50% MFU for sequence lengths under 6 million tokens. In a separate finding, P2P attained 48.7% MFU on TPU 7, contrasting with 37.1% MFU observed on TPU 5p.

Google has outlined two directions for future development. The first involves extending support to incorporate more architectures, including those that blend sliding-window and global attention layers, as well as linear attention methods such as Gated Delta Net (GDN) and Kimi Delta Attention (KDA). Secondly, efforts will focus on boosting performance through refining Tokamax kernels, making improvements to the P2P backward pass, and creating "recipes by model and context length" tailored for different TPU architectures.

Nathan Beach, a director at Google, offered insight on this development, 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 updated version, MaxText 0.2.4, is now accessible via PyPi, DockerHub, and GitHub.

Why it matters

This enhancement directly addresses the memory and computational bottlenecks faced when training large language models with very long context windows. Developers working on state-of-the-art LLMs can now leverage MaxText to push context limits significantly further on Google's TPU infrastructure.

Earlier coverage

Related coverage

Also worth reading

  1. Angular 21.2.27 released, fixes component template capture during compile
  2. next.js 16.6.0-canary.0 released, adds experimental new server for Switchyard
  3. next.js 16.5.0-rc.4 released, featuring turbopack document chunking updates
  4. Optimizely Supply-Chain Attack Delivers Malware Through Websites of 178 Global Brands
  5. Browser DNS trace tool lets you follow recursive lookups from root to answer