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

make validated LoRA-training config the form defaults; drop the one-off script

[._.]/ Adam Eivy1c87639ff293
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 8166afad01..c7aa486a98 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -8,6 +8,8 @@
## Changed
+- **LoRA training defaults now reflect what actually trains a clean character LoRA on Apple Silicon.** The Train LoRA form previously seeded weak/cautious values (4B base, 600 steps, rank 16, lr 5e-5) — the 4B-first and low-lr choices were leftovers from misdiagnosing an early "divergence" (the real cause was captions over-describing invariant identity, so it bound to words rather than the trigger token, not the learning rate). Validated end-to-end on a 44-image real-face dataset: the form now defaults to **9B base · 1200 steps · rank 32 · lr 1e-4 · 768px · checkpoint/sample every 300**, which binds identity cleanly and fast. The base-model picker prefers the 9B Klein id (it captures identity better than 4B and trains via the panic-safe 4-bit QLoRA tier the server forces) and avoids the heavy `*-bf16` variant. Per-run values remain fully editable in the form. (`server/services/loraTraining/runtimes.js` `TRAINING_DEFAULTS`, `client/src/components/loraTraining/TrainingPanel.jsx`)
+
- **Share the `--user-loras` JSON parser between the two video LoRA runners.** `parse_user_loras` (the strict `[{path, strength}]` validator that surfaces a Node-side bug before any model load) was duplicated verbatim in `scripts/generate_ltx2.py` (dgrauet `ltx2` runtime) and `scripts/generate_av_lora.py` (mlx_video runtime); it now lives once in `scripts/_runner_common.py` (stdlib-only at import, so it's safe to import from either MLX venv — verified in both) and both runners import it, so a future fix to the validation contract can't drift between them. (`scripts/_runner_common.py`, `scripts/generate_ltx2.py`, `scripts/generate_av_lora.py`)
- **Retire the repo-local `/claim`, `/gitup`, and `/work` slash commands in favor of slashdo.** The custom 46 KB `.claude/commands/claim.md` procedure (and its `.agents/skills/claim/SKILL.md` adapter) is replaced by slashdo's `/do:next`, which runs the same claim-an-item-in-a-worktree-and-ship-a-PR flow; `/gitup` and `/work` are dropped in favor of `/do:push` and slashdo's worktree workflow. The slashdo submodule is bumped v3.5.0 → v3.9.0 so `/do:next` ships from the module itself (symlinked into `.claude/commands/do/next.md` like the other `/do:*` commands) instead of relying on a separate global install. The CoS `plan-task` / `claim-issue` scheduled agents are unaffected — they carry their own self-contained prompts and never loaded the deleted command file.
diff --git a/client/src/components/loraTraining/TrainingPanel.jsx b/client/src/components/loraTraining/TrainingPanel.jsx
index 3fea9e2c2e..d5ce730b45 100644
--- a/client/src/components/loraTraining/TrainingPanel.jsx
+++ b/client/src/components/loraTraining/TrainingPanel.jsx
@@ -46,7 +46,17 @@ export default function TrainingPanel({ dataset, readiness, triggerSaving, onRun
// torch fallback trains the same bf16 Klein bases.
const trainable = (Array.isArray(list) ? list : []).filter((m) => m.runner === 'flux2');
setModels(trainable);
- setBaseModelId((prev) => prev || trainable[0]?.id || '');
+ // Default to the 9B base — it captures identity better than 4B and trains
+ // fine via 4-bit QLoRA (the server forces the panic-safe quant tier
+ // regardless of which inference id is picked). Prefer the plain 9B id we
+ // validated (flux2-klein-9b); avoid the explicit *-bf16 variant (the heavy
+ // path that GPU-watchdog-panics this M5). Fall back to any 9B, then first.
+ setBaseModelId((prev) => {
+ if (prev) return prev;
+ const nineB = trainable.filter((m) => /9b/i.test(m.id));
+ const nonBf16 = nineB.find((m) => !/bf16/i.test(m.id));
+ return (nonBf16 || nineB[0] || trainable[0])?.id || '';
+ });
}).catch(() => setModels([]));
}, []);
diff --git a/scripts/train-adam-lora.sh b/scripts/train-adam-lora.sh
deleted file mode 100644
index c97661312f..0000000000
--- a/scripts/train-adam-lora.sh
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env bash
-# Kick off a stronger Adam Eivy LoRA training run, on demand.
-#
-# Why this script instead of the in-app "Train" button:
-# The app spawns the trainer as a child of portos-server, and pm2's TreeKill
-# SIGINTs the whole process tree on any server restart (memory ceiling, code
-# reload, another agent's restart) — which killed multi-hour runs repeatedly.
-# This launches the trainer STANDALONE (reparented to launchd, ppid 1) so it is
-# immune to every pm2/server restart. It also forces 4-bit QLoRA on the 9B base
-# (LORA_TRAIN_MAX_QUANT_BITS=4) — the bf16 9B path crawls + GPU-watchdog-panics
-# this M5 Max. See docs/research/2026-06-13-mflux-training-watchdog-panic.md.
-#
-# It creates a fresh run via the API (so the dataset is staged + the config built
-# the normal way), cancels the API's pm2-child trainer, then relaunches that exact
-# staged config standalone. On completion you finalize/register via the UI's
-# "Use this" on a checkpoint, or re-run with --register.
-#
-# Usage:
-# ./scripts/train-adam-lora.sh # rank 64, 1800 steps, LR 1e-4, 9B
-# STEPS=2400 RANK=64 ./scripts/train-adam-lora.sh
-# ./scripts/train-adam-lora.sh --register <runId> # register a finished standalone run's best checkpoint
-#
-# Tunables (env overrides):
-set -euo pipefail
-cd "$(dirname "$0")/.."
-
-DATASET="${DATASET:-46aa3b3b-3c0e-4c97-824d-e29102d9fd5e}" # Adam Eivy, 44 imgs, vision-captioned
-BASE_MODEL="${BASE_MODEL:-flux2-klein-9b}"
-STEPS="${STEPS:-1800}"
-RANK="${RANK:-64}"
-LR="${LR:-0.0001}"
-RES="${RES:-768}"
-SEED="${SEED:-7}"
-CKPT_EVERY="${CKPT_EVERY:-300}"
-SAMPLE_EVERY="${SAMPLE_EVERY:-300}"
-NAME="${NAME:-Adam Eivy (9B 4bit r${RANK} ${STEPS}st)}"
-
-PY=./data/python/venv/bin/python
-API="https://127.0.0.1:5555"
-
-# --- auth: Basic header from the keychain password (set once via:
-# security add-generic-password -a portos -s portos-auth -w 'YOUR_PASSWORD' )
-PW="$(security find-generic-password -a portos -s portos-auth -w 2>/dev/null || true)"
-if [[ -z "$PW" ]]; then
- echo "❌ No portos-auth password in keychain. Set it with:"
- echo " security add-generic-password -a portos -s portos-auth -w 'YOUR_PASSWORD'"
- exit 1
-fi
-BASIC="$(printf ':%s' "$PW" | base64)"
-auth=(-H "Authorization: Basic $BASIC")
-
-# --- register mode: finalize a finished standalone run's best checkpoint
-if [[ "${1:-}" == "--register" ]]; then
- RUNID="${2:?usage: --register <runId>}"
- echo "📦 Registering best checkpoint for run $RUNID via resume-finalize…"
- curl -sk -m 15 -X POST "$API/api/lora-training/runs/$RUNID/resume" "${auth[@]}" \
- | "$PY" -m json.tool
- echo "→ watch the UI; it finalizes from the newest checkpoint and registers the LoRA."
- exit 0
-fi
-
-echo "🏋️ Creating run: $BASE_MODEL · $STEPS steps · rank $RANK · LR $LR · ${RES}px · seed $SEED"
-RESP="$(curl -sk -m 20 -X POST "$API/api/lora-training/runs" "${auth[@]}" \
- -H "Content-Type: application/json" \
- -d "$("$PY" - "$DATASET" "$BASE_MODEL" "$NAME" "$STEPS" "$RANK" "$LR" "$RES" "$SEED" "$CKPT_EVERY" "$SAMPLE_EVERY" <<'PYEOF'
-import json, sys
-ds, base, name, steps, rank, lr, res, seed, ck, sm = sys.argv[1:11]
-print(json.dumps({
- "datasetId": ds, "baseModelId": base, "name": name,
- "params": {"steps": int(steps), "rank": int(rank), "learningRate": float(lr),
- "resolution": int(res), "seed": int(seed),
- "checkpointEvery": int(ck), "sampleEvery": int(sm)},
-}))
-PYEOF
-)")"
-RUNID="$(printf '%s' "$RESP" | "$PY" -c 'import json,sys; print(json.load(sys.stdin)["runId"])')"
-echo " runId: $RUNID"
-RUN="data/training-runs/$RUNID"
-
-# Wait for the server to stage config + dataset dir.
-for i in $(seq 1 30); do [[ -f "$RUN/mflux-train.json" ]] && break; sleep 1; done
-[[ -f "$RUN/mflux-train.json" ]] || { echo "❌ config never staged"; exit 1; }
-
-# Cancel the API's pm2-child trainer; we relaunch the SAME config standalone.
-curl -sk -m 10 -X POST "$API/api/lora-training/runs/$RUNID/cancel" "${auth[@]}" >/dev/null || true
-sleep 4; pkill -f "train_mflux_lora.*$RUNID" 2>/dev/null || true
-pkill -f "bin/mflux-train" 2>/dev/null || true; sleep 2
-
-# Free unified memory (the periodic preview-gen spike has OOM-killed runs).
-ollama ps 2>/dev/null | tail -n +2 | awk '{print $1}' | while read -r m; do [[ -n "$m" ]] && ollama stop "$m" 2>/dev/null || true; done
-
-echo "🚀 Launching STANDALONE (immune to pm2 restarts)…"
-PYTHONUNBUFFERED=1 LORA_TRAIN_MAX_QUANT_BITS=4 nohup "$PY" scripts/train_mflux_lora.py \
- --config "$RUN/mflux-train.json" --output-dir "$RUN" \
- --total-steps "$STEPS" --segment-steps "$CKPT_EVERY" --cooldown-sec 90 \
- > "$RUN/standalone.log" 2>&1 &
-sleep 20
-TP="$(pgrep -f "train_mflux_lora.*$RUNID" || true)"
-echo " trainer pid $TP (ppid $(ps -o ppid= -p "$TP" 2>/dev/null | tr -d ' ') — 1 = launchd = detached)"
-echo
-echo "✅ Running. Watch: tail -f $RUN/standalone.log"
-echo " Samples land in $RUN/samples/ at each ${SAMPLE_EVERY}-step mark."
-echo " When done, register the best checkpoint: ./scripts/train-adam-lora.sh --register $RUNID"
-echo " (or click 'Use this' under the best checkpoint in the Train LoRA UI)"
diff --git a/server/services/loraTraining/runtimes.js b/server/services/loraTraining/runtimes.js
index e7d65d110a..a168ad84cd 100644
--- a/server/services/loraTraining/runtimes.js
+++ b/server/services/loraTraining/runtimes.js
@@ -26,20 +26,24 @@ import { isFlux2, flux2VariantFromModel, FLUX2_BF16_BASE_REPOS } from '../../lib
export const TRAINING_RUNTIMES = Object.freeze({ MFLUX: 'mflux', FLUX2: 'flux2' });
-// Defaults tuned down after a FLUX.2 Klein face LoRA diverged: at the old
-// 1000 steps / lr 1e-4, the sample collapsed to a black frame by ~step 500
-// while the loss kept dropping. Halving the LR and shortening the run keeps
-// it in the useful window; 768 captures more facial detail than 512 (a 4K
-// source crushed to 512 loses the face) and the memory-derived quantize/low_ram
-// still covers smaller machines. Tighter checkpoint/sample cadence gives the
-// checkpoint picker more healthy steps to choose from.
+// Defaults validated 2026-06-15 on a real-face character LoRA (44-image dataset,
+// FLUX.2 Klein 9B 4-bit): identity bound cleanly and fast, stable through the run.
+// History worth knowing before lowering these again: an earlier run "diverged"
+// (sample collapsed to black) and the defaults were cut to 600 steps / lr 5e-5 /
+// rank 16 — but the real cause was captions over-describing invariant identity
+// (it bound to the words, not the trigger), NOT the learning rate. With good
+// captions, lr 1e-4 + rank 32 + ~1200 steps converges faster and sharper without
+// collapse. 768 captures more facial detail than 512; checkpoint/sample cadence
+// gives the picker several healthy steps to choose from. The base model + quant
+// tier are chosen elsewhere (deriveMfluxMemoryConfig + the base-model picker,
+// which prefers 9B); these are the per-run hyperparameters the form seeds from.
export const TRAINING_DEFAULTS = Object.freeze({
- steps: 600,
- rank: 16,
- learningRate: 0.00005,
+ steps: 1200,
+ rank: 32,
+ learningRate: 0.0001,
resolution: 768,
- checkpointEvery: 150,
- sampleEvery: 150,
+ checkpointEvery: 300,
+ sampleEvery: 300,
});
// bf16 training bases per FLUX.2 size variant (torch runtime). Inference may