conversion
Plan and safely inspect cross-framework model conversions without loading models, downloading artifacts, or running conversion code.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- conversion
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Plan and safely inspect cross-framework model conversions without loading models, downloading artifacts, or running conversion code.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/direction-matrix.md8.4 KB
- 参考文档references/troubleshooting.md10.8 KB
- 脚本scripts/inspect_conversion_args.py13.6 KB
03 SKILL.md 正文
Conversion planning
Use this sub-skill when a task needs a framework direction, checkpoint contract,
conversion flag review, or a no-side-effect argument check for this repository's
convert_models.py. The source code in this snapshot dispatches only the edges
listed in the direction matrix. Framework
labels are lower-case and exact: gluon, mxnet, pytorch, chainer,
keras, tensorflow (legacy TF1), tf2 (TF2/Keras), and tfl (TFLite
destination only).
This is a planning and validation route. It does not load a model, install a
backend, download weights, or execute conversion code. Route model construction
and checkpoint loading to the model-inference sub-skill, and route backend
installation or compatibility diagnosis to the framework-compatibility
sub-skill. The conversion script imports cvutil and other backends before it
can do useful work, so do not use it as a dry-run parser.
Safe route
-
Read the direction matrix. Treat an absent edge as unsupported by this CLI; do not reverse the flags or compose two conversions implicitly.
-
From this sub-skill directory, inspect the CLI contract without repository imports:
python3 scripts/inspect_conversion_args.py --listThe bundled inspector is standard-library only. It reports the exact dispatch function for each edge, required identity/checkpoint flags, and the inspector-only policies.
-
Validate a concrete plan before running anything. Supply local source and destination paths when available; this checks required arguments, direction, positive class/channel counts, model type, path collision, and policy gates:
python3 scripts/inspect_conversion_args.py \ --src-fwk gluon --dst-fwk tf2 \ --src-model resnet18 --dst-model resnet18 \ --src-params ./resnet18.params --dst-params ./resnet18.tf2.h5Add
--check-filesonly when a filesystem-presence check is wanted. It does not open a checkpoint.--cpu-only,--entrypoint, and--output-dirare inspector policy controls, not flags accepted byconvert_models.py. -
Only after a valid plan, use the exact flags in the matrix. Preserve model identity, class count, input channel count, and checkpoint provenance. The conversion functions assert parameter counts, names, and shapes (with documented special cases); the inspector cannot prove those conditions.
-
Validate the converted model through the model-inference route. Do not use
prep_model.pyas an argument check: it requires a local Gluon--resumefile and siblingtrain.log, evaluates four publication targets, and writes a_resultdirectory plus metadata.
Hard gates
tensorflowis the legacy TensorFlow 1.x graph/session path.tf2is the TensorFlow 2.x/Keras path. Never exchange these labels.tflis only the destination of the TF2-to-TensorFlow-Lite branch.- The CLI parser itself does not restrict
--model-type, but destination TF2 code uses exactlyimagefor its image branch and treats every other string as the audio branch. The inspector accepts only the documentedimageoraudiovalues to prevent accidental selection of that fallback. --load-ignore-extraand--remove-moduleare parsed globally.--load-ignore-extrais meaningful for Gluon and PyTorch sources: Gluon passes it toload_parameters(ignore_extra=...), while PyTorch filters extra stored keys.--remove-moduleis meaningful only for a PyTorch source; its branch is used only whenload-ignore-extrais false and handles a DataParallelmodule.wrapper. Neither flag repairs shape or architecture mismatches.- A CPU-only
gluon -> pytorchplan is blocked/unverified by policy. The focused Gluon/PyTorch tests explicitly usemx.gpu(0)and.cuda(); the tests do not prove CPU behavior. The main CLI initializesuse_cuda=False, but that implementation detail is not CPU verification. - The
convert_models.pytf2 -> tflbranch calls TF2prepare_modelwithuse_pretrained=Trueand an empty weight path; it does not consume a local--src-paramsfile, and its--dst-modelis not used for model construction. For no-network local work, use a separately prepared local-input TF2-to-TFLite wrapper with its--inputweight path. That wrapper should write<output-dir>/<model>.tfliteonly when the directory already exists, then allocate a TFLite interpreter and compare a random-input result. This sub-skill's inspector only validates the direction and does not perform export. - The local TF2-to-TFLite example declares
--input-shapeas oneintwith a tuple default. Its default is(1, 640, 480, 3), but a custom multi-value shape is not supported by this snapshot's parser: one custom integer later fails during slicing and four shell integers are rejected byargparse. Treat custom shape requests as blocked/unverified unless separately wrapped and reviewed. - Do not run native conversion tests, long training, weight or dataset downloads, or backend installation as part of this planning route.
For exact input/output contracts and failure recovery, use troubleshooting.
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).