GPU smoke wrapper
Browse files- smoke_gpu.py +43 -0
smoke_gpu.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""GPU smoke-job wrapper: pulls the code from the Hub repo, runs a short
|
| 2 |
+
train.py (with trackio + checkpoint upload) and an evaluate.py sweep, and
|
| 3 |
+
prints the results. Run via `uv` with deps torch, numpy, huggingface_hub,
|
| 4 |
+
trackio."""
|
| 5 |
+
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
import subprocess
|
| 9 |
+
import sys
|
| 10 |
+
|
| 11 |
+
REPO = "eac123/ptr-recurrent-depth"
|
| 12 |
+
SPACE_ID = os.environ["TRACKIO_SPACE_ID"]
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def sh(cmd):
|
| 16 |
+
print("+", " ".join(cmd), flush=True)
|
| 17 |
+
subprocess.run(cmd, check=True)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
from huggingface_hub import snapshot_download
|
| 21 |
+
|
| 22 |
+
snapshot_download(repo_id=REPO, repo_type="model",
|
| 23 |
+
allow_patterns=["*.py", "ptr/*.py"], local_dir=".")
|
| 24 |
+
sys.path.insert(0, os.getcwd())
|
| 25 |
+
|
| 26 |
+
sh([sys.executable, "train.py", "--arch", "rec", "--depth", "1",
|
| 27 |
+
"--iters", "4", "--seed", "0", "--run-name", "smoke-t4", "--steps", "300",
|
| 28 |
+
"--eval-every", "150", "--eval-n", "200", "--out-dir", "out",
|
| 29 |
+
"--hub-repo", REPO, "--space-id", SPACE_ID])
|
| 30 |
+
sh([sys.executable, "evaluate.py", "--ckpt", "out/smoke-t4.pt",
|
| 31 |
+
"--out-dir", "results", "--n-per-cell", "50"])
|
| 32 |
+
|
| 33 |
+
with open("results/smoke-t4_eval.json") as fh:
|
| 34 |
+
ev = json.load(fh)
|
| 35 |
+
print("SMOKE OK. acc@k=8:", ev["acc_vs_k"]["8"], "acc@k=64:",
|
| 36 |
+
ev["acc_vs_k"]["64"], "lookup:", ev["lookup_reference_acc"])
|
| 37 |
+
try:
|
| 38 |
+
from huggingface_hub import HfApi
|
| 39 |
+
HfApi().upload_file(path_or_fileobj="results/smoke-t4_eval.json",
|
| 40 |
+
path_in_repo="results/smoke-t4_eval.json",
|
| 41 |
+
repo_id=REPO, repo_type="model")
|
| 42 |
+
except Exception as e: # non-fatal for the smoke test
|
| 43 |
+
print("eval-json upload failed (non-fatal):", e)
|