Nodes/ComfyUI-latent-ops/LatentOperationFill
ComfyUI Node

LatentOperationFill

Reset a latent to a constant

By hnmr293·Created about a year ago·Updated about a year ago· 2
LatentOperationFill
    • op
    value0.0000

    Sometimes you don't want to transform a latent - you want to erase it. LatentOperationFill does exactly that: every single element of the latent gets set to the same value, so you're left with a flat, featureless tensor that has the shape of the latent you gave it and none of its content. It's a "blank slate" tool, and it's more useful than it sounds: a flat latent is the perfect starting point for latent arithmetic, because it lets you build up structure by adding pieces instead of blending over what's already there.

    It's from hnmr293's ComfyUI-latent-ops pack, and yes - deferred op, not a result.

    How it works

    The node captures value and builds a closure that runs torch.ones_like(latent) * value when applied. It keeps the shape, dtype, and device of whatever latent you eventually apply it to, but overwrites every element with your constant. Fill with 0 and you've got a clean zero latent; fill with any other value and you've got a flat field at that level. Note it takes the shape from the latent it's applied to - so you can wire any latent just to donate its shape, and Fill doesn't care what that latent's actual values were.

    What matters

    • value - FLOAT, default 0, range -10000 to 10000, step 0.0001. The constant every element becomes.
    • op - the only output. A LATENT_OPERATION - a deferred operation.

    And the pack-wide rule that bites everyone once: the op output isn't a latent and won't connect to one. This pack ships no Apply node, so you need a consumer that accepts LATENT_OPERATION, or the fill never happens. It's the design of every Operation node here, not a bug in this one.

    Installing it

    Same pack, same nothing-to-install: pure torch, no requirements.txt, no model files. ComfyUI Manager → search "ComfyUI-latent-ops" → install, or:

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

    Restart ComfyUI; it's under hnmr/latent_ops.

    Troubleshooting

    The classic combo is Fill at 0 → then LatentOperationAddBroadcast or LatentOperationAdd to start building structure from a clean slate. Watch out for the implicit expectation trap: if you were hoping Fill would resize or reshape the latent, it won't - it only replaces values, so the output shape is whatever the applied latent had. And if you set value to something non-zero and then decode, expect a flat, uniform image - that's the point, not an error.

    Categoryhnmr/latent_ops

    Inputs (1)

    NameTypeDefaultDescription
    valueFLOAT0.0000-10000–10000

    Outputs (1)

    NameTypeDescription
    opLATENT_OPERATION