ComfyUI Node

Blocks

Per-block merge weights — the SuperMerger MBW dial for ComfyUI

By ljleb·Created 3 years ago·Updated about a month ago· 101
Blocks
    • recipe
    presetcustom
    blocks,,,,,,,,,,,,,,,,,,,,,,,,,
    default0.00
    model_config

    If you've ever watched an A1111 user rhapsodize about SuperMerger and wondered what "merge block weighted" actually is, this is it. Blocks Mecha Hyper produces a param recipe containing one weight per architecture block, in the same supermerger convention: for sd1-ldm that's 26 blocks (BASE, IN00–IN11, MID, OUT00–OUT11), and for sdxl-sgm it's 21 blocks (BASE, IN00–IN08, MID, OUT00–OUT08, VAE). You feed those block weights into the alpha (or param) input of a merge node, and the merge treats each block's weight separately: heavy on the input blocks, lighter on the middle, whatever your experiments say. One weight per block, no more, no less. People spent a lot of the SDXL era here, and this node is the ComfyUI-native version of that workflow.

    Inputs

    • model_config - sd1-ldm or sdxl-sgm. This decides how many blocks exist (both are 25) and how the keys map to them. Everything else follows from it.
    • blocks - the actual weights, as a comma-separated string, one value per block in config order: e.g. 0.4,0.6,0.8,...,0.5. Empty entries fall back to default. The string is zipped against the block list, so it should have one value per block for your chosen model_config.
    • default - the fallback weight (default 0.0) applied to any block you leave blank.
    • preset - currently just custom; the string-based presets are scaffolding for later. Ignore it.

    Output: one recipe (MECHA_RECIPE) in param space.

    Wiring it into a merge

    The trick is knowing which input accepts a param recipe. On Weighted Sum Mecha Recipe, the alpha slot is a MECHA_RECIPE - feed Blocks Mecha Hyper straight into it and suddenly a flat 50/50 becomes 25 individually-weighted blends. Same story on Add Difference's alpha, or any of the scale/mask operations that take a param. That's the pattern: block weights are a parameter input, never a model input.

    A useful sanity check before you tune 25 numbers: set default to a uniform value (say 0.5) and all blocks to match, and confirm the merge behaves identically to a plain alpha of 0.5. Then start moving one block at a time - the classic recipe is "load up the early blocks, back off the middle" for style transfers, though the exact curve is model-specific. There's a whole folklore of SDXL block-weight presets that still applies here verbatim, because the block layout is the same one SuperMerger used.

    Install & gotchas

    ComfyUI Manager → search mecha → "Mecha Merge Node Pack", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ljleb/comfy-mecha.git
    pip install -r comfy-mecha/requirements.txt
    

    Restart after. Dependency is sd-mecha==1.1.7.

    Two things to keep straight. The block count is fixed by model_config - the sd1-ldm config has 26 blocks and sdxl-sgm has 21, with different key ordering, so a preset tuned on one won't mean the same thing on the other. Match the length of your blocks string to the config you picked (extra or missing entries just fall back to default). And the output is a param recipe, not a model - wire it into a param slot, not into Mecha Merger. The node itself has no merge_checkpointing (it's pure parameter construction), but the merge node consuming it does, so cache there.

    Categorymecha

    Inputs (4)

    NameTypeDefaultDescription
    presetCOMBOcustom1 options: custom
    blocksSTRING,,,,,,,,,,,,,,,,,,,,,,,,,
    defaultFLOAT0.00-18446744073709550000–18446744073709550000
    model_configCOMBO2 options: sd1-ldm, sdxl-sgm

    Outputs (1)

    NameTypeDescription
    recipeMECHA_RECIPE