AXLearn: Modular, Hardware-Agnostic Large Model Training

Mark Lee, Chang Lan, Tom Gunter, John Peebles, Hanzhi Zhou, Xuan Kelvin Zou, Sneha Bangalore, Chung-Cheng Chiu, Nan Du, Xianzhi Du, Philipp Dufter, Liang He, Ruixuan Hou, Haoshuo Huang, Dongseong Hwang, Xiang Kong, Jinhao Lei, Tao Lei, Ethan Li, Jiarui Lu, Zhiyun Lu, Yiping Ma, David Qiu, Vivek Rathod, Senyu Tong, Zhucheng Tu, Chong Wang, Jianyu Wang, Yongqiang Wang, Zirui Wang, Floris Weers, Sam Wiseman, Guoli Yin, Bowen Zhang, Xiyou Zhou, Danyang Zhuo, Cheng Leong, Ruoming Pang

TL;DR

Apple has open-sourced AXLearn, a JAX/XLA-based deep learning system designed for scalable, high-performance large model training. By enforcing strict modular encapsulation, AXLearn allows developers to add complex features like Mixture of Experts (MoE) with constant code complexity ($O(1)$) while remaining entirely hardware-agnostic across GPUs, TPUs, and AWS Trainium.

What Problem Does This Problem Address?

Training state-of-the-art large language models requires massive infrastructure and extreme optimization. However, existing deep learning frameworks often force a painful trade-off between engineering agility and hardware performance.

Most frameworks rely heavily on object-oriented subtyping or flat configuration files. When developers want to introduce a new feature—such as swapping a standard feed-forward network for a Mixture of Experts (MoE) layer—the changes cascade upward through the model hierarchy, requiring hundreds of lines of code modifications across multiple files.

Furthermore, many top-tier training systems are locked into specific hardware ecosystems (e.g., Megatron-LM for Nvidia GPUs, MaxText for Google TPUs). For large enterprises, this creates severe supply-chain vulnerabilities and limits the ability to leverage cost-effective cloud infrastructure across different vendors.

Methods

AXLearn addresses these challenges through two core design principles: strict encapsulation and a compiler-first approach.

Instead of subtyping, AXLearn uses a purely Python-based hierarchical configuration tree to compose models. To modify a model, users write "config modifiers" that programmatically traverse and alter the tree.

Figure 1. Specifying MoE Transformer in AXLearn. Blue compo- nents are reused from the specification of standard Transformer. In AXLearn, a user script that defines MoE only needs to specify the green parts of the neural network.

Because JAX requires purely functional, stateless programs, managing state (like model parameters, PRNG keys, and training summaries) can quickly clutter code. AXLearn solves this with an abstraction called InvocationContext. When a module executes, its context is pushed to an implicit stack that handles state propagation and PRNG splitting behind the scenes, allowing developers to write clean, imperative-style code.

To remain hardware-agnostic, AXLearn builds on top of the XLA compiler and GSPMD. It introduces "mesh rules"—mappings from specific accelerator types to target-dependent optimization strategies (like FSDP, tensor parallelism, or activation rematerialization)—allowing the exact same model code to run efficiently on different hardware backends.

Datasets

The authors evaluated AXLearn's training performance using standard open-source model architectures: Llama2-7B, Llama2-70B, and Qwen-3 30B-A3B. For the inference benchmarks, they utilized the ShareGPT dataset to supply realistic user prompts.

Key Insights and Ideas

  • Asymptotic Lines-of-Code (LoC) Complexity: The authors propose a formal framework to measure system extensibility by evaluating how code changes scale asymptotically ($O$) when introducing new features. While other systems scale linearly or quadratically ($O(N)$ or $O(NM)$), AXLearn achieves constant $O(1)$ complexity.
  • Unified Training and Inference: A highly modular training framework can double as a highly efficient inference engine. By reusing AXLearn's encapsulated attention and KV cache components, the authors built a TPU serving system that significantly outperforms specialized inference engines.
  • Compiler-First with Escape Hatches: Relying on a compiler like XLA provides excellent hardware portability, but compilers can struggle to auto-derive highly optimized kernels. AXLearn treats custom hand-tuned kernels (like FlashAttention or AWS Nki) as encapsulated "black-box" nodes within the computation graph, combining portability with peak hardware utilization.

Key Results

  • Zero-Line Feature Integration: Integrating Rotary Position Embeddings (RoPE) or MoE requires exactly 0 lines of code changes to existing interfaces in AXLearn, compared to hundreds or thousands of lines in frameworks like DeepSpeed or Megatron-LM.
Table 2. LoC analysis of deep learning systems. N denotes number of modules in a system, and M denotes number of variants of a feature. LoC Estimates represent changes necessary within each system’s API interfaces to integrate a single variant of RoPE or MoE under a standard production setting. Note that in AXLearn, 0 LoC changes to existing interfaces are necessary.
  • State-of-the-Art Performance: AXLearn delivers hardware utilization comparable to or better than vendor-specific frameworks. For example, training Llama2-7B on a 32×H100 cluster yields a Model FLOPS Utilization (MFU) of 54.2%, matching MaxText and outperforming Megatron-LM.
Table 3. Comparing AXLearn with state-of-art systems on training performance. Systems are benchmarked on identical hardware within each model–hardware configuration. For example, the first four rows (PyTorch FSDP, Megatron, MaxText, and AXLearn) are evaluated on a 32 × H100-8 cluster.
  • Massive Scalability: The system demonstrates near-linear weak scaling up to 32,768 TPUs for a 150B parameter model.
  • Inference Speedups: On TPUs, AXLearn achieved up to a 500x speedup in Time-To-First-Token (TTFT) and a 6x speedup in Time-Per-Output-Token (TPOT) compared to vLLM (though the authors note TPU support for vLLM is still experimental).
  • Resilient Recovery: On a 32,768 TPU cluster, AXLearn successfully detected a hardware failure, initiated a slice-level hot-swap within 4 minutes, and fully restored the checkpoint in 9 minutes, losing only 21 minutes of total training progress.

Limitations and Future Work

While AXLearn achieves hardware agnosticism, it inherits the backend performance characteristics of XLA. On Nvidia GPUs, Megatron-LM still holds a slight edge because PyTorch currently offers finer-grained scheduling capabilities than XLA. Additionally, achieving peak performance on emerging platforms still requires writing and maintaining backend-specific custom kernels, which demands specialized hardware expertise. The authors plan to expand their unified training and inference capabilities to non-TPU backends in future work.

Summary updated

BibTeX
@inproceedings{lee2026axlearn,
  author = {Mark Lee and Chang Lan and Tom Gunter and John Peebles and Hanzhi Zhou and Xuan Kelvin Zou and Sneha Bangalore and Chung-Cheng Chiu and Nan Du and Xianzhi Du and Philipp Dufter and Liang He and Ruixuan Hou and Haoshuo Huang and Dongseong Hwang and Xiang Kong and Jinhao Lei and Tao Lei and Ethan Li and Li Li and Jiarui Lu and Zhiyun Lu and Yiping Ma and David Qiu and Vivek Rathod and Senyu Tong and Zhucheng Tu and Chong Wang and Jianyu Wang and Yongqiang Wang and Zirui Wang and Floris Weers and Sam Wiseman and Guoli Yin and Bowen Zhang and Xiyou Zhou and Danyang Zhuo and Cheng Leong and Ruoming Pang},
  title = {{AXLearn: Modular, Hardware-Agnostic Large Model Training}},
  booktitle = {MLSys},
  year = {2026},
  url = {https://openreview.net/forum?id=41x11EB3bc},
}
Figure