model merging nodes powered by sd-mecha, a memory efficient state dict recipe merger.
comfy-mecha is a complete model merging node pack for ComfyUI with a focus on low memory footprint.
Recipe workflows can get much, much more complex than this.
If you are familiar with writing python code, you might be interested in using the sd-mecha library directly for experiments as an alternative to ComfyUI: https://github.com/ljleb/sd-mecha
Assuming you have ComfyUI-Manager installed:
You can also install the node pack manually:
cd custom_nodes
git clone https://github.com/ljleb/comfy-mecha.git
pip install -r comfy-mecha/requirements.txt
Nodes used for merging. They all have Recipe
in their name except for Mecha Merger
.
... Mecha Recipe
return a merge recipeMecha Merger
takes a MECHA_RECIPE
as input, and returns a unet and a text encoderSerializer
takes a MECHA_RECIPE
as input, and returns the recipe instructions using the mecha formatDeserializer
takes a mecha recipe string as input, and returns the deserialized MECHA_RECIPE
(this is the inverse operation of Serializer
)Mecha Model Recipe
loads a model as a recipe to be used as input to other recipe nodes. model architecture auto-detection is not yet supported, so please make sure the right model_arch
parameter is selected!Mecha Lora Recipe
loads a lora model as a recipe to be used as input to other recipe nodes. again, model architecture auto-detection is not yet supported, so make sure to use the right model_arch
Mecha Recipe List
takes an arbitrary number of recipes and returns a MECHA_RECIPE_LIST
. It is intended to be used as input to recipe nodes that accept an arbitrary number of recipes as input, i.e. the bounds
input of Clip Mecha Recipe
Nodes used to specify hyper(parameters) to merge methods. For example, Weighted Sum Mecha Recipe
has a hyper input alpha
with a default value of 0.5
.
Blocks Mecha Hyper
can specify a different hyper for each block of the models to be merged (AKA "merge block weighted" or "MBW")Float Mecha Hyper
specifies the same float for all blocks of the models to be mergedTo add custom merge nodes, you can add python scripts that make use of the mecha extension API under the mecha_extensions
directory.
The node pack will run all scripts placed there before creating the comfy nodes.
Currently, the documentation for the mecha extension API is under construction. For now, to get more information, you can either take a look at the custom merge method example, open a discussion post to ask questions, or join the discord server.