ptr-recurrent-depth / smoke_gpu.py
eac123's picture
GPU smoke wrapper
38326d2 verified
Raw History Blame Contribute Delete
1.58 kB
"""GPU smoke-job wrapper: pulls the code from the Hub repo, runs a short
train.py (with trackio + checkpoint upload) and an evaluate.py sweep, and
prints the results. Run via `uv` with deps torch, numpy, huggingface_hub,
trackio."""
import json
import os
import subprocess
import sys
REPO = "eac123/ptr-recurrent-depth"
SPACE_ID = os.environ["TRACKIO_SPACE_ID"]
def sh(cmd):
print("+", " ".join(cmd), flush=True)
subprocess.run(cmd, check=True)
from huggingface_hub import snapshot_download
snapshot_download(repo_id=REPO, repo_type="model",
allow_patterns=["*.py", "ptr/*.py"], local_dir=".")
sys.path.insert(0, os.getcwd())
sh([sys.executable, "train.py", "--arch", "rec", "--depth", "1",
"--iters", "4", "--seed", "0", "--run-name", "smoke-t4", "--steps", "300",
"--eval-every", "150", "--eval-n", "200", "--out-dir", "out",
"--hub-repo", REPO, "--space-id", SPACE_ID])
sh([sys.executable, "evaluate.py", "--ckpt", "out/smoke-t4.pt",
"--out-dir", "results", "--n-per-cell", "50"])
with open("results/smoke-t4_eval.json") as fh:
ev = json.load(fh)
print("SMOKE OK. acc@k=8:", ev["acc_vs_k"]["8"], "acc@k=64:",
ev["acc_vs_k"]["64"], "lookup:", ev["lookup_reference_acc"])
try:
from huggingface_hub import HfApi
HfApi().upload_file(path_or_fileobj="results/smoke-t4_eval.json",
path_in_repo="results/smoke-t4_eval.json",
repo_id=REPO, repo_type="model")
except Exception as e: # non-fatal for the smoke test
print("eval-json upload failed (non-fatal):", e)