model-and-weight-utilities
Inspect ControlNet model/config APIs and safely reason about checkpoint initialization, transfer, and state-dict mappings.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- model-and-weight-utilities
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Inspect ControlNet model/config APIs and safely reason about checkpoint initialization, transfer, and state-dict mappings.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md6.6 KB
- 参考文档references/configuration-and-architecture.md6.3 KB
- 参考文档references/troubleshooting.md5.8 KB
- 参考文档references/weight-utilities.md6.6 KB
- 脚本scripts/inspect_weight_mapping.py15.1 KB
03 SKILL.md 正文
Model and Weight Utilities
Use this sub-skill when a user needs to understand ControlNet architecture/configs, inspect model-loading APIs, dry-run checkpoint key mappings, initialize ControlNet weights from Stable Diffusion, transfer an existing ControlNet to a compatible community checkpoint, or debug checkpoint-loading failures.
For generated-image app usage, route to gradio-inference-apps. For fine-tuning loops, Fill50K data, sd_locked, and dataset schema, route to training-and-datasets. For detector outputs and control-map creation, route to annotators-and-preprocessing.
Quick Routing
- Read API reference when inspecting
create_model,load_state_dict,get_state_dict,ControlNet,ControlledUnetModel,ControlLDM, orDDIMSamplersignatures and method responsibilities. - Read configuration and architecture when comparing
cldm_v15.yamlwithcldm_v21.yaml, explainingjpg/txt/hint, zero convolutions, locked/trainable branches, low-VRAM behavior, or attention options. - Read weight utilities when adapting
tool_add_control.py,tool_add_control_sd21.py, or the ControlNet transfer-offset algorithm without destructive hard-coded outputs. - Read troubleshooting when checkpoint paths, config/checkpoint pairing, safetensors loading, CUDA/xformers, state-dict prefixes, or overwrite guards fail.
- Run
scripts/inspect_weight_mapping.pywhen a user asks for a non-destructive report of ControlNet key mapping or newly initialized keys before writing a checkpoint.
Safe Default Workflow
- Identify the base family first: SD1.x uses
cldm_v15/SD1.5 initialization; SD2.1 usescldm_v21/SD2.1 initialization. - Dry-run key mapping before saving anything: use the bundled inspector with a real checkpoint or
--self-testfor the mapping logic. - Treat model creation and checkpoint loading separately: configs define target classes and tensor shapes; checkpoints supply state-dict keys and tensor values.
- Preserve output safety: the original conversion scripts refuse missing input files, refuse existing output files, and require the output directory to exist; keep those guards in any adapted writer.
- Avoid network and generation side effects in diagnostics: the bundled inspector performs no downloads, model generation, training, or checkpoint writes.
Common User Requests
- "Create a ControlNet init checkpoint from SD1.5": read weight utilities, verify the input is an SD1.x checkpoint, dry-run with the inspector, then adapt the documented add-control writer only if an output save is explicitly requested.
- "Explain
cldm_v15vscldm_v21": read configuration and architecture, especially context dimension, text encoder, attention head settings, anduse_linear_in_transformer. - "Dry-run state-dict key mapping": run
scripts/inspect_weight_mapping.pywith--config-family sd15orsd21and optionally--checkpoint. - "Debug safetensors loading": read API reference for
load_state_dictbehavior and troubleshooting for dependency/device issues. - "Explain zero convolution learning": read configuration and architecture for the distilled FAQ explanation and how zero outputs become trainable after gradient updates.
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).