Follow the workflow from model export to application testing

Use the same workflow for both the GPT-2 and DistilBERT models:

  1. Prepare a PyTorch model for export.
  2. Lower the exported model to two ExecuTorch artifacts: portable and XNNPACK.
  3. Inspect the lowered graph to see what XNNPACK delegated.
  4. Copy the artifacts to the Raspberry Pi.
  5. Benchmark PyTorch eager, portable ExecuTorch, and ExecuTorch with XNNPACK.
  6. Run the delegated artifact inside a small application demo.
  7. Compare the trade-offs.

As you work, pay attention to the engineering trade-offs: artifact size, target latency, delegated regions, fallback operators, application responsiveness, and production validation still needed.

Script layout

The scripts are split so the main PyTorch and ExecuTorch flow is easy to find:

    

        
        
aot                        prepare/export/lower models on the development machine
pi/                        compare PyTorch and ExecuTorch on the Raspberry Pi
pi/core                    load `.pte` artifacts and turn model outputs into app behavior
_support                   shared setup, plotting, result writing, and HTML rendering

    

The AOT scripts show the ExecuTorch export and lowering workflow. The pi/core files show how a .pte model is used inside an application. The _support files keep the lab readable by moving repeated utilities out of the main path.

If you are reading code while you work through the module, start with the files in aot, pi/benchmark_model.py, and pi/core. The serve_* scripts are small wrappers that launch the browser demos.

Development and target environments

EnvironmentResponsibilityMain outputs
Development machinePrepare, export, lower, inspect graphs.pt2, .pte, metadata, Model Explorer notes
Raspberry PiBenchmark runtime paths and run demosJSON/CSV results, plots, app behavior observations
Previous page Complete and continue