Nodes/ComfyUI-Przewodo-Utils/DebugLatentShapes
ComfyUI Node

DebugLatentShapes

The console print your latent was begging for

By przewodo·Created about a year ago·Updated 4 months ago· 4
DebugLatentShapes
  • latent
  • *
shape_index

Every video or latent-size bug starts the same way: "the empty latent is the wrong shape but I can't see what shape it actually is." ComfyUI's UI shows you next to nothing about a LATENT object - it's an opaque black box on the canvas. This node is the two-second answer: feed it a latent, and it prints every dimension of the underlying tensor straight to the terminal, then hands one of those dimensions back as a number you can actually use.

The big sibling of this node in the same pack is ImageSizer, which computes the right dimensions for an empty latent. This one is the diagnostic - plug it in mid-graph to check whether your latent is the size you think it is before it wrecks a sampler downstream. If you're fighting resolution errors on Wan or LTX workflows, this is the first node you add.

How it works

A latent in ComfyUI is a dict, and the actual data lives under latent["samples"] as a 4D tensor. The shape is (batch, channels, height, width) - the height and width being compressed by the VAE, which is where beginners lose the plot (Wan's VAE compresses 4× per axis, LTX's 8×, so a 512-wide video latent shows up as 64 wide in the tensor).

The node loops over the shape and prints each axis to the console:

latent.shape[0] = 1
latent.shape[1] = 16
latent.shape[2] = 60
latent.shape[3] = 104

Then it returns shape[shape_index] - one specific dimension, as an integer. The trick it uses to never crash: it takes shape_index modulo the tensor's rank, so if you ask for index 5 on a 4D tensor it wraps around to index 1 instead of throwing. That's a nice touch for a debug node.

The inputs that matter

  • latent - the LATENT to inspect.
  • shape_index - which dimension you want back as the output number. Per the tooltip: 0 = batch, 1 = channels, 2 = height, 3 = width for typical latents.

The output is wildcard-typed but is really an integer - handy if you want to, say, feed the actual current width into a node that needs it, rather than guessing.

Installing it

From the ComfyUI-Przewodo-Utils pack. Manager → search the pack name, or:

cd ComfyUI/custom_nodes
git clone https://github.com/przewodo/ComfyUI-Przewodo-Utils.git

Restart ComfyUI. Zero extra dependencies beyond what ComfyUI already ships.

Where people get tripped up

Two things. First, the console output lands in your terminal, not on the canvas - so if you're running ComfyUI as a desktop app you may need to look at the window you launched it from. Second, don't mistake the output for a tensor: it's one bare integer. It's meant for inspection and for feeding single numbers into other nodes, not for replacing the latent it measured. If what you actually want is a correctly sized latent, the answer is ImageSizer on the input side, not this node on the output side.

CategoryPrzewodoUtils

Inputs (2)

NameTypeDefaultDescription
latentLATENTThe latent tensor to analyze. This node will print all dimensions and return a specific dimension value.
shape_indexINTIndex of the dimension to return (0=batch, 1=channels, 2=height, 3=width for typical latents). Uses modulo to prevent index errors.

Outputs (1)

NameTypeDescription
**