Nodes/ComfyUI-DareMerge/Block Gradient
ComfyUI Node

Block Gradient

The six sliders, as a reusable gradient

By 54rt1n·Created 3 years ago·Updated 2 years ago· 98
Block Gradient
  • model
  • LAYER_GRADIENT
◄time1.00►
◄label1.00►
◄input1.00►
◄middle1.00►
◄output1.00►
◄out1.00►

Block Gradient is the smallest node in the pack and possibly the most important one to understand, because it's the template for everything else. It takes a model and produces a LAYER_GRADIENT - the dict of per-layer merge ratios that drives every merger in ComfyUI-DareMerge. Six sliders in, one gradient out.

That's also exactly what Model Merger (Block) does internally: that node calls this one and feeds the result straight into the Advanced merger. So if you've used Model Merger (Block), you already know this node's six ratios:

  • time and label - conditioning embeddings (timestep, and on SDXL the label embedding).
  • input - the encoder blocks.
  • middle - the bottleneck blocks.
  • output and out - the decoder blocks and the final output layer.

Convention alert, once more, because it's the pack's universal rule: 1 means keep model A, 0 means keep model B. All six default to 1, so a fresh Block Gradient is "keep everything from A."

Why use it as a separate node

Because building the gradient separately means you can do something to it between generation and the merger. The whole gradient toolchain is built on that gap:

  • Combine it with another gradient via Gradient Operations (mean, max, multiply, whatever) to make a compound weighting.
  • Edit specific layers afterward with Gradient Edit - e.g. take a block gradient, then zero out one individual attention block without touching the others.
  • Inspect it with Gradient Reporting to confirm a layer key is actually covered before you spend a merge on it.

The block layout here is the SD1.5/SDXL-aware one - the pack sniffs the architecture from the state dict and buckets keys into input/middle/output accordingly. A gradient is architecture-bound: build it from the same model you merge, or the keys won't line up.

Install and gotchas

ComfyUI Manager (search "DareMerge") or:

cd ComfyUI/custom_nodes
git clone https://github.com/54rt1n/ComfyUI-DareMerge

Restart ComfyUI. Dependencies are matplotlib, numpy, torch, pillow - no downloads, nothing exotic.

Two things worth knowing before you chain this around. First, the six sliders are coarse - every key in the input stage gets the identical ratio, which is fine for stage-level control and useless for attention-level control (that's Attention Gradient's job). Second, remember the gradient is a filter: layers it doesn't name don't merge at all, so if you edit the gradient down to nothing and the merge comes out 100% model A, you've filtered the merge out of existence rather than set everything to A. That's the same silent-contract behavior as the rest of the pack - when in doubt, report first.

CategoryDareMerge/gradient

Inputs (7)

NameTypeDefaultDescription
modelMODEL—
timeFLOAT1.000–1—
labelFLOAT1.000–1—
inputFLOAT1.000–1—
middleFLOAT1.000–1—
outputFLOAT1.000–1—
outFLOAT1.000–1—

Outputs (1)

NameTypeDescription
LAYER_GRADIENTLAYER_GRADIENT—