Nodes/ComfyUI-ModelMergeCosmosPredict-2B-Slerp/Model Merge Cosmos Predict 2B (Slerp)
ComfyUI Node

Model Merge Cosmos Predict 2B (Slerp)

Sharper blends, one flipped slider

By rikunarita·Created about a month ago·Updated 18 days ago· 1
Model Merge Cosmos Predict 2B (Slerp)
  • model1
  • model2
  • MODEL
merge_modeslerp
pos_embedder.1.00
x_embedder.1.00
t_embedder.1.00
t_embedding_norm.1.00
blocks.0.1.00
blocks.1.1.00
blocks.2.1.00
blocks.3.1.00
blocks.4.1.00
blocks.5.1.00
blocks.6.1.00
blocks.7.1.00
blocks.8.1.00
blocks.9.1.00
blocks.10.1.00
blocks.11.1.00
blocks.12.1.00
blocks.13.1.00
blocks.14.1.00
blocks.15.1.00
blocks.16.1.00
blocks.17.1.00
blocks.18.1.00
blocks.19.1.00
blocks.20.1.00
blocks.21.1.00
blocks.22.1.00
blocks.23.1.00
blocks.24.1.00
blocks.25.1.00
blocks.26.1.00
blocks.27.1.00
final_layer.1.00

The 30-second pitch

This node merges two Cosmos Predict 2B checkpoints into one, with a twist: instead of the plain weighted-average merge ComfyUI does by default, it can use slerp (spherical linear interpolation), which blends weight vectors by angle and then restores their magnitude. The pitch is sharper, more stable blends when the two parents differ a lot.

Honestly, the audience here is small and specific. Cosmos-Predict2-2B is NVIDIA's world-model backbone - the model that quietly became famous as the base under Anima, not as something people generate with directly. If you run two fine-tunes from the same Cosmos 2B family and want them mixed, this is your node. If you're merging SDXL or Flux, keep walking; you want ModelMergeSimple or the per-architecture merge nodes, not this.

What ComfyUI already gives you

ComfyUI ships a built-in ModelMergeCosmosPredict2_2B (under model/merging/model specific) with the same inputs, the same 28-block sliders, the same category. This pack's node is that structure reimplemented: it adds a merge_mode dropdown and does the merge itself by pulling both models' state dicts rather than patching on the fly. So the README's "drop-in replacement" line is true about the graph - swap it for the official node and your wiring still connects. Where it stops being a drop-in: the ratio sliders are flipped. More on that below.

How it works

The node subclasses ComfyUI's ModelMergeBlocks, so it inherits the input machinery. When it runs it grabs the full state dict of both models, walks every key that exists in both, and figures out which layer it belongs to - an embedder, one of blocks.0blocks.27, or final_layer - then pulls that layer's ratio.

In slerp mode it normalizes each vector, computes the angle between them, interpolates the angle, then scales back to a norm that's linearly interpolated between the two parents'. If the vectors are nearly parallel (dot product above 0.9995) or a norm is near zero, it bails to plain linear. That fallback is the whole reason it doesn't explode: the slerp formula divides by sin(θ), and near-parallel vectors make that numerically unstable.

In linear mode it's a straightforward weighted average per key. The merged dict is loaded into a clone of model1 with strict=False (minor key mismatches tolerated), cleanup_models() frees VRAM, and out comes the MODEL. Keys only in model1 pass through unchanged; keys only in model2 get dropped. Console lines starting [Cosmos Slerp] tell you when a tensor fell back or keys didn't load.

The inputs that matter

  • model1, model2 (MODEL) - the two Cosmos Predict 2B checkpoints. Same architecture required; the layer names and 28 blocks are hardcoded to the 2B, so don't feed it a 14B or an unrelated model.
  • merge_mode - slerp (default) or linear. This is the whole point of the pack.
  • 33 ratio sliders - pos_embedder., x_embedder., t_embedder., t_embedding_norm., blocks.0. through blocks.27., final_layer., each 0.0–1.0 defaulting to 1.0.

Output is a single MODEL, wired into a KSampler like any other. It carries no CLIP or VAE of its own - feed the sampler model1's CLIP, same as with any merge node.

Here's the trap, stated plainly: in this node, the ratio is how much of model2 you keep. 1.0 = model2's weights, 0.0 = model1's. ComfyUI's built-in merge nodes use the opposite convention (1.0 keeps the first model). Swap this in for the official node with untouched sliders and you silently get the other parent - every layer at model2. Turn the sliders to 0 and you're back on model1.

One more thing the code teaches you: only the blocks.N. sliders reliably do what the UI says. The embedder and final_layer sliders match state-dict keys by a strict prefix, but the real keys carry a diffusion_model. prefix, so those matches miss and the layers quietly stay at ratio 1.0. The block sliders, matched with a mid-string search, actually bind. Treat the 28 block sliders as your real controls.

Installing it

No dependencies, no model downloads - requirements.txt is empty and everything comes from ComfyUI itself.

  • ComfyUI Manager → "Install via Git URL" → https://github.com/rikunarita/ComfyUI-ModelMergeCosmosPredict-2B-Slerp.git
  • or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/rikunarita/ComfyUI-ModelMergeCosmosPredict-2B-Slerp

Restart ComfyUI and it appears as "Model Merge Cosmos Predict 2B (Slerp)".

Troubleshooting

  • "It outputs the wrong model." Check your ratios: defaults at 1.0 mean full model2. If you meant "keep model1", set them to 0.
  • Embedder sliders seem to do nothing. See above - that's the prefix-match quirk, not your workflow.
  • Mushy generations. The two inputs must be architecturally identical Cosmos Predict 2B models. Shape mismatches fall back to linear per tensor (with a console warning), but a genuinely mismatched pair gives you garbage. And note Predict2's upstream repo was archived in late 2025 - it lives on as Anima's base, so whatever 2B weights you hold are the last of their line.

Merging is fast and free - minutes, no training, no GPU grind. Slerp won't rescue a bad pairing, but for two close Cosmos fine-tunes it's a genuinely nicer blend than the plain average, and the fallback logic means it won't crash on you. Just mind which end of the slider you're on.

Categorymodel/merging/model specific

Inputs (36)

NameTypeDefaultDescription
model1MODEL
model2MODEL
merge_modeCOMBOslerp2 options: linear, slerp
pos_embedder.FLOAT1.000–1
x_embedder.FLOAT1.000–1
t_embedder.FLOAT1.000–1
t_embedding_norm.FLOAT1.000–1
blocks.0.FLOAT1.000–1
blocks.1.FLOAT1.000–1
blocks.2.FLOAT1.000–1
blocks.3.FLOAT1.000–1
blocks.4.FLOAT1.000–1
blocks.5.FLOAT1.000–1
blocks.6.FLOAT1.000–1
blocks.7.FLOAT1.000–1
blocks.8.FLOAT1.000–1
blocks.9.FLOAT1.000–1
blocks.10.FLOAT1.000–1
blocks.11.FLOAT1.000–1
blocks.12.FLOAT1.000–1
blocks.13.FLOAT1.000–1
blocks.14.FLOAT1.000–1
blocks.15.FLOAT1.000–1
blocks.16.FLOAT1.000–1
blocks.17.FLOAT1.000–1
blocks.18.FLOAT1.000–1
blocks.19.FLOAT1.000–1
blocks.20.FLOAT1.000–1
blocks.21.FLOAT1.000–1
blocks.22.FLOAT1.000–1
blocks.23.FLOAT1.000–1
blocks.24.FLOAT1.000–1
blocks.25.FLOAT1.000–1
blocks.26.FLOAT1.000–1
blocks.27.FLOAT1.000–1
final_layer.FLOAT1.000–1

Outputs (1)

NameTypeDescription
MODELMODEL