Skill v1.0.0
currentLLM-judged scan90/100version: "1.0.0" name: export-model description: Export a registered PyTorch model to an ExecuTorch .pte artifact for SME2 profiling. Use when Codex needs to convert toy_cnn, EfficientSAM, EdgeTAM image encoder, or another registered model to portable ExecuTorch format with XNNPACK or portable backend, choose dtype or quantization settings, save graph metadata, or prepare artifacts for profiling.
Export Model
Operating Rules
- Run from the repository root with
.venvactivated. - Export to
model_profiling/out_<model>/artifacts/for the Learning Path examples unless the user requests another output root. - Prefer
--backend xnnpackfor SME2 profiling because the runner comparison is intended to show delegated backend behavior. - Do not assume
.etrecordexists. Check for it and use it when present, but do not fail the export solely because it was not produced. - If exporting a custom model, verify it is registered in
model_profiling/models/__init__.pybefore running the exporter.
Required Inputs
- Completed
setup-workspace. - Model name, dtype, backend, and output directory.
- For custom models: an implementation of
EagerModelBasewith stableget_eager_model()andget_example_inputs().
Procedure
- Activate the environment:
``bash source .venv/bin/activate ``
- For the built-in smoke model, export with:
``bash python model_profiling/export/export_model.py \ --model toy_cnn \ --backend xnnpack \ --dtype fp16 \ --outdir model_profiling/out_toy_cnn/artifacts ``
- For a named model, use the same shape:
```bash MODEL_NAME="<model_name>" DTYPE="fp16" OUTDIR="model_profiling/out_${MODEL_NAME}/artifacts"
python model_profiling/export/export_model.py \ --model "${MODEL_NAME}" \ --backend xnnpack \ --dtype "${DTYPE}" \ --outdir "${OUTDIR}" \ --save-graph ```
- For quantized exports, add
--quantizeonly after confirming the ExecuTorch checkout supports the model's quantization path:
``bash python model_profiling/export/export_model.py \ --model "${MODEL_NAME}" \ --backend xnnpack \ --dtype fp32 \ --quantize \ --outdir "${OUTDIR}" ``
- Validate the output:
``bash find "${OUTDIR}" -maxdepth 1 -name '*.pte' -type f -size +0 -print find "${OUTDIR}" -maxdepth 1 -name '*.etrecord' -type f -print PTE_FILE="$(find "${OUTDIR}" -maxdepth 1 -name '*.pte' -type f -size +0 | head -1)" test -n "${PTE_FILE}" ``
Success Criteria
- A non-empty
.pteexists in the selected artifact directory. - Optional
graph.jsonexists when--save-graphwas requested. - Optional
.etrecordis recorded for later analysis if the export flow produced one.
Failure Triage
Unknown model: register the model undermodel_profiling/models/or use an ExecuTorch example model name that exists in the current checkout.ImportErrorfrom model code: install the model dependency into.venvor adjust the model wrapper.- Torch export failure: inspect unsupported ops, dynamic control flow, input signatures, dtype casts, and shape constraints.
- XNNPACK partitioning failure: retry with
--backend portableto isolate export validity from delegation, then return to XNNPACK after fixing unsupported delegated ops. - Quantization failure: remove
--quantizeunless the model appears in the current ExecuTorch quantization options.
Handoff
After export succeeds, use run-profiling with the .pte path and the runner paths for the target platform.