sequential-router-v2 / code /scripts_seqroute /run_preflight_all.py
divy123's picture
Add files using upload-large-folder tool
0c64c71 verified
Raw History Blame Contribute Delete
1.12 kB
import json, subprocess, time, sys
from pathlib import Path
specs = json.load(open("/mnt/localssd/seqroute1m/scripts/models_spec.json"))
done = {p.stem for p in Path("/mnt/localssd/seqroute1m/manifests/preflight").glob("*.json") if "smoke" not in p.name and "bench" not in p.name}
todo = sorted([s for s in specs if s["id"] not in done and (len(sys.argv) < 2 or s["id"] in sys.argv[1:])], key=lambda s: -s["tp"])
free = list(range(8)); running = []; port = 18300
while todo or running:
for r in list(running):
if r[0].poll() is not None:
free += r[1]; running.remove(r)
while todo and len(free) >= todo[0]["tp"]:
s = todo.pop(0); g = [free.pop(0) for _ in range(s["tp"])]; port += 1
pr = subprocess.Popen(["/mnt/localssd/venvs/main/bin/python", "scripts/seqroute/preflight.py", s["id"], ",".join(map(str, g)), str(port)],
stdout=open(f"/mnt/localssd/seqroute1m/logs/pf_{s['id']}.log", "w"), stderr=subprocess.STDOUT)
running.append((pr, g)); print("launched", s["id"], g, flush=True)
time.sleep(10)
print("all preflights finished")