Nodes/ComfyUI-latent-ops/LatentOperationClampMin
ComfyUI Node

LatentOperationClampMin

Put a floor under your latent

By hnmr293·Created about a year ago·Updated about a year ago· 2
LatentOperationClampMin
    • op
    min0.0000

    Some latent operations will happily push your values negative when everything downstream expects them to stay put. If you've got a workflow that assumes a floor of zero - or any floor, honestly - LatentOperationClampMin is the one-liner that enforces it. Every value below your min gets lifted to exactly min; everything else sails through untouched. It's the bottom-half version of LatentOperationClamp, and it's dead simple.

    It's part of hnmr293's ComfyUI-latent-ops pack, and it uses the same deferred-op pattern as the rest of the Operation family: it hands back a recipe, not a transformed latent.

    How it works

    The node captures your min and builds a closure that runs latent.clamp(min=min) when finally applied. Elementwise, cheap, broadcast across every channel and position. There's no range check on min beyond the -10000 to 10000 slider, so if you genuinely want everything non-negative, set it to 0 and forget it.

    What matters

    • min - FLOAT, default 0. The floor. The author's tooltip: "Minimum value to clamp to."
    • op - the only output. A LATENT_OPERATION - a deferred operation.

    And the pack-wide caveat: the op output won't connect to a latent input. The pack ships no Apply node, so you need a consumer that accepts LATENT_OPERATION, or the op never runs. If that sounds like a pain, you're right - it's the one rough edge of this pack, and it applies to every Operation node here.

    Installing it

    No extra deps, no model downloads. ComfyUI Manager → search "ComfyUI-latent-ops" → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hnmr293/ComfyUI-latent-ops
    

    Restart ComfyUI; the node lives under hnmr/latent_ops.

    Troubleshooting

    Two practical notes. First, clamping the floor doesn't redistribute anything - values that were below min bunch up at the floor, which can look flat if you clamp hard and then preview. That's expected, not a bug. Second, pairing it with ClampMax gives you the same result as the two-sided Clamp node, so pick whichever reads better in your graph. And if you find yourself setting min because a downstream activation or decoder is choking on negatives, ask whether the real fix is a smoother curve (ELU, for instance) rather than a hard floor - but for a quick guard, this node is exactly right.

    Categoryhnmr/latent_ops

    Inputs (1)

    NameTypeDefaultDescription
    minFLOAT0.0000-10000–10000Minimum value to clamp to.

    Outputs (1)

    NameTypeDescription
    opLATENT_OPERATION