Skip to content

torch-neuronx v2.34.0

Choose a tag to compare

@neuron-public-ci neuron-public-ci released this 30 Nov 20:07
Immutable release. Only release title and notes can be modified.
c2c6277

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_mm and the models' own attention, not Neuron blockwise MoE kernels and sdpa. 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 in torch.compile, and about 60% lower cold time to first iteration (TTFI).
  • Standard PyTorch code: The torch.accelerator memory functions and torch.nn.attention.varlen.varlen_attn work 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_mm in torch.compile.
  • FlexAttention: Document masks, sliding windows, and attention sinks run faster, on NKI attention kernels.
  • FP8 and MXFP8: torch._scaled_mm runs on Neuron, with float8_e4m3fn on Trn3 only, and MXFP8 F.scaled_mm runs 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, and gather, and torch.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, set TORCH_NEURONX_DYNAMIC_NKI_BETA_LIST=0.
  • Grouped matrix multiplication: Most bfloat16 and float16 torch._grouped_mm calls stay in torch.compile graphs 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, and torch.topk of a long row run an NKI sort on the device, so the MoE dispatch argsort stays in the graph with fullgraph=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 the neuronx-cc version of this release and the default compiler flags.

Attention

  • FlexAttention: bfloat16 flex_attention calls with packed-document masks run on NKI attention kernels in eager mode and in torch.compile. Under torch.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_attn runs on Neuron in eager mode and in torch.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_mm with float32 tensor-wise or row-wise scales runs on Neuron for float8_e5m2 inputs, and on Trn3 also for float8_e4m3fn inputs. On Trn3, MXFP8 F.scaled_mm and torch._scaled_mm with float8_e8m0fnu scales also run on Neuron.
  • Device-generic memory APIs: The torch.accelerator memory functions, such as memory_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_region works with the neuron backend. For a large model, set TORCH_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, and layer_norm, accumulated in low precision. They now accumulate in float32. Eager operations and collectives no longer truncate float8_e4m3fn and float8_e5m2 values to whole numbers.
  • Wrong gradients: Gradients were wrong for depthwise convolutions with a stride above 1, eager scaled_dot_product_attention with dropout (issue), and compiled leaky_relu.
  • Integer results: int64 tensors in the all_gather, gather, and all_to_all collectives kept only the low 32 bits. Integer cumsum could be wrong for rows longer than 128 elements. Integer index_put_ and scatter_, integer topk, and compiled int32 sort were wrong for values above 2^24.
  • Distributed training: DTensor random initialization could give the same values on different shards. A compiled all_reduce_coalesced on a DeviceMesh subgroup reduced over all ranks. Eager scatter_add could 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 a neuron:0 tensor returned a tensor on neuron:0 (issue). torch.Event(device="neuron", enable_timing=True) could not measure elapsed_time(), torch.neuron.StreamContext was missing, and torch.optim.Muon failed.
  • Hangs and compilation time: Eager mode hung when torch.zeros or 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), and torch._grouped_mm now use dynamic NKI kernels. To restore the 2.33.0 behavior, set TORCH_NEURONX_USE_DYNAMIC_NKI_KERNELS=0 before Python starts.
  • Stall timeout: An operation that is stuck for more than 600 seconds now raises RuntimeError instead of hanging. If a rank can wait longer for a peer, set TORCH_NEURONX_STALL_TIMEOUT to more seconds, or to 0 to 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 polygamma now break the graph where the compiled result differed from eager mode. With fullgraph=True, some of these calls raise Unsupported. Use fullgraph=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_mm with float64 or mixed-dtype operands, torch.histc with a range that is not finite, and a functional operation on an empty neuron tensor and a CPU tensor.

Known issues and limitations

  • Dynamic shapes: Native dynamic shape support is in development. In this release, torch.compile requires dynamic=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 and torch._grouped_mm handle them in the graph, with no recompilation.
  • int64 in a compiled graph: A torch.compile graph 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, and torch.topk of 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, or torch.distributions.
  • Limited torch.fft support: Real-to-complex transforms, such as torch.fft.rfft, run on the neuron device. Other torch.fft transforms 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_CAPACITY above the number of documents in a batch.