.. meta::
   :description: Troubleshooting common errors and symptoms for MXFP8 training with TorchAO Neuron (torchao-neuron) and TorchTitan Neuron on AWS Trainium.
   :keywords: TorchAO, torchao-neuron, MXFP8, TorchTitan, TorchNeuron, AWS Neuron, Trainium, troubleshooting
   :date-modified: 2026-11-06
   :content-type-template: _content-types/reference-troubleshooting.rst

.. _torchao-neuron-troubleshooting:

====================================
Troubleshooting: TorchAO Neuron
====================================

Overview
--------

This topic covers common failure modes when training with the TorchAO Neuron
fused MXFP8 linear, on its own or through TorchTitan Neuron. Use it when an
MXFP8 run fails to start, fails on a kernel option, or behaves differently
from the bf16 baseline. Scope is MXFP8-specific. For TorchTitan run failures
see :doc:`/training/torchtitan/troubleshooting`; for lower-level TorchNeuron
issues see :doc:`/torch/troubleshooting`.

Common symptoms and solutions
-----------------------------

- **Symptom:** ``ValueError: cannot shard <name> of local shape <shape> by
  <degree> and keep every local dim a multiple of 32`` during model setup with
  pre-quantized weights. A related message names the dimension that sharding
  cannot rescue: ``... can be sharded on dim <d>, but dim <other> is <N>, which
  is not a multiple of 32 and is not divided by sharding``.

  **Possible causes:**

  - The pre-quantized path reads each weight twice, once as stored and once
    transposed, so both dimensions of every rank's local shard must be a
    multiple of 32. SimpleFSDP already chooses each weight's shard dimension to
    satisfy this, preferring the dimension tensor parallelism did not split, so
    this error means no dimension can satisfy it at the current parallelism:
    the sharded dimension must be divisible by the FSDP degree times 32, and
    the dimension left unsharded must be a multiple of 32 on its own. See
    :ref:`1D dynamic FSDP <mxfp8-prequant-dynamic-fsdp>`.

  **Solutions:**

  - Lower the FSDP shard degree, for example by raising the tensor-parallel
    degree, so a dimension divides evenly.
  - Run the recipe without ``prequantize_weights``. See
    :doc:`/training/torchtitan/tutorials/tutorial-mxfp8-training`.

- **Symptom:** ``Python lower_func failed for cache_key: ... Kernel validation
  exception: K must be divisible by 32 for unswizzled loading``. The required
  multiple is either 32 or 128, so the message may name either value.

  **Possible causes:**

  - The contraction dimension of a matmul is not a multiple of the alignment
    the NKI kernel requires when it loads an operand *unswizzled*, that is,
    in its original layout rather than pre-arranged into the layout the matmul
    expects. The required multiple is 32 with the ``1x32`` quantization layout
    or a fast DMA transpose, and 128 otherwise. Operands that are already
    swizzled are not subject to the check.

  **Solutions:**

  - Skip quantizing particular linear layers that do not fit the MXFP8 shape constraints. See :doc:`/training/torchtitan/tutorials/tutorial-mxfp8-training` for details on how to filter specific layers from the ``MXFP8LinearConverter`` in TorchTitan Neuron.

- **Symptom:** The training step time does not improve with MXFP8 quantization.

  **Possible causes:**

  - **Untuned kernels.** The default MXFP8 kernel configurations may not suit
    your shapes.

  - **The step is not matmul-bound.** MXFP8 accelerates only the linear and
    blockwise MoE matmuls. Core attention, the loss function, LayerNorm, RoPE
    and exposed collectives do not get faster, so a step dominated by those
    shows little gain. A low BF16 MFU is the signal. MXFP8 ``grouped_mm`` is
    not yet supported on TorchAO Neuron.

    If matmuls are a fraction ``p`` of the BF16 step time and MXFP8 speeds them
    up by ``s``, the step speeds up by ``1 / ((1 - p) + p / s)``.

  **Solutions:**

  - Tune the MXFP8 NKI kernels using
    :doc:`/training/torchtitan/tutorials/tutorial-mxfp8-autotuning`.
  - Profile the step with
    :doc:`/tools/neuron-explorer/how-to-profile-pytorch` to find what dominates
    it, and address those bottlenecks first. See
    :doc:`/training/torchtitan/troubleshooting`.

- **Symptom:** ``ValueError: disable_dma_transpose=True is 1x32 only; wrapX
  always uses the fast DMA transpose.``

  **Possible causes:**

  - ``NkiKernelOptions(disable_dma_transpose=True)`` combined with
    ``quant_scheme=QuantScheme.WRAPX``.

  **Solutions:**

  - Use ``quant_scheme=QuantScheme.ONE_X32`` with ``disable_dma_transpose``,
    or drop ``disable_dma_transpose`` for ``wrapX``.

- **Symptom:** ``ValueError: logical_layout=True is 1x32 only.``

  **Possible causes:**

  - ``NkiKernelOptions(logical_layout=True)`` combined with
    ``quant_scheme=QuantScheme.WRAPX``.

  **Solutions:**

  - ``logical_layout`` applies to the pre-quantized weight path with the
    ``1x32`` scheme only. Switch the scheme or drop the option.


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

- :doc:`/training/torchao-neuron/about-torchao-neuron`
- :doc:`/training/torchtitan/troubleshooting`
- :doc:`/torch/troubleshooting`
