webfm-eval / kaggle /notebook_run4.py
zziang's picture
run4: unpack cached traj, seed teacher, 8000 steps
6711723 verified
Raw History Blame Contribute Delete
2.18 kB
"""Kaggle notebook body: does more training keep closing the held-out gap?
Step count has moved the numbers a lot already:
1500 steps a07 +4.15 pp a08 +1.95 pp loss 0.226
4000 steps a07 +2.30 pp a08 -0.51 pp loss 0.179
The loss was still falling at 4000, so this run doubles it to 8000 and does the
same evaluation. The two columns now answer different questions: if a07 keeps
improving the student is still underfitted; if a07 stalls or regresses while a08
improves, it is starting to memorise the six training voices, and the next lever
is data diversity rather than more steps.
Trajectories come from the cached traj.zip, so the 50-minute generation pass is
skipped unless the cache is missing.
"""
import os
import subprocess
import sys
from notebook_eval import BUNDLE, MODEL, ROOT, WEIGHTS, pull, stage_deps, stage_repo
BUNDLE_REPO = "idefinity/webfm-eval"
HOLDOUT = "a07"
EVAL_VOICES = "a07,a08"
TRAIN_STEPS = "8000"
def run(tag: str, extra: dict, gpu: int = 0) -> int:
env = dict(os.environ, WORK_ROOT=str(ROOT), HOLDOUT=HOLDOUT, **extra)
env["CUDA_VISIBLE_DEVICES"] = str(gpu)
env["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
log = open(ROOT / f"run4_{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"run4_{tag}.log").read_text()[-2500:])
return rc
def main() -> None:
stage_repo()
stage_deps()
pull(WEIGHTS, MODEL)
pull(BUNDLE_REPO, BUNDLE, repo_type="dataset")
if (BUNDLE / "traj.zip").exists():
print("using cached trajectories", flush=True)
else:
raise SystemExit("traj.zip missing from the bundle — regenerate before running")
if run("final", {"STAGE": "all", "TRAIN_STEPS": TRAIN_STEPS, "BATCH": "16",
"EVAL_VOICES": EVAL_VOICES}) != 0:
raise SystemExit("train/export/eval failed")
run("int4", {"STAGE": "eval_int4", "EVAL_VOICES": EVAL_VOICES})
if __name__ == "__main__":
main()