export-and-interoperability
Build ONNX export and validation commands, package/load timm models via Hugging Face Hub or local directories, use Torch Hub compatibility, and safely clean or average checkpoints.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- export-and-interoperability
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Build ONNX export and validation commands, package/load timm models via Hugging Face Hub or local directories, use Torch Hub compatibility, and safely clean or average checkpoints.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/export-checkpoint-workflows.md7.7 KB
- 参考文档references/hub-and-conversion.md5.8 KB
- 参考文档references/troubleshooting.md7.1 KB
- 脚本scripts/timm_checkpoint_tools.py11.0 KB
- 脚本scripts/timm_onnx_command_builder.py6.4 KB
03 SKILL.md 正文
Export and Interoperability
Use this sub-skill when a task asks for timm model export, ONNX Runtime validation, pretrained model interchange through Hugging Face Hub or local directories, Torch Hub compatibility, or checkpoint cleanup/averaging before sharing weights.
Routing Checklist
- Use
references/export-checkpoint-workflows.mdfor ONNX export/validation command options, dynamic input caveats,exportable=True, reparameterization, checkpoint cleaning, checkpoint averaging, hash naming, and safetensors choices. - Use
references/hub-and-conversion.mdforhf-hub:andlocal-dir:model names,push_to_hf_hub, localconfig.jsonplus weight-file expectations, Torch Hub behavior, and conversion-script caveats. - Use
references/troubleshooting.mdfor missing optional dependencies, unsupported ONNX ops, dynamic-shape failures, checkpoint prefix/EMA mismatches, safe loading failures, local-dir packaging mistakes, Hugging Face auth/cache/network issues, and external conversion requirements. - Use
scripts/timm_onnx_command_builder.pyto print dryonnx_export.pyandonnx_validate.pycommands without importing timm or requiring ONNX dependencies. - Use
scripts/timm_checkpoint_tools.pyfor self-contained checkpoint inspection, dry command construction for cleaning/averaging, and bundled averaging; cleaning remains a generated command for a timm script checkout rather than a write action inside this helper.
High-Value Defaults
- Start ONNX work with a small, common model and static shape:
--model resnet18 --batch-size 1 --input-size 3 224 224; add--dynamic-sizeonly when deployment needs variable height/width. - Export through timm's export path, not ad hoc tracing: create models with
exportable=True, use--checkpointfor local weights, and add--reparamfor models that expose reparameterization before deployment. - Treat
--check-forwardas optional verification because it requires ONNX/ONNX Runtime support and may expose numerical or operator-coverage differences rather than command-construction mistakes. - Prefer safetensors for shared cleaned or averaged weights when the dependency is installed; keep
.pthonly for legacy consumers that need PyTorch serialization. - Keep checkpoint tools non-destructive: never overwrite an existing output, inspect candidate keys first, and decide whether EMA weights should be used before cleaning or averaging.
- For hosted or portable timm models, package both
config.jsonand a recognized weight filename; use exacthf-hub:org/model@revisionorlocal-dir:/path/to/model_dirsource prefixes when loading.
Boundary Routing
- Use
../model-library/for ordinarytimm.create_model, model discovery, pretrained config inspection, feature extraction, and generic checkpoint mismatch analysis before export. - Use
../cli-workflows/fortrain.py,validate.py, andinference.pycommands that are not ONNX-specific. - Use
../benchmarking-and-results/when the task is performance measurement rather than export or validation correctness. - Treat framework conversion scripts as reference-only starting points; do not promise turnkey conversion unless the external checkpoint format, framework package, and architecture mapping are available.
Bundled Helpers
python scripts/timm_onnx_command_builder.py export \
--output model.onnx --model resnet18 --input-size 3 224 224 --batch-size 1 --check-forward
python scripts/timm_checkpoint_tools.py inspect \
--checkpoint model_best.pth.tar
The helpers are intentionally conservative. The ONNX builder prints commands only. The checkpoint helper can inspect checkpoints, construct clean/average commands, and run bundled checkpoint averaging with overwrite refusal; checkpoint cleaning is emitted as a command for a trusted timm script checkout.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).