Model Merging

Model Merging

The purpose of these ComfyUI Workflows is to enable the creation of complex setups involving multiple model merges. You can experiment with different configurations and, once satisfied with the results, save the checkpoint by activating the CheckpointSave node. By default, this node saves checkpoints to the output/checkpoints/ folder.

These nodes are located under: advanced -> model_merging.

The following example demonstrates a basic merge between two different checkpoints.

You can load these images in ComfyUI to access the complete workflow.

Model Merging in ComfyUI

In ComfyUI, saved checkpoints include the entire workflow used in their creation, allowing them to be loaded into the UI just like images to retrieve the full workflow.

This particular example demonstrates the merging of three different checkpoints using simple block merging, where the input, middle, and output blocks of the U-Net can have different ratios.

merging of three different checkpoints using simple block merging example

Since LoRAs are a patch on the model weights, they can also be merged directly into the model.

In ComfyUI, you can also subtract model weights and add them, as demonstrated in this example used to create an inpaint model from a non-inpaint model using the formula:

(inpaint_model - base_model) * 1.0 + other_model.

If you’re familiar with the “Add Difference” option in other UIs, this is how it’s done in ComfyUI.

One important thing to note is that models are merged and saved in the precision used for inference on your hardware, which is typically 16-bit float. If you want to perform merges in 32-bit float, launch ComfyUI with the --force-fp32 option.

Advanced Merging: CosXL

Here’s an example of how to create a CosXL model from a regular SDXL model through merging. The requirements for this process are the CosXL base model, the SDXL base model, and the SDXL model you want to convert. In this particular example, the albedobase-xl model was used as the SDXL model.

Read other articles: