model-utilities
Use sd-scripts model and network utilities safely: LoRA merge/extract/resize/convert, checkpoint or Diffusers conversion, metadata inspection, ControlNet helpers, and image utility helpers.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- model-utilities
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use sd-scripts model and network utilities safely: LoRA merge/extract/resize/convert, checkpoint or Diffusers conversion, metadata inspection, ControlNet helpers, and image utility helpers.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/conversion-and-merge-workflows.md7.5 KB
- 参考文档references/troubleshooting.md6.7 KB
- 参考文档references/utility-catalog.md6.0 KB
- 脚本scripts/inspect_safetensors_metadata.py3.1 KB
03 SKILL.md 正文
Model Utilities
Use this sub-skill when the task is about manipulating, inspecting, converting, or planning model/adapter utility workflows with sd-scripts. These workflows are powerful and often write large checkpoint files, so default to read-only inspection and explicit planning before invoking destructive scripts.
Route First
- Use
../trainingfor training command selection, optimizer/network choices, and resume/save strategy. - Use
../generationfor image generation, prompt sampling, and inference pipeline use. - Use
../data-preparationfor dataset validation, captioning, bucketing, or cache setup unless the user specifically asks for an image utility such as canny edges or face-rotation crops. - Stay here for LoRA/network merge, extract, resize, conversion, metadata inspection, checkpoint/Diffusers conversion, SD3/FLUX component merging, ControlNet helper planning, and small image utility helpers.
Safe Operating Rules
- Identify the source family before planning: SD1/SD2, SDXL, SD3, FLUX, Hunyuan Image, Anima, Diffusers directory,
.ckpt, or.safetensors. - Treat merge, extract, resize, and conversion scripts as checkpoint writers. Confirm output paths, free disk space, precision, device, and backups before running them.
- Never reuse an input model path as an output path. Prefer a new output directory and an atomic-looking filename that records family, operation, precision, and date/version.
- Validate model counts against ratio counts before LoRA or checkpoint merges. For LoRA merge scripts,
--modelsand--ratiosmust align one-to-one. - Prefer CPU for planning and metadata inspection. Use GPU only when the selected utility needs it and the user accepts memory pressure.
- For quick safe inspection, use the bundled script:
python skills/sd-scripts/sub-skills/model-utilities/scripts/inspect_safetensors_metadata.py MODEL.safetensors --include-keys --max-keys 20
Common Workflows
- Metadata inspection: Use the bundled read-only helper for
.safetensorsheaders. It does not load tensor payloads and is safer than conversion utilities. - LoRA merge: Select the family-specific merge workflow for SD1/SD2, SDXL, or FLUX. Check model family, dimensions, alphas, ratio count, and output path first.
- LoRA extraction: Plan SD/SDXL or FLUX extraction separately. Extraction loads two large models and computes SVD; plan device, rank, precision, and memory.
- LoRA resize/check: Plan rank reduction, dynamic resizing, or tensor-stat inspection before replacing a production adapter.
- Format conversion: Confirm source and destination conventions before converting FLUX, Anima, or Hunyuan Image LoRA formats.
- Checkpoint/Diffusers conversion: Plan SD v1/v2 checkpoint/Diffusers conversion or FLUX Diffusers-to-safetensors conversion with explicit input/output format checks.
- Model merging: Treat safetensors checkpoint averaging and SD3 component assembly as large write operations that require backups and free disk checks.
- Control/image helpers: Plan edge-map generation, anime face crop/rotation, VAE-backed latent upscaling, or original ControlNet preprocessing only after confirming dependencies and output paths.
References
- Start with
references/utility-catalog.mdto select the right utility family and route adjacent tasks. - Use
references/conversion-and-merge-workflows.mdfor safety checklists and command-planning templates. - Use
references/troubleshooting.mdfor format mismatch, missing metadata, ratio mismatch, overwrite risk, disk, memory, and family-specific failure modes.
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).