Google Enhances its Open-Source MaxText Training Framework for Long-Context Training
Google integrated four context-parallelism strategies into MaxText, its open-source JAX training framework. They target limits that appear when training with very long sequences: memory pressure, computation, and communication between chips. The need is growing as context windows expand from hundreds of thousands of tokens toward millions. At these lengths, attention grows quadratically with sequence length, while activations and key-value caches grow linearly. Context parallelism splits a sequence across chips and streams keys and values between them, instead of storing the whole sequence on every chip. MaxText now offers All-Gather, All-to-All (Ulysses), P2P (Ring Attention), and A2A + P2P (USP). Google reported that the strategies support contexts up to 14 million tokens on TPU 5p and TPU 7. For Llama 3.1 8b, it reported 70% Model FLOPs Utilization for sequences up to 4 million tokens on TPU 5p. Ring Attention is the main choice for very long contexts; All-Gather remains a baseline when KV data fits.
What did Google add to MaxText, and what training challenge is it designed to address?
Google integrated four context-parallelism strategies into MaxText, its open-source JAX training framework. They target limits that appear when training with very long sequences: memory pressure, computation, and communication between chips. The need is growing as context windows expand from hundreds of thousands of tokens toward millions.
At these lengths, attention grows quadratically with sequence length, while activations and key-value caches grow linearly. Context parallelism splits a sequence across chips and streams keys and values between them, instead of storing the whole sequence on every chip. MaxText now offers All-Gather, All-to-All (Ulysses), P2P (Ring Attention), and A2A + P2P (USP).
Google reported that the strategies support contexts up to 14 million tokens on TPU 5p and TPU 7. For Llama 3.1 8b, it reported 70% Model FLOPs Utilization for sequences up to 4 million tokens on TPU 5p. Ring Attention is the main choice for very long contexts; All-Gather remains a baseline when KV data fits.
What is context parallelism, and how does it spread a long sequence across multiple chips?
Context parallelism is a way to divide work on a long input sequence across multiple chips. It matters because training on millions of tokens can exceed the memory and communication capacity of a single chip or an approach that duplicates the whole sequence everywhere. Google added this technique to MaxText to help address the limits of long-context training.
Each chip handles part of the sequence, rather than materializing the entire sequence on every chip. During attention calculations, keys and values are streamed between chips so the separate sequence parts can be used together. MaxText implements four strategies: All-Gather, All-to-All (Ulysses), P2P (Ring Attention), and A2A + P2P (USP). They have different memory needs and communication behaviors.
The strategies also differ in their ability to overlap communication with computation and scale beyond the number of KV heads. Google identifies Ring Attention as the primary workhorse for very long contexts, while All-Gather is a standard baseline when the KV data fits. With these approaches, Google reported TPU training at context lengths up to 14 million tokens.
How long a context can MaxText train on TPUs, and what Model FLOPs Utilization results did Google report?
Google reported that its new MaxText strategies support context lengths up to 14 million tokens on both TPU 5p and TPU 7. That is the largest training context stated in the article. The results matter because very long training sequences place heavy demands on memory, computation, and communication between chips.
In tests with Llama 3.1 8b, Google reported 70% Model FLOPs Utilization (MFU) for sequence lengths up to 4 million tokens on TPU 5p. It also reported approximately 50% MFU for sequence lengths below 6 million tokens. MFU is the measure used in the article to describe the reported training results; the article does not expand its calculation.
For P2P (Ring Attention), Google reported 48.7% MFU on TPU 7, compared with 37.1% on TPU 5p. These figures show results across different sequence lengths and TPU systems, rather than one single benchmark. The article names further kernel and backward-pass optimization as future work, so performance development is ongoing.
Why do attention, activations, and key-value caches make training harder as a sequence gets longer?
As a training sequence gets longer, the system must handle more information at once. The article identifies two major pressures: attention grows quadratically with sequence length, while activations and key-value (KV) caches grow linearly. The larger the sequence, the more these demands can constrain training on available hardware.
Attention involves relating sequence elements to one another, so its quadratic growth makes very long sequences especially demanding in computation. Activations are intermediate values used during training, and KV caches hold keys and values used by attention. Their linear growth still means more data must fit in high-bandwidth memory as the sequence expands. Google director Nathan Beach said attention memory is usually the first wall when training multi-million-token contexts on Google TPUs.
Context parallelism addresses this by splitting sequences across chips and streaming keys and values between them, rather than materializing the entire sequence on each chip. MaxText includes several approaches with different HBM needs and communication trade-offs. The article identifies P2P as the main workhorse for very long contexts, while All-Gather is a baseline when KV data fits.
How do All-Gather and Ring Attention differ in how they share keys and values between chips?
Both All-Gather and P2P (Ring Attention) are context-parallelism strategies for sharing the keys and values needed by attention across chips. Their practical difference is how that data moves and how much must be held at once. The article notes that the strategies have different high-bandwidth memory needs, communication overlap, and scalability.
In the standard All-Gather pattern, chips collect each other's key-value shards so the gathered data is available across the group. In Ring Attention, chips pass key-value blocks around a ring in stages, using each block as it arrives rather than gathering all blocks at once. These are established descriptions of the strategies; the article itself describes context parallelism generally as streaming keys and values between chips.
Google calls All-Gather the standard baseline for cases where KV data fits in memory. It names P2P as the primary workhorse for very long-context training. The article does not give a full numerical comparison of their memory use or communication speed, but it says that MaxText's strategies differ in HBM requirements and their ability to overlap communication with computation.
What kinds of tasks could benefit from models trained to handle millions of tokens at once?
A model that can handle a very large context can take in far more material for a task at once. Google engineers point to processing entire code repositories and ingesting hours of video as examples of applications that larger context windows enable. These are concrete cases from the article, not claims that every model or system already performs them.
The underlying idea is that the model is trained to work with longer sequences of tokens. Google notes that context windows grew from 128K–200K tokens three years ago to 1M–2M, with models trained toward 10M tokens arriving. Training at those lengths exposes system limits, so MaxText uses context parallelism to distribute sequences across chips and stream keys and values.
The reported TPU work supports training at contexts up to 14 million tokens. The article does not report specific repository or video applications, nor does it say these uses are already deployed. It does identify future work on more model architectures, including sliding-window and global attention combinations and linear attention mechanisms such as GDN and KDA.
What are tokens and a context window in a language model?
The article uses tokens as the unit for measuring sequence and context length, but it does not define what a token is. In common language-model usage, a token is a chunk of text processed by the model. It may be a whole word, part of a word, punctuation, or another text unit; tokenization depends on the model.
A context window is commonly the amount of tokenized input a model can handle at one time. The article describes the growth of these windows from 128K–200K tokens to 1M–2M and says models trained toward 10M tokens are arriving. It links larger windows to tasks such as processing entire code repositories or ingesting hours of video.
These general definitions explain the terms, but they are not definitions supplied by the article. The article focuses on the training challenge: attention grows quadratically, while activations and KV caches grow linearly with sequence length. Google added context-parallelism strategies to MaxText so long sequences can be distributed across chips and their keys and values streamed between them.
This brief was written by AI from the original reporting and checked by other models. Names, figures and quotes come from the source; read it for full context.
Read more in the JupiteX app
Pulse is free. New stories every 4 hours, each one broken into the questions that explain it.
Or read more news on the web