ComfyUI Node

Model

Turn any checkpoint into a merge ingredient

By ljleb·Created 3 years ago·Updated about a month ago· 101
Model
    • recipe
    model_path
    model_config

    Every merge recipe in the comfy-mecha pack starts with a model. This is the node that loads it. Model Mecha Recipe grabs a checkpoint from your models/checkpoints folder and hands you a MECHA_RECIPE in weight space - meaning "here are the full weights of this model, use them as-is." You'll wire this into the a and b inputs of merge nodes like Weighted Sum or Add Difference, or into a Subtract to compute a delta between two checkpoints.

    What the inputs mean

    • model_path - dropdown of checkpoints in your checkpoints folder (safetensors only). That's it for the everyday case.

    • model_config - the key layout sd-mecha should use to read the file. Leave auto and the library guesses from the file's structure, which works for nearly everything. The explicit choices matter when auto gets it wrong or the file is ambiguous:

      • sd1-ldm / sdxl-sgm - the classic SD1.5 / SDXL layouts. The common ones.
      • sdxl-kohya / sd1-kohya / sdxl-kohya_but_diffusers - kohya-trained checkpoints whose keys are named the kohya way (often with a lora_unet/lora_te split) rather than the plain model.diffusion_model.* style.
      • sdxl-diffusers_unet_only - a diffusers UNet with no text encoder.
      • flux-flux - for Flux checkpoints.
      • sd3-comfyui - SD3 family.
      • singleton-mecha - a model saved in the pack's own mecha format.

    Why it's memory-cheap

    This is where the pack's core trick lives. The node reads the safetensors header to learn every key and tensor offset, then builds a recipe that says "when asked, stream this tensor from disk." It does not load the model into RAM. The actual loading happens lazily, one key at a time, when a Mecha Merger finally executes the graph. That's why you can chain three or four SDXL checkpoints into one recipe on an 8 GB card that would OOM on any naive merge. The author (ljleb, also of sd-mecha) built the whole pack around this - the announcement post's pitch was literally "model merging node pack that does not take all your RAM."

    Wiring it

    Model Mecha Recipe ──▶ Weighted Sum ──▶ Mecha Merger ──▶ MODEL / CLIP / VAE
    Model Mecha Recipe ──▶
    

    Or for a delta:

    Model Mecha Recipe (fine-tune) ──▶ Subtract ──▶ Add Difference ──▶ Mecha Merger
    Model Mecha Recipe (base) ────────▶          ▲
    

    Output is a single recipe (MECHA_RECIPE). The node has no optional inputs - no merge_checkpointing here, because loading a model is already lazy; checkpoint the merge steps instead.

    Install & gotchas

    ComfyUI Manager → search mecha → install "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 ComfyUI after. Dependency is sd-mecha==1.1.7, no model downloads.

    Two things to keep in mind. First, both models in a merge must share a key structure - you can't blend an SD1.5 checkpoint with an SDXL one, and the node will cheerfully load either, so the error shows up later at merge time, not here. Second, if your checkpoint won't merge even though auto picked a config, manually switch model_config to the kohya variant - checkpoints trained with kohya's scripts are the usual culprit, and their keys look identical to untrained eyes.

    Categorymecha

    Inputs (2)

    NameTypeDefaultDescription
    model_pathCOMBO0 options:
    model_configCOMBO10 options: auto, flux-flux, sd1-kohya, sd1-ldm, sd3-comfyui, sdxl-diffusers_unet_only, +4

    Outputs (1)

    NameTypeDescription
    recipeMECHA_RECIPE