physicalai-train-exporting-and-validating
Installation
SKILL.md
Exporting and Validating Studio Policies
Export lives in library/src/physicalai/export/: backends.py (the ExportBackend enum — onnx, openvino, torch, executorch — plus per-backend parameter classes) and mixin_policy.py (ExportablePolicyMixin, which gives policies export(output_dir, backend=...)). The Python API is primary library behavior; the CLI entry library/src/physicalai/cli/export.py must preserve the same artifact contract. Studio owns export; Runtime owns loading.
Workflow
- Identify the inputs: source policy class (e.g.
physicalai.policies.ACT),.ckptpath, target backend, and the Runtime loader behavior expected for that backend.- Done when: all four are pinned before touching code.
- Pick the route and keep both consistent — they must produce the same artifact:
- Python:
policy.export(output_dir, backend=ExportBackend.ONNX). - CLI:
physicalai export --policy physicalai.policies.ACT --ckpt_path model.ckpt --backend onnx --output_dir ./export.
- Python:
- Read backend constraints before editing generic code. See the backend reference for the target (
references/<backend>.md). Do not generalize a fix across backends without checking each. - Export, then validate numerical parity against the Torch policy path on representative inputs. Parity proves correctness.
- Done when: max abs/rel diff on sample inputs is within the family's tolerance, or the divergence is understood and documented.
- Validate artifact structure and metadata against
references/export-contract.md.- Done when: the expected model file and metadata files exist, and input/output/feature names match Runtime preprocessing.
- Confirm the Runtime path. For deployment-bound artifacts, verify Runtime can auto-detect (by extension) or explicitly load the backend via
InferenceModel(...).