Pt To Latent
Re-badge a tensor as a latent — no VAE involved
- tens
- LATENT
Let's get the misleading part out of the way: Pt To Latent does not encode anything. It takes a TENSOR from the pack and wraps it in the {"samples": ...} structure ComfyUI calls a LATENT. That's it - a re-labeling, not a transformation. Which makes it both simpler than it looks and more dangerous than it looks.
ComfyUI-Pt-Wrapper (HowToSD's 200-node PyTorch training pack, spin-off of ComfyUI-Data-Analysis) does most of its work in its own TENSOR type. But ComfyUI's native sampler and VAE nodes speak LATENT, a dict with a samples key. When you want to hand something from the pack's world to ComfyUI's native world, this node is the handoff - think of it as an adapter plug, not a processor.
How it works. One input, tens; one output, LATENT. The implementation literally returns {"samples": tens}. The tensor just gets packaged.
The sharp edge: because it's a pure cast, whatever you feed it is now a "latent" that ComfyUI's VAE Decoder will happily try to decode. If your tensor isn't actually a latent-shaped sample (i.e. something a VAE decoder can turn into pixels), you'll get garbage images or shape errors - and the error messages will be confusing, because ComfyUI assumes the LATENT it's handed is real. The honest use case is when a pack pipeline genuinely produces a latent-like tensor - say, you trained or fine-tuned an encoder inside the pack and want to sample from it in the normal ComfyUI flow - and you need a way to get that tensor into VAE-land. If your goal was just "convert an image to a latent," that's what the standard VAE Encode node is for; this node is the wrong tool and will not give you a useful latent from a plain image.
Where it fits. It's the return bridge. Pt From Image Transpose takes ComfyUI images into the pack; Pt To Latent hands pack tensors back to native ComfyUI. Pair it with a VAE Decode node on the far side and you've closed the loop between a pack-built pipeline and the image world.
Install: ComfyUI Manager → "ComfyUI-Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
then restart. No model downloads; the pack's heavy requirements.txt (transformers, sklearn, sentencepiece, pinned gensim) is the only setup cost.
Troubleshooting: VAE Decode produces garbage or errors - your tensor isn't a real latent; this node casts, it doesn't conjure. Shape mismatch from the VAE - latents have specific channel counts per model (4 for SD1.5-era models, 16 for Flux); a tensor of the wrong channel count will explode or smear. If the node you wired it to rejects a LATENT that "looks fine," check that your tensor actually has the batch dimension ComfyUI expects. When in doubt, ask whether your tensor would survive being decoded - if the answer is "I don't know," the answer is probably no.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| tens | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |