File size: 2,911 Bytes
d0486d0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | --- interactive_inference.py 2026-11-15 23:10:27.217313570 +0000
+++ interactive_episode.py 2026-11-15 23:57:58.203583286 +0000
@@ -178,6 +178,22 @@
if dist.is_initialized():
dist.barrier()
+# [episode run] episode_id for each JSONL line (same order as MultiTextDataset), timing/skip helpers
+import json as _json, datetime as _dt, subprocess as _sp
+with open(config.data_path, encoding="utf-8") as _f:
+ _episode_ids = [_json.loads(l)["episode_id"] for l in _f if l.strip()]
+assert len(_episode_ids) == len(dataset)
+def _ts():
+ return _dt.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
+def _nframes(path):
+ r = _sp.run(["ffprobe", "-v", "error", "-count_frames", "-select_streams", "v:0", "-show_entries",
+ "stream=nb_read_frames", "-of", "csv=p=0", path], capture_output=True, text=True)
+ try:
+ return int(r.stdout.strip())
+ except ValueError:
+ return -1
+_want_frames = 4 * config.num_output_frames - 3
+
# ----------------------------- Inference loop -----------------------------
for i, batch_data in tqdm(enumerate(dataloader), disable=(local_rank != 0)):
idx = batch_data["idx"].item()
@@ -195,6 +211,15 @@
dtype=torch.bfloat16,
)
+ # [episode run] skip finished outputs (noise is still drawn above, so the RNG stream matches an uninterrupted run)
+ episode_id = _episode_ids[idx]
+ _out = os.path.join(config.output_folder, f"{episode_id}.mp4")
+ if os.path.exists(_out) and _nframes(_out) == _want_frames:
+ print(f"{_ts()} [EPISODE] skip {episode_id} (exists, {_want_frames} frames)", flush=True)
+ continue
+ print(f"{_ts()} [EPISODE] start {episode_id} seed={config.seed} (set once per process)", flush=True)
+ torch.cuda.reset_peak_memory_stats()
+
video = pipeline.inference(
noise=sampled_noise,
text_prompts_list=prompts_list,
@@ -218,13 +243,16 @@
model_type = "regular"
for seed_idx in range(config.num_samples):
- if config.save_with_index:
+ if True: # [episode run] name output by episode_id
+ output_path = _out
+ elif config.save_with_index:
output_path = os.path.join(config.output_folder, f"rank{rank}-{idx}-{seed_idx}_{model_type}.mp4")
else:
# Use the first prompt segment as the filename prefix to avoid overly long names
short_name = prompts_list[0][0][:100].replace("/", "_")
output_path = os.path.join(config.output_folder, f"rank{rank}-{short_name}-{seed_idx}_{model_type}.mp4")
write_video(output_path, current_video[seed_idx].to(torch.uint8), fps=16)
+ print(f"{_ts()} [EPISODE] saved {episode_id} -> {output_path} frames={current_video.shape[1]} peak_mem_gb={torch.cuda.max_memory_allocated()/2**30:.1f}", flush=True)
if config.inference_iter != -1 and i >= config.inference_iter:
break
|