This document is relevant for: Trn2, Trn3
Release Notes for Neuron Component: TorchNeuron#
The release notes for torch-neuronx, the native PyTorch backend for AWS Trainium.
torch-neuronx 2.13.3.1 and 2.14.3.1 (Neuron 2.34.0 Release)#
Date of release: 11/30/2026
Neuron 2.34.0 adds device support for more of the PyTorch API, and turns on dynamic NKI kernels for mixture-of-experts (MoE) models. FlexAttention runs faster with more masks, and FP8 and MXFP8 matrix multiplications run on Neuron.
Note
Install the torch-neuronx package family that matches the PyTorch version.
For example, install torch-neuronx==2.14.* with PyTorch 2.14.
Highlights#
MFU and cold TTFI: The TorchTitan Neuron MoE recipes now use upstream
torch._grouped_mmand the models’ own attention, not Neuron blockwise MoE kernels andsdpa. On Trn2, for Qwen3-30B-A3B, DeepSeek-V3-16B, and GPT-OSS-20B (TP4 x FSDP16), they have about 1.3x the MFU of the Neuron SDK 2.33.0 recipes, in eager mode and intorch.compile, and about 60% lower cold time to first iteration (TTFI).Standard PyTorch code: The
torch.acceleratormemory functions andtorch.nn.attention.varlen.varlen_attnwork on Neuron. Public issues on cross-device copies, SDPA dropout gradients, and cache reuse are fixed.MoE with no settings: Dynamic NKI kernels are on by default, also for
torch._grouped_mmintorch.compile.FlexAttention: Document masks, sliding windows, and attention sinks run faster, on NKI attention kernels.
FP8 and MXFP8:
torch._scaled_mmruns on Neuron, withfloat8_e4m3fnon Trn3 only, and MXFP8F.scaled_mmruns on Trn3.
Support matrix#
TorchNeuron supports the following operating systems on Linux x86_64.
Ubuntu version |
Support status |
Supported instances |
|---|---|---|
Ubuntu 22.04 |
Supported |
Trn2 and Trn3 |
Ubuntu 24.04 |
Supported |
Trn2 and Trn3 |
Ubuntu 26.04 |
Supported |
Trn2 and Trn3 |
The release wheels now install on Ubuntu 22.04, 24.04, and 26.04. Neuron no longer publishes new Ubuntu 22.04 DLAMIs or container images. Use Ubuntu 24.04 or Ubuntu 26.04 for a new environment.
Each package family supports all Python versions in its row.
|
PyTorch version |
Python versions |
|---|---|---|
|
2.13.0 |
3.12, 3.13, and 3.14 |
|
2.14.0 |
3.12, 3.13, and 3.14 |
Each PyTorch and Python combination has a release wheel.
To install torch-neuronx and the matching dependencies, see
Install and verify torch-neuronx.
What’s new#
Mixture of experts (MoE)#
Dynamic NKI kernels by default: Eager MoE routing operations, such as
scatter_add,index_put, andgather, andtorch.optim.AdamW(fused=True)run on dynamic-shape NKI kernels, so new token counts and parameter shapes do not recompile. To turn off the fused AdamW kernel, setTORCH_NEURONX_DYNAMIC_NKI_BETA_LIST=0.Grouped matrix multiplication: Most bfloat16 and float16
torch._grouped_mmcalls stay intorch.compilegraphs without a graph break, and grouped matrix multiplications are faster on Trn2 and Trn3. For the calls that still break the graph, see How to optimize a model with torch.compile.Sort on the device: In
torch.compile,torch.sort,torch.argsort, andtorch.topkof a long row run an NKI sort on the device, so the MoE dispatchargsortstays in the graph withfullgraph=True.Pre-compiled NEFFs:
torch._grouped_mm,scatter_add, and fused AdamW calls with the shapes of the stock TorchTitan Neuron MoE recipes, for Qwen3-30B-A3B, GPT-OSS-20B, and DeepSeek-V3-16B, load pre-compiled NEFFs from the package, so the first training step compiles fewer kernels. The NEFFs need theneuronx-ccversion of this release and the default compiler flags.
Attention#
FlexAttention: bfloat16
flex_attentioncalls with packed-document masks run on NKI attention kernels in eager mode and intorch.compile. Undertorch.compile, calls with sliding windows, attention sinks, or DeepSeek-V3-style attention (MLA) also run on these kernels.Variable-length attention:
torch.nn.attention.varlen.varlen_attnruns on Neuron in eager mode and intorch.compile. For the supported calls and limits of both, see Best practices for TorchNeuron.
Data types and PyTorch APIs#
FP8 and MXFP8 matrix multiplications:
torch._scaled_mmwith float32 tensor-wise or row-wise scales runs on Neuron forfloat8_e5m2inputs, and on Trn3 also forfloat8_e4m3fninputs. On Trn3, MXFP8F.scaled_mmandtorch._scaled_mmwithfloat8_e8m0fnuscales also run on Neuron.Device-generic memory APIs: The
torch.acceleratormemory functions, such asmemory_allocated(), work on Neuron.torch.neuron.mem_get_info()returns the free and total device memory. See the torch.neuron and torch.accelerator reference and the memory guide.Nested compile regions:
torch.compiler.nested_compile_regionworks with theneuronbackend. For a large model, setTORCH_NEURONX_INLINE_INVOKE_SUBGRAPH=1, or compilation can run out of memory.
New documentation#
Bug fixes#
Here’s what we fixed in 2.34.0:
Precision: bfloat16 and float16 reductions and normalizations, such as
sum,mean, andlayer_norm, accumulated in low precision. They now accumulate in float32. Eager operations and collectives no longer truncatefloat8_e4m3fnandfloat8_e5m2values to whole numbers.Wrong gradients: Gradients were wrong for depthwise convolutions with a stride above 1, eager
scaled_dot_product_attentionwith dropout (issue), and compiledleaky_relu.Integer results: int64 tensors in the
all_gather,gather, andall_to_allcollectives kept only the low 32 bits. Integercumsumcould be wrong for rows longer than 128 elements. Integerindex_put_andscatter_, integertopk, and compiled int32sortwere wrong for values above 2^24.Distributed training: DTensor random initialization could give the same values on different shards. A compiled
all_reduce_coalescedon aDeviceMeshsubgroup reduced over all ranks. Eagerscatter_addcould lose additions when rows shared a target, as in an MoE combine. Collectives held memory too long, which could cause out-of-memory errors.Device-generic code:
.to("neuron:1")on aneuron:0tensor returned a tensor onneuron:0(issue).torch.Event(device="neuron", enable_timing=True)could not measureelapsed_time(),torch.neuron.StreamContextwas missing, andtorch.optim.Muonfailed.Hangs and compilation time: Eager mode hung when
torch.zerosor a similar operation failed to compile. The first call of each compiled graph in each process was slow, even on a cache hit. A compiled graph recompiled in another virtual environment or checkout (issue).
Breaking changes and upgrade notes#
Dynamic NKI kernels on by default: Eager scatter, gather, and indexing calls,
torch.optim.AdamW(fused=True), andtorch._grouped_mmnow use dynamic NKI kernels. To restore the 2.33.0 behavior, setTORCH_NEURONX_USE_DYNAMIC_NKI_KERNELS=0before Python starts.Stall timeout: An operation that is stuck for more than 600 seconds now raises
RuntimeErrorinstead of hanging. If a rank can wait longer for a peer, setTORCH_NEURONX_STALL_TIMEOUTto more seconds, or to0to turn it off. See Troubleshooting: TorchNeuron.NEFF cache lock timeout:
TORCH_NEURONX_NEFF_CACHE_LOCK_TIMEOUT, the total wait for another process’s NEFF compilation, now defaults to 12000 seconds. When it runs out, the operation fails instead of compiling again. Set it above your longest compilation. See Environment variables.Random values: For seeds of 2^24 or more and for the default seed, random values on Neuron differ from 2.33.0. See Random number generation.
torch.compile matches eager mode: Operations such as
polygammanow break the graph where the compiled result differed from eager mode. Withfullgraph=True, some of these calls raiseUnsupported. Usefullgraph=False. See Graph breaks.DDP quantization hook: DDP with
quantization_pertensor_hook, which worked in 2.33.0, can now give wrong gradients or fail. Use DDP without a communication hook.New errors that match PyTorch: These calls now raise
RuntimeError, as PyTorch does:torch._grouped_mmwith float64 or mixed-dtype operands,torch.histcwith a range that is not finite, and a functional operation on an emptyneurontensor and a CPU tensor.
Known issues and limitations#
Dynamic shapes: Native dynamic shape support is in development. In this release,
torch.compilerequiresdynamic=False, and each new input shape can require another compilation, so pad or bucket inputs to reduce shape variation. MoE token counts that change from step to step are an exception: dynamic NKI kernels andtorch._grouped_mmhandle them in the graph, with no recompilation.int64 in a compiled graph: A
torch.compilegraph computes int64 values on the low 32 bits. A value outside the int32 range gives a wrong result with no error. For example,torch.sort,torch.argsort, andtorch.topkof int64 keys outside the int32 range sort in the wrong order. Keep int64 values in a compiled graph inside the int32 range, or run the operation in eager mode.First-run compilation: The first operation or graph run includes compilation time when the cache has no matching artifact. Later runs can reuse the cache.
Unsupported APIs: This release does not support
torch.sparse,torch.func,torch.nested, ortorch.distributions.Limited torch.fft support: Real-to-complex transforms, such as
torch.fft.rfft, run on theneurondevice. Othertorch.ffttransforms run on the CPU.FlexAttention with many documents: A compiled FlexAttention call returns NaN, with no error, when a batch has one packed document or more for each 128 tokens. Set
TORCH_NEURONX_FLEX_DOCUMENT_CAPACITYabove the number of documents in a batch.
torch-neuronx 2.13.3.0 and 2.14.3.0 (Neuron 2.33.0 Release)#
Date of release: 10/19/2026
Neuron 2.33.0 introduces the native torch-neuronx backend as a public beta.
It adds the neuron device through the PyTorch PrivateUse1 extension.
Move the model and its inputs to neuron to run them on Trainium2 or Trainium3.
For an overview, see What is TorchNeuron?.
Note
Install the torch-neuronx package family that matches the PyTorch version.
For example, install torch-neuronx==2.14.* with PyTorch 2.14.
Support matrix#
TorchNeuron supports the following operating systems on Linux x86_64.
Ubuntu version |
Support status |
Supported instances |
Wheel support |
|---|---|---|---|
Ubuntu 22.04 |
Supported |
Trn2 and Trn3 |
Planned for the next release |
Ubuntu 24.04 |
Supported |
Trn2 and Trn3 |
Planned for the next release |
Ubuntu 26.04 |
Supported |
Trn2 and Trn3 |
Supported |
Neuron no longer publishes new Ubuntu 22.04 DLAMIs or container images. Use Ubuntu 24.04 or Ubuntu 26.04 for a new environment.
The standalone wheels in this release support Ubuntu 26.04 only.
On Ubuntu 24.04, use the single-framework DLAMI
with torch-neuronx installed.
For a manual setup on Ubuntu 22.04 or Ubuntu 24.04, build torch-neuronx from
source.
Each package family supports all Python versions in its row.
|
PyTorch version |
Python versions |
|---|---|---|
|
2.13.0 |
3.12, 3.13, and 3.14 |
|
2.14.0 |
3.12, 3.13, and 3.14 |
Each PyTorch and Python combination has an Ubuntu 26.04 release wheel.
To install torch-neuronx and the matching dependencies, see
Install and verify torch-neuronx.
New features#
Neuron device for PyTorch: Move models and tensors with
.to("neuron"). Run supportedtorch.nn,torch.autograd, andtorch.optimcode.torch.acceleratordiscovers the Neuron device. In eager mode, an unsupported operation can run on the CPU.torch_neuronx.get_fallback_ops()lists recorded fallback operations. See the torch-neuronx operator compatibility table.Data types: Supported operations can use
bfloat16,float16,float32,int64, complex types, other integer types, andbool.torch.autocastsupports mixed-precision execution on theneurondevice.float64runs asfloat32and produces a warning.Eager execution: Operations run when Python calls them. Use standard control flow,
print, and breakpoints during development. Each operation compiles on first use and is cached for later calls.torch.compile:
torch.compile(model, backend="neuron")compiles a model or selected regions. It also compiles supported backward graphs. Code outside a compiled region runs in eager mode. The backend supportsmode="default"and static shapes. Setdynamic=False. See About torch.compile on Neuron.torch.distributed: This release provides a
neuronc10d backend. Initialize it withinit_process_group(backend="neuron"). The backend supportsall_reduce,all_gather,reduce_scatter,all_to_all,broadcast,reduce,gather,scatter, andbarrier. Point-to-point support includessend,recv, andbatch_isend_irecv. These operations support the following PyTorch parallelism APIs:Data parallelism with
DistributedDataParallel(DDP)Fully sharded data parallelism with
fully_shard(FSDP2)Tensor and sequence parallelism with DTensor and
DeviceMeshPipeline parallelism with
torch.distributed.pipeliningContext parallelism with PyTorch’s experimental
torch.distributed.tensor.experimental.context_parallel()API for scaled dot-product attention
You can combine supported APIs on one
DeviceMesh. Training runs on one node or many nodes. Collectives use Trainium collective cores within a node and EFA between nodes. See How to use torch.distributed on Neuron.Streams and events:
torch.neuron.Streamandtorch.neuron.Eventsupport device-work ordering and synchronization. Usewait_stream()orwait_event()to order dependent work. Usequery()to check completion. Usesynchronize()to wait for completion on the CPU. Streams are distinct by default, but they do not guarantee concurrent execution. SetTORCH_NEURONX_ENABLE_STREAMS=0before Python starts to use one stream.Profiling and memory:
torch.profilercaptures framework, runtime, and device traces for Neuron Explorer. A default Neuron session starts without additional configuration. Pass aNeuronConfigto select the captured information.torch_neuronx.memory_stats(),memory_summary(),empty_cache(), and memory snapshots report and manage device memory. See the profiling guide and the memory guide.Compilation cache: TorchNeuron caches compiled artifacts on disk. Processes and distributed ranks can reuse matching artifacts.
torch_neuronx.compiler.compile_only()builds the cache without execution. See About torch.compile on Neuron.Custom kernels with NKI:
torch_neuronx.nki_opregisters an NKI kernel as a PyTorch custom operation. The operation can run in eager mode and insidetorch.compile. Add a backward pass withtorch.library.register_autograd. Use profiling to identify operations that limit performance. Use NKI to implement or tune those operations. See How to work with NKI kernels.
Experimental features#
Operation concatenation: Combines eligible eager operations to reduce per-operation overhead. It is disabled by default. Set
TORCH_NEURONX_ENABLE_CONCATENATION=1before Python starts.
Breaking changes#
Moving from the XLA-based torch-neuronx: The native backend uses the
neurondevice instead oftorch_xlaandxm.xla_device(). Update code written for the XLA-based library.
Known issues and limitations#
Dynamic shapes: Native dynamic shape support is in development. In this release,
torch.compilerequiresdynamic=False, and each new input shape can require another compilation. Pad or bucket inputs to reduce shape variation.First-run compilation: The first operation or graph run includes compilation time when the cache has no matching artifact. Later runs can reuse the cache.
Unsupported APIs: This release does not support
torch.sparse,torch.func,torch.nested, ortorch.distributions.Limited torch.fft support: Real-to-complex transforms, such as
torch.fft.rfft, run on theneurondevice. Othertorch.ffttransforms run on the CPU.TorchAO and MXFP8: This release does not include TorchAO integration or composite MXFP8 data type support.
Getting started#
import torch
import torch_neuronx
model = torch.nn.Linear(16, 8).to("neuron").eval()
inputs = torch.randn(4, 16, device="neuron")
with torch.no_grad():
eager_output = model(inputs)
compiled_model = torch.compile(model, backend="neuron", dynamic=False)
compiled_output = compiled_model(inputs)
print(tuple(eager_output.cpu().shape))
print(tuple(compiled_output.cpu().shape))
Both calls return a tensor with shape (4, 8).
This document is relevant for: Trn2, Trn3