Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs([issue-1252]): log issue #1252 to changelog

[._.]/ Adam Eivy25f465b46f0e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 28ef2cf1c5..b94c26e76f 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -28,7 +28,7 @@
- **LoRA dataset workbench gains a "Re-caption all" button — re-run every caption through a new model** — "Caption all" already skips images that already have a caption (it only fills in the uncaptioned ones), so there was no one-click way to re-run a whole dataset through a freshly-picked vision model. A new **Re-caption all** button next to it sends `overwrite: true`, re-captioning every ready image with the model chosen in the caption-model picker (overwriting existing captions, including manual edits — the button's tooltip says so). The single-image "Re-caption" button already overwrote one image; this extends the same intent to the whole set. (`client/src/pages/LoraDatasetDetail.jsx`)
-- **Resume a killed LoRA training run from its last checkpoint — and see a failed run's samples** — A training run that got interrupted (an app restart, a manual cancel, a crash partway through) was a total loss: the panel showed only the error, hid the checkpoint picker (it rendered for *completed* runs only), and the only path forward was to start over from step 0 — re-spending all the GPU time the run had already banked. Two changes recover that work. (1) The Train panel now surfaces the **checkpoint picker for any run that saved a checkpoint**, not just completed ones — so you can scrub the failed run's sample previews to judge how far it got, and **"Use this"** still salvages a partial checkpoint into a usable LoRA. (2) A **Resume training** button re-launches a failed/canceled run from its newest checkpoint via the new `POST /api/lora-training/runs/:id/resume` — it re-enqueues a job against the *same* run id (mflux bakes the output path into its checkpoint zip and restores the optimizer + adapter state and step counter from `--resume <zip>`, so the resumed trainer must write back into the original run dir; a fresh dir would strand its artifacts where the watcher can't see them). New checkpoints and samples append to the existing timeline, and finalize registers the LoRA as usual. Resume is **mflux-only** for now: mflux's `--resume <zip>` restores the optimizer state and step counter so training picks up mid-run, whereas the torch FLUX.2 trainer's `--resume-from` only warm-starts the adapter and would re-run the full step count on a fresh optimizer — so the server refuses to resume a FLUX.2 run (start a fresh one) until that trainer learns true optimizer-state resume. (`server/services/loraTraining/index.js`, `server/services/loraTraining/checkpoints.js`, `server/routes/loraTraining.js`, `client/src/services/apiLoraTraining.js`, `client/src/components/loraTraining/TrainingPanel.jsx`)
+- **Resume a killed LoRA training run from its last checkpoint — and see a failed run's samples** — A training run that got interrupted (an app restart, a manual cancel, a crash partway through) was a total loss: the panel showed only the error, hid the checkpoint picker (it rendered for *completed* runs only), and the only path forward was to start over from step 0 — re-spending all the GPU time the run had already banked. Two changes recover that work. (1) The Train panel now surfaces the **checkpoint picker for any run that saved a checkpoint**, not just completed ones — so you can scrub the failed run's sample previews to judge how far it got, and **"Use this"** still salvages a partial checkpoint into a usable LoRA. (2) A **Resume training** button re-launches a failed/canceled run from its newest checkpoint via the new `POST /api/lora-training/runs/:id/resume` — it re-enqueues a job against the *same* run id (mflux bakes the output path into its checkpoint zip and restores the optimizer + adapter state and step counter from `--resume <zip>`, so the resumed trainer must write back into the original run dir; a fresh dir would strand its artifacts where the watcher can't see them). New checkpoints and samples append to the existing timeline, and finalize registers the LoRA as usual. Resume works for **both** local training engines: mflux (`--resume <zip>`) and the torch **FLUX.2** trainer (`--resume-from <dir>`) each restore the optimizer state and step counter, so a resumed run picks up mid-training and continues toward its original step total instead of over-training from a fresh optimizer or re-colliding checkpoint step numbers. (`server/services/loraTraining/index.js`, `server/services/loraTraining/checkpoints.js`, `server/routes/loraTraining.js`, `scripts/train_flux2_lora.py`, `client/src/services/apiLoraTraining.js`, `client/src/components/loraTraining/TrainingPanel.jsx`)
- **LoRA training picks the best checkpoint instead of blindly deploying the final step — and you can promote any checkpoint by eye** — A FLUX.2 character LoRA could finish "successfully" yet render garbage: the trainer always handed back the FINAL step's adapter, but late training **divergence** (a recurring FLUX.2 failure — the loss keeps dropping while the sample image collapses to a near-black frame) made that final step the worst one. Loss is no guide here; on the run that motivated this it was *anti-correlated* with quality (the lowest-loss checkpoint was visually broken). Two changes close the gap: (1) a **collapse guard** at finalize analyzes each checkpoint's preview (sharp entropy + per-channel stdev) and, when the final preview is a degenerate near-black/near-uniform collapse, deploys the latest *healthy* checkpoint instead and flags the run for review — calibrated with a wide margin (a real frame measured entropy 5.5–7.1 vs the collapse's 2.8) so it never vetoes a legitimate image; (2) a new **checkpoint picker** under a completed run (`/media/training`) shows every saved checkpoint as a preview thumbnail with its step + loss, and a **"Use this"** button re-extracts that step's adapter and overwrites the deployed LoRA in place — the human override for subtler degradation the guard leaves alone. Per-checkpoint loss is now captured at checkpoint time, and `lib/zipStream` gains `extractZipEntryToBuffer` to crack one adapter out of an mflux checkpoint zip long after the trainer exited. The final debounced checkpoint/sample now flush to the run record before finalize reads it, so the guard always sees the last artifacts. (`server/services/loraTraining/checkpoints.js`, `server/services/loraTraining/index.js`, `server/lib/zipStream.js`, `server/routes/loraTraining.js`, `client/src/components/loraTraining/CheckpointPicker.jsx`)