Nodes/Latent Tools/LTPreviewLatent
ComfyUI Node

LTPreviewLatent

See what a latent actually looks like without ever decoding it

By Machines-of-Disruption·Created about a year ago·Updated 8 months ago· 27
LTPreviewLatent
  • latent

    You generate garbage, and you can't tell whether the problem is the sampler, the prompt, or the latent you fed in. LTPreviewLatent answers one of those questions: it shows you the raw latent tensor as a set of plots, without running it through the VAE at all.

    What it is

    A terminal debug node from latent-tools with exactly one input and no outputs. You feed it a LATENT, and it renders a debug panel inside the node showing:

    • a distribution plot of the tensor's values (histogram-style),
    • a per-channel tile view, so you can see each latent channel separately,
    • a shape summary - batch size, channels, and the implied pixel resolution.

    It's built on lovely-tensors (the pack's only real dependency) and matplotlib's non-interactive backend. The whole point is that this is not a picture of your image. It's the compressed data the diffusion model actually works on.

    Why that's useful

    Here's the grounding: on SD 1.5 and SDXL the latent is 4 channels at an 8x spatial downscale - a 512x512 image becomes a 64x64 latent, and a 1024x1024 image a 128x128 latent. The node reflects that: it reports the latent shape and its 8x pixel equivalent. So when you check it, you're confirming the thing the sampler is about to denoise, not a post-decoded image.

    Concretely, three things people actually use it for:

    1. Verify a noise generator. Feed it the output of LTUniformLatent or LTGaussianLatent and confirm the distribution is what you asked for - is that "σ=1 Gaussian" actually bell-shaped, or did you wire the mean into the wrong port?
    2. Catch a dead branch. Zeroed-out or wrong-shaped latents show up immediately as a flat distribution or a nonsense shape, before they waste a sampling run.
    3. Check the noise mask. If the latent carries a noise_mask (from inpainting), the node plots that too.

    The one input

    latent (LATENT). That's the entire interface - there's no optional anything. And since it has no outputs, it sits at the end of a branch like a probe on an oscilloscope: it observes, it doesn't pass anything along.

    Where people trip up

    • The output appears inside the node's own panel, as an HTML render - not in the usual image preview slot. If you're staring at the main viewer waiting for something, that's the mistake.
    • Don't expect a pretty picture. Expect histograms and channel tiles. If you wanted to see the image, decode it - this node exists precisely to look before decode.
    • If the node throws on import, the first suspect is matplotlib - it's pulled in by lovely-tensors, and a stripped Python environment can lack it. The pack only declares lovely-tensors, so that's the dependency chain to fix.

    Installing it

    latent-tools is a small MIT-licensed pack by xl0 (Alexey Zaytsev), published on the Comfy Registry. Easiest path: ComfyUI Manager → Install Custom Nodes → search "Latent Tools" and install, then restart ComfyUI. Manual path:

    cd ComfyUI/custom_nodes
    git clone https://github.com/xl0/latent-tools
    

    Then restart ComfyUI; it shows up under LatentTools. No model files, no heavy install. It's a niche, single-author pack, and for a debug probe that's exactly right - small, readable, and easy to trust.

    CategoryLatentTools

    Inputs (1)

    NameTypeDefaultDescription
    latentLATENT

    Outputs (0)

    No outputs