File size: 4,617 Bytes
4af42ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
#!/bin/bash
# Builds ~/msm_run/release (same layout as ERCBench-ShotStream-400). Fails if any episode is invalid.
set -euo pipefail
W=~/msm_run; R=$W/release; M=$W/MultiShotMaster
rm -rf $R; mkdir -p $R/inputs $R/runs/logs $R/runs/scripts
~/shotstream_run/venv/bin/python $W/finalize.py | tee $W/logs/finalize.log   # needs PyAV + numpy (not in the MSM venv)
cp -r $W/inputs/json $W/inputs/all_200.csv $R/inputs/
cp $W/inference_episode.diff $R/runs/
cp $W/logs/worker_gpu*.log $W/logs/tokens_gpu*.jsonl $W/logs/finalize.log $R/runs/logs/
mkdir -p $R/runs/logs/aborted_before_owner_reorder && cp $W/logs/aborted_parallel/* $R/runs/logs/aborted_before_owner_reorder/
python3 - <<'EOF'
import csv, os
W = os.path.expanduser("~/msm_run")
used = {r["gpu"] for r in csv.DictReader(open(f"{W}/release/runs/timing.csv"))}
rows = [r for r in csv.reader(open(os.path.expanduser("~/gen_common/gpu_mem.csv"))) if len(r) > 1 and r[1].strip() in used]
with open(f"{W}/release/runs/logs/gpu_mem.csv", "w", newline="") as f:
    w = csv.writer(f); w.writerow(["timestamp_utc", "gpu", "memory_used", "utilization"]); w.writerows(rows)
EOF
cp $W/finalize.py $W/package_release.sh $W/run_worker.sh ~/gen_common/make_inputs.py ~/gen_common/tok_hook_run.py \
   $M/inference_episode.py ~/shotstream_run/scripts/verify_dataset.py $R/runs/scripts/
$W/venv/bin/pip freeze > $R/runs/pip_freeze.txt
$W/venv/bin/python - <<'EOF'
import csv, json, os, subprocess, sys, torch, torchvision, flash_attn, imageio
W = os.path.expanduser("~/msm_run")
t = list(csv.DictReader(open(f"{W}/release/runs/timing.csv")))
drv = subprocess.run(["nvidia-smi", "--query-gpu=driver_version", "--format=csv,noheader"], capture_output=True, text=True).stdout.split()[0]
offs = [int(o) for r in t for o in r["cut_offsets"].split()]
m = {
 "multishotmaster": {"repo": "https://github.com/KlingTeam/MultiShotMaster", "commit": "1df812dda262639e4a3ca6e4a1da9000b0a8e124"},
 "models": {"KlingTeam/MultiShotMaster (1.3B: MultiShotMaster_model_1.3B.safetensors + Wan2.1-T2V-1.3B components)": "5be642763b970d7e76a93958a122c459caa36681"},
 "prompt_dataset": {"repo": "BlueSourceJY/ERCBench-StoryMem-400", "revision": "c96eccaf5f9de67181aa6bdcd22fae85252d5821",
    "zip": "storymem_inputs_400.zip", "zip_sha256": "50ac67c03afc261a0228fc894596832676f4126ebf1a0edc5bf2628decc71c2f",
    "episode_list": "storymem_inputs/priority_200.ids.txt", "files_verified": 2045, "prompts_verified": 1000},
 "software": {"python": sys.version.split()[0], "torch": torch.__version__, "torch_cuda": torch.version.cuda,
    "torchvision": torchvision.__version__, "flash_attn": flash_attn.__version__, "imageio": imageio.__version__,
    "cudnn": torch.backends.cudnn.version(), "nvidia_driver": drv},
 "attention_backend": "FlashAttention-2 (flash_attn 2.8.3.post2, prebuilt wheel)",
 "video_writer": "diffsynth.utils.data.save_video(fps=15, quality=5) unchanged",
 "gpu": {"model": "NVIDIA H200", "used": sorted({int(r["gpu"]) for r in t}),
         "processes": "one process per GPU; episodes claimed in priority order (atomic mkdir claims)"},
 "generation_settings": {"script": "infer_multishot.py -> inference_episode.py (runs/inference_episode.diff)",
    "model": "1.3B (checkpoints/model_configs/model_path_1.3B.json)", "resolution": "832x480",
    "frames_per_shot": 75, "shot_groups": "[[0,75],[75,150],...] - whole episode generated in one pass",
    "fps": 15, "seed": 42, "seed_policy": "code default, set before every episode",
    "num_inference_steps": 50, "cfg_scale": 5.0, "sigma_shift": 5.0, "tiled": True,
    "text_encoder_input": "'Story:  Now: <shot prompt>' (code template with global_caption = '')",
    "negative_prompt": "code default (Chinese Wan negative prompt), one per shot"},
 "measured_cuts": {"definition": "frame with the strongest mean grayscale change in [configured-2, configured+8]",
    "offset_counts": {str(o): offs.count(o) for o in sorted(set(offs))}},
 "episodes": len(t), "shots": sum(int(r["shot_count"]) for r in t),
 "generation_seconds_total": round(sum(float(r["seconds"]) for r in t), 1),
 "start_dubai": min(r["start_dubai"] for r in t), "end_dubai": max(r["end_dubai"] for r in t),
}
json.dump(m, open(f"{W}/release/runs/run_manifest.json", "w"), indent=2)
print("manifest ok", m["episodes"], m["shots"], m["start_dubai"], m["end_dubai"], m["measured_cuts"]["offset_counts"])
EOF
cp $W/README_release.md $R/README.md
n_mp4=$(find $R/episodes -name episode.mp4 | wc -l); n_md=$(find $R/episodes -name metadata.json | wc -l)
echo "release: $n_mp4 mp4, $n_md metadata.json, $(du -sh $R | cut -f1)"
[ "$n_mp4" = 200 ] && [ "$n_md" = 200 ]