From e5ca7a12243e5523887d620b3ff0a166563a96c8 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 23 Mar 2026 00:06:10 +0100 Subject: [PATCH] Fix latent save node to skip non-serializable values in metadata LATENT dicts can contain nested tensors or other non-JSON-serializable objects. Filter them out instead of crashing on json.dumps. Co-Authored-By: Claude Opus 4.6 --- latent_node.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/latent_node.py b/latent_node.py index 177b812..6b19b2e 100644 --- a/latent_node.py +++ b/latent_node.py @@ -22,6 +22,14 @@ class SaveLatentAbsolute: CATEGORY = "latent" OUTPUT_NODE = True + @staticmethod + def _is_json_serializable(value): + try: + json.dumps(value) + return True + except (TypeError, ValueError): + return False + def save(self, samples, path, overwrite=False): path = os.path.expanduser(path) if not path.endswith(".latent"): @@ -42,7 +50,7 @@ class SaveLatentAbsolute: if isinstance(value, torch.Tensor): devices[key] = str(value.device) tensors[key] = value.contiguous() - else: + elif self._is_json_serializable(value): non_tensors[key] = value metadata = {"devices": json.dumps(devices)}