From 1cfe7f1932a6b5eaada2f41240961b29bc7241f9 Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Fri, 17 Jul 2026 09:12:31 +0000 Subject: [PATCH] Avoid serializing runtime timeline tensors --- ltx_director.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/ltx_director.py b/ltx_director.py index ff089f3..aa0dd87 100644 --- a/ltx_director.py +++ b/ltx_director.py @@ -208,6 +208,27 @@ def _build_runtime_timeline_payload(external_timeline, frame_rate: float) -> tup return tdata, " | ".join(local_prompts), ",".join(segment_lengths), duration_seconds, duration_frames +def _make_json_safe(value): + """Return a JSON-serializable copy of runtime data by stripping live tensor payloads.""" + if isinstance(value, torch.Tensor): + return None + if isinstance(value, dict): + cleaned = {} + for key, item in value.items(): + safe_item = _make_json_safe(item) + if safe_item is not None: + cleaned[key] = safe_item + return cleaned + if isinstance(value, (list, tuple)): + cleaned = [] + for item in value: + safe_item = _make_json_safe(item) + if safe_item is not None: + cleaned.append(safe_item) + return cleaned + return value + + def _compute_signal_peaks(samples: np.ndarray, num_peaks: int = PEAK_BUCKETS) -> list[float]: if samples.size == 0: return [0.0] * num_peaks @@ -2086,19 +2107,24 @@ class LTXDirector(io.ComfyNode): merged_tdata["segments"] = external_tdata["segments"] merged_tdata.setdefault("motionSegments", existing_tdata.get("motionSegments", [])) merged_tdata.setdefault("audioSegments", existing_tdata.get("audioSegments", [])) - timeline_data = json.dumps(merged_tdata) + timeline_data = json.dumps(_make_json_safe(merged_tdata)) local_prompts = external_local_prompts segment_lengths = external_segment_lengths if duration is None: duration_seconds = external_duration_seconds duration_frames = external_duration_frames + else: + merged_tdata = None # Parse timeline data - try: - tdata = _safe_json_loads(timeline_data) - except Exception as e: - log.error(f"[LTXDirector] execute timeline_data parse error: {e}") - tdata = {} + if merged_tdata is not None: + tdata = merged_tdata + else: + try: + tdata = _safe_json_loads(timeline_data) + except Exception as e: + log.error(f"[LTXDirector] execute timeline_data parse error: {e}") + tdata = {} # --- Automation overrides (connection-only inputs, in SECONDS) --- # When wired, these take precedence over the panel/timeline values.