Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Workflow:AUTOMATIC1111 Stable diffusion webui Checkpoint merging

From Leeroopedia


Knowledge Sources
Domains Model_Management, Stable_Diffusion, Model_Merging
Last Updated 2026-02-08 08:00 GMT

Overview

End-to-end process for combining two or three Stable Diffusion model checkpoints using weight interpolation to create a new merged model.

Description

This workflow enables users to merge Stable Diffusion checkpoints by interpolating their weights. Three interpolation methods are available: weighted sum (linear blend of two models), add difference (applies the difference between two models onto a third), and no interpolation (passthrough). The merge operates on individual tensor weights in the state dict, handling shape mismatches for special model types. The result is saved as a new checkpoint file with optional VAE baking and precision conversion.

Usage

Execute this workflow when you want to combine the characteristics of multiple fine-tuned models into a single checkpoint. Common use cases include blending an artistic style model with a realistic model, adding specific capabilities from one model to another, or creating an ensemble that inherits strengths from multiple base models.

Execution Steps

Step 1: Model selection

Select the primary model (Model A), secondary model (Model B), and optionally a tertiary model (Model C, required only for the "Add difference" method). All models must be Stable Diffusion checkpoints in .ckpt or .safetensors format. The primary model serves as the base that is modified by the merge operation.

Key considerations:

  • Models should ideally share the same base architecture (e.g., all SD 1.5 based or all SDXL)
  • The primary model structure determines the output architecture
  • Model C is only used in "Add difference" mode to compute the delta

Step 2: Merge method and parameters

Select the interpolation method and configure the merge multiplier (alpha, 0.0 to 1.0). For weighted sum: the output is (1-alpha)*A + alpha*B, where alpha=0.0 preserves model A entirely and alpha=1.0 produces model B entirely. For add difference: the output is A + alpha*(B-C), which extracts the training delta between B and C and applies it to A with adjustable strength.

Key considerations:

  • Weighted sum at alpha=0.5 produces an equal blend of both models
  • Add difference is useful for extracting and transplanting specific fine-tuning effects
  • The multiplier affects all layers uniformly (per-layer merge is not supported in the base UI)
  • Values outside 0.0-1.0 are technically valid but may produce unstable results

Step 3: Additional options

Configure optional merge settings: precision (full float32 or half float16), output format (.safetensors or .ckpt), VAE baking (embed a specific VAE into the merged model), weight discarding (regex pattern to exclude specific tensors), and custom output filename. These options control the final checkpoint properties.

Key considerations:

  • Half precision reduces file size by approximately 50% with minimal quality impact
  • Safetensors format is preferred for faster loading and security
  • VAE baking ensures a specific VAE is always used with the merged model
  • Weight discarding can remove unwanted components (e.g., EMA weights)

Step 4: Weight merging execution

Load the state dictionaries from all selected checkpoints. Iterate through each tensor in the primary model, find matching tensors in the secondary (and tertiary) models, and apply the selected interpolation function. Handle shape mismatches for special model variants (inpainting models have extra channels, InstructPix2Pix has 8-channel input). Convert to half precision if requested. Apply regex-based weight filtering to discard unwanted tensors.

Key considerations:

  • Shape-mismatched tensors fall back to using the primary model values
  • Inpainting models have 9-channel UNet input vs 4-channel for standard models
  • The merge tracks metadata about component models for provenance
  • Memory usage scales with the total size of all loaded state dicts

Step 5: Saving and registration

Save the merged state dict as a new checkpoint file in the models directory. The filename is auto-generated from the merge recipe or can be manually specified. Merge metadata (component model hashes, method, alpha value) is embedded in the file. The new checkpoint is registered in the model list and can be immediately loaded for generation. A merge recipe string is produced for reproducibility.

Key considerations:

  • Auto-generated filenames encode the merge method and component model names
  • The merge recipe can be used to reproduce the exact merge
  • Component model hashes (SHA256) are stored for provenance tracking
  • The merged model appears in the checkpoint dropdown after creation

Execution Diagram

GitHub URL

Workflow Repository