zziang commited on
Commit
343fa34
·
verified ·
1 Parent(s): b42b672

run 3: 4000 steps, keep traj cache

Browse files
Files changed (1) hide show
  1. kaggle/notebook_learn.py +81 -0
kaggle/notebook_learn.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Kaggle notebook body: is the student undertrained, or unable to generalise?
2
+
3
+ Run 2 landed at +3.05 pp overall: +1.95 pp on a voice it trained on (a08) and
4
+ +4.15 pp on the held-out one (a07). The CUDA source confirms the CFG convention
5
+ matches our training target exactly, so the recipe is not the suspect. What is:
6
+ the loss was still falling at step 1500, and 1500 x batch 16 = 24,000 samples
7
+ against roughly 28,800 frames of data — under one epoch.
8
+
9
+ So this run changes one thing: 4,000 steps. Same six voices, same a07 holdout,
10
+ same evaluation.
11
+
12
+ It also packs the trajectory cache into traj.zip so the next ablation does not
13
+ have to spend 50 minutes regenerating it.
14
+
15
+ traj 6 voices x 120 texts, 2 GPUs ~50 min
16
+ pack zip the cache ~2 min
17
+ train 4-step, 4000 steps ~65 min
18
+ eval a07 + a08, teacher vs student ~15 min
19
+ int4 same cells through int4 ~12 min
20
+ """
21
+ import os
22
+ import subprocess
23
+ import sys
24
+ import time
25
+
26
+ from notebook_eval import BUNDLE, MODEL, ROOT, WEIGHTS, pull, stage_deps, stage_repo
27
+
28
+ BUNDLE_REPO = "idefinity/webfm-eval"
29
+ SHARDS = [["a01", "a03", "a04"], ["a05", "a06", "a08"]]
30
+ HOLDOUT = "a07"
31
+ EVAL_VOICES = "a07,a08"
32
+ TRAIN_STEPS = "4000"
33
+
34
+
35
+ def run(tag: str, extra: dict, gpu: int = 0) -> int:
36
+ env = dict(os.environ, WORK_ROOT=str(ROOT), HOLDOUT=HOLDOUT, **extra)
37
+ env["CUDA_VISIBLE_DEVICES"] = str(gpu)
38
+ env["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
39
+ log = open(ROOT / f"learn_{tag}.log", "w")
40
+ p = subprocess.Popen([sys.executable, str(BUNDLE / "kaggle/train_voices.py")],
41
+ env=env, stdout=log, stderr=subprocess.STDOUT, cwd=str(ROOT))
42
+ rc = p.wait()
43
+ print(f"[{tag}] rc={rc}", flush=True)
44
+ if rc != 0:
45
+ print((ROOT / f"learn_{tag}.log").read_text()[-2500:])
46
+ return rc
47
+
48
+
49
+ def main() -> None:
50
+ stage_repo()
51
+ stage_deps()
52
+ pull(WEIGHTS, MODEL)
53
+ pull(BUNDLE_REPO, BUNDLE, repo_type="dataset")
54
+
55
+ print("== trajectories (6 voices, a07 held out) ==", flush=True)
56
+ procs = []
57
+ for gpu, shard in enumerate(SHARDS):
58
+ env = dict(os.environ, WORK_ROOT=str(ROOT), STAGE="traj", HOLDOUT=HOLDOUT,
59
+ VOICES=",".join(shard), CUDA_VISIBLE_DEVICES=str(gpu))
60
+ log = open(ROOT / f"traj_gpu{gpu}.log", "w")
61
+ procs.append(subprocess.Popen([sys.executable, str(BUNDLE / "kaggle/train_voices.py")],
62
+ env=env, stdout=log, stderr=subprocess.STDOUT, cwd=str(ROOT)))
63
+ while any(p.poll() is None for p in procs):
64
+ time.sleep(60)
65
+ n = len(list((ROOT / "train/traj").glob("*/*.pt")))
66
+ print(f"[{time.strftime('%H:%M')}] trajectories={n}", flush=True)
67
+ print("traj exits:", [p.returncode for p in procs])
68
+
69
+ # Keep the cache: regenerating it costs 50 minutes per experiment.
70
+ subprocess.run(f"cd {ROOT}/train && zip -qr ../traj.zip traj", shell=True, check=False)
71
+ print("cache size:", (ROOT / "traj.zip").stat().st_size // 1024 // 1024, "MB", flush=True)
72
+
73
+ if run("final", {"STAGE": "all", "TRAIN_STEPS": TRAIN_STEPS, "BATCH": "16",
74
+ "EVAL_VOICES": EVAL_VOICES}) != 0:
75
+ raise SystemExit("train/export/eval failed")
76
+
77
+ run("int4", {"STAGE": "eval_int4", "EVAL_VOICES": EVAL_VOICES})
78
+
79
+
80
+ if __name__ == "__main__":
81
+ main()