---
title: "Announcing Long-Context Training on TPUs with MaxText Context Parallelism"
description: "MaxText v0.2.4, Google Cloud’s open-source JAX training framework, now supports long-context training on Cloud TPUs through four context-parallel strategies: All-gather, A2A (DeepSpeed Ulysses), P2P (Ring Attention), and the A2A + P2P hybrid (Unified Sequence Parallelism, or USP). These strategies split a long sequence across chips to avoid exhausting high-bandwidth memory, and all use the Tokamax Splash Attention kernel. In benchmarks with Llama 3.1 8B on TPU 5p, P2P achieved 70% Model FLOPs Utilization (MFU) for sequences up to 4 million tokens. Context can be extended to 14 million tokens on both TPU 5p and TPU 7, with TPU 7 maintaining 50% MFU below 6 million tokens. The choice of strategy depends on whether gathered KV fits in HBM and on the number of KV heads, with offloading recommended before recomputation when memory is low."
---

# Announcing Long-Context Training on TPUs with MaxText Context Parallelism

[Google](https://yomu.fyi/company/google) · Michael Tran, Nuojin Cheng, Deepak Patil · Nov 9, 2026

**Type:** Announcement

## Summary

MaxText v0.2.4, Google Cloud’s open-source JAX training framework, now supports long-context training on Cloud TPUs through four context-parallel strategies: All-gather, A2A (DeepSpeed Ulysses), P2P (Ring Attention), and the A2A + P2P hybrid (Unified Sequence Parallelism, or USP). These strategies split a long sequence across chips to avoid exhausting high-bandwidth memory, and all use the Tokamax Splash Attention kernel. In benchmarks with Llama 3.1 8B on TPU 5p, P2P achieved 70% Model FLOPs Utilization (MFU) for sequences up to 4 million tokens. Context can be extended to 14 million tokens on both TPU 5p and TPU 7, with TPU 7 maintaining 50% MFU below 6 million tokens. The choice of strategy depends on whether gathered KV fits in HBM and on the number of KV heads, with offloading recommended before recomputation when memory is low.

## Context

Long-context training, including pretraining and post-training, has become a foundation of frontier AI models. Longer native sequence lengths give LLMs the working memory to read a whole code repository or ingest hours of video, and reason through multi-step agentic tasks. In three years, context windows have grown from 128K–200K tokens to 1M–2M, and models trained toward 10M tokens are arriving. Efficient training at multi-million-token sequence lengths runs into bottlenecks: attention FLOPs grow quadratically with sequence length, and activations including keys and values for every token grow with sequence length, exhausting HBM and triggering out-of-memory failures.

## Approach / What changed

MaxText v0.2.4 supports four context-parallel strategies on Cloud TPU: All-gather, A2A (DeepSpeed Ulysses), P2P (Ring Attention), and the A2A + P2P hybrid (Unified Sequence Parallelism, or USP), all using the Tokamax Splash Attention kernel. The choice depends on whether gathered KV fits in HBM and on the number of KV heads. When gathered KV fits, All-gather with load balancing is simplest and often fastest. When it does not, the ring family is recommended, with USP preferred when KV heads allow an A2A factor of 2 or more, and P2P alone for MLA models or when head count does not divide.

## Takeaways

- MaxText v0.2.4 supports four context-parallel strategies on Cloud TPU: All-gather, A2A (Ulysses), P2P (Ring Attention), and the A2A + P2P hybrid (USP), all using the Tokamax Splash Attention kernel.
- P2P (Ring Attention) is the primary workhorse for very long-context training, outperforming All-gather at almost every context length from 64K to 14M tokens on a 64-chip TPU 5p slice with Llama 3.1 8B.
- When memory is low, offload saved activations, optimizer states, and parameters to host memory before recomputing; at long context lengths, these transfers are hidden behind compute, making offloading effectively free.

## FAQ

### What is context parallelism in MaxText?

Context parallelism splits a long sequence across chips so no chip holds the activations of the whole sequence. It can be combined with data and tensor parallelism, and the smallest context-parallel size that fits your sequence in HBM is usually the right one.

### How do I choose a context parallelism strategy?

The choice depends on whether the gathered KV fits in HBM and on the number of KV heads. When gathered KV fits, use All-gather with load balancing. When it does not, use the ring family: USP when KV heads allow an A2A factor of 2 or more, and P2P alone for MLA models or when head count does not divide.

### What performance does P2P achieve at long context?

In benchmarks with Llama 3.1 8B on a 64-chip TPU 5p slice, P2P outperformed All-gather at almost every context length from 64K to 14M tokens. On 64 TPU 7 chips, P2P training of 14M tokens reached 48.7% MFU compared to 37.1% on TPU 5p.

**Tags:** [Context Parallelism](https://yomu.fyi/topic/context-parallelism), [JAX](https://yomu.fyi/topic/jax), [LLMs](https://yomu.fyi/topic/llm), [MaxText](https://yomu.fyi/topic/maxtext), [TPU](https://yomu.fyi/topic/tpu)

- Source: [Google](https://developers.googleblog.com/announcing-long-context-training-on-tpus-with-maxtext-context-parallelism)
- Source URL: https://developers.googleblog.com/announcing-long-context-training-on-tpus-with-maxtext-context-parallelism
- Ingested by Yomu: 2026-11-09T21:00:16.736Z

[Read original post](https://developers.googleblog.com/announcing-long-context-training-on-tpus-with-maxtext-context-parallelism)
