File size: 2,148 Bytes
84b07f4 | 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 62 | """Kaggle notebook body: teach the student the whisper voice.
Radio v2 showed the split cleanly: teacher 0.22 on the whisper line, student
1.00. a09 was added after training, so the student has never seen it. This run
adds 120 trajectories for a09 to the cached six voices and retrains at the same
4000 steps, then evaluates a09 against a08 as an in-distribution control.
Trajectories are unpacked from the cache first, so the a09 pass appends to the
same directory instead of replacing it.
"""
import os
import subprocess
import sys
import time
import zipfile
from notebook_eval import BUNDLE, MODEL, ROOT, WEIGHTS, pull, stage_deps, stage_repo
BUNDLE_REPO = "idefinity/webfm-eval"
TRAJ = ROOT / "train/traj"
def run(tag: str, extra: dict, gpu: int = 0) -> int:
env = dict(os.environ, WORK_ROOT=str(ROOT), **extra)
env["CUDA_VISIBLE_DEVICES"] = str(gpu)
env["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
log = open(ROOT / f"r3_{tag}.log", "w")
p = subprocess.Popen([sys.executable, str(BUNDLE / "kaggle/train_voices.py")],
env=env, stdout=log, stderr=subprocess.STDOUT, cwd=str(ROOT))
rc = p.wait()
print(f"[{tag}] rc={rc}", flush=True)
if rc != 0:
print((ROOT / f"r3_{tag}.log").read_text()[-2500:])
return rc
def main() -> None:
stage_repo()
stage_deps()
pull(WEIGHTS, MODEL)
pull(BUNDLE_REPO, BUNDLE, repo_type="dataset")
TRAJ.mkdir(parents=True, exist_ok=True)
cache = BUNDLE / "traj.zip"
if cache.exists():
with zipfile.ZipFile(cache) as z:
z.extractall(ROOT / "train")
print("unpacked cache:", len(list(TRAJ.glob("*/*.pt"))), "files", flush=True)
# One voice, one GPU: ~120 generations.
if run("a09", {"STAGE": "traj", "VOICES": "a09"}) != 0:
raise SystemExit("a09 trajectories failed")
print("total trajectories:", len(list(TRAJ.glob("*/*.pt"))), flush=True)
if run("train", {"STAGE": "all", "TRAIN_STEPS": "4000", "BATCH": "16",
"EVAL_VOICES": "a09,a08"}) != 0:
raise SystemExit("train/eval failed")
if __name__ == "__main__":
main()
|