This document is relevant for: Trn1, Trn2, Trn3
Training paths (native and legacy XLA)#
Train models on AWS Trainium with PyTorch. This section splits by the PyTorch
path you build on: native PyTorch (TorchNeuron), or the legacy PyTorch/XLA path
on the older torch-neuronx XLA library. Use TorchNeuron for new work. The
XLA path stays documented for workloads already running on it.
Warning
TorchNeuron and the legacy torch-neuronx (XLA) library share the
torch-neuronx package name but are different products with different APIs
and version lineages. Pick one path and stay on it; do not mix their APIs in
a single workload.
Native PyTorch training (TorchNeuron)#
TorchNeuron is the Neuron native PyTorch backend. It runs eager mode,
torch.compile with the neuron backend, and the standard distributed
APIs: FSDP, DTensor, DDP, and functional collectives. Most PyTorch training
code runs on Trainium after you change device placement from cuda to
neuron.
See Training best practices for choosing FSDP, tensor parallelism, pipeline parallelism, and meshes on Trainium.
Supported Training Libraries#
Legacy PyTorch/XLA training (torch-neuronx XLA)#
Note
The torch-neuronx library referenced here is the older XLA-based
product, not TorchNeuron. It is in maintenance status for customers with
existing XLA workloads. For new training, use the native PyTorch path above.
This document is relevant for: Trn1, Trn2, Trn3