ComfyUI-ModelUtils
A collection of ComfyUI custom nodes for inspecting, modifying, merging, and creating model files. Supports Models, TextEncoders, LoRAs, Checkpoints, and Embeddings.
Features
- MetaKeys – Inspect and display metadata and tensor keys from model files
- RenameKeys – Batch rename tensor keys using pattern matching
- PruneKeys – Remove unwanted layers/keys from models
- Mergers – Combine 2 or 3 models with configurable blend modes and ratios
- LoRA Extraction – Extract LoRA adapters from model pairs using various SVD rank selection methods (Fixed, Ratio, Quantile, Knee-detection, Frobenius-norm)
- Diffusion Model Dtype Conversion – Stream models to fp32, fp16, or bf16 while preserving excluded tensor dtypes
Layer filters
Nodes with exclude_patterns or skip_patterns have an appended include_mode toggle
(off by default). Turn it on to process only layers matching that same field,
using the node's existing regex or glob syntax. An empty include filter selects
nothing. Nonmatches follow the node's usual exclusion behavior: preserve the
source/anchor layer for pattern-exclusion mergers, resize, or conversion; omit
it from analysis or extraction. LoRA Merge to Model retains its existing skip
semantics: nonmatching base tensors are omitted from the saved model, while
guarded low-bit base tensors are always preserved. Its filter uses regex only.
discard_patterns, where available, still takes precedence.
Example Workflows
Per-layer parameters
Connect Layer Parameter Configuration to layer_parameters on standard
two/three-input mergers, extraction nodes, or LoRA resize nodes. For example,
fixed extraction accepts (blocks\.4[589]\.attn\.qkv_proj) a:64 b:32 c:0.99 d:0.
Short aliases and full names, with whitespace or comma separators, are supported.
The configurator's documentation output lists every method's bindings and bounds.
Only explicitly assigned values override the receiving node; other settings and existing filters still apply. Overlapping rules and rules matching no target layer fail before streaming or writing. LoRA patterns target the existing normalized logical layer names, not individual factor/alpha suffixes.
Acknowledgements
The LoRA extraction functionality was inspired by and references the excellent work from:
- kohya-ss/sd-scripts – Training scripts for Stable Diffusion
- KohakuBlueleaf/LyCORIS – Advanced LoRA techniques
- bmaltais/kohya_ss – Windows-friendly GUI for sd-scripts
License
See LICENSE for details.



