.. meta::
   :description: Which PyTorch APIs and operators run on TorchNeuron. How the torch-neuronx compatibility table classifies each API, support counts by namespace, how eager mode and torch.compile handle an unsupported operator, and how to find CPU fallbacks in your own model.
   :keywords: TorchNeuron, torch-neuronx, supported operators, operator coverage, ATen, CPU fallback, compatibility table, torch.compile, AWS Neuron, Trainium
   :date-modified: 2026-11-06

.. _torchneuron-supported-operators:

Supported PyTorch APIs and operators
====================================

This topic explains which PyTorch APIs run on TorchNeuron, how the
``torch-neuronx`` compatibility table classifies them, and how to find out
which operators in your own model run on CPU instead of on the device. The
per-API detail lives in the
`torch-neuronx operator compatibility table <https://github.com/aws-neuron/torch-neuronx/blob/main/docs/torch_api_compatibility.md>`__,
which is regenerated for each ``torch-neuronx`` release.

Applies to
----------

- ``torch-neuronx`` (TorchNeuron) on Trn2 and Trn3 Trainium instances.
- Eager mode and ``torch.compile(backend="neuron")``.

How support is classified
-------------------------

The compatibility table lists the public PyTorch API surface, namespace by
namespace (``torch``, ``torch.Tensor``, ``torch.nn``, ``torch.distributed``,
and so on), and marks each entry with one of three values:

.. list-table::
   :header-rows: 1
   :widths: 20 80

   * - Value
     - Meaning
   * - ``Y``
     - Supported on Neuron. The ``limitations`` column says how: **Native** entries
       run on the Neuron device; **Host-only** entries run in Python on the host
       and do no tensor computation (configuration, metadata, hooks), and work
       with Neuron tensors; **Needs a process group** entries require
       ``torch.distributed.init_process_group`` first.
   * - ``CPU_FALLBACK``
     - Works, but the named ATen operator runs on the CPU and the result is copied
       back to the Neuron device. The model runs; the operation is slower. The
       ``limitations`` column names the operator that falls back and, where
       coverage differs by data type, which dtypes are affected.
   * - ``N``
     - Not supported on Neuron. Quantized operator variants, non-Neuron backends
       under ``torch.backends``, removed APIs, and sparse tensor layouts make up
       most of this group.

Support by namespace
--------------------

Counts below are taken from the compatibility table as published with
``torch-neuronx`` 2.34.0. Later releases change the numbers; the table on
GitHub is the source of record.

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

   * - Section
     - APIs listed
     - ``Y``
     - ``CPU_FALLBACK``
     - ``N``
   * - ``torch APIs``
     - 472
     - 362
     - 94
     - 16
   * - ``torch.nn``
     - 359
     - 312
     - 39
     - 8
   * - ``torch.nn.functional``
     - 112
     - 75
     - 37
     - 0
   * - ``torch.nn.attention.varlen``
     - 2
     - 2
     - 0
     - 0
   * - ``torch.Tensor``
     - 530
     - 393
     - 110
     - 27
   * - Tensor Attributes
     - 4
     - 4
     - 0
     - 0
   * - ``torch.autograd``
     - 62
     - 57
     - 2
     - 3
   * - ``torch.library``
     - 21
     - 18
     - 0
     - 3
   * - ``torch.backends``
     - 43
     - 13
     - 0
     - 30
   * - ``torch.distributed``
     - 90
     - 84
     - 3
     - 3
   * - ``torch.distributed.algorithms.join``
     - 9
     - 9
     - 0
     - 0
   * - ``torch.distributed.fsdp``
     - 45
     - 45
     - 0
     - 0
   * - ``torch.distributed.optim``
     - 14
     - 14
     - 0
     - 0
   * - ``torch.distributed.tensor.parallel``
     - 9
     - 9
     - 0
     - 0
   * - ``torch.distributed.checkpoint``
     - 31
     - 31
     - 0
     - 0
   * - ``torch.distributions``
     - 68
     - 37
     - 31
     - 0
   * - ``torch.futures``
     - 10
     - 10
     - 0
     - 0
   * - ``torch.linalg``
     - 41
     - 8
     - 33
     - 0
   * - ``torch.signal``
     - 11
     - 10
     - 1
     - 0
   * - ``torch.special``
     - 56
     - 13
     - 43
     - 0
   * - ``torch.nn.init``
     - 15
     - 14
     - 1
     - 0
   * - ``torch.optim``
     - 60
     - 58
     - 1
     - 1
   * - DDP Communication Hooks
     - 17
     - 13
     - 2
     - 2
   * - Pipeline Parallelism
     - 21
     - 21
     - 0
     - 0
   * - Quantization
     - 219
     - 139
     - 36
     - 44
   * - ``torch.random``
     - 6
     - 6
     - 0
     - 0
   * - ``torch.Storage``
     - 98
     - 90
     - 0
     - 8
   * - ``torch.utils.data``
     - 19
     - 19
     - 0
     - 0
   * - Type Info
     - 2
     - 2
     - 0
     - 0
   * - Removed APIs
     - 8
     - 0
     - 0
     - 8
   * - **All sections**
     - **2454**
     - **1868**
     - **433**
     - **153**

``CPU_FALLBACK`` entries are spread across the table. The largest groups by
count are ``torch.Tensor`` (110), ``torch APIs`` (94), ``torch.special`` (43),
``torch.nn`` (39), and ``torch.nn.functional`` (37). In proportion to their
size, ``torch.linalg`` (33 of 41), ``torch.special`` (43 of 56), and
``torch.distributions`` (31 of 68) rely on the CPU fallback most. Of the 153
``N`` entries, 44 are in Quantization and 30 are non-Neuron backends under
``torch.backends``.

What happens to an unsupported operator
---------------------------------------

The behavior depends on the execution path:

- **Eager mode.** An ATen operator with no Neuron implementation runs on the
  CPU: inputs are copied to the host, the operator runs there, and the result
  is copied back. The model keeps running. By default, an operator that fails
  on the device also falls back to CPU; set
  ``TORCH_NEURONX_FALLBACK_ONLY_FOR_UNIMPLEMENTED_OPS=1`` to raise execution
  errors instead and fall back only for operators that have no Neuron
  implementation. Some operators also route specific inputs to the CPU on
  purpose, for example ``topk`` on ``int64`` inputs; the ``limitations`` column
  of the compatibility table records these cases, and they run on the CPU
  regardless of the variable. See :ref:`torchneuron-env-vars`.
- **torch.compile.** With ``backend="neuron"``, TorchDynamo breaks the graph at
  an operator the backend cannot lower, in addition to the breaks it inserts for
  constructs it cannot capture. Each captured segment compiles independently,
  and the operator at the break runs through eager dispatch, so it falls back to
  the CPU if it has no Neuron implementation, as in eager mode. With
  ``fullgraph=True``, such an operator raises an error (or a warning, for some
  operators) instead of breaking the graph. If an operator the backend cannot
  lower still reaches compilation inside a captured graph, compilation fails by
  default; set ``TORCH_NEURONX_DISABLE_FALLBACK_EXECUTION=0`` to run the
  original graph eagerly instead. See :ref:`torch-compile-ref`.

Find the fallbacks in your model
--------------------------------

``torch-neuronx`` tracks, per process, which operators ran on the device and
which ran on the CPU. Clear the counters, run one step, and read them back:

.. code-block:: python

   import torch
   import torch_neuronx

   model = MyModel().to("neuron")
   x = torch.randn(8, 1024, device="neuron")

   torch_neuronx.clear_op_tracking()
   model(x)
   torch.neuron.synchronize()

   print("Ran on Neuron:", torch_neuronx.get_executed_ops())
   print("Ran on CPU:   ", torch_neuronx.get_fallback_ops())

``get_fallback_ops()`` returns the ATen operator names that fell back, in the
``aten::`` namespace with the overload name where one exists. Operators that
``torch.compile`` left out of a graph and that then fell back in eager dispatch
are included. A name with a bracketed suffix, such as
``aten::copy_[noncontiguous_scatter_cpu_bounce]`` or
``<op>[epilogue_cpu_roundtrip]``, marks an operator that ran on the
device but moved a non-contiguous input or output through the host; it is not a
whole-operator fallback. Look each bare name up in the compatibility table to
see whether a supported alternative exists.
A ``torch.profiler`` trace captured with Neuron Explorer also shows the host
time these round trips cost; see :ref:`capture-pytorch`.

Related topics
--------------

- `torch-neuronx operator compatibility table <https://github.com/aws-neuron/torch-neuronx/blob/main/docs/torch_api_compatibility.md>`__: per-API status, dtype coverage, and the operator behind each fallback.
- :ref:`about-pytorch-neuron`: how TorchNeuron executes ATen operators.
- :ref:`best-practices-pytorch-neuron`: validating a model in eager mode before ``torch.compile``.
- :ref:`torch-compile-ref`: supported and unsupported surfaces under ``torch.compile``.
