AGENT SKILL

python-simplification

CLI and Python API workflows for simplifying ONNX models.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
python-simplification
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
CLI and Python API workflows for simplifying ONNX models.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Python Simplification

Use this sub-skill when the task is to simplify an ONNX model from a file or an onnx.ModelProto with onnxsim.simplify or the onnxsim CLI.

Covers

  • Static and dynamic input shapes.
  • Correctness checking with check_n, check_rtol, check_atol, and input_fill.
  • Input data injection, optimizer skipping, and constant-folding control.
  • Provider selection, including the CUDA shortcut behavior.
  • External-data output and large tensor warnings.
  • Target opset conversion and local function inlining.
  • Custom operator schema import for validation.
  • Graph diff output after simplification.

Do not use this sub-skill for

  • Custom graph rewriter design, function-rule authoring, or profiling / model metrics depth. Hand those off to the sibling advanced-graph-control sub-skill (../advanced-graph-control/SKILL.md).
  • Build, install, wheel, C API, Rust, WASM, or packaging troubleshooting. Hand those off to the sibling bindings-and-packaging sub-skill (../bindings-and-packaging/SKILL.md).

Read first

Standard flow

  1. Identify whether the caller has an ONNX file or an in-memory ModelProto.
  2. Decide how shapes and validation inputs will be supplied: overwrite_input_shapes, test_input_shapes, input_data, or input_fill.
  3. Choose optimizer and folding controls: skip_optimization, skip_constant_folding, skip_shape_inference, skip_fuse_bn, mutable_initializer, initializers_as_constants, and inline_functions.
  4. Decide backend and opset behavior: providers, --cuda, and target_opset_version.
  5. Run simplification, then validate with check_n and a direct round-trip comparison when needed.
  6. Save external data or print graph diff only when asked.

Helper script

Use scripts/simplify_tiny_model.py for a safe smoke run:

python scripts/simplify_tiny_model.py --help
python scripts/simplify_tiny_model.py --check-n 3 --input-fill arange --print-summary
python scripts/simplify_tiny_model.py --output tiny-simplified.onnx

The script builds a tiny synthetic model, simplifies it with the public API, validates the result, and never downloads models.

Common outcomes

  • File CLI calls return a simplified ONNX path and, when requested, graph diff output.
  • Python API calls return (model_simp, check); treat check=False as a stop signal unless the caller explicitly wants an exploratory run.
  • If providers is omitted, folding stays on CPU.
  • For a fast smoke run, use the bundled helper script with --print-summary.

Routing notes

  • The sub-skill accepts the core simplification surface only. For custom rewriters and profiling / metrics depth, move to the sibling advanced-graph-control sub-skill.
  • For packaging or backend installation problems, move to the sibling bindings-and-packaging sub-skill.
  • If a provider request fails, consult the troubleshooting table before changing the model.

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