# TorchNeuron

> Source: https://aiwiki.ai/wiki/torchneuron
> Updated: 2026-10-20
> Categories: AI Infrastructure, Software Development
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "TorchNeuron." aiwiki.ai, 20 Oct 2026. https://aiwiki.ai/wiki/torchneuron
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

TorchNeuron is an open-source native [PyTorch](https://aiwiki.ai/wiki/pytorch) backend from [Amazon Web Services](https://aiwiki.ai/wiki/amazon_web_services) for [AWS Trainium](https://aiwiki.ai/wiki/aws_trainium) accelerators. It registers a `neuron` device with PyTorch and supports model training and inference through eager execution, graph compilation, and custom kernels. AWS introduced it in October 2026; the Neuron 2.33 documentation identifies it as a public beta for Trainium2 and Trainium3.[1][5]

The Python distribution is named `torch-neuronx`, which is also the name of AWS's older PyTorch/XLA integration. The native backend and the XLA-based software are distinct implementations. TorchNeuron's public source repository identifies itself as the native backend and carries an Apache 2.0 license.[3][4]

## Overview

| Property | Details |
| --- | --- |
| Developer | Amazon Web Services |
| Software type | Native, out-of-tree PyTorch device backend |
| Device identifier | `neuron` |
| Initial availability | Public beta in Neuron 2.33; conference launch announced for October 20, 2026 |
| Supported accelerator families | Trainium2 and Trainium3 |
| Execution paths | Eager execution and `torch.compile` |
| Custom kernels | Neuron Kernel Interface (NKI) |
| Package | `torch-neuronx` |
| Source license | Apache 2.0 |

The hardware and release scope above come from the current TorchNeuron documentation and repository, rather than from the broader list of devices supported by other Neuron SDK components.[1][2][3]

## Native device integration

TorchNeuron uses PyTorch's `PrivateUse1` extension mechanism. PyTorch's dispatcher sends tensor operations to the backend, which implements core ATen operations and communication primitives for Trainium. This makes Trainium a PyTorch device rather than requiring a separate model-definition framework. The backend can autoload with PyTorch on Neuron hardware.[1]

Both a model and its input tensors must be placed on `neuron`. Device-independent code can use `torch.accelerator`; code that explicitly selects a CUDA device needs corresponding changes.[3][5]

AWS's announcement describes a device switch as the main change for standard PyTorch model code. That claim has a compatibility boundary: the published API table distinguishes native operations, operations that fall back to the CPU, and unsupported APIs. It does not establish that arbitrary CUDA-specific extensions or all PyTorch programs run unchanged.[5][6]

## Execution modes

### Eager execution

Eager execution dispatches individual operations as Python calls them. It supports interactive development with ordinary control flow, logging, and breakpoints. Each operator can compile to a Neuron Executable File Format (NEFF) artifact on first use; subsequent calls reuse compiled work. Immediate Python execution therefore does not mean compilation is absent.[1]

Adaptive eager execution combines eligible operations to reduce individual dispatch overhead. This is an experimental feature, disabled by default in the initial public beta. The documented switch is `TORCH_NEURONX_ENABLE_CONCATENATION=1`, set before starting Python.[3]

### Graph compilation

The [torch.compile](https://aiwiki.ai/wiki/torch_compile) path selects `backend="neuron"`. TorchDynamo captures FX graphs, AOT Autograd separates forward and backward computation, and the backend lowers graphs through StableHLO to the Neuron compiler. The compiler emits NEFF artifacts for execution by the Neuron Runtime. This path does not use TorchInductor's GPU code generation.[7]

Graph breaks can divide a model into separately compiled regions. `fullgraph=True` makes a graph break raise an error instead. NKI kernels registered as PyTorch operators can remain inside the compiled graph. Compilation artifacts are cached, but changes in input signatures or compiler configuration can require further compilation.[7]

The initial beta requires static shapes with `dynamic=False` and supports the default compilation mode. CUDA-specific compiler options are not interchangeable with Neuron settings. The repository also notes that non-contiguous inputs are copied to contiguous tensors for compiled calls.[3][7]

## Distributed training

TorchNeuron implements a `neuron` backend for [distributed training](https://aiwiki.ai/wiki/distributed_training) through `torch.distributed`. Its documentation covers DistributedDataParallel, FSDP2, DTensor-based tensor parallelism, and pipeline parallelism. A process group must be initialized before allocating Neuron tensors; the backend uses the launcher's local rank information to assign workers to available cores.[8]

`torchrun` can launch multiple workers. Multi-node jobs require Elastic Fabric Adapter (EFA) installation and configuration on each node, compatible package versions, and network connectivity between workers. The documented basic test performs an `all_reduce` across workers, providing a separate check of communication before a model is distributed.[8]

## Custom kernels and profiling

The Neuron Kernel Interface is a Python-based language and compiler for direct programming of Neuron devices. It provides instruction-level access to NeuronCores and uses tile-oriented programming. Its library supplies prebuilt kernels that can be checked before implementing an operation from scratch.[9]

TorchNeuron exposes custom kernels as PyTorch operations using `nki_op`. These operations can run eagerly or inside a compiled graph; training through one requires an appropriate backward implementation. This is a hardware-specific optimization route, distinct from portable high-level PyTorch model code.[2][9]

Neuron Explorer provides device and system profiling views, source-code correlation, and distributed-workload analysis. Device traces show hardware activity and utilization, while system traces cover framework operations, runtime calls, and CPU activity. Its viewers can help distinguish a kernel bottleneck from host or communication overhead.[10]

## Installation and version selection

AWS's installation quickstart specifies a Trn2 or Trn3 instance and Ubuntu 24.04 or 26.04. A Neuron Base DLAMI provides system components such as the driver and tools; a generic Ubuntu image requires installing them. The Python environment also needs the Neuron runtime, collective libraries, compiler dependencies, and matching framework packages.[11]

The Neuron 2.33 release notes list native package families for PyTorch 2.13.0 and 2.14.0, with Python 3.12, 3.13, and 3.14. Framework and backend versions must match. The current repository's quickstart uses PyTorch 2.14 and a `torch-neuronx==2.14.*` pin, rather than an unqualified installation of any historical package version.[2][3]

AWS's verification example checks device availability and compares a matrix multiplication on Neuron against a CPU result. This checks the installation, not the correctness or performance of an arbitrary model.[11]

## Compatibility and limitations

The initial release has material gaps. Its release notes exclude `torch.sparse`, `torch.func`, `torch.nested`, and `torch.distributions`. They also state that TorchAO integration and composite MXFP8 support are absent. `float64` executes as `float32` with a warning, which matters for code requiring 64-bit floating-point precision.[2]

Compatibility is operation-specific. For example, the repository's table marks `torch.eye` as native, `torch.complex` as CPU fallback, and quantized tensor creation as unsupported. A model can therefore execute a mixture of device and CPU work; successful execution alone does not demonstrate that every operation ran on Trainium.[6]

AWS tested broad model coverage using reduced configurations and tracked loading, forward and backward execution, compilation, and CPU fallback. These checks concern compatibility; they are not a published guarantee of production-scale performance for every checkpoint.[5]

## Relationship to earlier Neuron software

The older XLA-based `torch-neuronx` uses PyTorch/XLA conventions. Native TorchNeuron instead selects the `neuron` device and uses standard eager and compiler extension paths. Migrating an existing XLA-specific program can require changes even though both products use the same distribution name.[1][4]

AWS keeps the XLA-based documentation available and describes that lineage as being in maintenance status, receiving critical bug fixes and security patches rather than being at end of support. The separate legacy `torch-neuron` package for Inf1 is archived. These statuses should not be conflated with the public-beta status of the native TorchNeuron backend.[4]

## References

1. AWS Neuron Documentation. ["What is TorchNeuron?"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/torch/about-pytorch-neuron.html). Accessed October 20, 2026.
2. AWS Neuron Documentation. ["Release Notes for Neuron Component: TorchNeuron"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/release-notes/components/torchneuron.html). Neuron 2.33.0 release, dated October 19, 2026. Accessed October 20, 2026.
3. AWS Neuron. ["torch-neuronx (Beta)"](https://github.com/aws-neuron/torch-neuronx). Source repository and README. Accessed October 20, 2026.
4. AWS Neuron Documentation. ["PyTorch Support on Neuron"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/archive/frameworks/torch/index.html). Archived framework documentation and maintenance-status notice. Accessed October 20, 2026.
5. Bshara, Nafea, et al. ["Introducing TorchNeuron: Native PyTorch backend for AWS Trainium"](https://pytorch.org/blog/introducing-torchneuron-native-pytorch-backend-for-aws-trainium/). PyTorch Blog, October 19, 2026. Accessed October 20, 2026.
6. AWS Neuron. ["PyTorch API compatibility"](https://github.com/aws-neuron/torch-neuronx/blob/main/docs/torch_api_compatibility.md). Source repository documentation. Accessed October 20, 2026.
7. AWS Neuron Documentation. ["How torch.compile works on Neuron"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/torch/compile/about-torch-compile.html). Accessed October 20, 2026.
8. AWS Neuron Documentation. ["How to use torch.distributed on Neuron"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/torch/guides/torch-distributed.html). Accessed October 20, 2026.
9. AWS Neuron Documentation. ["Neuron Kernel Interface (NKI)"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/nki/index.html). Accessed October 20, 2026.
10. AWS Neuron Documentation. ["Neuron Explorer"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/tools/neuron-explorer/index.html). Accessed October 20, 2026.
11. AWS Neuron Documentation. ["Quickstart: Install and verify torch-neuronx"](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/torch/get-started/quickstart-torch-neuron.html). Accessed October 20, 2026.

