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

record CONFIRMED display-off fix for the M5 LoRA watchdog panic (9B seg-OFF reached step 302)

[._.]/ Adam Eivya6831473599f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 552d10f3a4..638c190ddb 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -3,7 +3,8 @@
## Local model stack
- **[issue-1329] Pinned a validated mlx/mlx-metal trio for LoRA training so the GPU-watchdog stack can't silently drift back to the known-bad build.** The three M5 Max kernel panics during FLUX.2 LoRA training all happened on mlx/mlx-metal 0.30.6, but `setup-image-video.sh` installed `mflux>=0.17` as a *floor* and let pip resolve mlx under mflux's `mlx<0.32` cap — so a reinstall could land back on a panicking build. The setup script now pins the bisect-validated trio **mflux 0.17.5 · mlx 0.31.2 · mlx-metal 0.31.2**, proven by run `d36562a0` completing a full LoRA training to adapter extraction (flux2-klein-4b, bf16, 768px, segmentation on) on the panicking M5 Max with no panic or reboot. The runtime-fingerprint half shipped earlier (#1406). (`scripts/setup-image-video.sh`, `docs/research/2026-06-13-mflux-training-watchdog-panic.md`)
-- **[issue-1329] Applied the upstream-confirmed fix for the LoRA-training GPU watchdog panic.** A search of the MLX tracker turned up the root cause: [mlx #3267](https://github.com/ml-explore/mlx/issues/3267) — the Metal GPU watchdog kills sustained LoRA training whose command buffers compete with active-display compositing (escalating to a `watchdogd` kernel panic + hard reboot on M5-class silicon). The MLX maintainer's confirmed workaround is the `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` env var, which PortOS now sets automatically in the trainer (it propagates to the `mflux-train` child; set it to `0` to disable). The trainer logs `STATUS:watchdog mitigation · AGX_RELAX_CDM_CTXSTORE_TIMEOUT=…` so a paniclog records whether it was active. Notably, per #3267 the kill is at the IOGPU layer *above* the process boundary — so process-teardown segmentation alone does not prevent it, and the strongest user-side mitigation is to train with the display asleep / lid closed under `caffeinate -s` or over SSH. No fresh upstream issue was filed (it would duplicate #3267 / #3186); the draft is retained for a possible data-point comment on the panic tracker. (`scripts/train_mflux_lora.py`, `docs/TROUBLESHOOTING.md`, `docs/research/2026-06-13-mflux-training-watchdog-panic.md`)
+- **[issue-1329] Applied the upstream-confirmed fix for the LoRA-training GPU watchdog panic.** A search of the MLX tracker turned up the root cause: [mlx #3267](https://github.com/ml-explore/mlx/issues/3267) — the Metal GPU watchdog kills sustained LoRA training whose command buffers compete with active-display compositing (escalating to a `watchdogd` kernel panic + hard reboot on M5-class silicon). The MLX maintainer's confirmed workaround is the `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` env var, which PortOS now sets automatically in the trainer (it propagates to the `mflux-train` child; set it to `0` to disable). The trainer logs `STATUS:watchdog mitigation · AGX_RELAX_CDM_CTXSTORE_TIMEOUT=…` so a paniclog records whether it was active. Notably, per #3267 the kill is at the IOGPU layer *above* the process boundary — so process-teardown segmentation alone does not prevent it, and the strongest user-side mitigation is to keep the display off (SSH headless or `pmset displaysleepnow`) for heavy sustained runs. Our data points were posted to #3267 rather than filed as a duplicate. (`scripts/train_mflux_lora.py`, `docs/TROUBLESHOOTING.md`, `docs/research/2026-06-13-mflux-training-watchdog-panic.md`)
+- **[issue-1329] Confirmed on the M5 Max what actually stops the watchdog panic: keeping the display off.** A clean A/B on the *same* 9B-bf16 segmentation-OFF config (the heaviest, most panic-prone) — both with `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` set — settled it: with the **display active** the box hard-rebooted at step 0 within minutes (first telemetry-captured panic showed Nominal thermal pressure, i.e. a GPU **driver hang** not heat, with `WindowServer` the top-CPU thread); with the **display asleep** (`pmset displaysleepnow`) the identical run reached **step 302**, clearing the documented 150–300 panic window with no panic. So the env var is necessary but not sufficient for heavy runs — for a 9B/heavy bf16 job, drive the box over SSH or sleep the display, and keep segmentation on. `caffeinate -s` does not sleep the display, and closing the lid suspends the whole machine. TROUBLESHOOTING now documents the working recipe. (`docs/TROUBLESHOOTING.md`, `docs/research/2026-06-13-mflux-training-watchdog-panic.md`)
## Mood boards
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index fb5fa5f49b..84d9255714 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -317,15 +317,22 @@ display asleep / lid closed under `caffeinate -s &`, or drive the box headless o
SSH from another machine. With no WindowServer compositing the watchdog has nothing
to protect and largely stops firing.
-> **Validated on M5 Max (2026-06-27): the env var alone is NOT enough for heavy
-> runs.** A 9B-bf16 segmentation-OFF run *with `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1`
-> set but the display active* still hard-rebooted within minutes. Telemetry showed
-> Nominal thermal pressure (so it's a GPU **driver hang**, not heat) and the
-> paniclog had `WindowServer` as the top-CPU thread (active-display contention).
-> For a **9B / heavy bf16 run you must also keep the display off** (lid closed /
-> asleep / SSH headless) — and prefer **segmentation ON** (the shipped default),
-> which on this box completed a full 4B run cleanly. `caffeinate -s` alone does
-> *not* turn the display off; it only prevents system sleep.
+> **Validated on M5 Max (2026-06-27) — keeping the display off is what works.**
+> A clean A/B on the *same* 9B-bf16 segmentation-OFF config, both with
+> `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` set:
+> - **Display active** → hard-rebooted within minutes (at step 0). Telemetry: Nominal
+> thermal pressure (a GPU **driver hang**, not heat); paniclog top-CPU thread was
+> `WindowServer` (active-display contention).
+> - **Display asleep** (`pmset displaysleepnow`, lid open) → **reached step 302**,
+> clearing the documented 150–300 panic window with no panic.
+>
+> So for a **9B / heavy bf16 run, the env var is necessary but not sufficient — you
+> must also keep the display off**: drive the box over SSH (cleanest), or run
+> `pmset displaysleepnow` right after launching. `caffeinate -s` alone does *not*
+> turn the display off; it only prevents system sleep, and **closing the lid sleeps
+> the whole machine** (suspending the run) unless an external display is attached.
+> Also prefer **segmentation ON** (the shipped default), which completed a full 4B
+> run cleanly on this box.
**Mitigations already in place**:
- `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` is set automatically by the trainer (the
diff --git a/docs/research/2026-06-13-mflux-training-watchdog-panic.md b/docs/research/2026-06-13-mflux-training-watchdog-panic.md
index 83f43b7c64..1a62515e04 100644
--- a/docs/research/2026-06-13-mflux-training-watchdog-panic.md
+++ b/docs/research/2026-06-13-mflux-training-watchdog-panic.md
@@ -57,11 +57,20 @@ run defeats the env var when the display is compositing. The empirically-known
survivors on this box are: **(a) segmentation ON** (run `d36562a0`, 4B, completed)
and **(b) the #3267 thread's display-off levers** (lid closed / display asleep /
SSH headless) — these were NOT both in effect for the failed run (display was on).
-The next validation worth a destructive session is **9B seg-OFF with the display
-genuinely asleep / lid closed** (or SSH headless), to isolate whether display-off
-alone clears it; until then the safe production combo is **segmentation ON +
-display off for heavy runs**, which is what PortOS ships by default (segmentation
-on). The version bisect is moot — 0.31.2 is not the variable; the display is.
+
+**CONFIRMED (2026-06-27): display-off clears it.** The clean A/B was run — the
+*identical* 9B bf16 seg-OFF config, AGX env still set, **only the display changed
+to asleep** (`pmset displaysleepnow`, lid open, `caffeinate -s`). It reached
+**STEP:302/600**, clearing the entire 150–300 panic window with no panic and no
+reboot (vs the display-on counterpart that died at STEP:0). So the variable is
+unambiguously the **active display / WindowServer GPU compositing** (mlx #3267),
+not the mlx version, not thermal, not memory. The version bisect is moot — 0.31.2
+was never the problem; the display is. **Working recipe for heavy (9B bf16)
+sustained runs on this M5 Max: `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` (shipped) +
+display asleep + (ideally) segmentation ON.** PortOS ships the env var and
+segmentation-on by default; the remaining user action is to keep the display off
+(SSH headless or `pmset displaysleepnow`) for big sustained runs — documented in
+TROUBLESHOOTING.
## Summary
@@ -303,7 +312,8 @@ doesn't lose which version was under test.
|---|---|---|---|---|---|
| (baseline, not run) | 0.17.5 | 0.30.6 | 0.30.6 | known-bad (3 panics 06-13/14) | none captured (sudo was off) |
| 2026-06-14 candidate #1 | 0.17.5 | **0.31.2** | **0.31.2** | ✅ **VALIDATED (seg-ON)** — full LoRA run `d36562a0` completed to adapter extraction (4B bf16, 768px, 4×150-step segs); box up, no panic. Pinned 2026-06-27 (#1329). | telemetry captured; GPU/power normal through the run |
-| 2026-06-27 AGX fix (seg-OFF) | 0.17.5 | 0.31.2 | 0.31.2 | ❌ **PANICKED** — `flux2-klein-9b` bf16, 768px, **segmentation OFF**, `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` set, under `caffeinate -s` **but the display was active**. Hard-rebooted ~11 min in, at **STEP:0** (sustained training GPU load just beginning), same `watchdog timeout: no checkins from watchdogd in 93 seconds` signature (`AppleARMWatchdogTimer`/`AppleInterruptControllerV3`), paniclog `panic-full-2026-06-27-101518`. **The AGX env var alone does NOT prevent the panic on heavy (9B bf16) seg-OFF with the display active.** | ✅ **first telemetry-captured panic** — `Current pressure level: Nominal` throughout, GPU pegged (1592 MHz, 97% active, 24.4 W), then powermetrics **stops at 10:12:19** while the watchdog fires at 10:15:18 → **driver hang, NOT thermal/swap** (compressor 13% OK). Paniclog: `WindowServer` was the top-CPU thread = active-display contention (mlx #3267). |
+| 2026-06-27 AGX fix (seg-OFF, **display ON**) | 0.17.5 | 0.31.2 | 0.31.2 | ❌ **PANICKED** — `flux2-klein-9b` bf16, 768px, **segmentation OFF**, `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` set, under `caffeinate -s` **but the display was active**. Hard-rebooted ~11 min in, at **STEP:0** (sustained training GPU load just beginning), same `watchdog timeout: no checkins from watchdogd in 93 seconds` signature (`AppleARMWatchdogTimer`/`AppleInterruptControllerV3`), paniclog `panic-full-2026-06-27-101518`. **The AGX env var alone does NOT prevent the panic on heavy (9B bf16) seg-OFF with the display active.** | ✅ **first telemetry-captured panic** — `Current pressure level: Nominal` throughout, GPU pegged (1592 MHz, 97% active, 24.4 W), then powermetrics **stops at 10:12:19** while the watchdog fires at 10:15:18 → **driver hang, NOT thermal/swap** (compressor 13% OK). Paniclog: `WindowServer` was the top-CPU thread = active-display contention (mlx #3267). |
+| 2026-06-27 AGX fix (seg-OFF, **display OFF**) | 0.17.5 | 0.31.2 | 0.31.2 | ✅ **SURVIVED** — *same* `flux2-klein-9b` bf16, 768px, **segmentation OFF**, `AGX_RELAX_CDM_CTXSTORE_TIMEOUT=1` set, only change = **display asleep** (`pmset displaysleepnow` after launch; lid open, `caffeinate -s`). Reached **STEP:302/600** (checkpoints 0/150/300), **clearing the whole 150–300 panic window**, no panic, no reboot (box up 5h20m). Stopped cleanly at the success bar — the display-off A/B counterpart of the row above. Scratch `data/training-runs/_validate-agx-segoff-displayoff/`. | telemetry captured; clean throughout |
**Verdict & pin (2026-06-27, #1329).** The candidate #1 "IN FLIGHT" row above was
the *seg-OFF scratch* run, which was **manually stopped clean at step ~11** (never
@@ -316,15 +326,12 @@ in `scripts/setup-image-video.sh` (replacing the `mflux>=0.17` floor that let ml
drift), per phosphene's "every pin is a paid lesson."
This validates the **production config** (segmentation ON — the shipped
-mitigation). The **pure seg-OFF sustained 9B-bf16 verdict on 0.31.2 remains
-untested** — a seg-OFF run reproduces the original panic condition and risks a
-session-killing hard reboot (~3.5–7 h to clear the panic window at ~1.3–1.6
-min/step). Run it on the throwaway dataset if a definitive "the driver hang
-itself is fixed" answer is wanted; until then the pin rests on a completed
-real-world run plus segmentation as the standing mitigation. The upstream
-mflux/MLX issue draft (`docs/research/2026-06-14-upstream-issue-draft-m5-watchdog.md`)
-stays unfiled pending a telemetry-captured seg-OFF repro that disambiguates
-thermal vs driver.
+mitigation). The **pure seg-OFF sustained 9B-bf16 verdict on 0.31.2 is now also
+settled** (2026-06-27): it **panics with the display ON and survives with the
+display OFF** (the two A/B rows above) — so the driver hang is real but is gated
+by active-display GPU contention, not by the mlx version. We did NOT file a fresh
+upstream issue (it would duplicate mlx #3267 / #3186); instead the telemetry +
+display-off A/B were posted as data-point comments on mlx #3267.
**Speed finding (2026-06-14 ~14:10) — 9B bf16 is pathologically slow on this box; 4B is ~25× faster.**
The first Freydis run (`flux2-klein-9b`, bf16, 768px, 600 steps) ran **14 minutes
@@ -351,8 +358,9 @@ already grinding her exact dataset into a throwaway dir. Dual-purposing it on
the mlx **0.31.2** stack finishes her LoRA *and* gives 0.31.2 a real-world test.
Trade-off: with segmentation ON a survived run proves "0.31.2 + segmentation
completes" (the production config), NOT "0.31.2 alone survives sustained GPU" —
-the pure seg-OFF verdict on 0.31.2 remains untested (rerun on the throwaway
-dataset later if wanted). Telemetry still capturing per-run.
+the pure seg-OFF verdict on 0.31.2 was settled later on 2026-06-27 (the two
+display ON/OFF A/B rows in the bisect table: panics with the display on, survives
+to step 302 with it off). Telemetry still capturing per-run.
**Candidate #1 live notes (2026-06-14 ~13:45, seg-OFF scratch — superseded):** scratch run
`data/training-runs/_bisect-mlx0312/` (9B bf16, 768px, low_ram, segmentation