Skip to content

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

pin HunyuanVideo to fp32 + mark deprecated; fix invisible progress on BYOV video runtimes

[._.]/ Adam Eivyef49861dc185
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index aa87a6f61c..dfaefcb5dd 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -29,6 +29,8 @@ TBD
## Fixed
+- **HunyuanVideo: pin to fp32 + mark deprecated; fix invisible per-step progress on all BYOV video runtimes.** The hunyuan runner previously defaulted to fp16, which trips an MPS matmul assertion (`MPSNDArrayMatrixMultiplication.mm:5799 failed assertion: Destination NDArray and Accumulator NDArray cannot have different datatype`) within ~2s of `predict()`. Verified bf16 hits the same assertion — only fp32 across DiT + VAE + both text encoders works on Apple Silicon, because MPS matmul kernels always use an fp32 accumulator internally and assert when the output dtype differs. At 576×1024×121 frames × 30 steps fp32 is a 4-8 hr render, so the entry is also flagged `deprecated: true` (lands in the "Legacy" optgroup). Migration `044-hunyuan-fp32-deprecated.js` patches the precision/deprecated/name fields onto existing installs' `data/media-models.json`; fresh installs pick up the shape via the updated `data.reference/media-models.json` and `DEFAULT_REGISTRY` seed. Two adjacent ergonomic fixes also landed in `server/services/videoGen/local.js` that apply to every BYOV video runtime (HunyuanVideo + Wan 2.2 + LTX-2): `PYTHONUNBUFFERED=1` on the spawn env so tqdm + loguru + STAGE: prints flush per-line (previously the UI saw no progress for the entire run because child stdio was line-buffered against a pipe), and `caffeinate -dis` (was `-i`) so display + idle + system sleep are all blocked — fixes a regression where a laptop on battery would sleep mid-render and leave the Python child in uninterruptible-wait until a hard kill. For HunyuanVideo specifically, `scripts/generate_hunyuan.py` monkey-patches `tqdm.tqdm` / `tqdm.auto.tqdm` so each diffusion step emits a `STAGE:inference:step:N:30:` line that `local.js#handleLine` parses into an SSE progress event — without this, even with unbuffered stdio, the pipeline's `tqdm` against a pipe was too sparse for the UI to render a step count. Set `hv.text_encoder_precision_2` alongside `hv.text_encoder_precision` so CLIP-L follows the same dtype as Llama — otherwise CLIP silently loaded at fp16 against an fp32 Llama and tripped the assertion via mixed-dtype embeddings.
+
- **Scheduled `reference-watch` was silently read-only, breaking weekly PLAN.md updates.** `DEFAULT_TASK_INTERVALS['reference-watch']` in `server/services/taskSchedule.js` carried `taskMetadata: { readOnly: true }`, which `agentPromptBuilder.js` translated into a "## Read-Only Task — Do NOT commit, push, or modify any files" guard at the bottom of the prompt. But the v2 reference-watch prompt (`PROMPT_VERSIONS['reference-watch'] = 2`) explicitly instructs the agent to APPEND slug-tagged `[ref-watch-…]` checklist items to PLAN.md and commit them — the agent (correctly) refused to write any files, defeating the whole flow on every weekly cron firing. The on-commit trigger path in `referenceRepos.js#triggerReferenceAnalysis` was already correct (`readOnly: false`, with an inline comment documenting exactly this pitfall); the scheduled-cron default drifted. Flipped the default to `readOnly: false`, updated the stale comment, and pinned the contract via tests in `taskSchedule.test.js` (default-interval contract) and `referenceRepos.test.js` (trigger-path contract).
- **Big-local-models PR review pass.** Multi-agent review of the big-local-models branch surfaced eight cross-file regressions that landed alongside the Memory Management + new-runtime work:
diff --git a/data.reference/media-models.json b/data.reference/media-models.json
index c8247cf04e..c91be1c8b2 100644
--- a/data.reference/media-models.json
+++ b/data.reference/media-models.json
@@ -63,12 +63,14 @@
},
{
"id": "hunyuan_video",
- "name": "HunyuanVideo (13B, ~60 GB — swap text encoder to 4-bit Gemma)",
+ "name": "HunyuanVideo (13B — fp32-only on MPS, ~4-8 hr per render)",
"repo": "tencent/HunyuanVideo",
"runtime": "hunyuan",
"mode": "t2v",
"steps": 30,
- "guidance": 6
+ "guidance": 6,
+ "precision": "fp32",
+ "deprecated": true
}
],
"windows": [
diff --git a/scripts/migrations/044-hunyuan-fp32-deprecated.js b/scripts/migrations/044-hunyuan-fp32-deprecated.js
new file mode 100644
index 0000000000..7fbb24fe56
--- /dev/null
+++ b/scripts/migrations/044-hunyuan-fp32-deprecated.js
@@ -0,0 +1,94 @@
+/**
+ * Pin HunyuanVideo to fp32 + mark it deprecated on the macOS video catalog.
+ *
+ * `scripts/generate_hunyuan.py` previously defaulted to fp16, which silently
+ * trips an MPS matmul assertion ("Destination NDArray and Accumulator NDArray
+ * cannot have different datatype") within ~2s of the first forward pass.
+ * Verified empirically that bf16 hits the same assertion — only fp32 across
+ * DiT + VAE + both text encoders works on Apple Silicon. At 576×1024×121
+ * frames × 30 steps that's a 4-8 hr render, so on top of the dtype pin we
+ * also flag the model `deprecated: true` so it moves to the "Legacy" optgroup
+ * in the model picker (out of the default flow, still selectable if a user
+ * wants to run it overnight).
+ *
+ * `data.reference/media-models.json` now carries `precision: 'fp32'` +
+ * `deprecated: true` on the `hunyuan_video` entry plus an updated name that
+ * surfaces the constraint. Fresh installs pick this up via setup-data.js,
+ * but `media-models.json` is in the gitignored `data/` tree and is not in
+ * JSON_MERGE_TARGETS — so existing installs keep their pre-flip entry and
+ * crash on the next HunyuanVideo render. This migration patches the three
+ * fields onto an unmodified `hunyuan_video` entry without touching anything
+ * else.
+ *
+ * Idempotent: a second run finds the fields already present, or finds a
+ * user-customized entry (precision pinned to a different dtype, name
+ * changed) and exits without writing.
+ */
+
+import { readFile, writeFile } from 'fs/promises';
+import { join } from 'path';
+
+const REL_PATH = 'data/media-models.json';
+
+// The exact pre-change name from data.reference. We only auto-rename when the
+// stored name still matches this — a user who renamed the entry keeps theirs.
+const OLD_SHIPPED_NAME = 'HunyuanVideo (13B, ~60 GB — swap text encoder to 4-bit Gemma)';
+const NEW_SHIPPED_NAME = 'HunyuanVideo (13B — fp32-only on MPS, ~4-8 hr per render)';
+
+export default {
+ async up({ rootDir }) {
+ const path = join(rootDir, REL_PATH);
+ const raw = await readFile(path, 'utf-8').catch((err) => {
+ if (err.code === 'ENOENT') return null;
+ throw err;
+ });
+ if (raw == null) {
+ console.log(`📄 ${REL_PATH} not present — skipping (fresh install will copy from data.reference)`);
+ return;
+ }
+
+ let config;
+ try {
+ config = JSON.parse(raw);
+ } catch (err) {
+ console.log(`⚠️ ${REL_PATH}: invalid JSON, skipping (${err.message})`);
+ return;
+ }
+
+ const macos = Array.isArray(config?.video?.macos) ? config.video.macos : null;
+ if (!macos) {
+ console.log(`⚠️ ${REL_PATH}: no video.macos[] array — skipping`);
+ return;
+ }
+
+ const entry = macos.find((m) => m?.id === 'hunyuan_video');
+ if (!entry) {
+ console.log(`✅ ${REL_PATH}: no 'hunyuan_video' entry — user removed it, nothing to migrate`);
+ return;
+ }
+
+ let changed = false;
+ if (entry.precision == null) {
+ // Only set when absent. A user who pinned a non-fp32 dtype is opting
+ // into the broken path knowingly (e.g. to retest after an Apple MPS
+ // fix); don't overwrite their choice.
+ entry.precision = 'fp32';
+ changed = true;
+ }
+ if (entry.deprecated !== true) {
+ entry.deprecated = true;
+ changed = true;
+ }
+ if (entry.name === OLD_SHIPPED_NAME) {
+ entry.name = NEW_SHIPPED_NAME;
+ changed = true;
+ }
+
+ if (changed) {
+ await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
+ console.log(`📝 ${REL_PATH}: pinned HunyuanVideo to fp32 + marked deprecated (MPS matmul fp16/bf16 broken)`);
+ } else {
+ console.log(`✅ ${REL_PATH}: HunyuanVideo entry already pinned to fp32 + deprecated, no changes`);
+ }
+ },
+};
diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.js
index a267d050c9..71c1b692dc 100644
--- a/server/lib/mediaModels.js
+++ b/server/lib/mediaModels.js
@@ -79,12 +79,19 @@ const DEFAULT_REGISTRY = {
// scripts/setup-image-video.sh`.
{
id: 'hunyuan_video',
- name: 'HunyuanVideo (13B, ~60 GB — swap text encoder to 4-bit Gemma)',
+ // fp32-only on MPS: fp16/bf16 trip an MPS matmul accumulator-dtype
+ // assertion within ~2s of the first forward pass. At 576×1024×121
+ // frames × 30 steps that's a 4-8 hr render — marked `deprecated`
+ // so it lands in the "Legacy" optgroup. Migration 044 patches
+ // existing installs that still have the pre-fix shape.
+ name: 'HunyuanVideo (13B — fp32-only on MPS, ~4-8 hr per render)',
repo: 'tencent/HunyuanVideo',
runtime: 'hunyuan',
mode: 't2v',
steps: 30,
guidance: 6.0,
+ precision: 'fp32',
+ deprecated: true,
},
],
windows: [