.. _torchneuron_rn:

.. meta::
   :description: Release notes for TorchNeuron (torch-neuronx), the native PyTorch backend for AWS Trainium, in AWS Neuron SDK 2.34.0.
   :keywords: TorchNeuron, torch-neuronx, PyTorch 2.13, PyTorch 2.14, release notes, Trainium, torch.compile, MoE, FlexAttention, MXFP8, NKI
   :date-modified: 2026-11-12

Release Notes for Neuron Component: TorchNeuron
===============================================

The release notes for ``torch-neuronx``, the native PyTorch backend for AWS Trainium.

.. _torchneuron-2-34-0-rn:

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.

.. list-table::
   :header-rows: 1
   :widths: 30 30 40

   * - 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.

.. list-table::
   :header-rows: 1
   :widths: 35 35 30

   * - ``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
:doc:`Install and verify torch-neuronx
</torch/get-started/quickstart-torch-neuron>`.

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 :ref:`How to optimize a model with torch.compile <torch-compile-bp-1>`.
* **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 :ref:`Best practices for TorchNeuron <additional-recommendations>`.

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 :doc:`torch.neuron and torch.accelerator reference </torch/reference/api/torch-neuron-module>` and the :doc:`memory guide </torch/reference/guidelines-memory-management>`.
* **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
~~~~~~~~~~~~~~~~~

* :doc:`Supported PyTorch APIs and operators </torch/reference/api/supported-operators>`
* :doc:`torch.neuron and torch.accelerator reference </torch/reference/api/torch-neuron-module>`
* :doc:`Random number generation </torch/reference/random-number-generation>`
* :doc:`Tutorial: Fine-tune a Hugging Face model with LoRA and TRL on Neuron </torch/tutorials/tutorial-hf-fine-tuning>`

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 <https://github.com/aws-neuron/torch-neuronx/issues/1031>`__), 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 <https://github.com/aws-neuron/torch-neuronx/issues/1021>`__).
  ``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 <https://github.com/aws-neuron/torch-neuronx/issues/1027>`__).

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 :doc:`Troubleshooting: TorchNeuron </torch/troubleshooting>`.
* **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 :doc:`Environment variables </torch/reference/env-vars>`.
* **Random values**: For seeds of 2^24 or more and for the default seed, random values on Neuron differ from 2.33.0.
  See :doc:`Random number generation </torch/reference/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 :ref:`Graph breaks <torchneuron-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.

.. _torchneuron-2-33-0-rn:

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 :doc:`/torch/about-pytorch-neuron`.

.. 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.

.. list-table::
   :header-rows: 1
   :widths: 20 20 25 35

   * - 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 :doc:`single-framework DLAMI </setup/pytorch/dlami>`
with ``torch-neuronx`` installed.
For a manual setup on Ubuntu 22.04 or Ubuntu 24.04, `build torch-neuronx from
source
<https://github.com/aws-neuron/torch-neuronx?tab=contributing-ov-file#setup-development-environment>`_.

Each package family supports all Python versions in its row.

.. list-table::
   :header-rows: 1
   :widths: 35 35 30

   * - ``torch-neuronx`` package family
     - PyTorch version
     - Python versions
   * - ``2.13.3.0.*``
     - 2.13.0
     - 3.12, 3.13, and 3.14
   * - ``2.14.3.0.*``
     - 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
:doc:`Install and verify torch-neuronx
</torch/get-started/quickstart-torch-neuron>`.

New features
~~~~~~~~~~~~

* **Neuron device for PyTorch**: Move models and tensors with ``.to("neuron")``.
  Run supported ``torch.nn``, ``torch.autograd``, and ``torch.optim`` code.
  ``torch.accelerator`` discovers 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 <https://github.com/aws-neuron/torch-neuronx/blob/main/docs/torch_api_compatibility.md>`__.

* **Data types**: Supported operations can use ``bfloat16``, ``float16``,
  ``float32``, ``int64``, complex types, other integer types, and ``bool``.
  ``torch.autocast`` supports mixed-precision execution on the ``neuron`` device.
  ``float64`` runs as ``float32`` and 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 supports ``mode="default"`` and static shapes.
  Set ``dynamic=False``.
  See :doc:`About torch.compile on Neuron
  </torch/compile/about-torch-compile>`.

* **torch.distributed**: This release provides a ``neuron`` c10d backend.
  Initialize it with ``init_process_group(backend="neuron")``.
  The backend supports ``all_reduce``, ``all_gather``, ``reduce_scatter``,
  ``all_to_all``, ``broadcast``, ``reduce``, ``gather``, ``scatter``, and
  ``barrier``.
  Point-to-point support includes ``send``, ``recv``, and ``batch_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 ``DeviceMesh``
  * Pipeline parallelism with ``torch.distributed.pipelining``
  * Context 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 :doc:`How to use torch.distributed on Neuron
  </torch/guides/torch-distributed>`.

* **Streams and events**: ``torch.neuron.Stream`` and ``torch.neuron.Event``
  support device-work ordering and synchronization.
  Use ``wait_stream()`` or ``wait_event()`` to order dependent work.
  Use ``query()`` to check completion.
  Use ``synchronize()`` to wait for completion on the CPU.
  Streams are distinct by default, but they do not guarantee concurrent execution.
  Set ``TORCH_NEURONX_ENABLE_STREAMS=0`` before Python starts to use one stream.

* **Profiling and memory**: ``torch.profiler`` captures framework, runtime,
  and device traces for Neuron Explorer.
  A default Neuron session starts without additional configuration.
  Pass a ``NeuronConfig`` to select the captured information.
  ``torch_neuronx.memory_stats()``, ``memory_summary()``, ``empty_cache()``,
  and memory snapshots report and manage device memory.
  See the :doc:`profiling guide
  </tools/neuron-explorer/how-to-profile-workload>` and the
  :doc:`memory guide </torch/reference/guidelines-memory-management>`.

* **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 :doc:`About torch.compile on Neuron
  </torch/compile/about-torch-compile>`.

* **Custom kernels with NKI**: ``torch_neuronx.nki_op`` registers an NKI kernel
  as a PyTorch custom operation.
  The operation can run in eager mode and inside ``torch.compile``.
  Add a backward pass with ``torch.library.register_autograd``.
  Use profiling to identify operations that limit performance.
  Use NKI to implement or tune those operations.
  See :doc:`How to work with NKI kernels
  </torch/guides/how-to-work-with-nki>`.

Experimental features
~~~~~~~~~~~~~~~~~~~~~

* **Operation concatenation**: Combines eligible eager operations to reduce
  per-operation overhead.
  It is disabled by default.
  Set ``TORCH_NEURONX_ENABLE_CONCATENATION=1`` before Python starts.

Breaking changes
~~~~~~~~~~~~~~~~

* **Moving from the XLA-based torch-neuronx**: The native backend uses the
  ``neuron`` device instead of ``torch_xla`` and ``xm.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.compile`` requires ``dynamic=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``, 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.
* **TorchAO and MXFP8**: This release does not include TorchAO integration or
  composite MXFP8 data type support.

Getting started
~~~~~~~~~~~~~~~

.. code-block:: python

   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)``.
