""" Train LLM From Scratch β€” control panel (Home). Run with: streamlit run ui/app.py """ from __future__ import annotations import os import streamlit as st from ui import jobs, theme from ui.stages import ABS_DOC, STAGES theme.setup_page("Control Panel", "🧠") theme.hero("🧠 Train LLM From Scratch β€” Control Panel", "Pretrain β†’ SFT β†’ Reward Model β†’ DPO β†’ PPO β†’ GRPO Β· evaluate Β· chat β€” all from one place.") # Master pipeline diagram (the hand-drawn overview). overview = ABS_DOC("docs/diagrams/00_overview.png") if os.path.exists(overview): st.image(overview, use_container_width=True) st.markdown( "Use the **pages in the sidebar** to prepare data, configure and launch each training stage " "(with live logs + metric charts), evaluate on GSM8K, and chat with any checkpoint." ) # --- GPU status --- st.subheader("πŸ–₯️ GPUs") gpus = theme.gpu_status() if gpus: cols = st.columns(len(gpus)) for col, (i, name, used, total, util) in zip(cols, gpus): col.metric(f"GPU {i} Β· {name.split(' ')[-1]}", f"{used/1024:.0f}/{total/1024:.0f} GB", f"{util}% util") else: st.info("No GPUs detected (nvidia-smi unavailable) β€” CPU / smoke mode only.") # --- Job status --- st.subheader("πŸ“‹ Jobs") busy = jobs.gpu_busy() if busy: st.warning(f"A GPU job is currently running: **{busy}**. Other GPU launches are guarded until it finishes.") active = jobs.active_jobs() if active: for rec in active: s = jobs.status(rec["job_id"]) st.markdown( f'
{rec["job_id"]}   {theme.status_badge(s)} ' f'  {" ".join(rec["cmd"][:3])} …
', unsafe_allow_html=True) else: st.caption("No jobs launched yet.") # --- Pipeline map --- st.subheader("πŸ—ΊοΈ Pipeline") for key, sgt in STAGES.items(): s = jobs.status(key) st.markdown( f'
' f'{sgt.emoji} {sgt.title}   {theme.status_badge(s)} ' f'  {sgt.script}
', unsafe_allow_html=True) st.divider() st.caption("Docs: see the MkDocs site (`mkdocs serve`) or the `docs/` folder. " "CLI reference: `POST_TRAINING.md`.")