Nodes/Model Utility Toolkit/Layer Parameter Configuration
ComfyUI Node

Layer Parameter Configuration

Layer Parameter Configuration

By silveroxides·Created 2 years ago·Updated 3 days ago· 17
Layer Parameter Configuration
    • layer_parameters
    • documentation
    ◄rules►
    ◄glob_patternsfalse►

    Most merge nodes give you exactly one number for the entire model. That is fine until you want model B's attention layers and model A's everything else, or you want one block of an extracted LoRA to keep rank 64 while the rest drops to 8. Doing that used to mean a Python script or a merge tool outside ComfyUI. This node is the way to say it in plain text and hand the answer to a merger.

    It does no merging itself. It is a config node: you write rules, it parses and validates them, and it passes the result down one wire as a MODELUTILS_LAYER_PARAMETERS object. Whatever you connect it to does the actual work, per layer.

    What you'd actually reach for it for

    Merging is how a huge fraction of the checkpoints on CivitAI exist - whole ecosystems are chains of merges and fine-tunes, and per-layer control is what separates "another blend at 0.65" from something you designed. The same applies to LoRA extraction, where the interesting knob is which blocks get which rank: a face LoRA lives in blocks 4–8 of the attention stack, and spending rank budget on the other 20 blocks just adds noise to the file.

    The pack's own scope is 39 receiving nodes: 10 standard two- and three-input mergers (checkpoint, diffusion model, text encoder, LoRA, embedding), 25 extraction variants (LoRA, DoRA, learned DoRA, text-encoder LoRA/DoRA × Fixed, Ratio, Quantile, Knee, Frobenius), and 4 LoRA resizers (Fixed, Ratio, Frobenius, Cumulative). Those nodes gained an optional layer_parameters input; this node is what you feed it.

    How it works

    Each line of the rules field is one pattern plus assignments:

    (blocks\.4[589]\.attn\.qkv_proj) a:64 b:32 c:0.99 d:0
    

    The pattern goes in parentheses, then one or more name:value pairs separated by whitespace or commas, with whitespace allowed around the colons. Blank lines and lines starting with # are ignored; inline comments are not supported. Values may be negative or scientific, and must be finite.

    Matching is regex substring search by default - attn matches anywhere in the key - so \. matters if you mean a literal dot. Flip glob_patterns on and the same text is treated as a case-sensitive glob substring pattern instead. That setting is independent of the receiving node's own filters, which stay whatever they were.

    The short aliases (a, b, c…) are positional: they map to that receiver method's binding order, and different merge modes and extraction methods have different bindings. Full parameter names work too, and the documentation output is a generated table of every receiver's bindings and numeric bounds. Read it once before you guess - a wrong letter is a hard error, not a silent miss.

    Only the values you assign override the receiving node; everything else, including its own exclusions and include filters, still applies. Name matching happens before exclusions, and validation happens before any tensor is streamed, so bad rules fail in a second instead of forty minutes into a merge.

    Inputs and outputs

    Two inputs, and that's it:

    • rules - the multiline rule text above.
    • glob_patterns - off = regex substring, on = case-sensitive glob substring.

    Two outputs:

    • layer_parameters - wire this to the optional layer_parameters socket on a merger, extraction, or LoRA resize node. It is useless anywhere else.
    • documentation - a big markdown string with the syntax, per-receiver bindings and bounds, and examples. Connect it to a Show Text or Save Text node; you will want it the first time.

    Install

    ComfyUI Manager → search Model Utility Toolkit (registry id comfyui-modelutils, publisher silveroxides). Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-ModelUtils
    

    then restart ComfyUI and install its requirements with ComfyUI's own Python:

    python -m pip install -r ComfyUI/custom_nodes/ComfyUI-ModelUtils/requirements.txt
    

    The one that matters is unifiedefficientloader - the pack's per-tensor streaming engine, used by every node here. Pillow, mutagen, and av are only used by the CivitAI info/downloader nodes, and the shipped code imports them defensively. No model downloads. This pack is written against ComfyUI's newer V3 node schema (comfy_api.latest), so update ComfyUI before filing a bug if it refuses to import.

    Where people get burned

    A rule that matches nothing aborts the run. That sounds harsh and it is, deliberately - a typo'd pattern that silently did nothing to a 12 GB merge would be worse. Same for two lines that both match the same layer: that is an error, not last-one-wins. Start broad ((attn)), confirm it hits, then narrow.

    Bounds are enforced per method. DARE-family probability coefficients must land in 0–1, merge coefficient modes outside those cases allow −10 to 10, ranks must be integers, and Frobenius resize rejects min_rank above max_rank. For fixed extraction, setting linear_dim also raises the corresponding rank cap - worth knowing before you wonder why the file came out bigger than your cap.

    Not everything is per-layer, and that is on purpose. Probe offsets, iteration counts, optimizer settings, seeds, file paths, dtype, and device stay main-node settings.

    LoRA patterns target normalized logical block names, not the lora_down / lora_up / alpha factor keys. Write the block name you see in the model, not a tensor-dump suffix.

    CategoryModelUtils/Configuration

    Inputs (2)

    NameTypeDefaultDescription
    rulesSTRINGOne (pattern) name:value rule per line. Short aliases or full names are accepted; separate assignments with whitespace or commas. See Documentation for receiver-specific bindings.
    glob_patternsBOOLEANfalseUse case-sensitive glob substring matching instead of regex substring search. Independent of receiving nodes' exclusion-filter syntax.

    Outputs (2)

    NameTypeDescription
    layer_parametersMODELUTILS_LAYER_PARAMETERS—
    documentationSTRING—