Nodes/MTB Nodes/Save Tensors (mtb)
ComfyUI Node Runs on cloud

Save Tensors (mtb)

Dump raw image/mask/latent tensors to disk for debugging

By melMass·Created 3 years ago·Updated about a month ago· 721
Save Tensors (mtb)
  • image
  • mask
  • latent
    filename_prefixComfyPickle

    This one isn't for anyone using ComfyUI to make pictures - it's for anyone debugging why a pipeline is producing garbage, by getting the raw torch tensor out of the graph and into a notebook where you can actually inspect it.

    What it's for

    ComfyUI hides tensor shapes, dtypes, and value ranges from you by design - you see rendered images, not the numbers underneath. That's fine until something's subtly wrong (a mask that's inverted, a latent that's the wrong scale, an image tensor clamped to the wrong range) and you need to look at the actual data. Save Tensors pickles whatever you plug into it - image, mask, or latent - straight to disk, so you can load it up in a Jupyter notebook or a plain Python REPL with torch.load() and poke at it directly: check .shape, .dtype, .min()/.max(), whatever you need.

    Inputs and outputs

    • filename_prefix - required, default ComfyPickle. It's the only required field, because you might only want to dump one of the three tensor types on a given debug pass.
    • image, mask, latent - all optional. Wire in whichever you're trying to inspect; you don't have to fill all three.

    No outputs - this is a terminal node, same class as a save node, it writes to disk and the graph ends there.

    When to reach for it

    You'll want this when a downstream node is behaving strangely and you suspect the data, not your prompt or your settings - a mask doing the opposite of what you expect, a latent coming out of a custom sampler that looks off, an image tensor from a custom node whose author's docs don't say what range or dtype it outputs. Rather than guessing, dump it, load it outside Comfy, and look. It's a debug tool, not a production node - you won't find a reason to leave it in a finished workflow.

    Installing it

    ComfyUI Manager: search "MTB Nodes," install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/melMass/comfy_mtb
    

    restart, and if the node's missing afterward, go into the comfy_mtb folder and run pip install -r requirements.txt yourself - Manager's dependency install for this pack doesn't always catch everything on the first pass, and that's the fix that resolves most "installed but not showing up" reports.

    Common issues

    The usual startup noise about "some nodes could not be loaded, check /mtb" refers to the pack's optional extras (face swap, DeepBump) and has nothing to do with this node - a debug node like this has no heavy or unusual dependencies of its own, it's just pickling a tensor. The real gotcha is on the reading side, not the saving side: you need torch available in whatever environment you open the pickle in later, and if you saved a latent, remember ComfyUI latents are already in the compressed VAE latent space, not pixel space - don't expect torch.load() to hand you something you can view directly as an image without decoding it first.

    Categorymtb/debug

    Inputs (4)

    NameTypeDefaultDescription
    filename_prefixSTRINGComfyPickle
    imageoptIMAGE
    maskoptMASK
    latentoptLATENT

    Outputs (0)

    No outputs