From f8b19994a802b87ebef425a5d7f15adf27dd3830 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 23 Mar 2026 00:08:40 +0100 Subject: [PATCH] Fix load latent compatibility with ComfyUI-saved latent files ComfyUI saves latents under key 'latent_tensor', remap to 'samples' so downstream nodes get the expected LATENT dict format. Co-Authored-By: Claude Opus 4.6 --- latent_node.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/latent_node.py b/latent_node.py index 6b19b2e..160291d 100644 --- a/latent_node.py +++ b/latent_node.py @@ -77,11 +77,17 @@ class LoadLatentAbsolute: def load(self, path): path = os.path.expanduser(path) - samples = safetensors.torch.load_file(path, device="cpu") + raw = safetensors.torch.load_file(path, device="cpu") with safetensors.safe_open(path, framework="pt") as f: meta = f.metadata() + # ComfyUI's built-in save latent uses key "latent_tensor" → remap to "samples" + if "latent_tensor" in raw and "samples" not in raw: + raw["samples"] = raw.pop("latent_tensor") + + samples = dict(raw) + # Restore original devices if meta and "devices" in meta: devices = json.loads(meta["devices"])