add onnx_ir/onnxscript deps and finish notebook
Browse files- kaggle/notebook_eval.py +2 -1
- kaggle/notebook_finish.py +60 -0
kaggle/notebook_eval.py
CHANGED
|
@@ -41,7 +41,8 @@ HF_MIRROR = "https://hf-mirror.com"
|
|
| 41 |
DEPS = [
|
| 42 |
"transformers==4.46.3", "tokenizers", "accelerate==1.3.0", "huggingface_hub",
|
| 43 |
"soundfile==0.12.1", "tqdm", "loguru", "x_transformers==2.9.2",
|
| 44 |
-
"diffusers==0.33.0", "onnxruntime", "onnx", "
|
|
|
|
| 45 |
]
|
| 46 |
ALIASES = {"cv2": "opencv-python", "yaml": "pyyaml", "PIL": "pillow", "sklearn": "scikit-learn"}
|
| 47 |
|
|
|
|
| 41 |
DEPS = [
|
| 42 |
"transformers==4.46.3", "tokenizers", "accelerate==1.3.0", "huggingface_hub",
|
| 43 |
"soundfile==0.12.1", "tqdm", "loguru", "x_transformers==2.9.2",
|
| 44 |
+
"diffusers==0.33.0", "onnxruntime", "onnx", "onnx_ir", "onnxscript",
|
| 45 |
+
"inflect", "einops", "packaging",
|
| 46 |
]
|
| 47 |
ALIASES = {"cv2": "opencv-python", "yaml": "pyyaml", "PIL": "pillow", "sklearn": "scikit-learn"}
|
| 48 |
|
kaggle/notebook_finish.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Finish the run: quantise and evaluate the student trained in the previous pass.
|
| 2 |
+
|
| 3 |
+
The training pass ended after ONNX export with
|
| 4 |
+
`ModuleNotFoundError: No module named 'onnx_ir'` — the quantiser moved to
|
| 5 |
+
onnx-ir. The weights are fine and sit in that pass's output, so this mounts them
|
| 6 |
+
and repeats only the two missing stages.
|
| 7 |
+
|
| 8 |
+
Nothing here regenerates trajectories or retrains.
|
| 9 |
+
"""
|
| 10 |
+
import glob
|
| 11 |
+
import os
|
| 12 |
+
import shutil
|
| 13 |
+
import subprocess
|
| 14 |
+
import sys
|
| 15 |
+
|
| 16 |
+
from notebook_eval import BUNDLE, MODEL, ROOT, WEIGHTS, pull, stage_deps, stage_repo
|
| 17 |
+
|
| 18 |
+
BUNDLE_REPO = "idefinity/webfm-eval"
|
| 19 |
+
EVAL_VOICES = "a08,a01"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def find_student() -> str | None:
|
| 23 |
+
hits = glob.glob("/kaggle/input/**/train/student4.pt", recursive=True)
|
| 24 |
+
hits += glob.glob("/kaggle/input/**/student4.pt", recursive=True)
|
| 25 |
+
print("student4.pt candidates:", hits)
|
| 26 |
+
return hits[0] if hits else None
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def run(stage: str, extra: dict | None = None) -> int:
|
| 30 |
+
env = dict(os.environ, WORK_ROOT=str(ROOT), STAGE=stage, **(extra or {}))
|
| 31 |
+
env["CUDA_VISIBLE_DEVICES"] = "0"
|
| 32 |
+
return subprocess.run([sys.executable, str(BUNDLE / "kaggle/train_voices.py")], env=env).returncode
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def main() -> None:
|
| 36 |
+
stage_repo()
|
| 37 |
+
stage_deps()
|
| 38 |
+
subprocess.run("pip install -q onnx_ir onnxscript", shell=True, check=False)
|
| 39 |
+
pull(WEIGHTS, MODEL)
|
| 40 |
+
pull(BUNDLE_REPO, BUNDLE, repo_type="dataset")
|
| 41 |
+
|
| 42 |
+
src = find_student()
|
| 43 |
+
if not src:
|
| 44 |
+
raise SystemExit("student4.pt not found — attach kkonda/webfm-train-voices as input")
|
| 45 |
+
dst = ROOT / "train"
|
| 46 |
+
dst.mkdir(parents=True, exist_ok=True)
|
| 47 |
+
shutil.copyfile(src, dst / "student4.pt")
|
| 48 |
+
print(f"using {src} ({os.path.getsize(src)/1e6:.0f} MB)")
|
| 49 |
+
|
| 50 |
+
print("== export + quantise ==", flush=True)
|
| 51 |
+
rc = run("export")
|
| 52 |
+
print("export rc", rc)
|
| 53 |
+
|
| 54 |
+
print("== eval ==", flush=True)
|
| 55 |
+
rc = run("eval", {"EVAL_VOICES": EVAL_VOICES})
|
| 56 |
+
print("eval rc", rc)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
main()
|