.. meta::
   :description: Frequently asked questions about the Neuron Graph Compiler (neuronx-cc) for Trn2, Trn3, Trn1, and Inf2, including where to compile, precision, supported operators, dynamic shapes, and recompilation.
   :keywords: neuronx-cc, FAQ, Neuron compiler, TorchNeuron, torch.compile, dynamic shapes, auto-cast, NEFF, Trn2, Trn3
   :date-modified: 2026-11-16

.. _neuronx_compiler_faq:

Neuron Compiler FAQ (``neuronx-cc``)
====================================

.. contents:: Table of contents
   :local:
   :depth: 1

Where can I compile to Neuron?
---------------------------------

You can do the one-time compilation from a framework-level model to a NEFF binary on any
EC2 instance, or on premises.

The simplest option is to compile on the Trainium or Inferentia2 instance where the model
runs. To compile on a different host, set ``--target`` to the instance family where the
NEFF runs (for example, ``trn2`` or ``trn3``). Large models need a host with a large amount
of memory. You can also install Neuron in your own environment. For example, you can compile
in your training fleet and use a configuration management application to distribute the NEFF
files to your inference fleet.

.. _neuron-vs-neuronx:

Which Neuron compiler should I use?
-----------------------------------

Use ``neuronx-cc``. It is the only current Neuron compiler, and it supports NeuronCore-v2
through NeuronCore-v4 (Trn2, Trn3, Trn1, Trn1n, and Inf2). ``neuron-cc``, the compiler for
Inf1, is a retired component.

How is the compiler called from PyTorch?
----------------------------------------

:ref:`TorchNeuron <about-pytorch-neuron>` calls ``neuronx-cc`` for you. In eager mode,
TorchNeuron compiles each operation the first time it runs. With
``torch.compile(backend="neuron")``, it compiles the captured graph as one unit. To pass
compiler options, set the ``NEURON_CC_FLAGS`` environment variable. See
:ref:`about-torchneuron-torch-compile` and :ref:`torch-compile-ref`.

My current neural network is based on FP32, how can I use it with Neuron?
-------------------------------------------------------------------------

You can compile and deploy FP32 models with Neuron. By default, ``neuronx-cc`` compiles
matrix multiplication operations in the datatype of the model (``--auto-cast=none``). To cast
them to BF16 for better performance, pass ``--auto-cast=matmult --auto-cast-type=bf16``. For
more information about performance and accuracy tuning, see
:ref:`neuronx-cc-training-mixed-precision`.

The Neuron compiler keeps the application interface: FP32 inputs and outputs. The transfer
of large FP32 tensors can slow your application. To decrease execution time, cast the inputs
and outputs to FP16 or BF16 in the ML framework before compilation.

Which operators does Neuron support?
---------------------------------------

To list the operators, run the ``neuronx-cc list-operators`` command. See
:ref:`neuron-compiler-cli-reference-guide`.

To request support for new operators, open an issue on our `GitHub forum <https://github.com/aws/aws-neuron-sdk/issues/new>`_.

Does the compiler support dynamic shapes and control flow?
----------------------------------------------------------

``neuronx-cc`` compiles graphs with static shapes. It does not support dynamic shapes. For the
error that the compiler reports, see :ref:`error-code-emod025`. To use inputs of different
sizes, pad them to a fixed set of shapes (buckets).

Resolve data-dependent control flow in the framework before compilation. With
``torch.compile``, PyTorch splits the graph at data-dependent control flow (a graph break),
and TorchNeuron runs that code in eager mode.

Will I need to recompile again if I updated runtime/driver version?
----------------------------------------------------------------------

The compiler and runtime keep compatibility for major version releases with each other. The
versioning is defined as major.minor, with compatibility for all versions with the same major
number. If the versions do not match, the runtime logs an error and the load fails. You must
then compile the model again.

TorchNeuron includes the compiler version and ``NEURON_CC_FLAGS`` in its compile cache key, so
a change to either one causes a new compilation.

I have a NEFF binary, how can I tell which compiler version generated it?
-------------------------------------------------------------------------

Record the compiler version when you compile. To see the installed version, run
``pip show neuronx-cc``.

How long does it take to compile?
------------------------------------

The time depends on the model size and complexity. For most models, compilation takes a few
minutes. Large models can take longer.

Why is my model producing different results compared to CPU/GPU?
----------------------------------------------------------------

NeuronCore-v2 through NeuronCore-v4 support multiple casting modes for floating point
numbers. Each mode has a different balance of performance and accuracy. The default casting
mode is a balance between performance and accuracy. On some models, it can cause a loss of
precision.

For the options that change the casting mode, see ``--auto-cast`` and ``--auto-cast-type``
in :ref:`neuron-compiler-cli-reference-guide`.

Is my model type supported?
---------------------------

``neuronx-cc`` has explicit support for select model families with the ``--model-type``
option, and it supports many other model types. To see the supported operators, run the
``list-operators`` subcommand. See the :ref:`neuron-compiler-cli-reference-guide` for
details. Neuron adds support for new operators and models in each release.

For the models that Neuron supports for inference and training, see
:ref:`vLLM Neuron <vllm-neuron-home>` and :ref:`TorchTitan Neuron <torchtitan-neuron-landing>`.

Related information
-------------------

- :ref:`What is the Neuron Graph Compiler (neuronx-cc)? <neuronx-cc-overview>`
- :ref:`Neuron Compiler CLI reference <neuron-compiler-cli-reference-guide>`
- :ref:`Neuron Graph Compiler error codes <ncc-errors-home>`
