SPB Git

spb/forge-studio Public

The Instruments of LLM training — a native macOS cockpit for Forge. Train language models from scratch on Apple Silicon without a terminal.

Swift 95.7% Shell 4.3%
6.3 KB · 129 lines markdown
Rendered Raw Blame History
1<!-- Author: Simon-Pierre Boucher — contact@spboucher.ai -->23<div align="center">45# 🔥 Forge Studio67### The Instruments of LLM training — a native macOS cockpit for [Forge](https://github.com/spboucher-ai/forge)89**Train language models from scratch on Apple Silicon without ever opening a terminal.**10Pick a dataset, shape an architecture, hit Start — and watch the loss fall on a11silky live dashboard.1213Swift + SwiftUI + Swift Charts · macOS 14+ · Apple Silicon · zero third-party dependencies1415</div>1617---1819## ✨ What it is2021[Forge](https://github.com/spboucher-ai/forge) is a from-scratch C++20 + Metal LLM22training framework: its own tensors, autograd, flash attention, Muon optimizer,23MoE, QAT, and the `.forge` zero-copy weight format. **Forge Studio is its native24GUI companion** — the whole train-a-model workflow, end to end, as a first-party-feeling25Mac app:26271. **Prepare data** — TinyStories or streamed Hugging Face mixtures28   (FineWeb-Edu, DCLM, Cosmopedia, research presets), with a live console292. **Design a model** — every Forge config field, from `n_layers` to30   DeepSeek-style MoE routing, with live validation313. **Train** — launch, monitor, stop; runs survive app crashes without lying324. **Understand** — a loss dashboard built to the TensorBoard/W&B standard, native335. **Compare** — multi-run overlays on the *tokens* axis, the honest one346. **Use the model** — generate and evaluate from any checkpoint, in-app3536Forge Studio never reimplements training. It drives the real `forge` binary and37reads its structured metrics — what you see is exactly what the framework did.3839## 📊 The dashboard4041The centerpiece. Built on Swift Charts, fed by an actor-isolated metrics store:4243- **Raw + smoothed loss** — low-opacity raw train line under a bias-corrected EMA44  (TensorBoard semantics, 0→0.99 slider), val loss as connected points45- **Hover crosshair** with a full callout: step, train, EMA, perplexity, val46- **Pinch-zoom & pan** on X, double-click to reset, and a **"follow live ⏵" pill**47  that re-pins the window to incoming data after you've panned away mid-run48- **Best-val marker** — dashed rule + `best val 2.146 @ step 999` annotation49- **Log/linear Y**, secondary charts for LR schedule (watch warmup + cosine/WSD50  actually happen), tokens/sec, grad norm with the `grad_clip` threshold drawn51- **Scale discipline**: raw data is never discarded; the UI reads LTTB-downsampled52  snapshots (~2× pixel width). Measured: 200,000 CSV rows ingest in ~1.1 s and53  snapshot to chart width in <250 ms — hover stays hitch-free on 100k-step runs5455## 🛡️ Runs that can't lie5657- Single-writer **state machine** (`queued → launching → running → … → finished |58  failed | stopped`) with an explicit legal-transition table — illegal transitions59  are unrepresentable60- **Atomic persistence** (temp-file-then-rename) for the registry: `kill -9` the61  app whenever you like62- **Crash recovery**: runs persisted as active at launch are truthfully resolved —63  including the case where the forge process is *still alive* — with an honest64  explanation and the recovery path (`ckpt_latest.bin`)65- **Watchdog**: a "possibly stalled" badge when metrics stop flowing for 30 s66- Stop is SIGTERM and the UI tells you exactly what that means (Forge doesn't67  checkpoint on signals; you lose at most `checkpoint_every` steps)68- Local **notifications** with the final loss when a run finishes or fails6970## 🧪 Ground truth, tested7172`RESEARCH.md` documents the full Forge contract (config schema, CLI, `log.csv`73grammar, checkpoint/resume, signal behavior) extracted from the source. The test74suite enforces it:7576- `ForgeConfig` round-trips the **real** `configs/*.json` from the forge repo,77  byte-compatible field names78- The Swift param-count formula matches `forge info` for every shipped config79- CSV/stdout parsers are exercised against real and mutated lines (legacy80  6-column headers, garbage, truncation)81- LTTB invariants (endpoints exact, monotonic X), EMA bias correction,82  state-machine table, LR-preview math vs `scheduler.h`, 200k-point stress test8384## 🚀 Quick start8586```bash87# 1. Build Forge (once)88git clone https://github.com/spboucher-ai/forge && cd forge89cmake -B build && cmake --build build -j9091# 2. Run Forge Studio92#    — from the DMG on the Releases page, or from source:93git clone https://github.com/spboucher-ai/forge-studio && cd forge-studio94./scripts/package-app.sh release && open dist/ForgeStudio.app95```9697In **Settings**: point to `forge/build/forge` (validated live via `forge info`) and98pick a workspace. Then **Datasets → New dataset** (TinyStories at vocab 4096 takes99a few minutes), **+ New run**, pick the `gpt-10m` preset, Start — first loss point100lands within seconds.101102## 🏗️ Architecture103104| Layer | What lives there |105|:--|:--|106| `Models/` | `ForgeConfig` (Codable mirror of every Forge field + validation + derived math), `Run` (state machine), `MetricPoint`, `Dataset` (bin-header readers) |107| `Services/` | `ProcessRunner` (actor, incremental line streaming), `LogParser` (header-driven CSV + stdout events), `MetricsStore` (actor, incremental tail, LTTB snapshots), `RunStore` (atomic registry), `RunSupervisor`, `ForgeBinaryLocator`, `SystemInfo` |108| `Charts/` | `TrainingChartView` (the interactive dashboard), `Downsampler` (LTTB), `Smoothing` (bias-corrected EMA) |109| `Views/` | Navigation shell, run dashboard, New Run editor (presets, derived panel, LR preview), Compare, Datasets, Checkpoints/Generate/Eval, Settings |110| `scripts/` | `package-app.sh` (SwiftPM → .app), `generate-icon.sh`, `notarize.sh` (Developer ID + hardened runtime + DMG + notarytool + stapler) |111112Swift Concurrency throughout: the process I/O and metrics paths never touch the113main thread; the UI observes debounced snapshots. No third-party packages.114115## 🗺️ Roadmap116117- Linked axes across secondary charts + synchronized crosshair118- Clickable checkpoint annotations on the loss chart119- Exhaustive form for every architecture-variant knob (today: JSON import covers them)120- PNG/CSV chart export, run queue for sequential trainings121- `.forge` repo browser (weight history as commits — the format already does git-style deltas)122123## 👤 Author124125**Simon-Pierre Boucher** — contact@spboucher.ai126127Built alongside [Forge](https://github.com/spboucher-ai/forge). If Forge is the128engine, Studio is the cockpit.129