AWS has introduced TorchNeuron, an open-source software tool that allows developers to run existing PyTorch applications on its Trainium AI chips with minimal code changes. The tool supports AI training and inference workloads through PyTorch’s native programming interfaces.
TorchNeuron is scheduled to enter public beta on October 20 during the PyTorch Conference North America. The software supports AWS Trainium2 and Trainium3 chips and is being released under the Apache 2.0 open-source licence.
Native PyTorch support expands Trainium compatibility
TorchNeuron integrates with PyTorch through its existing hardware extension system, allowing developers to use Trainium through standard programming interfaces. Developers can select Trainium by changing the device setting in their code to neuron, while applications using supported hardware-independent PyTorch interfaces can run without changes to their model code.
PyTorch already supports Nvidia GPUs through CUDA, which provides access to Nvidia’s computing libraries and development tools. TorchNeuron extends native PyTorch support to AWS Trainium through the framework’s PrivateUse1 hardware extension mechanism.
“Developers should have a consistent experience across hardware platforms,” Jana van Greunen, director of PyTorch engineering at Meta, said. The integration allows developers to use existing PyTorch development and distributed training interfaces on supported Trainium hardware.
TorchNeuron supports PyTorch’s eager execution mode, allowing developers to debug individual operations using standard Python tools. It also supports torch.compile, which optimises model operations for Trainium hardware.
The software supports distributed training through standard PyTorch interfaces, including Fully Sharded Data Parallelism 2 (FSDP2), DistributedDataParallel, tensor parallelism, and pipeline parallelism. These capabilities allow developers to distribute training workloads across multiple Trainium accelerators and servers.
Developers can also use Neuron Explorer alongside the standard PyTorch profiler to examine hardware activity, identify performance bottlenecks, and trace operations back to their source code. The Neuron Kernel Interface provides additional control by allowing developers to create custom operations for specific workloads.
Hugging Face has added native TorchNeuron support to its Transformers, Diffusers, Accelerate, PEFT, and TRL libraries. Previously, supported Trainium workloads relied on the separate XLA-based Optimum Neuron integration, which used specialised model classes and training tools.
The new integration allows developers to use standard Hugging Face model definitions and training scripts on Trainium. Hugging Face said TorchNeuron supports 89% of the 100 most-used text-generation model architectures, compared with 46% under Optimum Neuron version 0.4.5.
The figures measure model architecture compatibility rather than inference performance. Developers can load supported models onto Trainium using the device_map=”neuron” setting, while Diffusers also supports image and video generation workloads.
Hugging Face said the new integration allows developers to save trained models using standard Transformers checkpoints. These checkpoints can be uploaded to the Hugging Face Hub and loaded on other supported hardware.
Early performance results and technical limitations
AWS and PyTorch have published examples of organisations testing TorchNeuron for AI inference workloads, including speech AI companies Deepgram and Cartesia. The deployments demonstrate how the software has been used with existing PyTorch applications.
Deepgram worked with the AWS Generative AI Innovation Center over several months to move its model to native PyTorch on Trainium. The company reported improved cost performance compared with its existing GPU systems.
“In the benchmarks we evaluated, Trainium processes about 60% more input audio seconds per dollar than our existing GPU baselines,” Adam Sypniewski, CTO of Deepgram, said.
The result reflects Deepgram’s evaluated speech AI workloads rather than a general performance comparison between Trainium and GPU-based cloud instances.
Voice AI company Cartesia also tested TorchNeuron with its existing inference pipeline. According to the company, its engineers were able to run standard PyTorch code on Trainium with minimal changes, while using custom kernels to optimise operations that have a greater effect on processing latency.
TorchNeuron remains in public beta and does not yet support every PyTorch operation. According to AWS documentation, native dynamic shape support is still under development, while APIs such as torch.sparse, torch.func, and torch.nested remain unsupported.
The current release also requires dynamic=False when using torch.compile, and different input shapes can require separate compilations. AWS recommends grouping or padding inputs to reduce repeated compilation.
Unsupported operations can fall back to CPU execution in eager mode, potentially affecting performance. Developers can use TorchNeuron’s profiling tools to identify these operations and other performance bottlenecks.
TorchNeuron is being distributed through the AWS Neuron software stack for compatible Trainium2 and Trainium3 instances. Its open-source implementation is available through AWS’s GitHub repository under the Apache 2.0 licence.
See also: AWS and Azure face EU gatekeeper rules over cloud lock-in

Want to learn more about Cloud Computing from industry leaders? Check out Cyber Security & Cloud Expo taking place in Amsterdam, California, and London. The comprehensive event is part of TechEx and is co-located with other leading technology events, click here for more information.
Cloud Computing News is powered by TechForge Media. Explore other upcoming enterprise technology events and webinars here.
