Blog

ExecuTorch Integrated with Zephyr RTOS

By October 9, 2026No Comments
ExecuTorch Integrated with Zephyr RTOS: blog card with Zephyr console output showing MobileNetV2 inference in 28 ms
ExecuTorch Integrated with Zephyr RTOS: blog card with Zephyr console output showing MobileNetV2 inference in 28 ms

ExecuTorch is now a Zephyr module. You add it to your manifest, configure it in prj.conf, and build it with west like anything else.

ExecuTorch is PyTorch’s open source export and runtime stack for running AI locally on edge devices such as phones, wearables, laptops, browsers, embedded systems, and microcontrollers. It now ships as an official Zephyr external module. As a result, developers can easily deploy a PyTorch model on tiny devices with just a config change in their firmware build, like adding any other Zephyr module.

In this post we look at how the integration works, then build and run a quantized MobileNetV2 on real hardware. The example board is an Alif Ensemble E8 DevKit, where the whole convolutional graph runs on the Arm Ethos-U55 NPU and we measure where the time actually goes.

Serial console showing Zephyr booting, the ExecuTorch MobileNetV2 model loading, inference completing in 28 ms and the top-1 prediction matching the host reference

How the integration works

A Zephyr module is an external repository that west pulls into the build, bringing its own Kconfig and CMake. Zephyr already uses this for vendor HALs, filesystems, Bluetooth and the like. ExecuTorch now works the same way, and once it is pulled into your workspace you configure it like any other first-party Zephyr subsystem.

Adding ExecuTorch to a Zephyr workspace

Create a workspace and install the Zephyr SDK with Zephyr’s Getting Started Guide, then add ExecuTorch as described on the ExecuTorch module page. In practice, that means adding the project to your west.yml and running west update:

●●●west.yml
manifest:
  projects:
    - name: executorch
      url: https://github.com/pytorch/executorch
      revision: main  # or a release tag, see the note below
      path: modules/lib/executorch
      submodules: true
Screenshot of the ExecuTorch page in the Zephyr external modules documentation

Figure 1: The official ExecuTorch Zephyr module documentation

Taking one Zephyr-supported board all the way: MobileNetV2 on the Alif Ensemble E8

To test the workflow on hardware, we used the Alif Ensemble E8 DevKit. Its high-performance Arm Cortex-M55 core is paired with an Arm Ethos-U55 NPU configured for 256 multiply-accumulate operations per cycle. The application uses the upstream Zephyr board target and the ExecuTorch sample in the repository without requiring a fork of Zephyr.

Prerequisites

You install ExecuTorch twice: once on your laptop to export the model, once as a Zephyr module to build firmware. The laptop side is pip install executorch==1.5.1 and ethos-u-vela==5.1.0; the device side comes from the west manifest above. The export step is covered in the AOT documentation.

The full set for this walkthrough:

  • A Linux or macOS host with Python 3.12 or newer.
  • west, cmake<4.0.0, pyelftools, ninja and jsonschema.
  • A Zephyr 4.4.0 workspace and Zephyr SDK 1.0.1 with the arm-zephyr-eabi toolchain. Zephyr 4.4 requires SDK 1.0.1; earlier SDKs will not work.
  • Python packages executorch==1.5.1, ethos-u-vela==5.1.0, tosa-tools==2026.5.0, and torchvision for the pretrained weights.
  • An Alif Ensemble E8 DevKit.
  • A J-Link for west flash, or Alif SE Tools to write MRAM directly.
Alif Ensemble E8 DevKit board running MobileNetV2 on its Arm Ethos-U55 NPU

Figure 2: The Alif Ensemble E8 DevKit running MobileNetV2 on its Arm Ethos-U55 NPU

Measurement Result
Model MobileNetV2, int8 quantized, 224×224×3 input
execute() 27.7 ms (n=20, min 27.68 / max 27.71)
Input preprocessing 33.3 ms (uint8 to float32, 150,528 elements)
Output retrieval ~1 µs
Full pipeline 61.0 ms
Graph partitioning Single Ethos-U partition; the int8 to float boundary runs on the CPU
Model size 3,364,928 B .pte, in MRAM
Firmware + model 3,811,280 B of 5,600 KB flash (66.5%)
RAM 3,257,044 B of 8 MB (38.8%)

Table 1: Measured on ExecuTorch v1.5.1, Zephyr 4.4.0, Zephyr SDK 1.0.1

The export runs on your laptop against the pip-installed ExecuTorch, not the module west pulled into the workspace, so you can run it from any directory. The Arm ahead-of-time compiler quantizes MobileNetV2, lowers supported graph regions for Ethos-U, runs the Arm Vela compiler, and packages the result as a .pte program.

●●●Host: export and compile the model
python -m executorch.backends.arm.scripts.aot_arm_compiler \
    --model_name=mv2 \
    --quantize \
    --delegate \
    --target=ethos-u55-256 \
    --output=mv2_ethosu.pte

The Zephyr side uses that file as a build input:

●●●Zephyr: build and flash
west build -b ensemble_e8_dk/ae822fa0e5597ls0/rtss_hp \
    modules/lib/executorch/zephyr/samples/mv2-ethosu \
    -- -DET_PTE_FILE_PATH=mv2_ethosu.pte
west flash

west flash needs a J-Link. Without one, use Alif’s SE Tools to write MRAM directly.

Watch the flash address if you go that route. The ATOC entry in zephyr.json has to match the address the image is linked at, and the board config sets CONFIG_FLASH_LOAD_OFFSET=0x8000, so mramAddress must be 0x80008000. Get it wrong and packaging still succeeds; the board just does not boot, which looks like a flashing problem rather than a memory-layout one.

Serial console output on the Alif Ensemble E8: model loads from MRAM, inference completes in 28 ms, top-1 prediction is class 258 Samoyed

Figure 3: Serial console output on the Alif Ensemble E8: the model loads from MRAM, inference completes in 28 ms, and the top-1 prediction is class 258, Samoyed.

What actually runs where

Diagram of the pipeline: ExecuTorch AOT export and Vela on the host, west build and flash for Zephyr, and inference on the Alif Ensemble E8 with the conv stack on the Ethos-U55 NPU and quantize/dequantize on the Cortex-M55

Figure 4: Export and build happen on the host; only the last stage runs on the board.

This model uses two Arm backends. The MobileNetV2 conv stack lowers into a single Ethos-U partition and runs on the NPU. The int8↔float boundary, one quantize in and one dequantize out, runs on the Arm Cortex-M55 through ExecuTorch’s Cortex-M backend, using CMSIS-NN kernels.

The Arm Ethos-U55 is an integer-only NPU and cannot perform the float conversion, so the partitioner assigns those two operators to the CPU backend. A single delegated partition with CMSIS-NN boundary operators is the expected result for this hardware.

Preprocessing costs more than inference

Inference takes 27.7 ms. Preparing the input takes 33.3 ms, longer than the inference itself.

The model expects float32 and the image arrives as uint8, so 150,528 values are converted in a scalar loop on the Arm Cortex-M55 before the NPU starts. That is roughly 88 cycles per element at 400 MHz, well above what a subtract and a divide require. The loop reads from MRAM and writes 602 KB of float32, so it is memory-bound rather than compute-bound.

On this pipeline the accelerator is not the bottleneck. Feeding it is. That is worth accounting for when sizing an NPU for a camera application.

Note: This conversion can be removed. ExecuTorch’s QuantizeInputs pass changes the model to take int8 input directly, so the application hands over int8 data and the float conversion goes away.

Predictions, and bringing your own image

We baked three photographs into the firmware, classified them on the device, and compared them against float32 torchvision MobileNetV2 on the same images. Quantization was calibrated on 250 real ImageNet photos. For example, here is what the dog input looks like:

White fluffy dog sitting on grass, used as test input and classified as 258 Samoyed

Figure 5: dog.jpg, classified as 258 Samoyed on both the device and the host

Image Device (INT8 + NPU) Host (float32) Verification
dog 258 Samoyed 258 Samoyed Exact match
banana 954 banana 954 banana Exact match
modem 662 modem 662 modem Exact match

All three match. One thing to watch when doing this yourself: the host reference and the exported model must use the same checkpoint and preprocessing, or you will chase a mismatch that is not there.

To try your own image, regenerate the input header. The test image is compiled into the firmware, so this is a rebuild rather than a runtime change:

●●●Host: regenerate the input header
python gen_input.py your_photo.jpg

The script resizes and centre-crops to 224×224 and records the float32 PyTorch prediction, so the device output has a reference to compare against. Rebuild and reflash after regenerating.

ImageNet has no “person” class, so portraits return an unrelated label with low confidence. Photographs of animals, food, vehicles and objects work well.

Note: These examples need ExecuTorch 1.6.0 or later. If 1.6.0 isn’t released yet when you read this, use revision: main in the manifest. Earlier releases run end to end, but the predictions won’t match the table above.

Getting started

The ExecuTorch Zephyr samples ship board configurations for the Alif Ensemble E8, the Corstone-320 FVP, and the Arduino UNO Q. If you do not have hardware, the Corstone-320 FVP runs the same build, though simulation is far slower than the board. Other Cortex-M boards need their own configuration and enough memory for the model.

Your feedback is welcome. For runtime bugs and contributions, use pytorch/executorch on GitHub or the #microcontrollers channel in the ExecuTorch Discord. If you have an Ethos-U board and try this, we especially want to hear about it. The validated board list only grows one report at a time.