customization-and-development
Extend ModelScope with custom pipelines, registered components, safe scaffolding, contributor workflow, test levels, and trust-boundary guidance.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- customization-and-development
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Extend ModelScope with custom pipelines, registered components, safe scaffolding, contributor workflow, test levels, and trust-boundary guidance.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/contributor-guidance.md6.6 KB
- 参考文档references/extension-workflows.md9.7 KB
- 参考文档references/troubleshooting.md7.8 KB
- 脚本scripts/pipeline_template_plan.py4.0 KB
03 SKILL.md 正文
Customization and Development
Use this sub-skill when the user wants to extend ModelScope itself or create a custom ModelScope-facing pipeline/model/preprocessor wrapper. Keep the workflow safe by default: plan scaffolding before running it, avoid downloads and training during design checks, and treat remote code/plugin execution as an explicit trust decision.
Route first
- Existing pipeline inference,
pipeline(),Model.from_pretrained(), devices, batching, and output keys: use../pipelines-and-models/SKILL.md. - Training or evaluating an existing model/trainer configuration: use
../training-and-evaluation/SKILL.md. - Generic repository maintenance unrelated to ModelScope extension points: do not use this sub-skill unless the user is editing a ModelScope checkout.
Read the right reference
- Custom pipeline/model/preprocessor design, CLI template arguments,
configuration.jsonshape, registration patterns, and trust gates:references/extension-workflows.md. - Contributor workflow, test levels, focused test selection, linter/pre-commit,
git-lfs/submodule data notes, and repository-development guardrails:
references/contributor-guidance.md. - Error diagnosis for template generation, registry misses, config trust gates,
plugin loading, focused tests, and optional backend gaps:
references/troubleshooting.md.
Safe planner
Before running ModelScope's scaffold command, create a dry-run command plan:
python scripts/pipeline_template_plan.py \
--task_name my-task \
--model_name MyCustomModel \
--preprocessor_name MyCustomPreprocessor \
--pipeline_name MyCustomPipeline \
--filename ms_wrapper.py \
--save_file_path ./custom_pipeline \
--configuration_path ./custom_pipeline
The bundled planner prints the modelscope pipeline --action create ... command
only. It validates that --filename ends with .py; it does not create files,
import ModelScope, contact the network, download models, train, or overwrite
anything.
Operating guardrails
- Import-time side effects matter. The stock template contains top-level code
that writes
configuration.jsonwhen the generated Python file is imported or run. Inspect and refactor generated code before using it as a package module. - Registration is import-driven. Decorators such as
@PIPELINES.register_modulerun only after the wrapper/plugin module has been imported, or after a packaged ModelScope module has been indexed and lazily imported. - Match all routing keys:
task/registry group, decoratormodule_name, andconfiguration.jsontypefields must agree. - Prefer JSON/YAML configuration for passive data. Python configs and remote model code execute Python and require an explicit trust decision.
- Treat
plugins,allow_remote, andtrust_remote_code=Trueas code execution boundaries. Do not enable them merely to bypass an error. - CUDA/domain-specific execution is optional and unverified in this production scope. Provide CPU/local smoke checks first and record what remains unverified.
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).