"""Add the interpolated H3 curve embedding to the direct-runner input capture.""" from pathlib import Path model = Path("/opt/ComfyUI/comfy/ldm/minimax/model.py") source = model.read_text(encoding="utf-8") old = 'torch.save({"hidden": h.detach().cpu(), "timesteps": t_vals.detach().cpu(), "position_ids": layout.position_ids, "segments": mod_segments}, os.path.join(capture_dir, "input.pt"))' new = 'torch.save({"hidden": h.detach().cpu(), "timesteps": t_vals.detach().cpu(), "t_emb": t_emb.detach().cpu(), "position_ids": layout.position_ids, "segments": mod_segments}, os.path.join(capture_dir, "input.pt"))' if source.count(old) == 1: source = source.replace(old, new) elif new not in source: raise RuntimeError("Unable to locate the H3 input capture payload.") model.write_text(source, encoding="utf-8") print("Applied H3 curve embedding capture patch.")