Nodes/ComfyUI-kewky_tools/Tensor Debug++
ComfyUI Node

Tensor Debug++

Inspect the shape, dtype and stats of anything in your graph

By KewkLWΒ·Created 2 years agoΒ·Updated about a year agoΒ· 9
Tensor Debug++
  • tensor
  • STRING
β—„include_gradientsfalseβ–Ί
β—„include_statisticsfalseβ–Ί

Sometimes a workflow doesn't error, it just does something wrong - the wrong shape lands in a node, a latent is on the CPU when it should be on the GPU, a value blew up to NaN somewhere and now everything downstream is black. Tensor Debug++ is the node you clip onto a wire to actually see what's flowing through it. Point it at a tensor and it prints the structure: shape, data type, device, memory footprint, and - if you ask - gradients and statistics. It's a print-statement you can drop into the graph without editing any Python.

This is a builder's tool, not a generator's. Nobody making pretty pictures needs it. But if you're wiring up custom nodes, debugging why two things won't connect, or chasing a NaN, being able to inspect the actual tensor instead of guessing is the difference between a five-minute fix and an hour of flailing.

How it works

The node takes an input of any type (it's typed *, the ComfyUI wildcard, so you can feed it a latent, an image, a model, whatever) and walks its structure. For a plain tensor it reports shape, dtype, device, and memory use. It handles nested tensors and PyTorch modules too, so pointing it at a model gives you a summary of parameters and total memory rather than a single line. With the optional flags on, it adds gradient info and statistical measures - min, max, mean, standard deviation - which is exactly what you want when you suspect values have gone out of range. It's an output node, meaning it runs to produce its report as a terminal step in the graph rather than needing something to consume its result.

The inputs and outputs that matter

  • tensor - the thing you're inspecting. Wildcard-typed, so wire in almost anything.
  • include_gradients (default off) - adds gradient information to the report. Leave it off unless you're specifically debugging a training/gradient path; for ordinary inference tensors there's nothing to show.
  • include_statistics (default off) - adds min / max / mean / std. This is the one to turn on when you're chasing a NaN or an out-of-range value - a mean that's nan or a max in the millions tells you instantly where things went sideways.

The output is a single STRING - the report itself. Route it into a display / show-text node to read it, or just check your ComfyUI console. Because it's an output node it'll execute even with nothing hanging off it.

How to install it

  • ComfyUI Manager - search ComfyUI-kewky_tools, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/KewkLW/ComfyUI-kewky_tools.git, then restart.

Pure Python, no downloads. This is one of the pack's original nodes and there's an included "open .py file" context-menu helper in the same pack that pairs nicely with it when you're spelunking node internals.

Common issues & troubleshooting

The report is empty or unhelpful. Turn on include_statistics. Bare shape/dtype is often not enough to spot the problem - the numbers are where the truth is. If you flipped include_gradients on and got nothing, that's expected on an inference tensor that carries no gradient; it's not broken.

Chasing a black-image / NaN bug. This is the node's best use. NaN propagation decodes to black, and a common cause is fp16 math on older GPUs or a bad value early in the chain. Wire Tensor Debug++ in at a few points with include_statistics on and watch for the first spot where mean or max reads nan or something absurd - that's your culprit, upstream of where the black actually appeared.

"Where's the output?" It prints to the report string and the console, not to an image. If you want it on-canvas, connect the STRING to a text-display node.

It's overkill for most workflows. Honest expectation-setting: if you're not building nodes or debugging a genuine tensor-level problem, you'll never touch this. It's a diagnostic for when something's structurally wrong, and it's very good at that one job - not a node you leave in a finished graph.

CategoryπŸ§”πŸ»β€β™‚οΈπŸ‡° πŸ‡ͺ πŸ‡Ό πŸ‡°

Inputs (3)

NameTypeDefaultDescription
tensor*β€”
include_gradientsBOOLEANfalseβ€”
include_statisticsBOOLEANfalseβ€”

Outputs (1)

NameTypeDescription
STRINGSTRINGβ€”