webfm-eval / kaggle /notebook_finish.py
zziang's picture
eval: load student after freeing teacher, a08 only
2d691c1 verified
Raw History Blame Contribute Delete
2.18 kB
"""Finish the run: quantise and evaluate the student trained in the previous pass.
The training pass ended after ONNX export with
`ModuleNotFoundError: No module named 'onnx_ir'` — the quantiser moved to
onnx-ir. The weights are fine and sit in that pass's output, so this mounts them
and repeats only the two missing stages.
Nothing here regenerates trajectories or retrains.
"""
import glob
import os
import shutil
import subprocess
import sys
from notebook_eval import BUNDLE, MODEL, ROOT, WEIGHTS, pull, stage_deps, stage_repo
BUNDLE_REPO = "idefinity/webfm-eval"
EVAL_VOICES = "a08"
def find_student() -> str | None:
local = BUNDLE / "student4.pt"
if local.exists():
return str(local)
hits = glob.glob("/kaggle/input/**/train/student4.pt", recursive=True)
hits += glob.glob("/kaggle/input/**/student4.pt", recursive=True)
print("student4.pt candidates:", hits)
return hits[0] if hits else None
def run(stage: str, extra: dict | None = None) -> int:
env = dict(os.environ, WORK_ROOT=str(ROOT), STAGE=stage, **(extra or {}))
env["CUDA_VISIBLE_DEVICES"] = "0"
env["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
return subprocess.run([sys.executable, str(BUNDLE / "kaggle/train_voices.py")], env=env).returncode
def main() -> None:
stage_repo()
stage_deps()
subprocess.run("pip install -q onnx_ir onnxscript", shell=True, check=False)
pull(WEIGHTS, MODEL)
pull(BUNDLE_REPO, BUNDLE, repo_type="dataset")
src = find_student()
if not src:
raise SystemExit("student4.pt not found — attach kkonda/webfm-train-voices as input")
dst = ROOT / "train"
dst.mkdir(parents=True, exist_ok=True)
shutil.copyfile(src, dst / "student4.pt")
print(f"using {src} ({os.path.getsize(src)/1e6:.0f} MB)")
print("== export + quantise ==", flush=True)
rc = run("export")
print("export rc", rc)
if rc != 0:
raise SystemExit("export/quantise failed")
print("== eval ==", flush=True)
rc = run("eval", {"EVAL_VOICES": EVAL_VOICES})
print("eval rc", rc)
if rc != 0:
raise SystemExit("eval failed")
if __name__ == "__main__":
main()