Hugging FaceRégis Pierrard, Simon Pagezy, Michael Benayoun, Jingya Huang, Alvaro Moran, David Corvoysier, Jeff BoudierAnnouncement
TorchNeuron: running HF models on AWS Trainium is easier than ever
Summary
TorchNeuron is a new PyTorch plugin that adds a native Neuron backend for AWS Trainium, supporting eager mode, torch.compile, and distributed APIs like FSDP and TP. It will be available as a public beta starting October 20, 2026, and can be installed with pip install torch-neuronx. Hugging Face libraries such as Transformers, Diffusers, Accelerate, PEFT, and TRL now run directly on Trainium without needing the Optimum Neuron wrapper, using the same classes and scripts as on any other accelerator. For text generation, 89% of the top 100 most-used model architectures are supported out of the box, compared to 46% with Optimum Neuron v0.4.5. Training uses standard TRL scripts with only a few Neuron-specific settings like static shapes and torch.compile, and the resulting checkpoints are hardware-agnostic.
Context
The post announces the public beta of TorchNeuron, a new PyTorch backend for AWS Trainium that replaces the previous Optimum Neuron approach based on PyTorch XLA. It provides examples for text generation inference, training with TRL, and image generation with Diffusers, highlighting native support for eager execution, torch.compile, and distributed parallelism.
Approach / What changed
TorchNeuron is a PyTorch plugin that adds a native Neuron backend for AWS Trainium, supporting eager mode, torch.compile, and native distributed APIs like FSDP and TP. It integrates directly into PyTorch, allowing Hugging Face libraries (Transformers, Diffusers, Accelerate, PEFT, TRL) to run on Trainium without the Optimum Neuron wrapper. Users install it with pip install torch-neuronx and use standard scripts with device_map=neuron or torch.compile.
Takeaways
TorchNeuron integrates as a native PyTorch device, supporting eager mode, torch.compile, and distributed primitives like FSDP and TP, eliminating the need for the Optimum Neuron wrapper.
With TorchNeuron, 89% of the top 100 most-used text-generation model architectures are supported out of the box, up from 46% with Optimum Neuron v0.4.5.
Training on Trainium uses standard Hugging Face libraries (Transformers, Accelerate, PEFT, TRL) with only a few Neuron-specific settings such as static shapes and torch.compile, and produces hardware-agnostic checkpoints.
FAQ
How do I install TorchNeuron?
TorchNeuron will be available as a public beta starting October 20, 2026, and can be installed with pip install torch-neuronx.
What Hugging Face libraries are supported with TorchNeuron?
Transformers, Diffusers, Accelerate, PEFT, and TRL run directly on Trainium with TorchNeuron, using the same classes and scripts as on any other accelerator.
How does parallelism work during training on Trainium?
Parallelism is handled natively by Transformers using a DistributedConfig with tensor-parallel (TP) and FSDP sizes. The model is sharded as weights are loaded, and the Trainer does not wrap it again.
Source and freshness
- Source
- huggingface.co
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.