Nodes/Mickmumpitz-Nodes/Latent Exists
ComfyUI Node

Latent Exists

Check whether you actually have a latent — without breaking the graph

By mickmumpitz·Created 8 months ago·Updated 9 days ago· 47
Latent Exists
  • latent
  • latent
  • exists

ComfyUI is strict about types, and None is a bad citizen. If a branch of your graph sometimes produces a latent and sometimes doesn't - first iteration vs. later ones, or a loaded vs. unloaded path - you can't just wire "maybe a latent" into a sampler. Latent Exists is the pack's guard: it takes an optional latent in, reports whether it was there, and crucially, always returns a usable latent out so the downstream graph never sees a hole.

It's part of a small family of existence-check nodes in this pack (there's a sibling Audio Exists, and a Mask Exists under the hood too) built around the same idea: keep lazy, conditional graphs type-safe.

How it works

The logic is two lines: if latent came in, it goes out unchanged and exists is True. If it's None, the node synthesizes a placeholder - {"samples": torch.zeros(1, 4, 8, 8)} - and returns it with exists set to False.

That placeholder matters more than it looks. Because the node always returns a real LATENT, whatever consumes it downstream never crashes on None. The 8×8 spatial size is deliberately tiny so a non-lazy switch that evaluates the unused branch doesn't blow up your VRAM while doing it. And the node is careful to note: if a downstream consumer is resolution-sensitive, this placeholder is not going to decode into anything meaningful - it's a signal, not a frame.

Inputs and outputs

  • latent (LATENT, optional) - connect whatever might or might not exist.
  • Outputs:
    • latent (LATENT) - the real latent, or the placeholder.
    • exists (BOOLEAN) - True if the input was real, False if you got the placeholder.

The exists boolean is the branch signal. Wire it into a switch or a conditional to pick different downstream paths, and wire the latent output into whatever consumes the latent in both branches.

Where it fits

Iterative video is the natural home. On iteration 0 there's no previous latent to continue from; on iteration 1+ there is. Rather than building two separate sampler setups or wrestling with a switch that chokes on None, Latent Exists lets one graph handle both - the boolean routes, the placeholder keeps the unused path valid. It's exactly the kind of plumbing the pack's multi-iteration workflows need, and it's from the same family as the Free VRAM nodes that keep those workflows from grinding to a halt.

Installing

ComfyUI Manager → search "Mickmumpitz" → install → restart, or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/mickmumpitz/ComfyUI-Mickmumpitz-Nodes

Deps are numpy, Pillow, opencv-python - nothing heavy, nothing to download.

Gotchas

The main trap is treating the placeholder as real. If your logic says "exists is False, so skip," make sure the consumer of the placeholder latent is actually bypassed by your switch - the placeholder is a token so the graph doesn't error, not a canvas to sample from. And remember: if you connect nothing to latent, you get the placeholder + False. Some people expect an unconnected input to error; here it just reports "no latent," which is the feature, not a bug.

CategoryMickmumpitz/Utils

Inputs (1)

NameTypeDefaultDescription
latentoptLATENT

Outputs (2)

NameTypeDescription
latentLATENT
existsBOOLEAN