Nodes/ComfyUI-DonutNodes/Model Merge ZIT
ComfyUI Node

Model Merge ZIT

Blend 30 transformer layers by hand

By DonutsDelivery·Created about a year ago·Updated about 15 hours ago· 25
Model Merge ZIT
  • model1
  • model2
  • MODEL
early1.00
lowmid1.00
upmid1.00
late1.00
x_embedder1.00
t_embedder1.00
cap_embedder1.00
refiners1.00
final1.00
other1.00
granularitygrouped
layer_01.00
layer_11.00
layer_21.00
layer_31.00
layer_41.00
layer_51.00
layer_61.00
layer_71.00
layer_81.00
layer_91.00
layer_101.00
layer_111.00
layer_121.00
layer_131.00
layer_141.00
layer_151.00
layer_161.00
layer_171.00
layer_181.00
layer_191.00
layer_201.00
layer_211.00
layer_221.00
layer_231.00
layer_241.00
layer_251.00
layer_261.00
layer_271.00
layer_281.00
layer_291.00
context_refiner1.00
noise_refiner1.00
final_layer1.00
norm_final1.00

SDXL has ModelMergeBlocks - a node that lets you blend two checkpoints per-block, so you can take the composition from model A and the aesthetics from model B without a blunt 50/50. Z-Image Turbo (the 6B model the community crowned as SDXL's successor) never had an equivalent, because its architecture is a 30-layer transformer, not a UNet with named input/middle/output blocks. ModelMergeZIT is that equivalent: per-block merging for Z-Image Turbo / Lumina2 models, with the 30 layers bundled into four meaningful groups so you don't have to know what layer 19 does to use it.

How it works

You wire in two models and a set of ratios. The ratio is the language of the whole node: 0.0 = use model1, 1.0 = use model2, anything between is a blend. The layers are grouped by what they actually do in a diffusion transformer:

  • early (layers 0–5) - translation/encoding: turning your prompt into the model's internal representation.
  • lowmid (layers 6–14) - composition/layout: where the structure of the image lives.
  • upmid (layers 15–23) - details/attributes: fine-grained features.
  • late (layers 24–29) - refinement/aesthetics: style and final polish.

Plus the non-layer pieces: x_embedder (patch embedding), t_embedder (timestep embedding), cap_embedder (text embedding), refiners (context + noise refiner), final (final layer + norm), and other (padding tokens etc.). Every one has a ratio slider, default 1.0 - which in this node's convention means "use model2 for this block." So the first thing you'll do is flip the ones you care about.

There's a granularity selector that changes the whole personality: grouped (default) gives you the four group sliders plus the component sliders - the original ModelMergeZIT behavior; blocks exposes all 30 layer_0layer_29 sliders individually - the original ModelMergeZITBlocks behavior, folded into the same node. Start grouped; drop to blocks when you've identified a specific layer range and want to move just one.

Output: MODEL, ready for a KSampler - or better, a DonutModelSave node, because per-block merges are worth keeping.

Practical strategy

The standard recipe for a Z-Image merge: put your base (usually Z-Image Turbo) on model1 and your style/character model on model2, then think in terms of the four groups. Want the base's structure with the other model's look? Pull lowmid toward 0 (keep model1's composition) and leave late at 1 (model2's aesthetics). The group tooltips map the architecture's real job to each range, which is the entire reason to use this over a blind average.

Two caveats. Merging Z-Image models is still more art than science - the community consensus on ZiT merging is younger and thinner than SDXL's, so expect to iterate and A/B. And it's memory-hungry to have two 6B models loaded at once; if you're on a 12GB card, expect to be tight. Start with granularity = grouped so you're only moving four levers, and only descend to per-layer when the grouped result tells you where the problem lives.

Install

Part of ComfyUI-DonutNodes: ComfyUI Manager → search "DonutNodes" → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/DonutsDelivery/ComfyUI-DonutNodes.git donutnodes
cd donutnodes
python -m pip install -r requirements.txt

Pack dependencies (opencv-python-headless, scipy, matplotlib, psutil, tqdm, requests) only - the merge itself is pure tensor math on models you already have. No model downloads.

Categoryadvanced/model_merging

Inputs (47)

NameTypeDefaultDescription
model1MODEL
model2MODEL
earlyFLOAT1.000–1Layers 0-5: Translation/encoding
lowmidFLOAT1.000–1Layers 6-14: Composition/layout
upmidFLOAT1.000–1Layers 15-23: Details/attributes
lateFLOAT1.000–1Layers 24-29: Refinement/aesthetics
x_embedderFLOAT1.000–1Patch embedding (converts image patches to tokens)
t_embedderFLOAT1.000–1Timestep embedding
cap_embedderFLOAT1.000–1Caption/text embedding
refinersFLOAT1.000–1context_refiner + noise_refiner
finalFLOAT1.000–1final_layer + norm_final
otherFLOAT1.000–1Remaining (pad tokens, etc.)
granularityoptCOMBOgroupedgrouped: per-group ratios (original ModelMergeZIT). blocks: per-layer ratios (original ModelMergeZITBlocks).
layer_0optFLOAT1.000–1Layer 0: Translation/encoding
layer_1optFLOAT1.000–1Layer 1: Translation/encoding
layer_2optFLOAT1.000–1Layer 2: Translation/encoding
layer_3optFLOAT1.000–1Layer 3: Translation/encoding
layer_4optFLOAT1.000–1Layer 4: Translation/encoding
layer_5optFLOAT1.000–1Layer 5: Translation/encoding
layer_6optFLOAT1.000–1Layer 6: Composition/layout
layer_7optFLOAT1.000–1Layer 7: Composition/layout
layer_8optFLOAT1.000–1Layer 8: Composition/layout
layer_9optFLOAT1.000–1Layer 9: Composition/layout
layer_10optFLOAT1.000–1Layer 10: Composition/layout
layer_11optFLOAT1.000–1Layer 11: Composition/layout
layer_12optFLOAT1.000–1Layer 12: Composition/layout
layer_13optFLOAT1.000–1Layer 13: Composition/layout
layer_14optFLOAT1.000–1Layer 14: Composition/layout
layer_15optFLOAT1.000–1Layer 15: Details/attributes
layer_16optFLOAT1.000–1Layer 16: Details/attributes
layer_17optFLOAT1.000–1Layer 17: Details/attributes
layer_18optFLOAT1.000–1Layer 18: Details/attributes
layer_19optFLOAT1.000–1Layer 19: Details/attributes
layer_20optFLOAT1.000–1Layer 20: Details/attributes
layer_21optFLOAT1.000–1Layer 21: Details/attributes
layer_22optFLOAT1.000–1Layer 22: Details/attributes
layer_23optFLOAT1.000–1Layer 23: Details/attributes
layer_24optFLOAT1.000–1Layer 24: Refinement/aesthetics
layer_25optFLOAT1.000–1Layer 25: Refinement/aesthetics
layer_26optFLOAT1.000–1Layer 26: Refinement/aesthetics
layer_27optFLOAT1.000–1Layer 27: Refinement/aesthetics
layer_28optFLOAT1.000–1Layer 28: Refinement/aesthetics
layer_29optFLOAT1.000–1Layer 29: Refinement/aesthetics
context_refineroptFLOAT1.000–1Context refinement
noise_refineroptFLOAT1.000–1Noise refinement
final_layeroptFLOAT1.000–1Final output layer
norm_finaloptFLOAT1.000–1Final normalization

Outputs (1)

NameTypeDescription
MODELMODEL