01 • Case Study

EasyTrain

A local fine-tuning studio for Apple Silicon. Upload a dataset, start a LoRA or DoRA run, watch the training logs stream in, then talk to the model you just trained — without touching a CLI.

Role
Solo — design, backend, frontend
Frontend
Next.js App Router
Backend
FastAPI + mlx-lm
Platform
Apple Silicon (M-series)
easytrain — next dev · run 7f3a1c
$ pnpm dev
▲ Next.js 16.1.3 (Turbopack)
- Local: http://localhost:3000
✓ Ready in 1.2s
 
GET / 200 · 38ms
POST /api/runs 201 · run 7f3a1c
↳ rewrite → 127.0.0.1:8765 FastAPI · mlx-lm
WS /ws/runs/7f3a1c open — streaming stdout
 
staged backend/data/datasets/train.jsonl · validated
load mlx-community/Llama-3.2-1B-Instruct-4bit
train mlx_lm.lora.run · iters 300 · stdout → ws
train iter 60 · loss 1.702
train iter 140 · loss 1.094
train iter 220 · loss 0.841
train iter 300 · loss 0.761 · val 0.803
saved backend/data/checkpoints/7f3a1c/adapters.safetensors
 
POST /api/runs/7f3a1c/chat 200 · adapter loaded
Illustrative output. The dev-server lines, the proxy target, the endpoints and the checkpoint paths are the real ones; timings and loss values depend on your machine and dataset.
02 • Motivation

The CLI is excellent. The visibility isn't.

mlx-lm is the real work here. It runs LoRA and DoRA training on Apple Silicon and it does it well — this project is a front end for it, not a replacement.

What it doesn't give you is a way to see anything. Getting from “I have a dataset” to “I have an adapter I can talk to” means remembering flag names, babysitting a terminal for twenty minutes with no signal about whether the run is healthy, and then writing throwaway inference code to find out whether it worked.

Three things change when that moves into a browser. The dataset is checked before the run starts instead of failing partway through. The training output arrives as it happens, so a run that has gone wrong looks wrong immediately. And the adapter is chattable in the same window the moment it lands on disk.

03 • Architecture

Two processes, one origin

The browser never talks to Python directly. Next.js rewrites /api/* through to the FastAPI process and opens a WebSocket at /ws/runs/:id for log streaming. One origin in the browser, no CORS configuration, and the front end never learns where the backend actually lives.

On the Python side the surface is deliberately small, one module per concern:

  • main.pythe FastAPI app — upload, train, runs, chat, WebSocket
  • trainer.pytraining orchestration, capturing stdout line by line
  • inference.pyloads the base model plus a run's adapter and generates
  • datasets.pyvalidates .jsonl and .json before a run is allowed to start
  • runs.pythe in-memory registry of runs
  • config.pywhere data lives on disk
EasyTrain's training view, showing a run in progress with streaming logs and a chat panel
The training view: run configuration on the left, streamed output in the middle, and the chat panel that talks to the adapter once the run finishes.
04 • Decisions

Four choices worth explaining

Drive mlx-lm rather than reimplement it

The trainer builds an argparse-style namespace from the UI config and calls the same entry point the CLI does. When mlx-lm gains a flag it is available immediately; when it fixes a bug the fix is inherited. The cost is real and worth stating: progress has to be parsed back out of captured stdout, because there is no callback to hook into.

A WebSocket for logs, not polling

Training output arrives one line at a time over a run that can last an hour. Polling would either miss lines between requests or hammer the backend to avoid missing them. Stdout and stderr are captured per line and pushed over the socket — and the same lines stay readable from GET /api/runs/<id>, so reloading the page doesn't lose a run in progress.

Validate datasets at upload

A malformed dataset fails deep inside the training loop, after the setup time has been spent, with an error that doesn't point at the file. Upload is the only moment where the file is small enough to check cheaply, so the format is validated there — .jsonl with either a text field for causal LM or a messages array for chat — and staged per run so a rerun trains on the same data.

In-memory run registry, on purpose

Runs are kept in a dictionary rather than a database. This is a tool you run on your own machine and stop when you're done; a persistence layer would be more code than the problem justifies. The tradeoff is genuine and documented below rather than hidden.

05 • Limitations

What it doesn't do

  • The run registry lives in memory. Restarting the backend empties the list of runs, though the adapters themselves stay on disk until you delete them — only the record of them is lost.
  • Full fine-tuning trains every weight and needs substantially more memory than LoRA. On a 16GB machine, LoRA is the realistic option, and the UI doesn't pretend otherwise.
  • The first chat after a run finishes reloads the model cold. Later messages in the same process reuse the Hugging Face cache, so the delay is a one-off — but it is noticeable.
  • Apple Silicon only. It's mlx-lm underneath, so there is no CUDA path and no plan to add one.
06 • Stack

Built with

Next.jsReactTypeScriptTailwind CSS v4FastAPIPythonmlx-lmMLXLoRADoRAWebSocketuvpnpm