Nodes/ZF-ComfyUI-Helper/ZF Load Single Tensor Latent
ComfyUI Node

ZF Load Single Tensor Latent

Load .pt latents from disk — and read the pickle warning before you do

By Z-yaofang·Created 2 months ago·Updated 19 days ago· 1
ZF Load Single Tensor Latent
    • latent
    • file_path
    file_nameComfyPickle_latent_00001
    folder_path/root/Latent
    wan_has_reftrue
    wan_drop_lastfalse
    wan_loopedfalse

    If you've saved latents through certain video tooling - most notably kijai's WAN wrapper, which dumps .pt files named like ComfyPickle_latent_00001 - you've hit the wall where ComfyUI's built-in loaders won't touch them. LoadTensorLatentFromPath (display name "ZF Load Single Tensor Latent") is the pack's answer: it loads one PyTorch .pt or .pth latent straight from a folder path. The default file name is even ComfyPickle_latent_00001, which is a dead giveaway that WAN latent-continuation workflows are the intended audience.

    What it does under the hood

    The node runs torch.load on the file and then figures out what shape the content is in, so you don't have to:

    • A dict with a samples key - i.e. a full ComfyUI latent dict - is preserved as-is (and converted to float).
    • A dict with a latent_tensor key - the safetensors-style layout - gets wrapped as {"samples": ...}.
    • A bare tensor gets wrapped the same way: {"samples": tensor}.

    Either way you get a normal LATENT out of it, which is the whole trick - this node exists to normalize whatever weird-but-legit way someone saved the tensor into the one shape ComfyUI samplers and decoders expect. The WAN flags (wan_has_ref, wan_drop_last, wan_looped) get written into the latent dict too, same as the safetensors sibling node. Leave them at defaults unless your pipeline says otherwise.

    The safety note, stated plainly

    .pt files are Python pickles. Pickle can execute arbitrary code when loaded. This node deliberately loads with weights_only=False, which means a maliciously crafted file could run code on your machine. The README says it, and it's not lawyer-cover: only load tensor latents you created yourself or fully trust. Downloading a random .pt from a stranger's Google Drive and loading it here is how you get owned. This isn't FUD - it's the same warning that comes with any pickle-based loader in the ecosystem.

    The inputs and outputs that matter

    Inputs are minimal: file_name (extension optional, .pt is appended if you omit it), folder_path (defaults to /root/Latent - change it; that's a Linux-root path that won't exist on most machines), and the three WAN booleans. Outputs are latent and file_path (the resolved absolute path). The loader hashes the file for change-detection, so editing the file on disk and re-running picks up the new content without you having to bypass the node.

    Installing it

    Same story as the whole pack - this is a zero-dependency utility:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Z-yaofang/ZF-ComfyUI-Helper
    

    Restart ComfyUI, or install via ComfyUI Manager by searching ZF-ComfyUI-Helper. No models, no requirements.txt. It's listed under ZF Helper/Latent.

    Where people trip

    The biggest confusion is the extension rule: if you type ComfyPickle_latent_00001.pt the node is fine, but if you leave the extension off it appends .pt automatically - it does not try .pth as well. If your file is .pth, type the extension or the node can't find it. And again: that pickle warning isn't a footnote, it's the actual risk this node's one real downside.

    CategoryZF Helper/Latent

    Inputs (5)

    NameTypeDefaultDescription
    file_nameSTRINGComfyPickle_latent_00001
    folder_pathSTRING/root/Latent
    wan_has_refBOOLEANtrue
    wan_drop_lastBOOLEANfalse
    wan_loopedBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    latentLATENT
    file_pathSTRING