Nodes/ComfyUI-Pt-Wrapper/Pt From Latent
ComfyUI Node

Pt From Latent

Crack open a latent so the math graph can see it

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt From Latent
  • latent
  • TENSOR

In ComfyUI, a latent isn't a tensor - it's a dict with a samples key (plus noise and mask metadata hanging around). Pt From Latent is the node that pulls the actual tensor out of that dict so the Pt-Wrapper math graph can operate on it. If you've ever wanted to inspect, modify, or multiply a latent as numbers instead of treating it as an opaque blob, this is your entry point.

How it works

The node takes a LATENT and returns latent["samples"] - the raw sample tensor - relabeled as a TENSOR. That's the whole mechanism. What it unlocks: latents become ordinary tensors you can push through the pack's arithmetic nodes (Pt Add, Pt Mul, Pt FloorDiv), reduction ops (Pt Mean, Pt Max), or reshape nodes, then hand back to the diffusion graph. It's genuinely useful for experiments - scaling a latent channel, averaging latent batches, or just seeing what's actually in there with Pt Mean instead of staring at a black VAE preview.

One thing to know: the tensor you get is the samples only. The latent's other metadata (noise level, masks) doesn't come along for the ride. If you modify the tensor and want it back in the sampling pipeline, you'll need to re-wrap it - this node is one-way.

The one input

  • latent - a standard LATENT. Nothing else to set.

Because there's a sibling for every conversion in this pack, grab the right one: pixels come in via Pt From Image, numpy arrays via Pt From Numpy, and if you accidentally feed an IMAGE here the sockets won't match.

Where people get burned

  • Shape expectations: latents are usually (batch, channels, height/8, width/8) - spatially much smaller than the decoded image, since it's a compressed representation. Don't be surprised when the tensor you get out doesn't look like pixel dimensions.
  • One-way door: edits you make here don't propagate back into a LATENT automatically. Plan your graph so the modified tensor has a path onward.

Installing it

This is a ComfyUI-Pt-Wrapper node:

  • ComfyUI Manager → search "ComfyUI-Pt-Wrapper" → Install → restart.
  • Or cd ComfyUI/custom_nodes && git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper and restart.

Expect a heavy first install - the pack's requirements include transformers, datasets, peft, accelerate, scikit-learn, scipy, gensim and sentencepiece. No model downloads needed here. It's a small education-focused pack by HowToSD with almost no community chatter, so when it breaks, check the repo's docs/reference/ first and open an issue if needed (PRs are auto-closed, per the README).

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
latentLATENT

Outputs (1)

NameTypeDescription
TENSORTENSOR