Auto Merge Block Weighted
A robot picks your merge ratios, then argues about taste
- model1
- model2
- clip
- vae
Auto Merge Block Weighted (part of the Auto-MBW pack, szhublox/ambw_comfyui) is the node that takes the fiddliest, most hand-wavy part of checkpoint merging - "how much of model B's block 7 should go into model A?" - and hands it to a machine. It merges each of the U-Net's 25 blocks at several ratios, generates sample images for each candidate, runs them past an aesthetic classifier, and keeps the ratio that scored highest. Then it saves the whole thing as a new checkpoint.
Here's the part you need before you trust it: the author doesn't. Their README opens with "whether this is a good idea or not is anyone's guess. In practice this makes models that make images the classifier says are good. You would probably disagree with the classifiers' decisions often." The whole tool in one paragraph.
Why you'd reach for it
Model merging is how most CivitAI checkpoints get made: you interpolate two models' weights and get a hybrid, no training required. But "interpolate" has a lot of dials. The SD1.5 U-Net has 12 input blocks, a middle block, and 12 output blocks, and the right mix per block is a matter of taste. Hand-tuning 25 sliders is how you burn an afternoon.
This node is the "just run it and see" answer. Feed it two SD1.5 checkpoints and a prompt you care about, and it runs a greedy per-block search, applying each block's winning ratio permanently before moving on. It's a port of the Automatic1111 extension sdweb-auto-MBW, which the community rated "rumor is it's pretty good" but chronically under-documented.
How it works
The mechanism is dead simple, which is the point. For each block, it branches out from a ratio of 0.5 in powers of 0.5 - depth 2 tests {0, 0.5, 1}, depth 4 tests 9 ratios from 0 to 1, depth 6 tests 33. For each candidate it copies block B's weights into model A at that ratio, generates sample_count images with a hardcoded DDIM sampler (20 steps, CFG 7.0, at 64×64 - you can't change any of that), decodes them through your VAE, scores each with the chosen classifier, then un-merges and tries the next ratio. The best-scoring ratio gets applied for good, and it moves on to the next of all 25 blocks.
That's also the cost story. 25 blocks × ratios × samples images, each a 20-step sample. At depth 4 with a single sample that's 225 images; bump sample_count to 2 and it's 450. On a consumer GPU this is a "go make tea, several times" operation.
The inputs that matter
Despite the long list, you only really touch a few:
- model1 / model2 (MODEL) - the base and the donor. model1 is what gets mutated and saved.
- prompt / negative - the sample prompts. These define what "good" means, so put real effort here; the classifier can only vote on the images your prompt produces.
- search_depth / sample_count - the two cost dials. Start at depth 4, one sample, and accept that it's slow.
- classifier - the taste-maker:
laion,aesthetic,cafe_waifu, orcafe_aesthetic. Pick by what you're merging;cafe_waifuliterally scores "how much of a waifu is this." - filename_prefix - where the result lands (default
ambw).
There are no outputs. It's an output node: it saves a merged .safetensors checkpoint - including whatever CLIP and VAE you wired in - to your ComfyUI output folder.
Installing it
ComfyUI Manager will find it if you search "Auto-MBW", or grab it directly:
cd ComfyUI/custom_nodes
git clone https://github.com/szhublox/ambw_comfyui
Then restart ComfyUI. Here's the trap: the repo ships no requirements.txt, so Manager won't install anything for you, and the node won't run until clip and transformers exist in your environment:
pip install clip safetensors transformers
The small classifier weight files ship inside the repo, but the underlying CLIP models don't - the first run downloads ViT-L/14 (~875 MB) for laion, openai/clip-vit-base-patch32 for aesthetic, and the cafeai/cafe_waifu / cafeai/cafe_aesthetic pipelines for the cafe options. First run can look hung while it pulls those. And the code hardcodes .to('cuda') everywhere - GPU-or-bust.
Gotchas worth knowing
- Run with
--highvramif you can. The README says so outright: both models stay resident in VRAM and the whole thing is much faster. The merge also bypasses ComfyUI's ModelPatcher and mutates the state dict directly, which is why. - The sample images aren't saved - only the final checkpoint is. You get the winning ratios printed to the console, not the evidence.
- It's an SD1.5-era tool. The block layout (12 input + middle + 12 output) is hardcoded. It "runs" on SDXL but doesn't really make sense there.
- The hardcoded seed, sampler, and block order are arbitrary - the author's words. Treat results as a suggestion, not a verdict.
In short: a fun, genuinely automatic take on block merging that works exactly as advertised - and the author would be the first to tell you "advertised" is doing a lot of work.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| model1 | MODEL | — | |
| model2 | MODEL | — | |
| clip | CLIP | — | |
| vae | VAE | — | |
| prompt | STRING | masterpiece girl | — |
| negative | STRING | worst quality | — |
| search_depth | INT | 4 | — |
| sample_count | INT | 1 | — |
| classifier | COMBO | 4 options: laion, aesthetic, cafe_waifu, cafe_aesthetic | |
| filename_prefix | STRING | ambw | — |
Outputs (0)
No outputs