Skip to content

Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.

release(v3.4.1): chained windows — 10s/15s tiers, ~2x faster long clips + fixes

mrbizarrof66e59cf14c0
diff --git a/VERSION b/VERSION
index 1809198..47b322c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.4.0
+3.4.1
diff --git a/docs/H3_ENGINE.md b/docs/H3_ENGINE.md
index c5e2733..a3769c6 100644
--- a/docs/H3_ENGINE.md
+++ b/docs/H3_ENGINE.md
@@ -62,6 +62,7 @@ duplicating 75 GB.
| `LTX_H3_MODELS` | `<install>/mlx_models/hailuo-h3` | the three weight components |
| `LTX_H3_PYTHON` | `<H3_ROOT>/.venv/bin/python3.11` → `python` | interpreter override (a checkout without its own venv) |
| `LTX_H3_FORCE_CAPABLE` | unset | test-only: stop the UI hiding the pill on a small Mac. Does **not** make it render. |
+| `LTX_H3_DENSE_10S` | unset | re-adds the pre-chaining dense 10 s tier (36 min) for A/B work |
### Model layout — both shapes work
@@ -85,22 +86,81 @@ shape; the campaign checkout uses the first.
`H3_TIERS` in `mlx_ltx_panel.py` is the single source of truth — the UI renders
its chips from `/status.h3.tiers`, so a tier change is one Python edit.
-| Tier | Geometry | Sigma points | Wall time |
-|---|---|---|---|
-| Draft · 3s | 640×384 · 73f | 9 (8 forwards) | ~3 min |
-| HQ · 3s | 768×448 · 73f | 9 (8 forwards) | ~4-5 min |
-| HQ · 5s | 768×448 · 124f | 9 (8 forwards) | ~8 min |
-| Long · 10s | 768×448 · 243f | 16 (15 forwards) | ~36 min · batch |
-
-**Why 9 points for three of them and 16 for the last.** `--steps` is sigma
-*points*; the runner does `points - 1` forwards. A matched-cost A/B showed 8
-forwards is visually free at or below ~13k packed rows (640×384/73f ≈ 5.6k,
-768×448/124f ≈ 13.7k). The 10 s tier is a different regime — 768×448/243f is
-~25k rows, where 8 forwards **ghosts** — so it needs 15.
+| Tier | Geometry | Windows | Sigma points | Wall time |
+|---|---|---|---|---|
+| Draft · 3s | 640×384 · 73f | 1 | 9 (8 forwards) | ~3 min |
+| HQ · 3s | 768×448 · 73f | 1 | 9 (8 forwards) | ~4-5 min |
+| HQ · 5s | 768×448 · 124f | 1 | 9 (8 forwards) | ~8 min |
+| Long · 10s | 768×448 · 243f | **2 × 124f chained** | 9 (8 forwards) | ~17 min |
+| Long · 15s | 768×448 · 362f | **3 × 124f chained** | 9 (8 forwards) | ~27 min · batch |
+
+**Why 9 points everywhere now.** `--steps` is sigma *points*; the runner does
+`points - 1` forwards. A matched-cost A/B showed 8 forwards is visually free at
+or below ~13k packed rows (640×384/73f ≈ 5.6k, 768×448/124f ≈ 13.7k). A *dense*
+768×448/243f pass is ~25k rows, where 8 forwards **ghosts** (two astronauts on
+screen) — which is why the old 10 s tier needed 15 forwards and 36 minutes.
+Chaining removes that regime entirely: every pass is a 5 s pass, so every pass
+is inside the window where 8 forwards was proven.
Geometry rules the runner enforces: width and height must be multiples of 32,
and frame counts snap up to the `17n+5` grid.
+### Chained windows (v3.4.1)
+
+Window *N*'s **last decoded frame** becomes window *N+1*'s first-frame keyframe
+through the ordinary FL2VA conditioning path; the duplicate frame is dropped at
+the join and the pieces butt-join in pixel space, with a one-frame equal-power
+audio cross-fade (the chain's real overlap). The panel passes:
+
+```
+--frames <window_frames> --chain-windows N --chain-total-frames <delivered>
+```
+
+Measured (M4 Max 64 GB, `notes/CHAIN_WINDOWS.md` in the H3 campaign):
+
+| | Dense 10 s | Chained 10 s | Chained 15 s |
+|---|---:|---:|---:|
+| Wall | 36:12 | **17:05** | **26:34** |
+| Packed rows | 25,138 | 13,662 max | 13,580 flat |
+| Peak Metal | 42.6 GiB | 40.3 GiB | 40.2 GiB |
+
+Duration is now **linear in wall clock and constant in memory**. Seam grading:
+both 15 s joins measured *quieter* than the clip's own median frame-to-frame
+motion; identity (face, wardrobe, light) held across both.
+
+**Known artefact, surfaced in the UI:** every window receives the same prompt,
+so a prompt that scripts a line asks for that line in *each* window and gets it.
+The tier's `note` field carries that warning ("scripted dialogue repeats once
+per 5 s window — put dialogue cues late in the prompt") and the panel renders it
+under the tier strip. The fix is per-window prompts (`--chain-prompts` on the
+runner); when that reaches the panel UI, delete the `note` and the warning
+disappears everywhere at once.
+
+**Gating.** Chaining needs `--chain-windows` on the *installed* runner.
+`h3_supports_chain()` probes the script source, `/status.h3.chain` reports it,
+`h3_visible_tiers()` withholds the chained tiers from the UI when it's false,
+and `make_job` falls back to the longest single-pass tier rather than failing a
+queued job. `LTX_H3_DENSE_10S=1` restores the old dense 10 s tier for A/B work.
+
+### Export pass — the same post-process LTX renders get
+
+H3 writes 768×448 (12:7), which is neither 720p nor 1080p. The panel now runs
+the identical ffmpeg recipe an LTX render gets: lanczos fit inside the canvas +
+pad the remainder + `libx264` with the user's codec settings (`yuv420p crf 18`
+by default) + `+faststart`, audio copied through untouched. Letterbox bars on
+12:7 content are correct — no crop, no distortion.
+
+- Form field: `h3_upscale` = `off` | `fit_720p` (default) | `fit_1080p`. It is
+ in the `make_job` allowlist; an unlisted field silently no-ops on
+ `/queue/add`.
+- The native file stays on disk but is `set_hidden()` from the gallery, exactly
+ like the LTX upscale path. `UPSCALE_TAGS` (module-level) carries `1080p` /
+ `v1080p` so `/output/delete` trashes the native companion and Load Params
+ still finds the sidecar.
+- Sidecar gains `upscale` (target, method, source, codec) and `output_codec`,
+ and `h3.chain_windows` / `h3.window_frames` / `h3.delivered_frames` /
+ `h3.seams`.
+
---
## What H3 does *not* do
@@ -109,9 +169,10 @@ and frame counts snap up to the `17n+5` grid.
Character, A2V) is LTX-pipeline-specific; the picker snaps back to LTX with a
note. Character does too — it submits `mode=t2v` but stacks LTX LoRAs, and H3
has no LoRA path.
-- **LoRAs, upscale, orientation, accel, temporal interpolation**: none apply.
- Those controls carry `data-ltx-only` and fold away under
- `body[data-h3-engine="h3"]`.
+- **LoRAs, orientation, accel, temporal interpolation, the LTX upscale
+ control**: none apply. Those carry `data-ltx-only` and fold away under
+ `body[data-h3-engine="h3"]`. H3 has its own export control (`h3_upscale`,
+ `data-h3-only`) — see the export-pass section above.
- **External audio**: H3 generates its own. `i2v_clean_audio` stays LTX.
### `--first-frame` (Image mode) is branch-dependent
@@ -166,6 +227,8 @@ restart. `GET /status` → `.h3` tells you what resolved:
| Image mode snaps back to LTX | `h3.first_frame` false — the installed runner has no `--first-frame` |
| `ffmpeg not found on PATH` | the runner pipes raw RGB into `ffmpeg`; the panel prepends `FFMPEG_BIN` to the subprocess PATH, so this means the bundled binary is missing |
| Job cancelled but memory stays high | shouldn't happen — `/stop` SIGTERMs the whole process group and SIGKILLs after 8 s; check `STATE["h3_pgid"]` |
+| 10 s / 15 s tiers missing from the strip | `h3.chain` false — the installed runner has no `--chain-windows`; update the pack |
+| A render survived a panel crash | expected of `kill -9` (atexit can't run), but the NEXT boot reaps it: `state/h3_running.json` names the pid/pgid and `reap_orphan_subprocesses()` kills it before the queue moves. Same guard exists for the warm helper (`state/helper_running.json`). |
Metrics for every run are kept at `state/h3_metrics/<job_id>.json` (the runner's
own phase timings, peak GiB, packed rows), and summarised into the render's
diff --git a/docs/STATE.md b/docs/STATE.md
index e45822c..1a5ffa4 100644
--- a/docs/STATE.md
+++ b/docs/STATE.md
@@ -2,6 +2,52 @@
**Public release: `v3.1.1`.** The entire v3.0 line shipped — v3.0.0 (Characters / Voice / Image Studio / A2V, May 23) → v3.0.1 (FFLF crash fix) → v3.0.2 (Boost/Turbo accel restored after a 2-month silent regression) → v3.0.3 (HiDream hidden, #15) → v3.0.4 (CivitAI SSL) → v3.0.5 (A2V kwarg signature shim, #5) → v3.0.6 (deep-review hardening) → v3.0.7 (GPU-race fix + /status version surfacing) → **v3.0.8 (ltx-2-mlx v0.14.8 catch-up — codec-only patches, I2V "mosaic"/Metal-watchdog fix #17, ASCII version-skew handshake fix)** → **v3.0.9 (custom I2V Width×height inputs restored for power users; Train-tab dev-transformer Download "unknown install key" fix — form-encoding, reported by @cocktailpeanut)** → **v3.0.10 (model-integrity self-heal — boot scan + `/status.model_integrity` + a one-click Repair banner for corrupt/partial weights, the leading *non-Metal* "mosaic" garbage-decode cause; safetensors header+size check)** → **v3.0.11 (latent helper-handshake hang fixed: `_read_until` mixed `select()` on the raw fd with a buffered `readline()`, so any event the helper emitted *right before* `ready` — a version-skew line, the new runtime fingerprint — got stranded in the TextIOWrapper buffer and the panel hung 120 s → "helper failed to start: None". This is the true root cause behind the mislabeled "⚠️-emoji" handshake break. Now reads the raw fd via `os.read()` into a carry buffer and drains every complete line before re-`select()`-ing. PLUS: every render log self-documents its runtime — mlx/mlx-metal version + Apple chip + macOS — surfaced in `/status`, the `helper ready ·` line, and a standalone `runtime |` line, the exact data needed to triangulate the remaining MLX-numerical "mosaic")** → **v3.0.12 (the REAL mosaic fix + 3 more. The mosaic is NOT a code bug or the missing-upscaler theory (both disproved by local repro — the bare 6-file Q4 set renders byte-identical-clean on M4 Max); it's stale/corrupt weight *content* — right size, wrong bytes — that v3.0.10's header+size check can't see (confirmed: ronyeoh/#18 + claude3d/#5 fixed it only by a fresh full re-download). Added **deep checksum verify vs upstream**: Settings → Model files → "Verify model files (checksum)" / `/models/verify-deep` hashes every weight + compares to HuggingFace's published SHA-256 (proven to match local), mismatches feed the existing one-click Repair re-download. Validated: flipped 16 bytes mid-file → header+size passed, deep-verify caught it. ALSO in v3.0.12: character-LoRA-shows-as-"style-only" fix (#5 — `list_user_loras` recovers trigger+kind from the `_v2` filename when the sidecar is missing); `cgi`→`email` multipart migration (Python-3.13-ready, removes the boot DeprecationWarning, adopted from @ssfeather's PR #22); dynamic 3–8 multi-keyframe UI (adopted from @youngbee12's PR #20, ported clean with the integrity feature preserved + a JS ReferenceError fixed). Folds in v3.0.11's handshake fix + runtime fingerprint.)** → **v3.0.13 (character LoRA fixes, #5 @claude3d: a multi-word/spaced character filename no longer mislabels as style-only — the id regex gated out spaces before the sidecar was read; and the Character tab no longer silently falls back to plain T2V — a UI desync left the avatar's selection ring lit after `character_id` was cleared. Plus an `enhancePrompt` element-id fix. Cherry-picked to prod `ce03139`, release `814dc2d`.)** → **v3.1.0 (Ideogram 4 — open-weight 9.3B text-rendering image model + a visual text-placement canvas that places exact text via normalized-bbox captions. mflux 0.18 `mflux-generate-ideogram4`; gated `ideogram-ai/ideogram-4-fp8` ~26 GB, needs a HF Read token + license. Fixed the gated-download 401 that would have hit EVERY user — the panel now exports its configured token to subprocess env via `_sync_hf_token_to_env` so a stale `hf auth login` cache can't shadow it; proven clean-room. Validated end-to-end: 8-text-element field-guide poster rendered clean, every label placed per its bbox.)** → **v3.1.1 (Ideogram output-card buttons hotfix, reported by Mr Bizarro: an Ideogram image's prompt is a caption JSON, which broke every output surface that fed it into a plain box / inline onclick — the Recent-list Animate button was worked-but-dead because apostrophes/&/< in the caption terminated the single-quoted onclick. Display-layer fix: `_displayPromptFor` derives `high_level_description`, `escapeHtml` the onclick args, friendly `_imgEngineLabel`, and `loadParams` restores an Ideogram image into the visual canvas instead of dumping JSON. `params.prompt` stays the caption JSON; renders unaffected. Validated live.)** All validated end-to-end on the dev panel (deep-verify corrupt-detect + repair, /loras, byte-identical upload, multi-keyframe render, FFLF regression). See §4 for the full version history. The May-17 Codex C+ UI restructure (capability tiers, Q4 surface, Character as 5th mode pill, accel kill, HQ-speed move) and the Train-tab / LoRA-chrome work that followed are all baseline now, folded into v3.0.x. There is no `v2.0.6` tag.
+> **📯 2026-08-03 — v3.4.0 SHIPPED PUBLIC: the Hailuo H3 engine.** Public `origin/main` `0ef1a98`, tag `v3.4.0`, tree==beta. Engine picker (LTX-2.3 | Hailuo H3) in the Video tab; H3 in Text+Image (Image = first-frame conditioning); 4 measured tiers (Draft 3s ~3min / HQ 3s ~5min / HQ 5s ~8min / Long 10s ~36min); optional install_h3.js (~75GB, 64GB-RAM gated, clones mrbizarro/minimax-h3-mlx@codex/h3-engine); warm-helper teardown before H3 jobs; subprocess isolation — LTX untouched. Validated end-to-end by an independent agent (real t2v + first-frame i2v renders with audio, stop test, LTX regression, 5/5 SHIP). Release post LIVE: <https://beta.pinokio.co/posts/01kz48kve8g17ymk8dtms5j2g7> (robot-chef validation clip as hero). Residual known risk (accepted, owner-driven release): install_h3.js has never run on a truly clean machine — weights sources verified fetchable+ungated and the branch verified byte-identical to the validated runner; if a fresh-install report comes in, treat as hotfix priority. H3 experiment records: ~/AI/projects/hailuo-mlx/.
+
+> **🧪 2026-08-05 — v3.4.1 on `dev`/`beta` (NOT public): chained H3 tiers, the H3 export pass, crash-reap, and BT.709 on every delivered clip.** Four changes, all validated on the dev box before the push.
+>
+> - **Chained 10 s / 15 s H3 tiers** (`e831fb3`). Anything past 5 s now renders as N chained 5 s windows — window N's last decoded frame re-enters as window N+1's first-frame keyframe. 10 s went 36:12 (one dense 243f pass) → **17:05**; 15 s is newly reachable at **26:34**; memory is FLAT (13,580 rows/window, 40.2 GiB peak) so duration is linear in wall clock. The dense 10 s path stays behind `LTX_H3_DENSE_10S=1` for A/B. Honest artefact reported as data: one prompt is asked of every window, so a scripted line lands once per window — the tier carries a `note` the panel renders under the strip. Chaining needs `--chain-windows` on the INSTALLED runner, so it is probed (`/status.h3.chain`), the chained tiers are withheld when absent, and `make_job` falls back to the longest single-pass tier instead of failing a queued job.
+> - **H3 gets the export pass LTX already had** (`e831fb3`). H3's native 768×448 (12:7) no longer lands in a gallery of 1280×720 clips: same ffmpeg recipe (lanczos fit inside the canvas, pad the remainder, user's codec settings, `+faststart`, audio copied through). Default `fit_720p`, `fit_1080p` option, `off` for native. `h3_upscale` is in the make_job allowlist; native stays on disk but hidden, exactly like the LTX path; `UPSCALE_TAGS` is module-level so `/output/delete` and Load Params can't drift from `compute_upscale_plan`.
+> - **A SIGKILLed panel's children get reaped at the next boot** (`1dde141`). Both heavy children spawn with `start_new_session=True` (so `/stop` can killpg the tree), which means `kill -9 <panel>` leaves them running — and the restarted panel re-queues the in-flight job and starts a SECOND 40 GiB render next to the orphan. Each spawn now drops `state/h3_running.json` / `state/helper_running.json`; `reap_orphan_subprocesses()` runs before `worker_loop`.
+> - **BT.709 on every delivered clip** (`6b8f34f`). Every mp4 the panel handed the user read back `color_primaries/transfer/space = unknown`, so players guessed and the reported symptom was washed-out colour. **On ffmpeg 8 the output flags alone are not enough** — the filtergraph's frame properties override `-color_primaries`/`-color_trc`/`-colorspace`, and every export pass has a `-vf`. Measured on both builds a user can hit (8.0.1 bundled, 8.1.2 Homebrew): flags alone → primaries only; flags + a trailing `setparams` → all three. Applied to the H3 export, the LTX fit_720p/1080p upscale, the i2v audio mux, Long Clip Boost, and both PiperSR encodes. `setparams` is probed once and falls back rather than losing a render on an ancient build.
+>
+> **Corner tests run this session (dev box, documented H3 env):**
+> - **Scheduling — PASS.** Two batches. Batch 1 (5 jobs queued in the same second: LTX → H3 → H3 → H3 → LTX) executed strictly serially, each job starting the second the previous finished, 5/5 done. Batch 2 (H3 → LTX → H3) confirmed helper teardown before each H3 job and lazy respawn for the LTX job in between. Exports verified: H3 Draft → `1280×720`, 72f in / 72f out, AAC copied through, sidecar carries the full `upscale` plan; LTX Quick + `fit_720p` → `1280×720`, 48f in / 48f out. Gallery lists only the `_720p` files; natives hidden.
+> - **Crash-resume — PASS on the reap, PARTIAL on the live-orphan leg.** An *unplanned* crash mid-batch (see the collision note below) gave the real thing: panel gone, job persisted as `running`. Next boot cleared the stale guard without signalling anything and re-queued the job as `queued` — resumed, not zombie, no second render. The kill path itself was then exercised deliberately with decoy children on all three branches: **orphan with a dead owning panel → reaped** (`[boot] reaping orphaned h3 subprocess pid=… / h3 orphan gone`); **child whose owning panel is still alive → untouched, guard preserved**; **recycled pid whose cmdline no longer matches the needle → untouched, guard dropped**. What was NOT re-run end-to-end: `kill -9` against a live 40 GiB H3 render — see below.
+>
+> **⚠️ Machine collision, not a code fault.** Mid-test another agent started a separate ~40 GiB `generate_staged.py` run (the `hdloop` HD-loop campaign under `~/AI/projects/hailuo-mlx/codex/opt_out/`). Two H3 renders do not fit in 64 GB: the OS killed this panel *and* its H3 child, which is why the crash above was real rather than staged. Free memory stayed at ~11% afterwards, so no competing render was started to finish the live-orphan leg — re-run `kill -9` mid-H3-render when the box is idle. **Check `pgrep -f generate_staged` before any H3 work on this machine, and re-check it mid-run.**
+>
+> **Deferred (not touched here, deliberately):** the *base* render — LTX with export `off` — is still untagged, because that mp4 is written by the vendored `ltx_core_mlx` encode that `patch_ltx_codec.py` patches at install time. That call has no `-vf`, so flags alone would be enough there; it was left alone because widening the CODEC-ONLY patch on a release commit risks the installer. Same file, same visit: that encode passes `-shortest` alongside `-c:a aac`, which is why a 49-frame LTX render delivers 48 frames (the panel's duration model already assumes this). Both belong in one careful pass over `patch_ltx_codec.py`.
+
+> **🚨 2026-08-05 — v3.4.0 FIELD REGRESSION FIXED on `dev`/`beta`: "I installed other packs and Hailuo H3 vanished."** A public v3.4.0 user installed H3, rendered with it happily (10 s clips on an M5 Pro), then installed other optional packs — and H3 disappeared from the panel. He ran **Reset**; H3 was still gone.
+>
+> **Root cause — `mlx_ltx_panel.py:_h3_python()` + `pinokio.js` h3_ready, both trusting `.venv/bin/python3.11`.** Nothing is ever deleted. `install_h3.js` builds the H3 venv with `uv venv`, and uv creates the interpreter as a symlink chain into Pinokio's **shared, app-external** managed Python:
+>
+> ```
+> minimax-h3-mlx/.venv/bin/python3.11 -> python
+> minimax-h3-mlx/.venv/bin/python -> <pinokio>/cache/XDG_DATA_HOME/uv/python/
+> cpython-3.11-macos-aarch64-none/bin/python3.11
+> ```
+>
+> That target belongs to Pinokio, not to Phosphene (verified on this machine against the LTX venv, which has the identical chain). Any other pack install — or any other Pinokio app — that makes uv re-resolve, bump or prune the managed interpreter leaves the chain **dangling**. `Path.exists()` follows symlinks, so `_h3_python()` returns `None`, `h3_available()` goes false, and the panel tells a user with **~75 GB of H3 weights still on disk** that H3 is "not installed". The engine pill demotes, the tier strip disappears — "H3 vanished".
+>
+> **Why Reset made it worse, not better.** `reset.js` removes only `ltx-2-mlx/`, so it never touches `minimax-h3-mlx/` — it *cannot* repair this. And because Reset makes `env_ready` false, `pinokio.js` early-returns at the `!env_ready` branch, which never reaches the H3 row — so after Reset there was **no H3 affordance anywhere in the product**. That is the whole reported experience, exactly.
+>
+> **This bug class was already documented in this repo and we repeated it.** `required_files.json → env._comment` records the same trap for the LTX venv, cocktailpeanut-confirmed: *"we used to point at `bin/python3.11` but uv creates that as a symlink chain … Pinokio's `info.exists()` check returned false on that chain … use `pyvenv.cfg` instead."* H3 shipped pointing at `bin/python3.11` anyway. **Any new venv-backed pack must not probe `bin/python*`.**
+>
+> **Fixed (`3c9bdf6`):**
+> - `h3_paths()` / `h3_status()` now report **why**, not just that it's unavailable: `reason` (`ok` | `not_installed` | `missing_weights` | `missing_venv` | `missing_runner`) plus `repairable`, `venv_broken`, `weights_ok`, all on `/status.h3` and the page bootstrap. `repairable` = weights on disk, only code/venv broken.
+> - The panel offers **repair, not reinstall**: engine pill (`needs repair · weights kept`), the H3 card (rewritten for the repair case), the job-time error, and a new branch in `updateModelsCard()` — gated on `repairable`, so a user who never installed H3 is never nagged.
+> - `pinokio.js` probes the interpreter with **`fs.existsSync`** (follows symlinks → a dangling chain is definitively false) instead of `info.exists`, so menu and panel agree by construction. Adds **"Repair Hailuo H3 (weights kept — no re-download)"** and keeps it reachable from **every** menu state, including post-Reset.
+> - `install_h3.js`'s venv step no longer trusts a path guard — a dangling chain can read as *present* depending on whether the check stats the link or the target, which would silently skip the repair. It now asks whether the interpreter **runs** and rebuilds only when it doesn't (~50 ms on a healthy install, ~2 min self-heal when broken, zero bytes re-downloaded).
+> - `reset.js` documents that `minimax-h3-mlx/` and `mlx_models/hailuo-h3/` are user content and must never be added to it.
+>
+> **Validation.** Sandbox at the DEFAULT paths (no env overrides) driving the **real** `h3_paths()` (spliced from the panel) and the **real** `pinokio.js` menu block, across healthy → stomp → Reset → repair. Before: panel "not installed", menu after Reset `[Install, Models]`. After: panel `reason=missing_venv repairable=true venv_broken=true weights_ok=true`, menu `Repair Hailuo H3` present in the healthy *and* post-Reset states, back to clean once the venv is rebuilt — **5/5 weight components untouched throughout**. `py_compile` + `node --check` on all nine root scripts. The live panel was **not** restarted (a Codex GPU experiment held the box), so this is code-level + simulation validation; a real Pinokio click-through of Repair is the remaining gate.
+>
+> **User recovery on v3.4.0 today, without the fix:** sidebar → **Install Hailuo H3** again. It is idempotent, the weights are still on disk, so it rebuilds the venv and skips every intact file — minutes, not 75 GB. If they already hit Reset, they must click **Install** (base) first, because the H3 entry only renders once the LTX env is back.
+>
+> **Public hotfix?** Judgement: **ride v3.4.1**, don't emergency-patch v3.4.0. It is a discoverability/labelling failure, not data loss (nothing is deleted, no render is corrupted), the workaround is one sidebar click, and H3 is a 64 GB-only opt-in pack so the blast radius is small. But v3.4.1 should ship **soon** rather than waiting to accumulate — every affected user currently reads this as "I lost my 75 GB download".
+
Current `dev` head: see `git log -1` for the live SHA. `dev` tracks `beta/main` (private repo — see §1).
> ## 🆕 IN PROGRESS on `dev` 2026-08-03 — **Hailuo H3 as a SECOND video engine** (not pushed, VERSION untouched)
diff --git a/install_h3.js b/install_h3.js
index 92c23ba..b6d0506 100644
--- a/install_h3.js
+++ b/install_h3.js
@@ -14,11 +14,14 @@
// audio by 22 dB), while the H3 port needs mlx>=0.32. Separate venvs mean an
// H3 install can never break LTX rendering, and removing H3 is `rm -rf`.
//
-// Everything below is safe to re-run:
+// Everything below is safe to re-run, and re-running it is ALSO the repair
+// path — the Pinokio menu points "Repair Hailuo H3" at this same script:
// clone — skipped when minimax-h3-mlx/.git exists
-// venv — skipped when .venv/bin/python3.11 exists
+// venv — reused when its interpreter actually runs; rebuilt when it
+// doesn't (see the self-healing note on that step)
// uv pip — already-installed packages are no-ops
// weights — hf_hub_download resumes partial files, skips intact ones
+// So a user whose engine broke re-runs this and pays ~2 minutes, not 75 GB.
//
// The panel discovers the result on its next /status tick (a couple of
// seconds) and unlocks the engine picker. No restart.
@@ -92,17 +95,33 @@ module.exports = {
// MLX wheels. Force 3.11 with uv, then target it explicitly on every pip
// step. If a wrong-Python venv is already there, nuke it — it holds no
// user data.
+ //
+ // SELF-HEALING, and deliberately NOT gated on `when: !exists(...)`.
+ // `uv venv` builds the interpreter as a symlink chain into Pinokio's
+ // SHARED managed Python:
+ // .venv/bin/python3.11 -> python
+ // .venv/bin/python -> <pinokio>/cache/XDG_DATA_HOME/uv/python/
+ // cpython-3.11-macos-aarch64-none/bin/python3.11
+ // That target is Pinokio's, not ours. Any other pack install (or any other
+ // Pinokio app) that makes uv re-resolve, bump or prune the managed
+ // interpreter leaves this chain DANGLING — the engine stops resolving even
+ // though the venv, the clone and all ~75 GB of weights are untouched. That
+ // is the v3.4.0 "installed other packs and Hailuo H3 vanished" report.
+ //
+ // A path-existence `when:` guard cannot fix that reliably: depending on
+ // whether the check stats the link or its target, a dangling chain reads
+ // as either present (repair silently skipped — the failure mode we must
+ // never ship) or absent. So we ask the only question that actually
+ // matters — does this interpreter RUN? — inside the shell, and rebuild
+ // only when it doesn't. Healthy installs pay ~50 ms and skip the rebuild;
+ // broken ones self-heal in ~2 minutes without re-downloading a byte.
{
- when: "{{!exists('minimax-h3-mlx/.venv/bin/python3.11')}}",
method: "shell.run",
params: {
path: "minimax-h3-mlx",
message: [
- "echo '=== H3 venv create ==='",
- "which uv && uv --version || echo 'uv NOT FOUND'",
- "rm -rf .venv",
- "uv venv --python 3.11 --seed .venv",
- ".venv/bin/python --version || echo 'venv python NOT executable'"
+ "echo '=== H3 venv check ==='",
+ "if .venv/bin/python -c 'import sys' >/dev/null 2>&1; then echo 'H3 venv healthy - reusing it'; else echo 'H3 venv missing or broken (dangling interpreter) - rebuilding, no weights are re-downloaded'; which uv && uv --version || echo 'uv NOT FOUND'; rm -rf .venv; uv venv --python 3.11 --seed .venv; .venv/bin/python --version || echo 'venv python NOT executable'; fi"
]
}
},
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.py
index 5e0a9de..24724c8 100644
--- a/mlx_ltx_panel.py
+++ b/mlx_ltx_panel.py
@@ -4390,33 +4390,90 @@ H3_FPS = 24.0
#
# Height/width must be multiples of 32 (runner errors otherwise). Frames land
# on the 17n+5 grid: 73 = 3.0 s, 124 → snaps to 124 (5.1 s), 243 → 10.1 s.
-H3_TIERS: dict[str, dict] = {
- "draft_3s": {
- "key": "draft_3s", "label": "Draft · 3s",
- "width": 640, "height": 384, "frames": 73, "steps": 9,
- "spec": "640×384 · 73f", "eta": "~3 min",
- "blurb": "Fastest look-see. Good enough to judge motion + dialogue timing.",
- },
- "hq_3s": {
- "key": "hq_3s", "label": "HQ · 3s",
- "width": 768, "height": 448, "frames": 73, "steps": 9,
- "spec": "768×448 · 73f", "eta": "~4-5 min",
- "blurb": "Same length as Draft at the delivery resolution.",
- },
- "hq_5s": {
- "key": "hq_5s", "label": "HQ · 5s",
- "width": 768, "height": 448, "frames": 124, "steps": 9,
- "spec": "768×448 · 124f", "eta": "~8 min",
- "blurb": "The workhorse: a full 5 s beat with synced dialogue.",
- },
- "long_10s": {
- "key": "long_10s", "label": "Long · 10s",
- "width": 768, "height": 448, "frames": 243, "steps": 16,
- "spec": "768×448 · 243f", "eta": "~36 min · batch",
- "blurb": "Needs 15 forwards — 8 ghosts at this row count. Queue it and walk away.",
- },
-}
+#
+# CHAINED TIERS (v3.4.1). Anything past 5 s is now rendered as N chained 5 s
+# WINDOWS instead of one dense pass: window N's last decoded frame re-enters as
+# window N+1's first-frame keyframe, the duplicate frame is dropped at the join
+# and the pieces butt-join in pixel space (runner flags --chain-windows /
+# --chain-total-frames). Measured on the 64 GB M4 Max:
+# 10 s dense = 36:12 (243f, 15 forwards, 25k packed rows, 42.6 GiB peak)
+# 10 s chain = 17:05 (2 × 124f, 8 forwards each, 13k rows, 40.2 GiB peak)
+# 15 s chain = 26:34 (3 × 124f — a length the dense path cannot reach here)
+# Chaining is what makes 8 forwards legitimate at 10 s+: every pass is a 5 s
+# pass, so every pass is inside the regime where 8 forwards was validated.
+# Cost is linear in duration and FLAT in memory (13,580 rows per window, every
+# window), which is the whole argument for it.
+#
+# Tier keys used by the chained path:
+# frames = DELIVERED frames (what the user gets; drives duration)
+# window_frames = frames per window handed to --frames
+# chain_windows = N (>1 means chained; the runner needs --chain-windows)
+# note = the honest artefact warning, rendered under the tier strip
+H3_TIER_CHAIN_NOTE = ("Scripted dialogue repeats once per 5 s window — put "
+ "dialogue cues late in the prompt.")
+
+
+def _build_h3_tiers() -> dict[str, dict]:
+ tiers: dict[str, dict] = {
+ "draft_3s": {
+ "key": "draft_3s", "label": "Draft · 3s",
+ "width": 640, "height": 384, "frames": 73, "steps": 9,
+ "spec": "640×384 · 73f", "eta": "~3 min",
+ "blurb": "Fastest look-see. Good enough to judge motion + dialogue timing.",
+ },
+ "hq_3s": {
+ "key": "hq_3s", "label": "HQ · 3s",
+ "width": 768, "height": 448, "frames": 73, "steps": 9,
+ "spec": "768×448 · 73f", "eta": "~4-5 min",
+ "blurb": "Same length as Draft at the delivery resolution.",
+ },
+ "hq_5s": {
+ "key": "hq_5s", "label": "HQ · 5s",
+ "width": 768, "height": 448, "frames": 124, "steps": 9,
+ "spec": "768×448 · 124f", "eta": "~8 min",
+ "blurb": "The workhorse: a full 5 s beat with synced dialogue.",
+ },
+ "long_10s": {
+ "key": "long_10s", "label": "Long · 10s",
+ "width": 768, "height": 448, "frames": 243,
+ "window_frames": 124, "chain_windows": 2, "steps": 9,
+ "spec": "768×448 · 243f · 2×5s", "eta": "~17 min",
+ "blurb": "Two chained 5 s windows — half the dense pass's 36 min, "
+ "and no duplicated-subject ghosting.",
+ "note": H3_TIER_CHAIN_NOTE,
+ },
+ "long_15s": {
+ "key": "long_15s", "label": "Long · 15s",
+ "width": 768, "height": 448, "frames": 362,
+ "window_frames": 124, "chain_windows": 3, "steps": 9,
+ "spec": "768×448 · 362f · 3×5s", "eta": "~27 min · batch",
+ "blurb": "Three chained windows. Identity held across both joins in "
+ "validation. Queue it and walk away.",
+ "note": H3_TIER_CHAIN_NOTE,
+ },
+ }
+ # The dense 10 s pass is kept reachable for A/B work but is NOT offered by
+ # default: it costs 2.1× the chained tier for the same delivered clip.
+ if os.environ.get("LTX_H3_DENSE_10S", "").strip() in ("1", "true", "yes"):
+ tiers["long_10s_dense"] = {
+ "key": "long_10s_dense", "label": "Long · 10s (dense)",
+ "width": 768, "height": 448, "frames": 243, "steps": 16,
+ "spec": "768×448 · 243f · single pass", "eta": "~36 min · batch",
+ "blurb": "One dense pass at 15 forwards — the pre-chaining path. "
+ "Kept for A/B only; the chained tier is 2.1× faster.",
+ }
+ return tiers
+
+
+H3_TIERS: dict[str, dict] = _build_h3_tiers()
H3_TIER_DEFAULT = "draft_3s"
+# Post-render export targets for an H3 clip. H3 writes 768×448 (12:7) natively,
+# which is neither 720p nor 1080p, so the panel applies the SAME ffmpeg recipe
+# LTX renders get: lanczos fit inside the canvas, pad the remainder, re-encode
+# with the user's codec settings. Letterboxing 12:7 into 16:9 is correct — no
+# crop, no distortion.
+H3_UPSCALE_MODES = ("off", "fit_720p", "fit_1080p")
+H3_UPSCALE_DEFAULT = "fit_720p"
# Modes H3 can serve. Text = prompt only; Image = FL2VA first-frame
# conditioning. Everything else (FFLF, Extend, Remix, Character, A2V) is
# LTX-pipeline-specific and has no H3 equivalent.
@@ -4440,7 +4497,12 @@ def _h3_model_roots() -> list[Path]:
def _h3_python() -> Path | None:
"""Interpreter for the H3 pack. LTX_H3_PYTHON overrides (dev boxes that
- keep the venv in a sibling checkout); otherwise the pack's own .venv."""
+ keep the venv in a sibling checkout); otherwise the pack's own .venv.
+
+ STRICT on purpose: this is the interpreter we spawn, so it must resolve to
+ a real executable. `.exists()` follows symlinks, so a dangling chain
+ correctly returns None here — see _h3_venv_present() for why that happens
+ and h3_paths() for how we report it as "repair", not "never installed"."""
override = os.environ.get("LTX_H3_PYTHON", "").strip()
if override:
p = Path(override)
@@ -4452,6 +4514,34 @@ def _h3_python() -> Path | None:
return None
+def _h3_venv_present() -> bool:
+ """Whether an H3 venv was ever BUILT here — regardless of whether its
+ interpreter still resolves.
+
+ `pyvenv.cfg` is the marker, NOT `bin/python3.11`. `uv venv` builds the
+ interpreter as a symlink chain into Pinokio's SHARED, app-external managed
+ Python:
+
+ .venv/bin/python3.11 -> python
+ .venv/bin/python -> <pinokio>/cache/XDG_DATA_HOME/uv/python/
+ cpython-3.11-macos-aarch64-none/bin/python3.11
+
+ That target belongs to Pinokio, not to Phosphene. Any other pack install
+ (or any other Pinokio app) that makes uv re-resolve, bump or prune the
+ managed interpreter leaves this chain DANGLING — at which point
+ `.exists()` is False and H3 reads as "never installed" even though the
+ venv, the runner and all ~75 GB of weights are untouched on disk. This is
+ the user-reported v3.4.0 regression: "installed other packs, H3 vanished".
+
+ required_files.json already documents this exact trap for the LTX venv
+ ("Pinokio's info.exists() check returned false on that chain ... use
+ pyvenv.cfg instead: a tiny ASCII file uv writes to every venv root, never
+ a symlink, never moves"). H3 was repeating it. `bin/activate` is the same
+ kind of plain file and is kept as a secondary probe."""
+ venv = H3_ROOT / ".venv"
+ return (venv / "pyvenv.cfg").is_file() or (venv / "bin" / "activate").is_file()
+
+
def h3_paths() -> dict:
"""Resolve every H3 component. Never raises — reports what's missing so
the UI can render an honest install card instead of a stack trace."""
@@ -4482,6 +4572,36 @@ def h3_paths() -> dict:
missing.append("Q8 components (text_encoder / video_vae / audio_vae)")
if text_config is None:
missing.append("upstream text_encoder config.json")
+
+ # ---- WHY it's unavailable, not just THAT it is --------------------------
+ # The three failure classes need three different sentences from the UI:
+ #
+ # missing_weights — the ~75 GB really isn't there. A real download.
+ # missing_venv — the venv exists but its interpreter no longer
+ # resolves (the shared-uv-Python stomp above), or it
+ # was never built. Weights are on disk: a REPAIR, ~2
+ # minutes, not 75 GB.
+ # missing_runner — the clone is gone/partial but the weights (which
+ # live under mlx_models/, a different tree) survived.
+ # Also a repair.
+ #
+ # `repairable` is the load-bearing one: weights present + code/venv gone.
+ # It is what stops the panel silently reporting "not installed" to a user
+ # who has 75 GB of H3 weights sitting on their disk.
+ weights_ok = dit is not None and compact_root is not None and text_config is not None
+ runner_ok = runner.is_file()
+ venv_ok = python is not None
+ venv_built = _h3_venv_present()
+ if not missing:
+ reason = "ok"
+ elif not weights_ok and not (runner_ok or venv_built):
+ reason = "not_installed"
+ elif not weights_ok:
+ reason = "missing_weights"
+ elif not venv_ok:
+ reason = "missing_venv"
+ else:
+ reason = "missing_runner"
return {
"root": str(H3_ROOT),
"models": str(H3_MODELS),
@@ -4492,6 +4612,14 @@ def h3_paths() -> dict:
"compact_root": compact_root,
"text_config": text_config,
"missing": missing,
+ "reason": reason,
+ "runner_ok": runner_ok,
+ "venv_ok": venv_ok,
+ # venv dir + pyvenv.cfg are there but the interpreter doesn't resolve →
+ # the dangling-shared-uv-Python case, verbatim.
+ "venv_broken": venv_built and not venv_ok,
+ "weights_ok": weights_ok,
+ "repairable": bool(weights_ok and not (runner_ok and venv_ok)),
}
@@ -4512,31 +4640,60 @@ def h3_capable() -> bool:
return SYSTEM_RAM_GB >= H3_MIN_RAM_GB
-_H3_FF_CACHE: dict[str, bool] = {}
+_H3_FLAG_CACHE: dict[str, bool] = {}
-def h3_supports_first_frame() -> bool:
- """Whether the INSTALLED runner accepts `--first-frame` (FL2VA image
- conditioning). The flag landed after the first public branch, so an older
- checkout renders Text fine but would die with an argparse error on Image.
- Probed from the script source (cheap, no subprocess) and cached per mtime.
+def _h3_runner_has_flag(flag: str) -> bool:
+ """Whether the INSTALLED runner accepts `flag`.
+
+ H3 ships as an optional pack that a user may have installed months ago, so
+ a flag the panel wants can simply not exist in their checkout. Probing the
+ script source is cheap (no subprocess), deterministic, and lets the UI hide
+ what the pack can't do instead of dying 30 s into a render with an argparse
+ error. Cached per (flag, runner mtime).
"""
runner = H3_ROOT / "scripts" / "generate_staged.py"
try:
- key = f"{runner}:{runner.stat().st_mtime_ns}"
+ key = f"{flag}:{runner}:{runner.stat().st_mtime_ns}"
except OSError:
return False
- if key in _H3_FF_CACHE:
- return _H3_FF_CACHE[key]
+ if key in _H3_FLAG_CACHE:
+ return _H3_FLAG_CACHE[key]
try:
- supported = "--first-frame" in runner.read_text(encoding="utf-8", errors="replace")
+ supported = flag in runner.read_text(encoding="utf-8", errors="replace")
except OSError:
supported = False
- _H3_FF_CACHE.clear()
- _H3_FF_CACHE[key] = supported
+ # Drop entries for older mtimes of the same script; keep this dict tiny.
+ for stale in [k for k in _H3_FLAG_CACHE if not k.endswith(key.split(":", 1)[1])]:
+ _H3_FLAG_CACHE.pop(stale, None)
+ _H3_FLAG_CACHE[key] = supported
return supported
+def h3_supports_first_frame() -> bool:
+ """Whether the INSTALLED runner accepts `--first-frame` (FL2VA image
+ conditioning). The flag landed after the first public branch, so an older
+ checkout renders Text fine but would die with an argparse error on Image."""
+ return _h3_runner_has_flag("--first-frame")
+
+
+def h3_supports_chain() -> bool:
+ """Whether the INSTALLED runner accepts `--chain-windows` (window chaining).
+
+ Chaining landed on codex/h3-engine after the first public pack, so an older
+ checkout can render 3 s and 5 s fine but has no way to reach 10 s / 15 s.
+ When this is false the chained tiers are withheld from the UI entirely and
+ make_job falls back to the longest single-pass tier."""
+ return _h3_runner_has_flag("--chain-windows")
+
+
+def h3_visible_tiers() -> list[dict]:
+ """The tiers this installation can actually render, in table order."""
+ chain_ok = h3_supports_chain()
+ return [t for t in H3_TIERS.values()
+ if chain_ok or int(t.get("chain_windows") or 1) <= 1]
+
+
def h3_status() -> dict:
"""Compact H3 snapshot for /status + the page bootstrap."""
paths = h3_paths()
@@ -4547,13 +4704,26 @@ def h3_status() -> dict:
"available": available,
"installed": available,
"first_frame": available and h3_supports_first_frame(),
+ "chain": available and h3_supports_chain(),
"min_ram_gb": H3_MIN_RAM_GB,
"ram_gb": round(SYSTEM_RAM_GB, 1),
"root": paths["root"],
"models": paths["models"],
"missing": paths["missing"],
- "tiers": list(H3_TIERS.values()),
+ # WHY it's unavailable — ok | not_installed | missing_weights |
+ # missing_venv | missing_runner. `repairable` means the ~75 GB of
+ # weights are still on disk and only the clone/venv needs rebuilding,
+ # so the UI can offer "Repair H3" (minutes) instead of lying about a
+ # 75 GB download the user already did. `venv_broken` narrows it
+ # further to the dangling shared-uv-Python case.
+ "reason": paths["reason"],
+ "repairable": paths["repairable"],
+ "venv_broken": paths["venv_broken"],
+ "weights_ok": paths["weights_ok"],
+ "tiers": h3_visible_tiers(),
"default_tier": H3_TIER_DEFAULT,
+ "upscale_modes": list(H3_UPSCALE_MODES),
+ "default_upscale": H3_UPSCALE_DEFAULT,
"modes": list(H3_MODES),
"size_note": "~75 GB · needs 64 GB unified memory · "
"MiniMax Community License (territory restrictions apply)",
@@ -4585,6 +4755,12 @@ def _apply_generation_profile_to_job(job: dict) -> None:
params["generation_profile_label"] = profile.get("label")
if not profile.get("compact"):
return
+ # H3 geometry is tier-defined and lives on its own grids (32-aligned dims,
+ # 17n+5 frames). Every clamp below is an LTX-pipeline clamp — applying one
+ # would hand the H3 runner a shape it rejects, and H3 already refuses to
+ # start under 60 GB anyway, so a compact profile can never reach it.
+ if (params.get("engine") or "ltx").strip().lower() == "h3":
+ return
mode = (params.get("mode") or "").lower()
quality = (params.get("quality") or "balanced").lower()
if mode not in ("t2v", "i2v", "i2v_clean_audio", "a2v"):
@@ -5350,6 +5526,14 @@ class WarmHelper:
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
text=True, bufsize=1, start_new_session=True,
)
+ # Crash guard: the helper is in its own session, so a SIGKILLed
+ # panel would leave it resident holding the LTX weights while the
+ # next panel spawns a second one. Boot reaps it from this file.
+ try:
+ _proc_guard_write("helper", self.proc.pid,
+ os.getpgid(self.proc.pid), note="warm helper")
+ except OSError:
+ pass
# Fresh fd → drop any bytes carried over from a prior helper's pipe
# so _read_until's line buffer starts clean for this process.
self._read_carry = b""
@@ -5664,6 +5848,7 @@ class WarmHelper:
except Exception:
pass
self.proc = None
+ _proc_guard_clear("helper")
def is_alive(self) -> bool:
# Snapshot the ref so a concurrent kill() can't null self.proc between
@@ -5758,6 +5943,120 @@ def _kill_h3_proc() -> None:
pass
+# ---- crash guards: subprocesses that outlive a SIGKILLed panel --------------
+#
+# Both heavy children (the H3 render and the LTX warm helper) are spawned with
+# start_new_session=True so /stop can killpg the whole tree. That same flag
+# means they are NOT in the panel's process group, so `kill -9 <panel>` — a
+# crash, an OOM reaper, Force Quit — leaves them running: atexit hooks don't
+# run on SIGKILL. An orphaned H3 render holds ~40 GiB while the restarted panel
+# picks the same job back off the queue and starts a SECOND one.
+#
+# So each spawn drops a tiny guard file naming the child; boot reaps it. The
+# guard records the OWNING panel's pid, and reaping verifies the recorded pid
+# is still running the expected script before signalling anything — a recycled
+# pid must never get killed, and a second panel's children must never be
+# reaped by this one.
+_PROC_GUARDS: dict[str, tuple[Path, str]] = {
+ "h3": (STATE_DIR / "h3_running.json", "generate_staged"),
+ "helper": (STATE_DIR / "helper_running.json", "mlx_warm_helper"),
+}
+
+
+def _proc_guard_write(kind: str, pid: int, pgid: int, note: str = "") -> None:
+ entry = _PROC_GUARDS.get(kind)
+ if not entry:
+ return
+ try:
+ atomic_write_text(entry[0], json.dumps({
+ "kind": kind, "pid": int(pid), "pgid": int(pgid),
+ "panel_pid": os.getpid(), "started": iso_now(), "note": note,
+ }, indent=2))
+ except Exception: # noqa: BLE001 — a guard must never break a render
+ pass
+
+
+def _proc_guard_clear(kind: str) -> None:
+ entry = _PROC_GUARDS.get(kind)
+ if not entry:
+ return
+ try:
+ entry[0].unlink()
+ except (FileNotFoundError, OSError):
+ pass
+
+
+def _pid_cmdline(pid: int) -> str:
+ """`ps` command line for a pid, or "" when it's gone. Cheap and portable
+ enough here — this runs at most twice, at boot."""
+ try:
+ out = subprocess.run(["ps", "-o", "command=", "-p", str(pid)],
+ capture_output=True, text=True, timeout=5)
+ return (out.stdout or "").strip()
+ except Exception: # noqa: BLE001
+ return ""
+
+
+def _pid_alive(pid: int) -> bool:
+ try:
+ os.kill(pid, 0)
+ return True
+ except ProcessLookupError:
+ return False
+ except PermissionError:
+ return True # alive under another uid
+ except (OSError, TypeError, ValueError):
+ return False
+
+
+def reap_orphan_subprocesses() -> None:
+ """Boot hook — kill children a previous panel process left behind.
+
+ Only ever signals a pid whose CURRENT command line still matches the
+ script the guard was written for, and only when the panel that spawned it
+ is gone. Anything else (stale guard, recycled pid, a second live panel)
+ results in the guard being dropped and nothing being killed.
+ """
+ for kind, (guard, needle) in _PROC_GUARDS.items():
+ try:
+ if not guard.is_file():
+ continue
+ data = json.loads(guard.read_text(encoding="utf-8")) or {}
+ except (OSError, json.JSONDecodeError):
+ _proc_guard_clear(kind)
+ continue
+ panel_pid = int(data.get("panel_pid") or 0)
+ if panel_pid and panel_pid != os.getpid() and _pid_alive(panel_pid):
+ # Another panel is alive and owns this child — leave both alone.
+ continue
+ pid = int(data.get("pid") or 0)
+ pgid = int(data.get("pgid") or 0)
+ cmdline = _pid_cmdline(pid) if pid else ""
+ if pid and needle in cmdline:
+ print(f"[boot] reaping orphaned {kind} subprocess pid={pid} "
+ f"pgid={pgid} (previous panel died without cleaning up)",
+ flush=True)
+ for sig, wait_s in ((signal.SIGTERM, 8.0), (signal.SIGKILL, 2.0)):
+ try:
+ if pgid:
+ os.killpg(pgid, sig)
+ else:
+ os.kill(pid, sig)
+ except (OSError, ProcessLookupError):
+ break
+ deadline = time.time() + wait_s
+ while time.time() < deadline:
+ if not _pid_alive(pid):
+ break
+ time.sleep(0.25)
+ if not _pid_alive(pid):
+ break
+ print(f"[boot] {kind} orphan "
+ f"{'still alive - kill it manually' if _pid_alive(pid) else 'gone'}",
+ flush=True)
+ _proc_guard_clear(kind)
+
+
def _kill_image_procs() -> None:
"""Atexit hook — SIGTERM any in-flight image-engine subprocesses
(HiDream BF16 helper, mflux per-family binaries). Each engine registers
@@ -5787,6 +6086,68 @@ def compute_pad(w: int, h: int) -> tuple[int, int, str | None]:
return target_w, target_h, f"pad={target_w}:{target_h}:{pad_x}:{pad_y}:color=black"
+# Filename tags an export pass appends to the native render's stem
+# (`clip.mp4` → `clip_720p.mp4`). Single source of truth: /output/delete walks
+# this list to trash the hidden native alongside the visible card, and Load
+# Params walks it to find the sidecar that lives next to the exported file.
+# Anything compute_upscale_plan can emit as `tag` MUST be here.
+UPSCALE_TAGS = ("720p", "v720p", "1080p", "v1080p", "up2x")
+
+
+# ---- BT.709 tagging on every delivered file ---------------------------------
+#
+# Every clip the panel hands the user is Rec.709 (HD primaries, sRGB-ish
+# transfer) — but nothing was SAYING so, and an untagged HD file is a player
+# coin-flip: QuickTime guesses one way, Chrome another, and the symptom users
+# report is "washed out" or "too contrasty" colour that isn't in the pixels.
+#
+# The output options alone are NOT enough on ffmpeg 8. The filtergraph's own
+# frame properties override `-color_primaries` / `-color_trc` / `-colorspace`,
+# and every export pass here has a `-vf`. Measured on both builds a user can
+# hit (8.0.1, Pinokio's bundled binary; 8.1.2, Homebrew), scaling 768×448 →
+# 1280×720:
+#
+# flags only → primaries=bt709, transfer=unknown, matrix=unknown
+# flags + trailing setparams → primaries=bt709, transfer=bt709, matrix=bt709
+#
+# So the filter is what actually lands the tags and the flags stay as the
+# container-level belt to its braces. `setparams` only writes metadata — no
+# pixel conversion, no re-scaling, no measurable cost.
+BT709_SETPARAMS = "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709"
+BT709_FLAGS = ["-color_primaries", "bt709", "-color_trc", "bt709",
+ "-colorspace", "bt709"]
+_FFMPEG_FILTER_CACHE: dict[str, bool] = {}
+
+
+def _ffmpeg_has_filter(name: str) -> bool:
+ """Whether the resolved ffmpeg build carries `name`. `setparams` has shipped
+ since 4.2 (2019) so this is all but always true — but an export pass is the
+ last step of a render that can cost half an hour, and an unknown filter is a
+ hard failure. One cached ~50 ms probe buys the fallback path."""
+ if name in _FFMPEG_FILTER_CACHE:
+ return _FFMPEG_FILTER_CACHE[name]
+ ok = False
+ try:
+ out = subprocess.run([str(FFMPEG), "-hide_banner", "-filters"],
+ capture_output=True, text=True, timeout=15)
+ ok = any(line.split()[1:2] == [name]
+ for line in (out.stdout or "").splitlines() if line.strip())
+ except Exception: # noqa: BLE001 — a probe must never break a render
+ ok = False
+ _FFMPEG_FILTER_CACHE[name] = ok
+ return ok
+
+
+def bt709_vf(vf: str | None = None) -> str:
+ """`vf` with the BT.709 setparams filter appended (or it alone when there is
+ no other filtering to do). Returns `vf` untouched when the build lacks the
+ filter — the flags still tag primaries, which is what we had before."""
+ vf = (vf or "").strip().rstrip(",")
+ if not _ffmpeg_has_filter("setparams"):
+ return vf
+ return f"{vf},{BT709_SETPARAMS}" if vf else BT709_SETPARAMS
+
+
def compute_upscale_plan(w: int, h: int, mode: str | None,
helper_did_model_upscale: bool = False) -> dict | None:
"""Plan a panel-side ffmpeg upscale pass. Returns None when no further
@@ -5803,11 +6164,17 @@ def compute_upscale_plan(w: int, h: int, mode: str | None,
# upscale (Sharper) doubles them inside the helper before VAE decode.
eff_w = w * 2 if helper_did_model_upscale else w
eff_h = h * 2 if helper_did_model_upscale else h
- if mode == "fit_720p":
- # No crop, no distortion: fit inside standard 720p canvas and pad any
+ if mode in ("fit_720p", "fit_1080p"):
+ # No crop, no distortion: fit inside the standard canvas and pad any
# remainder. 1024×576 fills 1280×720 exactly; 1280×704 becomes 1280×704
# with 8px bars top/bottom; 704×1280 becomes 704×1280 with side bars.
- if eff_w >= eff_h:
+ # H3's native 768×448 is 12:7, so it letterboxes into 16:9 — correct.
+ if mode == "fit_1080p":
+ if eff_w >= eff_h:
+ target_w, target_h, tag = 1920, 1080, "1080p"
+ else:
+ target_w, target_h, tag = 1080, 1920, "v1080p"
+ elif eff_w >= eff_h:
target_w, target_h, tag = 1280, 720, "720p"
else:
target_w, target_h, tag = 720, 1280, "v720p"
@@ -6407,6 +6774,18 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,
_h3_tier = (f("h3_tier", H3_TIER_DEFAULT) or H3_TIER_DEFAULT).strip().lower()
if _h3_tier not in H3_TIERS:
_h3_tier = H3_TIER_DEFAULT
+ # Post-render export canvas for an H3 clip (parity with LTX's `upscale`).
+ # Separate field because the LTX control is data-ltx-only in the UI and is
+ # neutralised below — reusing it would make one pill mean two things.
+ _h3_upscale = (f("h3_upscale", H3_UPSCALE_DEFAULT) or H3_UPSCALE_DEFAULT).strip().lower()
+ if _h3_upscale in ("native", ""):
+ _h3_upscale = "off"
+ if _h3_upscale in ("720p", "fit720p"):
+ _h3_upscale = "fit_720p"
+ if _h3_upscale in ("1080p", "fit1080p"):
+ _h3_upscale = "fit_1080p"
+ if _h3_upscale not in H3_UPSCALE_MODES:
+ _h3_upscale = H3_UPSCALE_DEFAULT
if _engine == "h3":
if mode_in not in H3_MODES:
push(f"engine=h3 requested for mode={mode_in!r} — Hailuo H3 only "
@@ -6417,6 +6796,18 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,
f"{SYSTEM_RAM_GB:.0f} GB unified memory (needs "
f"{H3_MIN_RAM_GB:.0f}+) — falling back to LTX.")
_engine = "ltx"
+ elif (int((H3_TIERS[_h3_tier].get("chain_windows") or 1)) > 1
+ and h3_available() and not h3_supports_chain()):
+ # Chained tiers need --chain-windows on the INSTALLED runner. An
+ # older pack renders 3 s / 5 s fine, so fall back to the longest
+ # single-pass tier rather than failing the job outright.
+ _fallback = next(
+ (k for k, t in reversed(list(H3_TIERS.items()))
+ if int(t.get("chain_windows") or 1) <= 1), H3_TIER_DEFAULT)
+ push(f"h3_tier={_h3_tier!r} needs window chaining, which this H3 "
+ f"checkout doesn't have (no --chain-windows). Update the H3 "
+ f"pack; rendering {_fallback!r} instead.")
+ _h3_tier = _fallback
job = {
"id": _new_job_id(),
@@ -6436,6 +6827,10 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,
# (see CLAUDE.md and the restore/ingredients/control notes below).
"engine": _engine,
"h3_tier": _h3_tier,
+ # Export canvas for the H3 post-process (off / fit_720p /
+ # fit_1080p). SAME allowlist trap as every key in this dict: a new
+ # form field that isn't listed here silently no-ops on /queue/add.
+ "h3_upscale": _h3_upscale,
"prompt": prompt,
"negative_prompt": f("negative_prompt", ""),
"width": max(32, int(f("width", str(default_w)) or default_w)),
@@ -6567,11 +6962,17 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,
_tier_cfg = H3_TIERS[_h3_tier]
job["params"]["width"] = _tier_cfg["width"]
job["params"]["height"] = _tier_cfg["height"]
+ # DELIVERED frames — for a chained tier that is the stitched total, not
+ # the per-window count, so the queue card and the duration line read the
+ # clip the user actually gets. run_h3_job_inner splits it back out.
job["params"]["frames"] = _tier_cfg["frames"]
job["params"]["steps"] = _tier_cfg["steps"]
+ job["params"]["h3_chain_windows"] = int(_tier_cfg.get("chain_windows") or 1)
+ job["params"]["h3_window_frames"] = int(
+ _tier_cfg.get("window_frames") or _tier_cfg["frames"])
# LTX-only post-processing has no meaning for an H3 render: the runner
- # writes its own muxed mp4 at native size. Neutralise them so the
- # sidecar (and the ⓘ modal) don't claim an upscale that never ran.
+ # writes its own muxed mp4 and none of the LTX helper knobs apply.
+ # `h3_upscale` above carries the H3 export target instead.
job["params"]["upscale"] = "off"
job["params"]["temporal_mode"] = "native"
job["params"]["accel"] = "off"
@@ -7753,11 +8154,17 @@ def run_h3_job_inner(job: dict) -> None:
f"{SYSTEM_RAM_GB:.0f} GB. Render on the LTX engine instead.")
if paths["missing"]:
raise RuntimeError(
- "The Hailuo H3 pack isn't installed — missing: "
- + "; ".join(paths["missing"])
- + ". Install it from the Phosphene sidebar in Pinokio "
- "('Install Hailuo H3'), or point LTX_H3_ROOT / LTX_H3_MODELS at "
- "an existing checkout.")
+ ("The Hailuo H3 weights are on disk but the engine needs repair — "
+ if paths["repairable"] else
+ "The Hailuo H3 pack isn't installed — ")
+ + "missing: " + "; ".join(paths["missing"])
+ + (". Click 'Install Hailuo H3' in the Phosphene sidebar in "
+ "Pinokio — it is idempotent and skips every weight already on "
+ "disk, so this is a couple of minutes, NOT a 75 GB download."
+ if paths["repairable"] else
+ ". Install it from the Phosphene sidebar in Pinokio "
+ "('Install Hailuo H3'), or point LTX_H3_ROOT / LTX_H3_MODELS at "
+ "an existing checkout."))
if mode not in H3_MODES:
raise RuntimeError(
f"Hailuo H3 doesn't serve mode {mode!r} — only "
@@ -7767,8 +8174,28 @@ def run_h3_job_inner(job: dict) -> None:
tier = H3_TIERS.get(tier_key) or H3_TIERS[H3_TIER_DEFAULT]
width = int(p.get("width") or tier["width"])
height = int(p.get("height") or tier["height"])
+ # `frames` is what the clip DELIVERS. A chained tier renders it as N
+ # windows of `window_frames` each and the runner stitches them, dropping
+ # the duplicated join frame — so N windows deliver
+ # window_frames + (N-1)*(window_frames-1), trimmed to `frames`.
frames = int(p.get("frames") or tier["frames"])
steps = int(p.get("steps") or tier["steps"])
+ chain_windows = int(p.get("h3_chain_windows") or tier.get("chain_windows") or 1)
+ window_frames = int(p.get("h3_window_frames") or tier.get("window_frames") or frames)
+ if chain_windows > 1:
+ if not h3_supports_chain():
+ raise RuntimeError(
+ f"The {tier['label']} tier renders as {chain_windows} chained "
+ f"windows, but this H3 checkout has no `--chain-windows` "
+ f"({paths['runner']}). Update the H3 pack, or pick a 3 s / 5 s "
+ f"tier.")
+ _max_frames = window_frames + (chain_windows - 1) * (window_frames - 1)
+ if not 1 <= frames <= _max_frames:
+ # Belt and braces: the runner rejects an out-of-range trim with a
+ # parser error, which would read as a mystery crash in the log.
+ frames = _max_frames
+ else:
+ window_frames = frames
prompt = (p.get("prompt") or "").strip()
if not prompt:
raise RuntimeError("H3 needs a prompt — dialogue and sound are "
@@ -7832,12 +8259,21 @@ def run_h3_job_inner(job: dict) -> None:
"--text-config", str(paths["text_config"]),
"-o", str(out_path),
"--metrics", str(metrics_path),
- "--frames", str(frames),
+ # Per-WINDOW frame count. Identical to `frames` on every single-pass
+ # tier; on a chained tier it is the 5 s window the chain repeats.
+ "--frames", str(window_frames),
"--height", str(height),
"--width", str(width),
"--steps", str(steps),
"--seed", str(seed),
]
+ if chain_windows > 1:
+ # Window chaining: each window after the first is conditioned on its
+ # predecessor's last decoded frame, and --chain-total-frames trims the
+ # stitched clip to the tier's delivered length. The audio cross-fade
+ # defaults to one frame (the chain's real overlap) in the runner.
+ cmd += ["--chain-windows", str(chain_windows),
+ "--chain-total-frames", str(frames)]
if first_frame is not None:
cmd += ["--first-frame", str(first_frame)]
@@ -7849,7 +8285,11 @@ def run_h3_job_inner(job: dict) -> None:
push(f"[h3] {tier['label']} · {width}×{height} · {frames}f · "
f"{steps} sigma points ({steps - 1} forwards) · seed {seed}"
+ + (f" · {chain_windows} chained windows of {window_frames}f"
+ if chain_windows > 1 else "")
+ (f" · first frame {first_frame.name}" if first_frame else ""))
+ if chain_windows > 1 and tier.get("note"):
+ push(f"[h3] note: {tier['note']}")
push("[h3] $ " + " ".join(shlex.quote(c) for c in cmd))
t0 = time.time()
@@ -7862,6 +8302,13 @@ def run_h3_job_inner(job: dict) -> None:
proc: subprocess.Popen | None = None
step_rx = re.compile(r"^step (\d+)/(\d+):")
phase_rx = re.compile(r"^== (.+) ==$")
+ # A chained run prints `### window 2/3 ###` between windows and prefixes
+ # every phase name with `w2_`. Without both, the progress bar would run
+ # 5→92% and then jump back to 5% once per window, and the phase label would
+ # read "w2_joint_denoise" instead of English.
+ window_rx = re.compile(r"^#+ window (\d+)/(\d+) #+$")
+ window_prefix_rx = re.compile(r"^w(\d+)_")
+ cur_window, tot_windows = 1, max(1, chain_windows)
phase_label = "Loading H3 text encoder"
last_step, total_steps = 0, max(1, steps - 1)
try:
@@ -7880,14 +8327,34 @@ def run_h3_job_inner(job: dict) -> None:
with LOCK:
STATE["pid"] = proc.pid
STATE["h3_pgid"] = os.getpgid(proc.pid)
+ # Crash guard — see reap_orphan_subprocesses(). start_new_session means
+ # a SIGKILLed panel leaves this 40 GiB render running; the next boot
+ # reaps it from this file before the queue resumes the same job.
+ _proc_guard_write("h3", proc.pid, os.getpgid(proc.pid),
+ note=f"job {job['id']}")
assert proc.stdout is not None
for raw in proc.stdout:
line = raw.rstrip("\n")
if not line.strip():
continue
push(f"[h3] {line}")
+ m_window = window_rx.match(line.strip())
+ if m_window:
+ try:
+ cur_window = max(1, int(m_window.group(1)))
+ tot_windows = max(cur_window, int(m_window.group(2)))
+ except (TypeError, ValueError):
+ pass
+ # Reset the per-window clocks: the step counter restarts at 1
+ # for every window, and the denoise clock has to restart with
+ # it or the ETA prices this window off the previous one's load.
+ denoise_t0 = None
+ last_step = 0
m_phase = phase_rx.match(line.strip())
if m_phase:
+ raw_phase = m_phase.group(1).strip()
+ # `w2_joint_denoise` → `joint_denoise` on a chained run.
+ bare_phase = window_prefix_rx.sub("", raw_phase)
phase_label = {
"text_encode_q8": "Encoding prompt (Q8 text encoder)",
"text_cache_load": "Loading cached prompt embedding",
@@ -7898,8 +8365,9 @@ def run_h3_job_inner(job: dict) -> None:
"video_vae_decode": "Decoding video",
"audio_vae_decode": "Decoding audio",
"encode_mux": "Encoding mp4",
- }.get(m_phase.group(1).strip(), m_phase.group(1).strip())
- if m_phase.group(1).strip() == "joint_denoise":
+ "stitch": "Stitching windows",
+ }.get(bare_phase, bare_phase)
+ if bare_phase == "joint_denoise":
denoise_t0 = time.time()
m_step = step_rx.match(line.strip())
if m_step:
@@ -7910,16 +8378,25 @@ def run_h3_job_inner(job: dict) -> None:
pass
elapsed = time.time() - t0
# Denoise dominates wall time; give it the 5–92% band so the bar
- # doesn't sit at 0 through a 30 s model load and then jump.
+ # doesn't sit at 0 through a 30 s model load and then jump. On a
+ # chained run the band is split evenly across windows — each window
+ # is the same shape and measured within 0.3% of the others, so
+ # "window 2 of 3, step 4/8" is a real fraction of the whole clip.
+ win_span = 87.0 / float(tot_windows)
+ win_base = 5.0 + win_span * (cur_window - 1)
+ win_tag = f"Window {cur_window}/{tot_windows} · " if tot_windows > 1 else ""
if last_step:
- pct = 5.0 + 87.0 * (last_step / float(total_steps))
+ pct = win_base + win_span * (last_step / float(total_steps))
spent = elapsed if denoise_t0 is None else max(0.0, time.time() - denoise_t0)
per_step = spent / max(1, last_step)
- eta = max(0.0, (total_steps - last_step) * per_step)
- label = f"{phase_label} · step {last_step} / {total_steps}"
+ # Remaining steps in this window, plus every step of every
+ # window still to come.
+ left = (total_steps - last_step) + total_steps * (tot_windows - cur_window)
+ eta = max(0.0, left * per_step)
+ label = f"{win_tag}{phase_label} · step {last_step} / {total_steps}"
else:
- pct, eta = 3.0, 0.0
- label = phase_label
+ pct, eta = max(3.0, win_base), 0.0
+ label = f"{win_tag}{phase_label}"
with LOCK:
cur = STATE.get("current")
if cur and cur.get("id") == job["id"]:
@@ -7931,12 +8408,15 @@ def run_h3_job_inner(job: dict) -> None:
"eta_sec": eta,
"denoise_step": last_step,
"denoise_total": total_steps,
+ "window": cur_window,
+ "window_total": tot_windows,
}
rc = proc.wait()
proc = None
with LOCK:
STATE["pid"] = None
STATE["h3_pgid"] = None
+ _proc_guard_clear("h3")
if rc != 0:
raise RuntimeError(
f"H3 render exited with code {rc} — see the log above for the "
@@ -7957,11 +8437,56 @@ def run_h3_job_inner(job: dict) -> None:
with LOCK:
STATE["pid"] = None
STATE["h3_pgid"] = None
+ _proc_guard_clear("h3")
if not out_path.is_file():
raise RuntimeError(
f"H3 finished but no file landed at {out_path} — check the log.")
+ # ---- export pass: the SAME post-process an LTX render gets ------------
+ # H3 writes 768×448 (12:7), which is neither 720p nor 1080p and looks like
+ # a bug next to LTX output in the gallery. Run the identical ffmpeg recipe:
+ # lanczos fit inside the canvas, pad the remainder, re-encode with the
+ # user's codec settings, audio copied through untouched. Letterboxing 12:7
+ # into 16:9 is the correct answer — no crop, no distortion. The native file
+ # stays on disk but hidden from the gallery, exactly like the LTX path.
+ native_path = out_path
+ final_target = out_path
+ h3_upscale_mode = (p.get("h3_upscale") or H3_UPSCALE_DEFAULT).strip().lower()
+ if h3_upscale_mode not in H3_UPSCALE_MODES:
+ h3_upscale_mode = H3_UPSCALE_DEFAULT
+ upscale_plan = None
+ try:
+ upscale_plan = compute_upscale_plan(width, height, h3_upscale_mode)
+ except RuntimeError as exc:
+ push(f"[h3] export target ignored: {exc}")
+ if upscale_plan:
+ codec = output_codec_settings()
+ export_preset = os.environ.get("LTX_UPSCALE_PRESET", "medium")
+ upscaled_out = OUTPUT / (
+ f"{out_path.stem}_{upscale_plan['tag']}{out_path.suffix}")
+ run_ffmpeg_tracked([
+ str(FFMPEG), "-y", "-i", str(out_path),
+ "-vf", bt709_vf(upscale_plan["vf"]),
+ "-c:v", "libx264", "-pix_fmt", codec["pix_fmt"], "-crf", codec["crf"],
+ "-preset", export_preset,
+ *BT709_FLAGS,
+ "-movflags", "+faststart",
+ # H3 generates its own AAC track; re-encoding it would only lose
+ # fidelity, and the dialogue is the point of the engine.
+ "-c:a", "copy",
+ str(upscaled_out),
+ ], "H3 export")
+ upscale_plan["method"] = "ffmpeg_lanczos"
+ final_target = upscaled_out
+ push(f"[h3] export done → {upscaled_out.name} "
+ f"({upscale_plan['target_w']}×{upscale_plan['target_h']}, no crop, "
+ f"{codec['pix_fmt']} crf {codec['crf']}, preset={export_preset})")
+ set_hidden(str(native_path), True)
+ push(f"[h3] native source kept but hidden from gallery → {native_path.name}")
+ job["native_path"] = str(native_path)
+ job["upscaled_path"] = str(final_target)
+
# ---- metrics → sidecar ----------------------------------------------
metrics: dict = {}
try:
@@ -7971,14 +8496,23 @@ def run_h3_job_inner(job: dict) -> None:
elapsed = round(time.time() - t0, 2)
phases = {ph.get("name"): ph for ph in (metrics.get("phases") or [])
if isinstance(ph, dict)}
+ # A chained run reports per-window keys (w1_packed_rows, …) and no bare
+ # ones, because every window has its own row count. Fall back to window 1
+ # so the ⓘ modal shows a number instead of an empty field.
+ def _metric(name: str):
+ val = metrics.get(name)
+ return metrics.get(f"w1_{name}") if val is None else val
+
sidecar = {
- "output": str(out_path),
- "raw_output": str(out_path),
+ "output": str(final_target),
+ "raw_output": str(native_path),
+ "native_output": str(native_path),
"params": {
**p,
"engine": "h3",
"h3_tier": tier["key"],
"h3_tier_label": tier["label"],
+ "h3_upscale": h3_upscale_mode,
"width": width, "height": height, "frames": frames, "steps": steps,
"seed_used": seed,
"image": str(first_frame) if first_frame else None,
@@ -7991,25 +8525,36 @@ def run_h3_job_inner(job: dict) -> None:
"fps": H3_FPS,
"model": str(paths["dit"]),
"queue_id": job["id"],
+ "output_codec": output_codec_settings(),
"h3": {
"tier": tier["key"],
"runner": str(paths["runner"]),
"metrics_path": str(metrics_path),
- "packed_rows": metrics.get("packed_rows"),
- "prompt_tokens": metrics.get("prompt_tokens"),
+ "packed_rows": _metric("packed_rows"),
+ "prompt_tokens": _metric("prompt_tokens"),
"total_seconds": metrics.get("total_seconds"),
"mean_denoise_step_seconds": metrics.get("mean_denoise_step_seconds"),
"phase_seconds": {k: v.get("seconds") for k, v in phases.items()},
"peak_gib": max([v.get("peak_gib") or 0 for v in phases.values()] or [0]),
"first_frame": str(first_frame) if first_frame else None,
+ "chain_windows": chain_windows,
+ "window_frames": window_frames,
+ "delivered_frames": metrics.get("delivered_frames", frames),
+ "windows": metrics.get("windows"),
+ "seams": len(metrics.get("seams") or []) if chain_windows > 1 else 0,
},
}
- write_sidecar(out_path.with_suffix(out_path.suffix + ".json"), sidecar)
- job["output_path"] = str(out_path)
+ if upscale_plan:
+ sidecar["upscale"] = (
+ {k: v for k, v in upscale_plan.items() if k != "vf"}
+ | {"source": str(native_path), "codec": output_codec_settings()}
+ )
+ write_sidecar(final_target.with_suffix(final_target.suffix + ".json"), sidecar)
+ job["output_path"] = str(final_target)
p["elapsed_seconds"] = elapsed
- push(f"[h3] done in {elapsed}s → {out_path.name}")
+ push(f"[h3] done in {elapsed}s → {final_target.name}")
if p.get("open_when_done"):
- subprocess.run(["open", str(out_path)], check=False)
+ subprocess.run(["open", str(final_target)], check=False)
def run_job_inner(job: dict) -> None:
@@ -9308,11 +9853,15 @@ def run_job_inner(job: dict) -> None:
mux_crf = codec["crf"]
mux_cmd = [str(FFMPEG), "-y", "-i", str(raw_out), "-i", audio,
"-map", "0:v:0", "-map", "1:a:0"]
- if pad_filter:
- mux_cmd += ["-vf", pad_filter]
+ # bt709_vf returns "" only on an ffmpeg build with no `setparams` AND no
+ # pad to do — `-vf ""` is an error, so the flag goes in conditionally.
+ _mux_vf = bt709_vf(pad_filter)
+ if _mux_vf:
+ mux_cmd += ["-vf", _mux_vf]
mux_cmd += [
"-af", f"apad,atrim=0:{duration},asetpts=PTS-STARTPTS",
"-c:v", "libx264", "-pix_fmt", mux_pix_fmt, "-crf", mux_crf, "-preset", "medium",
+ *BT709_FLAGS,
"-movflags", "+faststart",
"-c:a", "aac", "-b:a", "192k",
"-t", f"{duration}",
@@ -9328,9 +9877,10 @@ def run_job_inner(job: dict) -> None:
temporal_preset = os.environ.get("LTX_TEMPORAL_PRESET", "medium")
temporal_cmd = [
str(FFMPEG), "-y", "-i", str(final_target),
- "-vf", f"minterpolate=fps={FPS}:mi_mode=mci:mc_mode=aobmc:vsbmc=1",
+ "-vf", bt709_vf(f"minterpolate=fps={FPS}:mi_mode=mci:mc_mode=aobmc:vsbmc=1"),
"-c:v", "libx264", "-pix_fmt", mux_pix_fmt, "-crf", mux_crf,
"-preset", temporal_preset,
+ *BT709_FLAGS,
"-movflags", "+faststart",
"-c:a", "copy",
"-t", f"{video_duration(frames)}",
@@ -9380,9 +9930,10 @@ def run_job_inner(job: dict) -> None:
else:
upscale_cmd = [
str(FFMPEG), "-y", "-i", str(final_target),
- "-vf", upscale_plan["vf"],
+ "-vf", bt709_vf(upscale_plan["vf"]),
"-c:v", "libx264", "-pix_fmt", mux_pix_fmt, "-crf", mux_crf,
"-preset", upscale_preset,
+ *BT709_FLAGS,
"-movflags", "+faststart",
"-c:a", "copy",
str(upscaled_out),
@@ -11473,7 +12024,6 @@ class Handler(BaseHTTPRequestHandler):
# variant has a `.json`. Bounded to the same OUTPUT/
# UPLOADS roots so this can't be tricked into leaking
# arbitrary `.json` files.
- UPSCALE_TAGS = ("720p", "v720p", "up2x")
stem = path.stem
ext = path.suffix
parent = path.parent
@@ -13460,12 +14010,12 @@ class Handler(BaseHTTPRequestHandler):
# (a) sidecar JSON of the clicked file (raw_output /
# native_output / output / upscaled_output fields),
# (b) filename heuristic — strip the known upscale-suffix
- # (`_720p`, `_v720p`, `_up2x`) from the stem to get the
- # raw, and append each suffix to get any companion
- # upscaled file that exists.
+ # (`_720p`, `_v720p`, `_1080p`, `_v1080p`, `_up2x`) from the
+ # stem to get the raw, and append each suffix to get any
+ # companion upscaled file that exists.
# Each candidate's matching sidecars (`<full>.json` and
- # `<stem>.json`) come along too.
- UPSCALE_TAGS = ("720p", "v720p", "up2x")
+ # `<stem>.json`) come along too. UPSCALE_TAGS is module-level so
+ # this list and compute_upscale_plan's tags can never drift.
def _add(seen: set, candidates: list, cand: Path) -> None:
key = str(cand)
@@ -17493,6 +18043,19 @@ HTML = r"""<!doctype html>
above already beats the grid rule (that fight was lost once already,
2026-05-17, when both quality strips showed at the same time). */
body[data-h3-engine="h3"] [data-ltx-only] { display: none !important; }
+ /* …and the mirror image: controls that only mean something to H3 (its
+ export canvas, the chained-tier artefact note) stay folded away on LTX.
+ `[hidden]` still wins for the ones JS toggles individually. */
+ body:not([data-h3-engine="h3"]) [data-h3-only] { display: none !important; }
+ [data-h3-only][hidden] { display: none !important; }
+ .h3-export-row {
+ display: flex; align-items: center; gap: 10px;
+ margin: 6px 0 8px 0; padding: 0 2px;
+ }
+ .h3-export-row > span.h3-export-label {
+ font-size: 11px; color: var(--muted); text-transform: uppercase;
+ letter-spacing: .4px; font-weight: 600; flex: 0 0 auto;
+ }
/* Customize disclosure inside the form — sub-tier UI, lighter than
a top-level <details>. Subtle border, indented body, distinct
@@ -21984,6 +22547,33 @@ HTML = r"""<!doctype html>
table stays the single source of truth for geometry + steps, so
a tier change is one Python edit, not two). -->
<div class="quality-strip pill-group" id="h3TierGroup" hidden></div>
+ <!-- Honest artefact note for the chained tiers. Rendered from the
+ tier's `note` field (server-side H3_TIERS), so the day per-window
+ prompts land in the UI the warning disappears with one Python
+ edit. Hidden for tiers that render as a single pass. -->
+ <div class="engine-hint" id="h3TierNote" data-h3-only hidden></div>
+ <!-- H3 export canvas. H3 renders 768×448 (12:7) natively, which is
+ neither 720p nor 1080p; this runs the SAME lanczos-fit + pad +
+ libx264 pass an LTX render gets, keeping the native file on disk
+ but hidden from the gallery. Letterbox bars on 12:7 content are
+ correct — no crop, no distortion. The hidden input is inside
+ genForm so FormData carries it; `h3_upscale` is in the make_job
+ allowlist (an unlisted field silently no-ops on /queue/add). -->
+ <div class="h3-export-row" id="h3ExportRow" data-h3-only>
+ <span class="h3-export-label">Export</span>
+ <div class="pill-group" id="h3UpscaleGroup" style="display:flex;gap:4px;flex:0 0 auto;">
+ <button type="button" class="pill-btn" data-h3-upscale="off"
+ style="padding:4px 10px;font-size:12px;"
+ title="Ship H3's native 768×448 with no post-process.">Native</button>
+ <button type="button" class="pill-btn active" data-h3-upscale="fit_720p"
+ style="padding:4px 10px;font-size:12px;"
+ title="Fit inside 1280×720 and pad — no crop, no distortion.">720p</button>
+ <button type="button" class="pill-btn" data-h3-upscale="fit_1080p"
+ style="padding:4px 10px;font-size:12px;"
+ title="Fit inside 1920×1080 and pad — no crop, no distortion.">1080p</button>
+ </div>
+ </div>
+ <input type="hidden" name="h3_upscale" id="h3_upscale" value="fit_720p">
<!-- 2026-05-17 (Codex C+ pass 6): the character-only skip-step
toggle moved out of here into the Customize section as
"HQ speed". It's a Q8 sampler control, not a character
@@ -28953,6 +29543,19 @@ function setAspect(a) {
function updateCustomizeSummary() {
const el = document.getElementById('customizeSummary');
if (!el) return;
+ // H3 renders on its own geometry and its own export control; every LTX knob
+ // summarised below is folded away in that state, so summarising them would
+ // describe a render that isn't happening.
+ if (document.body.dataset.h3Engine === 'h3') {
+ const tier = h3TierByKey((document.getElementById('h3_tier') || {}).value);
+ const up = (document.getElementById('h3_upscale') || {}).value || 'off';
+ const parts = [tier ? tier.spec : 'Hailuo H3'];
+ if (up === 'fit_720p') parts.push('720p export');
+ else if (up === 'fit_1080p') parts.push('1080p export');
+ else parts.push('native export');
+ el.textContent = parts.join(' · ');
+ return;
+ }
const q = document.getElementById('quality').value;
const w = parseInt(document.getElementById('width').value || 0);
const h = parseInt(document.getElementById('height').value || 0);
@@ -29081,8 +29684,32 @@ function h3TierByKey(key) {
let saved = null;
try { saved = localStorage.getItem('phos_h3_tier'); } catch (e) {}
if (saved && h3TierByKey(saved) && h3TierByKey(saved).key === saved) inp.value = saved;
+ // Same treatment for the export canvas, and for the same reason.
+ const up = document.getElementById('h3_upscale');
+ if (!up) return;
+ let savedUp = null;
+ try { savedUp = localStorage.getItem('phos_h3_upscale'); } catch (e) {}
+ const allowed = H3.upscale_modes || ['off', 'fit_720p', 'fit_1080p'];
+ if (savedUp && allowed.indexOf(savedUp) !== -1) up.value = savedUp;
})();
+// Export canvas for an H3 render. Separate from the LTX `upscale` control
+// (which is data-ltx-only and folds away on H3) so one pill never means two
+// things. Server-side make_job re-validates — a stale tab must never win.
+function setH3Upscale(mode) {
+ const allowed = H3.upscale_modes || ['off', 'fit_720p', 'fit_1080p'];
+ const v = allowed.indexOf(mode) !== -1 ? mode : (H3.default_upscale || 'fit_720p');
+ const inp = document.getElementById('h3_upscale');
+ if (inp) inp.value = v;
+ document.querySelectorAll('#h3UpscaleGroup [data-h3-upscale]').forEach(b =>
+ b.classList.toggle('active', b.dataset.h3Upscale === v));
+ try { localStorage.setItem('phos_h3_upscale', v); } catch (e) {}
+ if (typeof updateDerived === 'function') { try { updateDerived(); } catch (e) {} }
+}
+document.querySelectorAll('#h3UpscaleGroup [data-h3-upscale]').forEach(b => {
+ b.onclick = () => setH3Upscale(b.dataset.h3Upscale);
+});
+
function _engineRowVisible() {
// Only Macs that could actually run H3 see the picker at all. Showing a
// permanently-disabled engine to the ~80% of users under 64 GB is noise.
@@ -29094,7 +29721,11 @@ function renderH3Tiers() {
if (!strip) return;
const tiers = H3.tiers || [];
const active = (document.getElementById('h3_tier') || {}).value || H3.default_tier;
- strip.style.gridTemplateColumns = `repeat(${Math.max(1, tiers.length)}, 1fr)`;
+ // Five tiers in one row would squeeze "768×448 · 362f · 3×5s" into ~50 px.
+ // Past four, wrap to three per row — the chips keep their legible width and
+ // the strip grows a second line instead of shrinking its type.
+ const cols = tiers.length > 4 ? 3 : Math.max(1, tiers.length);
+ strip.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
strip.innerHTML = tiers.map(t => `
<button type="button" class="q-chip pill-btn pill-quality${t.key === active ? ' active' : ''}"
data-h3-tier="${escapeHtml(t.key)}" title="${escapeHtml(t.blurb || '')}">
@@ -29125,6 +29756,15 @@ function setH3Tier(key) {
if (h) h.value = tier.height;
if (f) f.value = tier.frames;
if (s) s.value = tier.steps;
+ // Chained tiers carry an honest artefact note (one prompt is asked of every
+ // window, so a scripted line lands once per window). Surface it where the
+ // user is choosing, not in a tooltip.
+ const noteEl = document.getElementById('h3TierNote');
+ if (noteEl) {
+ const n = tier.note || '';
+ noteEl.textContent = n;
+ noteEl.hidden = !n;
+ }
try { localStorage.setItem('phos_h3_tier', tier.key); } catch (e) {}
if (typeof updateDerived === 'function') { try { updateDerived(); } catch (e) {} }
}
@@ -29151,7 +29791,15 @@ function setEngine(engine, opts) {
if (target === 'h3') {
if (!H3.capable) { target = 'ltx'; reason = 'Hailuo H3 needs 64 GB unified memory.'; }
- else if (!H3.available) { target = 'ltx'; reason = 'Hailuo H3 isn\'t installed yet.'; }
+ else if (!H3.available) {
+ target = 'ltx';
+ // Distinguish "you never installed this" from "you DID install this and
+ // something broke it". Telling a user with 75 GB of H3 weights on disk
+ // that H3 "isn't installed" is the v3.4.0 regression report, verbatim.
+ reason = H3.repairable
+ ? 'Hailuo H3 needs repair — your weights are still on disk. Click the pill.'
+ : 'Hailuo H3 isn\'t installed yet.';
+ }
else if (!_h3ServesMode(currentMode)) {
target = 'ltx';
reason = 'Hailuo H3 renders Text and Image only — back on LTX-2.3 for this mode.';
@@ -29175,11 +29823,14 @@ function setEngine(engine, opts) {
chipH3.title = !H3.capable
? 'Needs 64 GB unified memory'
: (!H3.available
- ? 'Hailuo H3 isn\'t installed — click to see how (~75 GB)'
+ ? (H3.repairable
+ ? 'Hailuo H3 needs repair — weights are on disk, click for the one-click fix'
+ : 'Hailuo H3 isn\'t installed — click to see how (~75 GB)')
: 'Hailuo H3 — joint video + dialogue + sound. Text and Image only.');
}
- if (sub) sub.textContent = (H3.capable && !H3.available) ? 'not installed · ~75 GB'
- : 'video + dialogue';
+ if (sub) sub.textContent = (H3.capable && !H3.available)
+ ? (H3.repairable ? 'needs repair · weights kept' : 'not installed · ~75 GB')
+ : 'video + dialogue';
if (note) note.textContent = reason;
// Surface swap: H3 tier strip replaces the quality strip; data-ltx-only
@@ -29193,6 +29844,8 @@ function setEngine(engine, opts) {
if (target === 'h3') {
renderH3Tiers();
setH3Tier((document.getElementById('h3_tier') || {}).value || H3.default_tier);
+ setH3Upscale((document.getElementById('h3_upscale') || {}).value
+ || H3.default_upscale || 'fit_720p');
// LTX post-processing doesn't run on an H3 render (make_job neutralises
// all three server-side). Mirror that in the UI or the derived line lies:
// it was reading "768×448 → 1280×720 fit" for a render that ships 768×448.
@@ -29249,7 +29902,15 @@ function updateH3Availability(s) {
if (!next) return;
const changed = (next.available !== H3.available)
|| (next.capable !== H3.capable)
- || (next.first_frame !== H3.first_frame);
+ || (next.first_frame !== H3.first_frame)
+ // `chain` gates the 10 s / 15 s tiers, so the strip has to be
+ // re-rendered when an H3 pack update brings --chain-windows in.
+ || (next.chain !== H3.chain)
+ // Install→repair→install flips the pill's copy and the models
+ // card even when `available` itself hasn't moved yet.
+ || (next.repairable !== H3.repairable)
+ || (next.reason !== H3.reason)
+ || ((next.tiers || []).length !== (H3.tiers || []).length);
H3 = next;
if (changed) setEngine(currentEngine(), { persist: false });
}
@@ -29272,7 +29933,30 @@ function openH3InstallCard() {
const body = document.getElementById('h3InstallBody');
if (body) {
const missing = (H3.missing || []);
- body.innerHTML = `
+ // REPAIR is a different story from INSTALL and has to read like one. A
+ // user whose 75 GB of weights are still on disk must not be shown a "~75
+ // GB download" card — that is what made the v3.4.0 report read as "H3
+ // vanished and Reset didn't bring it back".
+ const intro = H3.repairable ? `
+ <p style="margin:0 0 10px">
+ <b>Hailuo H3 is installed — it just needs repairing.</b> Your weights
+ (~75 GB) are still on disk and are <em>not</em> re-downloaded.
+ </p>
+ <p style="margin:0 0 10px;color:var(--muted)">
+ ${H3.venv_broken
+ ? 'What broke: H3’s Python environment points at Pinokio’s shared '
+ + 'managed interpreter, and installing another pack moved it. '
+ + 'Rebuilding the environment takes about two minutes.'
+ : 'What broke: the engine’s code checkout is missing or incomplete. '
+ + 'Re-cloning it takes about a minute.'}
+ </p>
+ <p style="margin:0 0 10px">
+ Fix it from Pinokio: open the <b>Phosphene</b> entry in the Pinokio
+ sidebar and click <b>“Repair Hailuo H3”</b> (it appears in place of the
+ install entry). The step is idempotent — it skips every weight already
+ on disk. The panel picks the engine back up within a couple of seconds,
+ no restart.
+ </p>` : `
<p style="margin:0 0 10px">
<b>Hailuo H3</b> is a second video engine: one prompt in, video
<em>and</em> synced dialogue <em>and</em> sound out. It runs fully
@@ -29287,7 +29971,8 @@ function openH3InstallCard() {
in the Pinokio sidebar and click
<b>“Install Hailuo H3 (optional, ~75 GB)”</b>. The panel picks it up
within a couple of seconds — no restart.
- </p>
+ </p>`;
+ body.innerHTML = intro + `
${missing.length ? `<p style="margin:0;color:var(--muted);font-size:12px">
Currently missing: ${escapeHtml(missing.join('; '))}</p>` : ''}`;
}
@@ -31903,6 +32588,20 @@ function renderOutputInfoBody(path, data) {
const label = isSharp ? `${baseLabel} · Sharp (PiperSR)` : `${baseLabel} · Fast (Lanczos)`;
genRows.push(`<dt>Upscale</dt><dd>${escapeHtml(label + target)}</dd>`);
}
+ // H3's own export pass. `p.upscale` is always 'off' on an H3 render (the LTX
+ // knobs are neutralised server-side), so it needs its own row rather than
+ // silently claiming no post-process happened.
+ if (p.h3_upscale && p.h3_upscale !== 'off') {
+ const up = data.upscale || {};
+ const target = up.target_w && up.target_h ? ` → ${up.target_w} × ${up.target_h}` : '';
+ const base = p.h3_upscale === 'fit_1080p' ? '1080p fit (no crop)' : '720p fit (no crop)';
+ genRows.push(`<dt>Export</dt><dd>${escapeHtml(base + ' · Fast (Lanczos)' + target)}</dd>`);
+ }
+ // Chained windows — the honest shape of a 10 s / 15 s H3 clip.
+ if (data.h3 && Number(data.h3.chain_windows || 1) > 1) {
+ const c = data.h3;
+ genRows.push(`<dt>Chained</dt><dd>${escapeHtml(String(c.chain_windows))} × ${escapeHtml(String(c.window_frames))}f windows → ${escapeHtml(String(c.delivered_frames || p.frames || '—'))}f · ${escapeHtml(String(c.seams || (c.chain_windows - 1)))} join(s)</dd>`);
+ }
const codec = data.output_codec || (data.upscale && data.upscale.codec);
if (codec && codec.pix_fmt && codec.crf != null) {
const preset = codec.preset ? ` · ${codec.preset}` : '';
@@ -32299,6 +32998,33 @@ function updateModelsCard(s) {
return;
}
+ // ----- Hailuo H3 installed but broken → one-click repair -----------------
+ // `repairable` means the ~75 GB of H3 weights ARE on disk and only the
+ // clone/venv needs rebuilding. The overwhelmingly common cause: H3's venv
+ // interpreter is a symlink chain into Pinokio's SHARED uv-managed Python,
+ // and installing any other pack can move that target out from under it —
+ // the v3.4.0 "installed other packs and H3 vanished" report. Before this
+ // branch the panel just silently demoted the engine pill to "not
+ // installed", which reads as data loss and sent users to Reset (which does
+ // not touch H3 at all, so it never helped).
+ //
+ // Gated on `repairable`, so a user who never installed H3 is never nagged.
+ const h3s = s.h3 || {};
+ if (h3s.capable && !h3s.available && h3s.repairable) {
+ card.style.display = '';
+ card.classList.add('state-warn');
+ icon.innerHTML = '<svg class="ph" aria-hidden="true"><use href="#ph-warning-fill"/></svg>';
+ title.textContent = 'Hailuo H3 needs repair — your weights are still on disk';
+ sub.innerHTML = h3s.venv_broken
+ ? 'H3’s Python environment points at Pinokio’s shared interpreter and '
+ + 'another pack install moved it. Rebuilding takes ~2 minutes and '
+ + '<b>re-downloads nothing</b>.'
+ : 'H3’s code checkout is missing or incomplete. Restoring it takes ~1 '
+ + 'minute and <b>re-downloads nothing</b>.';
+ actions.innerHTML = `<button onclick="openH3InstallCard()">How to repair H3</button>`;
+ return;
+ }
+
// ----- All good — hide the card completely -------------------------------
// Per user feedback: the "Models ready · 3/3" status was visual noise once
// everything was downloaded. Hide the card on full readiness; the header
@@ -35514,6 +36240,11 @@ if __name__ == "__main__":
OUTPUT.mkdir(parents=True, exist_ok=True)
UPLOADS.mkdir(parents=True, exist_ok=True)
_sweep_orphan_tmps()
+ # Before the queue starts moving: kill anything a previous panel process
+ # left running (a SIGKILLed panel can't run its atexit hooks). Must happen
+ # BEFORE worker_loop starts, or the resumed job races an orphan that is
+ # still holding 40 GiB of the same GPU.
+ reap_orphan_subprocesses()
load_hidden()
load_queue()
threading.Thread(target=worker_loop, daemon=True).start()
diff --git a/pinokio.js b/pinokio.js
index 28496c5..fcf48ff 100644
--- a/pinokio.js
+++ b/pinokio.js
@@ -120,10 +120,63 @@ module.exports = {
// one 41 GB file; if that landed, the small siblings did too). Weights live
// under mlx_models/ so they survive Reset like every other model. Both
// download layouts are accepted, matching _h3_model_roots() in the panel.
- const h3_ready =
- info.exists("minimax-h3-mlx/.venv/bin/python3.11") &&
- (info.exists("mlx_models/hailuo-h3/models/deepbeep-pruned-bf16/MiniMax-H3-FL2VA-pruned_bf16.safetensors") ||
- info.exists("mlx_models/hailuo-h3/deepbeep-pruned-bf16/MiniMax-H3-FL2VA-pruned_bf16.safetensors"))
+ //
+ // Probed with Node's own fs, NOT info.exists() — deliberately, and this is
+ // the whole fix. `uv venv` builds the venv interpreter as a symlink chain
+ // into Pinokio's SHARED managed Python:
+ // .venv/bin/python3.11 -> python
+ // .venv/bin/python -> <pinokio>/cache/XDG_DATA_HOME/uv/python/
+ // cpython-3.11-macos-aarch64-none/bin/python3.11
+ // That target belongs to Pinokio, not to us: any other pack install (or
+ // any other Pinokio app) that makes uv re-resolve, bump or prune the
+ // managed interpreter leaves the chain DANGLING. Nothing is deleted — the
+ // venv, the clone and all ~75 GB of weights stay put — but H3 stops
+ // resolving. That is the v3.4.0 "installed other packs and Hailuo H3
+ // vanished" report.
+ //
+ // required_files.json already documents info.exists() as unreliable on
+ // exactly this chain, so it cannot answer the question we need answered
+ // here — "does this interpreter still resolve?" — in either direction.
+ // fs.existsSync FOLLOWS symlinks, so a dangling chain is definitively
+ // false, which makes the menu agree with the panel's _h3_python() by
+ // construction. (repoComplete() above already probes with fs.statSync +
+ // absolute paths for the same reason.) Keep the two in sync.
+ const h3Resolves = (rel) => {
+ try { return fs.existsSync(path.join(installRoot, rel)) } catch (e) { return false }
+ }
+ const h3_venv =
+ h3Resolves("minimax-h3-mlx/.venv/bin/python3.11") ||
+ h3Resolves("minimax-h3-mlx/.venv/bin/python")
+ const h3_runner = h3Resolves("minimax-h3-mlx/scripts/generate_staged.py")
+ // The weights are the expensive thing (~75 GB) and they live under
+ // mlx_models/, a completely different tree from the clone — so they
+ // routinely survive whatever broke the engine.
+ const h3_weights =
+ h3Resolves("mlx_models/hailuo-h3/models/deepbeep-pruned-bf16/MiniMax-H3-FL2VA-pruned_bf16.safetensors") ||
+ h3Resolves("mlx_models/hailuo-h3/deepbeep-pruned-bf16/MiniMax-H3-FL2VA-pruned_bf16.safetensors")
+ const h3_ready = h3_venv && h3_runner && h3_weights
+ // Weights on disk but the code/venv gone → a REPAIR, not a 75 GB install.
+ // install_h3.js is idempotent and skips every intact weight, so the same
+ // script serves both; only the label changes, because telling a user to
+ // "install ~75 GB" when they already have the 75 GB is the thing that
+ // made this look like data loss.
+ const h3_repair = h3_weights && !h3_ready
+
+ // Keep the H3 recovery affordance reachable from EVERY menu state, not
+ // only the healthy one. Reset wipes ltx-2-mlx, so env_ready goes false and
+ // the menu early-returns (below) long before it reaches the H3 row — which
+ // is exactly why the v3.4.0 reporter ran Reset and still found "no H3
+ // anywhere". The pack is independent of the LTX install (own clone, own
+ // venv, weights in a different tree), so offering the repair mid-reinstall
+ // is safe and never competes with the default action.
+ const pushH3Recovery = (m) => {
+ if (h3_repair && h3Capable()) {
+ m.push({ icon: "fa-solid fa-screwdriver-wrench",
+ text: "Repair Hailuo H3 (weights kept — no re-download)",
+ href: "install_h3.js" })
+ }
+ return m
+ }
// User-content folders persist across Reset (which only removes the venv).
// Keep their shortcuts visible whenever they exist on disk so users can
@@ -159,7 +212,7 @@ module.exports = {
if (has_outputs) m.push({ icon: "fa-solid fa-film", text: "Outputs", href: "mlx_outputs?fs=true" })
if (has_models) m.push({ icon: "fa-solid fa-cube", text: "Models", href: "mlx_models?fs=true" })
if (has_uploads) m.push({ icon: "fa-solid fa-image", text: "Uploads", href: "panel_uploads?fs=true" })
- return m
+ return pushH3Recovery(m)
}
// Env exists but base models aren't fully there → SHIP-BLOCKER fix.
@@ -173,6 +226,7 @@ module.exports = {
if (has_outputs) m.push({ icon: "fa-solid fa-film", text: "Outputs", href: "mlx_outputs?fs=true" })
if (has_models) m.push({ icon: "fa-solid fa-cube", text: "Models", href: "mlx_models?fs=true" })
if (has_uploads) m.push({ icon: "fa-solid fa-image", text: "Uploads", href: "panel_uploads?fs=true" })
+ pushH3Recovery(m)
m.push({ icon: "fa-regular fa-circle-xmark", text: "Reset", href: "reset.js" })
return m
}
@@ -217,7 +271,9 @@ module.exports = {
// ~75 GB, 64 GB+ Macs, MiniMax Community License with territory
// restrictions. Hidden entirely on machines that can't run it, so it
// never reads as a missing piece of the base install.
- baseMenu.push({ icon: "fa-solid fa-comments", text: "Install Hailuo H3 (optional, ~75 GB)", href: "install_h3.js" })
+ baseMenu.push(h3_repair
+ ? { icon: "fa-solid fa-screwdriver-wrench", text: "Repair Hailuo H3 (weights kept — no re-download)", href: "install_h3.js" }
+ : { icon: "fa-solid fa-comments", text: "Install Hailuo H3 (optional, ~75 GB)", href: "install_h3.js" })
}
baseMenu.push(
{ icon: "fa-solid fa-rotate", text: "Update", href: "update.js" },
diff --git a/reset.js b/reset.js
index a2785ee..5675ee1 100644
--- a/reset.js
+++ b/reset.js
@@ -3,6 +3,18 @@ module.exports = {
// Wipe the ltx-2-mlx clone and the venv inside it. Models stay (huge).
// Users who want to nuke models too should delete mlx_models/ via the
// "Models" file-browser entry in the Pinokio sidebar.
+ //
+ // DELIBERATELY NOT TOUCHED — the optional Hailuo H3 pack:
+ // minimax-h3-mlx/ its clone + its own venv
+ // mlx_models/hailuo-h3/ ~75 GB of weights (user content, must persist)
+ // H3 has no dependency on the LTX venv, so wiping LTX must never cost a
+ // user a 75 GB re-download. Note the corollary, learned from the v3.4.0
+ // report: because Reset does not touch H3, it also cannot REPAIR a broken
+ // H3 — reaching for Reset when the engine disappears is wasted effort.
+ // The fix for that lives in pinokio.js ("Repair Hailuo H3", kept visible
+ // in every menu state including post-Reset) and install_h3.js (which
+ // rebuilds a dangling venv in place). If you ever add an H3 path here,
+ // you are deleting user content — don't.
{ method: "fs.rm", params: { path: "ltx-2-mlx" } }
]
}
diff --git a/scripts/upscale_compare_pipersr.py b/scripts/upscale_compare_pipersr.py
index 11d0446..98957ec 100755
--- a/scripts/upscale_compare_pipersr.py
+++ b/scripts/upscale_compare_pipersr.py
@@ -74,11 +74,21 @@ def target_for_mode(width: int, height: int, mode: str) -> tuple[int, int, str]:
return 720, 1280, "v720p"
+# Rec.709 tagging — see the same block in mlx_ltx_panel.py. On ffmpeg 8 the
+# filtergraph's frame properties override the -color_* output options, so the
+# trailing `setparams` is what actually makes color_trc/colorspace land; without
+# it an export reads back as `unknown` and players guess at the colour.
+BT709_SETPARAMS = "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709"
+BT709_FLAGS = ["-color_primaries", "bt709", "-color_trc", "bt709",
+ "-colorspace", "bt709"]
+
+
def fit_filter(target_w: int, target_h: int) -> str:
return (
f"scale={target_w}:{target_h}:"
"force_original_aspect_ratio=decrease:flags=lanczos,"
- f"pad={target_w}:{target_h}:(ow-iw)/2:(oh-ih)/2:color=black"
+ f"pad={target_w}:{target_h}:(ow-iw)/2:(oh-ih)/2:color=black,"
+ f"{BT709_SETPARAMS}"
)
@@ -91,6 +101,7 @@ def make_lanczos(input_mp4: Path, output_mp4: Path, crf: str, pix_fmt: str, pres
"-i", str(input_mp4),
"-vf", fit_filter(target_w, target_h),
"-c:v", "libx264", "-pix_fmt", pix_fmt, "-crf", crf, "-preset", preset,
+ *BT709_FLAGS,
"-movflags", "+faststart",
"-c:a", "copy",
str(output_mp4),
@@ -195,6 +206,7 @@ def make_pipersr(input_mp4: Path, output_mp4: Path, crf: str, pix_fmt: str, pres
"-map", "0:v:0", "-map", "1:a?",
"-vf", fit_filter(target_w, target_h),
"-c:v", "libx264", "-pix_fmt", pix_fmt, "-crf", crf, "-preset", preset,
+ *BT709_FLAGS,
"-movflags", "+faststart",
"-c:a", "copy",
str(output_mp4),