Repository navigation
torch-neuronx v2.34.0
Release Notes for Neuron Component: torch-neuronx
These are 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.
torch-neuronx package family |
PyTorch version | Python versions |
|---|---|---|
2.13.3.1.* |
2.13.0 | 3.12, 3.13, and 3.14 |
2.14.3.1.* |
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
- Supported PyTorch APIs and operators
- torch.neuron and torch.accelerator reference
- Random number generation
- Tutorial: Fine-tune a Hugging Face model with LoRA and TRL on Neuron
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.