Abstract
AXLearn is Apple’s production-grade training system designed to handle massive deep learning models across diverse hardware environments, including GPUs, TPUs, and AWS Trainium. By enforcing strict encapsulation rather than traditional class inheritance, AXLearn allows engineers to integrate complex features, such as Mixture of Experts (MoE), with minimal code changes. This architectural approach maintains constant system complexity even as the number of models and hardware targets scales, providing a robust solution for training models with trillions of parameters.
Introduction: The Challenge of Scale and Brittle Systems
As deep learning models scale toward trillions of parameters, the software systems used to train them have become increasingly brittle. Most existing frameworks rely on subtyping (inheritance), where new model layers inherit from a base class. This often results in "leaky abstractions": adding a single feature like Rotary Position Embeddings (RoPE) frequently requires modifying every ancestor module in the code hierarchy. In production environments with hundreds of model variants, this leads to a "complexity explosion," where simple updates necessitate thousands of lines of code (LoC) changes.
Furthermore, many state-of-the-art systems are hardware-locked. For instance, Megatron-LM is heavily optimized for NVIDIA GPUs, while MaxText is tailored for Google TPUs. AXLearn addresses these challenges by providing a hardware-agnostic framework that allows seamless transitions between cloud providers and internal clusters without rewriting model definitions.
AXLearn Architecture: Modular Design and Hardware Agnosticism
AXLearn is built on top of JAX and the XLA compiler, introducing several novel architectural layers to ensure flexibility and performance:
- Strict Encapsulation: Instead of subtyping, AXLearn utilizes a hierarchical configuration tree. Child modules are treated as black boxes by their parents. This enables users to swap components—such as replacing a standard feed-forward network with an MoE layer—using a simple configuration modifier that traverses the tree without altering the parent Transformer layer's code.
- InvocationContext: To bridge the gap between JAX’s pure functional requirements and the imperative style familiar to PyTorch users, AXLearn introduces
InvocationContext. This manages states, random number seeds, and summaries behind the scenes, maintaining functional correctness while providing a familiar developer experience. - Mesh Rules: To maintain hardware agnosticism, AXLearn uses "mesh rules" to decouple model logic from parallelism strategies. Engineers define the model once, and mesh rules describe how to shard it across different hardware topologies (e.g., FSDP on TPUs versus Tensor Parallelism on GPUs).
Key Insights: Solving the Complexity Explosion
A core contribution of AXLearn is its approach to the asymptotic complexity of code. The authors propose measuring modularity by the number of lines of code (LoC) required to add a feature as a system scales. While traditional systems exhibit $O(NM)$ complexity—where $N$ is the number of modules and $M$ is the number of feature variants—AXLearn achieves $O(1)$ constant complexity.
This modularity is exemplified by the "10-Line Rule": integrating a complex feature across 1,000 different experimental configurations can often be accomplished with a single 10-line code snippet. Additionally, by reusing modular components, AXLearn serves as a unified engine for both training and inference, outperforming specialized tools like vLLM on TPUs by up to 2.8x in throughput.
Performance and Scaling Results
AXLearn matches or exceeds the performance of specialized, hardware-specific systems:
- Throughput: On NVIDIA H100 GPUs, AXLearn outperformed PyTorch FSDP in throughput for Llama2-70B. On TPUs, it achieved 68% Model Flops Utilization (MFU), slightly surpassing Google’s MaxText.
- Massive Scaling: The system demonstrated near-linear scaling up to 32,768 TPUs for a 150B parameter model.
- Resiliency: In real-world failure scenarios on 32k chips, AXLearn detected hardware faults, performed "hot-swaps" of failed nodes, and resumed training from checkpoints in just 21 minutes.
Conclusion and Future Work
AXLearn demonstrates that strict encapsulation and compiler-first resiliency can solve the modularity and scaling challenges of modern LLM training. While the framework is hardware-agnostic, achieving peak performance still benefits from backend-specific tuning, such as custom FlashAttention kernels. Future work aims to extend AXLearn's unified training and inference optimizations to a broader range of backends, including GPUs and AWS Trainium, and to further lower the learning curve associated with the JAX/XLA ecosystem.
Summary updated