How to Configure Elastic Training in MaxText on TPUs
Learn how to enable elastic training in MaxText to survive hardware failures and resume distributed AI workloads in seconds.
Google Cloud recently introduced elastic training for MaxText, allowing distributed AI workloads to survive hardware failures without crashing the entire cluster. By leveraging the Pathways execution backend, MaxText transforms TPU drops into catchable Python exceptions, recovering workloads in seconds rather than the typical 30 to 60 minutes. Here is how to configure elasticity for your next massive training run.
Understanding the Elastic Architecture
Traditional synchronous distributed training relies on an all-or-nothing approach. If a single accelerator fails in a 10,000-chip cluster, the entire job terminates. The new elastic framework decouples the training state from specific hardware nodes.
When a TPU v5p or TPU v6e node fails, the surviving nodes remain active. The control plane, managed by Google Kubernetes Engine (GKE) and the Kueue job orchestrator, automatically provisions a replacement or allows the job to continue on a reduced hardware slice. This self-healing approach maximizes your hardware goodput and significantly lowers the cost of training frontier models, an important consideration when scaling PyTorch training or JAX workloads.
Configuring MaxText Flags
Elastic training is now natively supported in the MaxText GitHub repository. To enable it, you must configure two specific flags in your training configuration:
dynamic_loading: Set this to enable dynamic node provisioning. This allows the cluster to inject replacement hardware mid-training without restarting the global job.recovery: Enable this flag to activate the automated failure recovery protocol. It instructs Pathways to catch the hardware disconnect as a Python exception and hold the surviving nodes in a waiting state.
The MaxText documentation covers the full parameter list for fine-tuning the timeout thresholds and minimum cluster slice requirements during a hardware replacement.
Asynchronous Checkpointing
Elasticity requires the model to resume from the most recent state almost immediately. This is handled through Asynchronous Checkpointing via the Orbax library. By offloading the state save operations to background threads, Orbax minimizes the performance penalty of frequent checkpoints.
Configure Orbax in your MaxText run to save states frequently. If your Mean Time Between Failures (MTBF) is expected to be once per day, asynchronous checkpointing ensures you lose at most a few minutes of compute when the replacement node spins up. Similar mechanisms are used when you reduce LLM API costs by preventing full workload restarts.
Next Steps
Before deploying your model on a multi-thousand TPU cluster, simulate a node failure in a smaller GKE environment. Terminate a pod mid-training and verify that Kueue successfully provisions a replacement while the main job holds state.
Get Insanely Good at AI
The book for developers who want to understand how AI actually works. LLMs, prompt engineering, RAG, AI agents, and production systems.
Keep Reading
Boost Model Accuracy With MaxText Post-Training on TPUs
Google's MaxText adds SFT and Reinforcement Learning support for single-host TPUs, enabling efficient LLM refinement with GRPO and Tunix integration.
Google Ships VS Code Extension for Remote Workbench Execution
Google released an open-source VS Code extension that connects local editor environments directly to cloud-based Gemini Enterprise Workbench instances.
TorchTPU and Full-Stack Optimization Anchor New TPU Developer Hub
Google has introduced a centralized platform providing model builders with technical resources, open-source recipes, and documentation for TPU optimization.
How to Provision Google Colab GPUs From the Command Line
Learn how to install the Google Colab CLI, provision high-performance remote GPUs from your local terminal, and execute headless machine learning workflows.
How to Find GPU Gaps in PyTorch 2.12 With torch.profiler
Learn how to identify performance bottlenecks and idle GPU lanes using the native torch.profiler in PyTorch 2.12 across Blackwell and AMD hardware.