A straightforward method for training your LLM, from downloading data to generating text.
fix(ui): read checkpoints, data and logs from the repo folders
FareedKhan-dev170d4ac5c4e8
diff --git a/ui/jobs.py b/ui/jobs.pyindex 19d0b79..7d3343a 100644--- a/ui/jobs.py+++ b/ui/jobs.py@@ -2,7 +2,7 @@Background job manager for the control panel.Launches the real training / data-prep scripts as detached subprocesses, captures their-output to a logfile, and records a tiny JSON registry under /ephemeral/ui_jobs/ so jobs+output to a logfile, and records a tiny JSON registry under logs/ui_jobs/ so jobssurvive Streamlit reruns and page navigation. Includes a GPU-busy guard so we never start asecond multi-GPU job on top of a running one (which would OOM the H100s)."""@@ -16,9 +16,9 @@ import subprocessimport sysimport time-from ui.stages import REPO_ROOT+from ui.stages import LOG_DIR, REPO_ROOT-JOB_DIR = "/ephemeral/ui_jobs"+JOB_DIR = os.path.join(LOG_DIR, "ui_jobs")_TORCHRUN = os.path.join(os.path.dirname(sys.executable), "torchrun")@@ -85,7 +85,6 @@ def launch(job_id: str, argv: list[str], *, kind: str = "cpu") -> dict:log_path = _log(job_id)env = {**os.environ, "PYTHONPATH": REPO_ROOT}env.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")- env.setdefault("HF_HOME", "/ephemeral/hf_cache")logf = open(log_path, "wb")proc = subprocess.Popen(argv, cwd=REPO_ROOT, env=env, stdout=logf, stderr=subprocess.STDOUT,diff --git a/ui/metrics.py b/ui/metrics.pyindex e36a545..bf89161 100644--- a/ui/metrics.py+++ b/ui/metrics.py@@ -1,4 +1,4 @@-"""Read the newest ``/ephemeral/logs/<prefix>_*.jsonl`` metrics file into a DataFrame."""+"""Read the newest ``logs/<prefix>_*.jsonl`` metrics file into a DataFrame."""from __future__ import annotationsdiff --git a/ui/pages/1_Data.py b/ui/pages/1_Data.pyindex dc93574..b46a297 100644--- a/ui/pages/1_Data.py+++ b/ui/pages/1_Data.py@@ -17,8 +17,8 @@ theme.hero("π¦ Data preparation","Download & preprocess the corpora β Pile (pretrain), Alpaca/Dolly/GSM8K (SFT), ""HH-RLHF/UltraFeedback (preferences), GSM8K + arithmetic (RL).")-st.caption("Each button launches the real `scripts/prepare_*.py` as a background job (sets "- "`HF_HOME=/ephemeral/hf_cache`). Large downloads take a while β watch the log below.")+st.caption("Each button launches the real `scripts/prepare_*.py` as a background job. "+ "Large downloads take a while, so watch the log below.")for name, args in DATA_SCRIPTS.items():job_id = "data_" + re.sub(r"[^a-z0-9]+", "_", name.lower()).strip("_")@@ -30,8 +30,6 @@ for name, args in DATA_SCRIPTS.items():if c2.button("Prepare", key=f"prep_{job_id}", disabled=(s == "running")):env_argv = [sys.executable, *args]rec = jobs.launch(job_id, env_argv, kind="cpu")- # data scripts need the HF cache env; relaunch path uses jobs env + HF_HOME- os.environ.setdefault("HF_HOME", "/ephemeral/hf_cache")st.session_state["last_data_job"] = job_idst.rerun()@@ -45,7 +43,7 @@ if job_to_show:if jobs.status(job_to_show) == "running" and st.toggle("Auto-refresh", value=True):time.sleep(3); st.rerun()-st.subheader("Files in /ephemeral/data")+st.subheader("Files in data/")if os.path.isdir(DATA_DIR):rows = []for fn in sorted(os.listdir(DATA_DIR)):@@ -54,4 +52,4 @@ if os.path.isdir(DATA_DIR):rows.append({"file": fn, "size": f"{os.path.getsize(p)/1e6:.1f} MB"})st.dataframe(rows, use_container_width=True, hide_index=True) if rows else st.caption("empty")else:- st.caption("/ephemeral/data does not exist yet.")+ st.caption("data/ does not exist yet.")diff --git a/ui/pages/8_Evaluate.py b/ui/pages/8_Evaluate.pyindex 313d9de..abcb4f4 100644--- a/ui/pages/8_Evaluate.py+++ b/ui/pages/8_Evaluate.py@@ -3,17 +3,19 @@from __future__ import annotationsimport glob+import osimport streamlit as stfrom ui import theme+from ui.stages import CKPT_DIRtheme.setup_page("Evaluate", "π")theme.hero("π Evaluate on GSM8K", "Greedy GSM8K accuracy for any checkpoint, with sample generations.")-ckpts = sorted(glob.glob("/ephemeral/ckpts/*.pt"))+ckpts = sorted(glob.glob(os.path.join(CKPT_DIR, "**", "*.pt"), recursive=True))if not ckpts:- st.warning("No checkpoints found in /ephemeral/ckpts. Train a stage first.")+ st.warning("No checkpoints found in models/. Train a stage first.")st.stop()ckpt = st.selectbox("Checkpoint", ckpts, index=len(ckpts) - 1)diff --git a/ui/pages/9_Chat.py b/ui/pages/9_Chat.pyindex ce8257f..0480589 100644--- a/ui/pages/9_Chat.py+++ b/ui/pages/9_Chat.py@@ -3,17 +3,19 @@from __future__ import annotationsimport glob+import osimport streamlit as stfrom ui import theme+from ui.stages import CKPT_DIRtheme.setup_page("Chat", "π¬")theme.hero("π¬ Chat", "Talk to any checkpoint β chat template for instruction models, raw mode for the base.")-ckpts = sorted(glob.glob("/ephemeral/ckpts/*.pt"))+ckpts = sorted(glob.glob(os.path.join(CKPT_DIR, "**", "*.pt"), recursive=True))if not ckpts:- st.warning("No checkpoints in /ephemeral/ckpts yet. Train a stage (or run a smoke job) first.")+ st.warning("No checkpoints in models/ yet. Train a stage (or run a smoke job) first.")st.stop()with st.sidebar:diff --git a/ui/stages.py b/ui/stages.pyindex a0680cd..13e8294 100644--- a/ui/stages.py+++ b/ui/stages.py@@ -9,14 +9,16 @@ from __future__ import annotationsimport osfrom dataclasses import dataclass+from config import pathsfrom config.post_training_config import (PretrainConfig, SFTConfig, RewardConfig, DPOConfig, PPOConfig, GRPOConfig,)REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))-CKPT_DIR = "/ephemeral/ckpts"-DATA_DIR = "/ephemeral/data"-LOG_DIR = "/ephemeral/logs"+# Absolute versions of data/, models/ and logs/, so the pages work from any working directory.+CKPT_DIR = os.path.join(REPO_ROOT, paths.CKPT_DIR)+DATA_DIR = os.path.join(REPO_ROOT, paths.DATA_DIR)+LOG_DIR = os.path.join(REPO_ROOT, paths.LOG_DIR)@dataclass(frozen=True)