Export

Export a PyTorch model to .pte format for ExecuTorch. Use when converting models, lowering to edge, or generating .pte files.

software-mansion-labs 0736892 2 files · 28.0 KB Updated

File contents

Export

Basic pattern

from executorch.exir import to_edge_transform_and_lower
from torch.export import export

exported = export(model.eval(), example_inputs)
edge = to_edge_transform_and_lower(exported)
with open("model.pte", "wb") as f:
    f.write(edge.to_executorch().buffer)

Model-specific scripts

Model Script
Llama examples/models/llama/export_llama.py
Whisper examples/models/whisper/
Parakeet examples/models/parakeet/export_parakeet_tdt.py

Debugging

  • Draft export: export(model, inputs, strict=False)
  • tlparse: TORCH_LOGS="+dynamo,+export" python script.py 2>&1 | tlparse

Guides

  • torch.export basics — torch.export.export(), dynamic shapes, strict mode, debugging

software-mansion-labs/executorch/tree/main/.claude/skills/export commit 073689247e

Frequently asked questions

npx skillmds@latest add software-mansion-labs/export