AGENT SKILL

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

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.md for 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.md for hf-hub: and local-dir: model names, push_to_hf_hub, local config.json plus weight-file expectations, Torch Hub behavior, and conversion-script caveats.
  • Use references/troubleshooting.md for 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.py to print dry onnx_export.py and onnx_validate.py commands without importing timm or requiring ONNX dependencies.
  • Use scripts/timm_checkpoint_tools.py for 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-size only when deployment needs variable height/width.
  • Export through timm's export path, not ad hoc tracing: create models with exportable=True, use --checkpoint for local weights, and add --reparam for models that expose reparameterization before deployment.
  • Treat --check-forward as 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 .pth only 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.json and a recognized weight filename; use exact hf-hub:org/model@revision or local-dir:/path/to/model_dir source prefixes when loading.

Boundary Routing

  • Use ../model-library/ for ordinary timm.create_model, model discovery, pretrained config inspection, feature extraction, and generic checkpoint mismatch analysis before export.
  • Use ../cli-workflows/ for train.py, validate.py, and inference.py commands 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

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351