| import marimo |
|
|
| __generated_with = "0.24.0" |
| app = marimo.App(width="medium", auto_download=["html"]) |
|
|
|
|
| @app.cell |
| def _(): |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| import os, sys, subprocess, json, time |
|
|
| SCRIPT_DIR = os.path.expanduser("~/DragonCode/scripts") |
| CONFIG_DIR = os.path.expanduser("~/DragonCode/configs") |
| LOG_DIR = os.path.expanduser("~/DragonCode/logs") |
|
|
| |
| |
| os.environ.setdefault("HF_TOKEN", os.environ.get("HF_TOKEN", "")) |
| os.environ["HF_HOME"] = os.path.expanduser("~/.cache/huggingface") |
|
|
| |
| TIER_ORDER = ["150M", "387M", "787M", "1.2B", "2.4B"] |
| CHINCHILLA = { |
| "150M": 3_000_000_000, |
| "387M": 7_740_000_000, |
| "787M": 15_740_000_000, |
| "1.2B": 24_000_000_000, |
| "2.4B": 48_000_000_000, |
| } |
|
|
| return (SCRIPT_DIR, CONFIG_DIR, LOG_DIR, TIER_ORDER, CHINCHILLA, os, subprocess, time) |
|
|
|
|
| @app.cell |
| def _(SCRIPT_DIR, CONFIG_DIR, LOG_DIR, os, subprocess, time): |
| |
| |
| |
| |
| |
| |
| TIER_STAGES = { |
| "150M": ["pretrain"], |
| "387M": ["pretrain"], |
| "787M": ["pretrain", "sft", "dpo", "golf", "merge", "verify", "gguf"], |
| "1.2B": ["pretrain", "sft", "dpo", "golf", "merge", "verify", "gguf"], |
| "2.4B": ["pretrain", "sft", "golf", "merge", "verify", "gguf"], |
| } |
|
|
| def _run(args, logfile): |
| """Run a CLI stage, streaming stdout to its own log file (tail-friendly).""" |
| os.makedirs(LOG_DIR, exist_ok=True) |
| with open(logfile, "a") as lf: |
| lf.write(f"\n=== {time.strftime('%Y-%m-%dT%H:%M:%SZ')} {' '.join(args)} ===\n") |
| lf.flush() |
| proc = subprocess.Popen( |
| args, cwd=SCRIPT_DIR, |
| stdout=subprocess.PIPE, stderr=subprocess.STDOUT, |
| text=True, bufsize=1, |
| ) |
| assert proc.stdout is not None |
| for line in proc.stdout: |
| lf.write(line); lf.flush() |
| print(line, end="", flush=True) |
| rc = proc.wait() |
| return rc |
|
|
| def run_stage(tier, stage): |
| script = f"dragoncode_{stage}.py" |
| config = os.path.join(CONFIG_DIR, f"DragonCode-{tier}.yaml") |
| cmd = [sys.executable, script, "--tier", tier, "--config", config] |
| logfile = os.path.join(LOG_DIR, f"DragonCode-{tier}-{stage}.log") |
| print(f"\n[DRIVE] {tier}/{stage} -> {' '.join(cmd)}", flush=True) |
| rc = _run(cmd, logfile) |
| if rc != 0: |
| print(f"[DRIVE] {tier}/{stage} FAILED rc={rc} (see {logfile})", flush=True) |
| return False |
| print(f"[DRIVE] {tier}/{stage} OK", flush=True) |
| return True |
|
|
| return (TIER_STAGES, run_stage) |
|
|
|
|
| @app.cell |
| def _(TIER_ORDER, TIER_STAGES, run_stage, time): |
| |
| |
| |
| |
| def run_all(): |
| for tier in TIER_ORDER: |
| for stage in TIER_STAGES[tier]: |
| ok = run_stage(tier, stage) |
| attempt = 0 |
| while not ok and attempt < 3: |
| attempt += 1 |
| time.sleep(8) |
| print(f"[DRIVE] {tier}/{stage} retry {attempt}/3", flush=True) |
| ok = run_stage(tier, stage) |
| if not ok: |
| print(f"[DRIVE] {tier}/{stage} failed after retries β stopping pipeline", flush=True) |
| return |
| print("[DRIVE] All 5 models complete.", flush=True) |
|
|
|
|
| return (run_all,) |
|
|
|
|
| @app.cell |
| def _(run_all): |
| |
| |
| |
| run_all() |
|
|
| return |
|
|
|
|
| if __name__ == "__main__": |
| app.run() |
|
|