"""Job bootstrap for the SQMM Cello reproduction (arXiv 2611.04574, Table 1). Assembles the code tree (patched files from the Hub dataset repo + the audio asset from the author repo at the pinned commit), runs all 8 configs x 5 runs, uploads results to the dataset repo. """ import os import subprocess import sys import urllib.request from huggingface_hub import HfApi, hf_hub_download REPO = "Fred-Rcky/sqmm-cello-reproduction" ROOT = os.path.expanduser("~/sqmm") PIN = "a47b84669edb0c16c9ff8370c3b6fbba25010efe" WAV_URL = f"https://raw.githubusercontent.com/Kiiwii10/SQMM/{PIN}/sound/gt_bach.wav" CODE_FILES = [ "main.py", "model.py", "train.py", "baselines.py", "datasets.py", "losses.py", "run_all.py", ] os.makedirs(os.path.join(ROOT, "sound"), exist_ok=True) # 1. code from the dataset repo for fname in CODE_FILES: path = hf_hub_download(repo_id=REPO, repo_type="dataset", filename=f"code/{fname}") dest = os.path.join(ROOT, fname) with open(path, "rb") as src, open(dest, "wb") as dst: dst.write(src.read()) print(f"[boot] fetched {fname}", flush=True) # 2. audio asset from the author repo at the pinned commit wav_dest = os.path.join(ROOT, "sound", "gt_bach.wav") urllib.request.urlretrieve(WAV_URL, wav_dest) print(f"[boot] fetched gt_bach.wav ({os.path.getsize(wav_dest)} bytes)", flush=True) # sanity: dataset loads, param counts resolve sys.path.insert(0, ROOT) os.chdir(ROOT) import datasets # noqa: E402 import baselines # noqa: E402 coords, targets = datasets.load_cello() assert coords.shape == (1, 1000, 1), coords.shape assert targets.shape == (1, 1000, 1), targets.shape for name, target in baselines.TARGET_PARAMS.items(): model, lr = baselines.build_baseline(name, coord_dim=1, out_features=1) count = sum(p.numel() for p in model.parameters() if p.requires_grad) status = "OK" if count == target else f"MISMATCH (target {target})" print(f"[boot] {name}: {count} params {status}", flush=True) assert status == "OK", f"{name} param count {count} != {target}" print("[boot] sanity checks passed", flush=True) # 3. run everything res = subprocess.run([sys.executable, "run_all.py"], cwd=ROOT) if res.returncode != 0: print("[boot] run_all.py FAILED", flush=True) sys.exit(1) # 4. upload results out_dir = os.path.join(ROOT, "out") api = HfApi(token=os.environ.get("HF_TOKEN")) api.upload_folder( repo_id=REPO, repo_type="dataset", folder_path=out_dir, path_in_repo="results", ) print("[boot] results uploaded", flush=True)