train the student on the whisper voice
Browse files- kaggle/notebook_radio3.py +61 -0
kaggle/notebook_radio3.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Kaggle notebook body: teach the student the whisper voice.
|
| 2 |
+
|
| 3 |
+
Radio v2 showed the split cleanly: teacher 0.22 on the whisper line, student
|
| 4 |
+
1.00. a09 was added after training, so the student has never seen it. This run
|
| 5 |
+
adds 120 trajectories for a09 to the cached six voices and retrains at the same
|
| 6 |
+
4000 steps, then evaluates a09 against a08 as an in-distribution control.
|
| 7 |
+
|
| 8 |
+
Trajectories are unpacked from the cache first, so the a09 pass appends to the
|
| 9 |
+
same directory instead of replacing it.
|
| 10 |
+
"""
|
| 11 |
+
import os
|
| 12 |
+
import subprocess
|
| 13 |
+
import sys
|
| 14 |
+
import time
|
| 15 |
+
import zipfile
|
| 16 |
+
|
| 17 |
+
from notebook_eval import BUNDLE, MODEL, ROOT, WEIGHTS, pull, stage_deps, stage_repo
|
| 18 |
+
|
| 19 |
+
BUNDLE_REPO = "idefinity/webfm-eval"
|
| 20 |
+
TRAJ = ROOT / "train/traj"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def run(tag: str, extra: dict, gpu: int = 0) -> int:
|
| 24 |
+
env = dict(os.environ, WORK_ROOT=str(ROOT), **extra)
|
| 25 |
+
env["CUDA_VISIBLE_DEVICES"] = str(gpu)
|
| 26 |
+
env["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
|
| 27 |
+
log = open(ROOT / f"r3_{tag}.log", "w")
|
| 28 |
+
p = subprocess.Popen([sys.executable, str(BUNDLE / "kaggle/train_voices.py")],
|
| 29 |
+
env=env, stdout=log, stderr=subprocess.STDOUT, cwd=str(ROOT))
|
| 30 |
+
rc = p.wait()
|
| 31 |
+
print(f"[{tag}] rc={rc}", flush=True)
|
| 32 |
+
if rc != 0:
|
| 33 |
+
print((ROOT / f"r3_{tag}.log").read_text()[-2500:])
|
| 34 |
+
return rc
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def main() -> None:
|
| 38 |
+
stage_repo()
|
| 39 |
+
stage_deps()
|
| 40 |
+
pull(WEIGHTS, MODEL)
|
| 41 |
+
pull(BUNDLE_REPO, BUNDLE, repo_type="dataset")
|
| 42 |
+
|
| 43 |
+
TRAJ.mkdir(parents=True, exist_ok=True)
|
| 44 |
+
cache = BUNDLE / "traj.zip"
|
| 45 |
+
if cache.exists():
|
| 46 |
+
with zipfile.ZipFile(cache) as z:
|
| 47 |
+
z.extractall(ROOT / "train")
|
| 48 |
+
print("unpacked cache:", len(list(TRAJ.glob("*/*.pt"))), "files", flush=True)
|
| 49 |
+
|
| 50 |
+
# One voice, one GPU: ~120 generations.
|
| 51 |
+
if run("a09", {"STAGE": "traj", "VOICES": "a09"}) != 0:
|
| 52 |
+
raise SystemExit("a09 trajectories failed")
|
| 53 |
+
print("total trajectories:", len(list(TRAJ.glob("*/*.pt"))), flush=True)
|
| 54 |
+
|
| 55 |
+
if run("train", {"STAGE": "all", "TRAIN_STEPS": "4000", "BATCH": "16",
|
| 56 |
+
"EVAL_VOICES": "a09,a08"}) != 0:
|
| 57 |
+
raise SystemExit("train/eval failed")
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
if __name__ == "__main__":
|
| 61 |
+
main()
|