ComfyUI Node

LoadTorchTensor

Pull a saved .pt tensor back into your ComfyUI graph

By TashaSkyUp·Created about a year ago·Updated about a year ago· 1
LoadTorchTensor
    • TORCH_TENSOR
    file/somewhere/some.pt

    You saved a tensor with SaveTorchTensor (or anyone's torch.save) and now you want it back in the graph. LoadTorchTensor is that reverse operation: give it a file path and it runs torch.load(file) and hands you the result as a TORCH_TENSOR. It's the persistence side of this pack's tensor lifecycle - save your features, labels, or processed data to disk, load them in a fresh workflow, and skip re-downloading or recomputing everything.

    It's a genuinely useful node for ML-in-ComfyUI work because torch.load/torch.save is the native PyTorch serialization format - the round-trip is lossless, fast, and dtype-exact, unlike saving to CSV or PNG. Anything the pack (or any torch code) saved as a .pt file comes back byte-for-byte the same.

    How it works

    The file input is a path string - the default is the placeholder /somewhere/some.pt, which you must replace with a real path. The node calls torch.load(file) and returns the tensor. Note there are no browse widgets or ComfyUI folder_paths integration here - you're typing a path your ComfyUI process can actually read. Relative paths resolve against ComfyUI's working directory, which can surprise you; an absolute path removes the guesswork.

    Input and output

    • file (STRING) - the .pt file path to load.
    • Output: one TORCH_TENSOR.

    Install

    ComfyUI Manager, search "EternalKernel PyTorch Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TashaSkyUp/EternalKernelPytorchNodes
    cd EternalKernelPytorchNodes
    pip install -r requirements.txt
    

    Restart ComfyUI; node under ETK/pytorch. No model files. Requirements are the standard ComfyUI stack plus scipy, scikit-learn, transformers, einops.

    Common issues

    • File not found / wrong working directory. The #1 complaint. Relative paths resolve against where you launched ComfyUI, not where the node "looks." Use an absolute path like C:/data/my_tensor.pt or /home/user/data/my_tensor.pt to be sure.
    • Loading non-tensor objects. This node doesn't validate what's in the file. torch.load on a state dict or a whole model returns that object instead of a tensor, and you'll only notice when a tensor node downstream misbehaves. Make sure the file actually contains a tensor (i.e. it was saved with torch.save(tensor, ...), as SaveTorchTensor does).
    • Path typos and slashes. Windows backslashes in a JSON workflow can escape badly. Forward slashes work everywhere.
    • Untrusted files. torch.load will happily deserialize arbitrary pickles. Loading a .pt file you didn't create runs code from whoever made it - standard pickle-safety warning, and this node doesn't add weights_only=True protection. Load only your own files.

    It's a quiet pack with no tutorials, but this node is a one-line wrapper around torch.load, so PyTorch's serialization docs are the authority. And the pack-wide quirk - it patches ComfyUI's validator to ignore return_type_mismatch - means a mismatched wire may not error out; verify types yourself.

    CategoryETK/pytorch

    Inputs (1)

    NameTypeDefaultDescription
    fileSTRING/somewhere/some.pt

    Outputs (1)

    NameTypeDescription
    TORCH_TENSORTORCH_TENSOR