extensibility
Extend MMDeploy with rewriters, backend/codebase support, custom ops, partition marks, and focused developer tests.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- extensibility
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Extend MMDeploy with rewriters, backend/codebase support, custom ops, partition marks, and focused developer tests.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/backend-and-codebase-support.md5.4 KB
- 参考文档references/custom-ops-and-partitioning.md5.5 KB
- 参考文档references/rewriters.md4.6 KB
- 参考文档references/testing.md5.0 KB
- 参考文档references/troubleshooting.md11.0 KB
03 SKILL.md 正文
MMDeploy Extensibility Router
Use this sub-skill when the task is to modify or extend MMDeploy internals rather than run routine model conversion. It covers developer work for:
- function, module, and symbolic rewrites used during export;
- new backend managers, backend wrappers, backend configs, and backend API packages;
- new codebase/task-processor support;
- backend custom ops and partition marks;
- focused rewrite/custom-op tests and skip-aware backend checks.
Route by task
| User need | Go to |
|---|---|
| Make a PyTorch/MMCV/OpenMMLab function exportable, replace a module during export, or emit backend-specific ONNX nodes | references/rewriters.md |
| Add a backend, make a backend wrapper discoverable, extend backend/codebase/task enums, or add a codebase task processor | references/backend-and-codebase-support.md |
| Add or debug backend custom ops, write a backend op unit test, mark partition boundaries, or connect marks to extraction | references/custom-ops-and-partitioning.md |
| Write focused tests for rewrites, custom ops, or wrappers; choose pytest targets and interpret backend skips | references/testing.md |
| Diagnose import, checker, backend, config, ABI, symbolic-domain, dynamic-axis, or partition failures | references/troubleshooting.md |
Operating boundaries
- Do not use this sub-skill for ordinary deployment commands, checkpoint conversion, quantization runs, benchmarking, SDK runtime inference, or regression orchestration.
- Do not treat backend installation/build as solved here. This sub-skill can identify the required backend/package/plugin evidence and then defer installation-heavy work to the backend/install owner.
- Treat native tests as evidence and future verification candidates. Do not assume every backend stack or optional OpenMMLab codebase is installed.
- Prefer minimal, deterministic developer tests with tiny tensors and explicit expected outputs before attempting full model conversion.
Standard extension workflow
- Identify the extension point: function rewrite, module rewrite, symbolic rewrite, backend manager/wrapper, codebase task processor, custom op, or partition mark.
- Confirm registration/import flow. Decorated rewrites, backend managers, wrappers, and codebase task processors only exist after their containing modules are imported.
- Add the smallest failing test first. Use direct
RewriterContextorpatch_modeltests for Python behavior, and use backend-aware export tests only when the backend/plugin is available. - Implement the extension with backend-specific registration where behavior diverges by backend. Keep default registrations backend-neutral.
- Assert recovery: functions and symbolics should revert after
RewriterContext; module rewrites should be intentionally permanent becausepatch_modelmutates the model. - If the change depends on a backend package, plugin, or upstream codebase, make skip behavior explicit and stop when the required runtime is unavailable.
Important invariants
RewriterContextactivates function and symbolic rewriters for the selected backend/IR and restores them on exit.patch_modelactivates module rewriters and mutates the model by replacing matching submodules.Backend,Codebase, andTaskenum values must matchbackend_config.typeandcodebase_configvalues.- Backend managers are discovered by importing
mmdeploy.backend.<backend_name>; the backend package__init__must import/register the manager. - Backend wrappers should consume named tensor dictionaries and return output-name keyed dictionaries.
@markpartition nodes must be inside a rewrite path and requirepartition_config.apply_marks=Trueto appear in exported ONNX.
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).