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

fix(video-gen): clamp FastH3 frame options to the 5-15s window its pipeline enforces

[._.]/ Adam Eivy830b8c7b2bc6
diff --git a/data.reference/media-models.json b/data.reference/media-models.json
index a9a0c920b9..a1c497be03 100644
--- a/data.reference/media-models.json
+++ b/data.reference/media-models.json
@@ -691,7 +691,6 @@
"defaultHeight": 480,
"defaultFrames": 124,
"frameOptions": [
- 107,
124,
141,
158,
@@ -705,8 +704,7 @@
294,
311,
328,
- 345,
- 362
+ 345
],
"fpsOptions": [
24
@@ -774,7 +772,6 @@
"defaultHeight": 480,
"defaultFrames": 124,
"frameOptions": [
- 107,
124,
141,
158,
@@ -788,8 +785,7 @@
294,
311,
328,
- 345,
- 362
+ 345
],
"fpsOptions": [
24
@@ -857,7 +853,6 @@
"defaultHeight": 480,
"defaultFrames": 124,
"frameOptions": [
- 107,
124,
141,
158,
@@ -871,8 +866,7 @@
294,
311,
328,
- 345,
- 362
+ 345
],
"fpsOptions": [
24
@@ -939,7 +933,6 @@
"defaultHeight": 480,
"defaultFrames": 124,
"frameOptions": [
- 107,
124,
141,
158,
@@ -953,8 +946,7 @@
294,
311,
328,
- 345,
- 362
+ 345
],
"fpsOptions": [
24
diff --git a/scripts/migrations/334-fasth3-upstream-source-mlx.js b/scripts/migrations/334-fasth3-upstream-source-mlx.js
index 89a24fe63a..801007a08d 100644
--- a/scripts/migrations/334-fasth3-upstream-source-mlx.js
+++ b/scripts/migrations/334-fasth3-upstream-source-mlx.js
@@ -10,18 +10,21 @@
* before the first render. One download serves all three rows.
*/
-import { readFile } from 'fs/promises';
-import { join } from 'path';
-import { atomicWrite } from '../../server/lib/fileUtils.js';
import { VIDEO_BUCKET_MLX, readVideoBucket } from '../../server/lib/mediaModelBuckets.js';
+import { readMediaRegistry, writeMediaRegistry } from './_lib.js';
-const REL_PATH = 'data/media-models.json';
+// H3's video VAE decodes only 17n+5 frame counts, and the MLX pipeline refuses
+// anything outside 5-15 s at 24 fps, so the grid is 124..345. Inlined rather
+// than imported from lib/mediaModels.js: a migration must keep writing the
+// values it shipped with, not whatever the live constant becomes three releases
+// later.
+const FRAME_OPTIONS = [124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345];
-// H3's video VAE decodes only 17n+5 frame counts, and FastH3 is a distilled H3.
-// Inlined rather than imported from lib/mediaModels.js: a migration must keep
-// writing the values it shipped with, not whatever the live constant becomes
-// three releases later.
-const FRAME_OPTIONS = [107, 124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362];
+// What migration 333 wrote. Its two extra ends — 107 (4.46 s) and 362 (15.08 s)
+// — sit outside the pipeline's window and raise instead of rendering, so an
+// install that already ran 333 carries a picker with a broken value at each end.
+const MIGRATION_333_FRAME_OPTIONS = [107, 124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362];
+const REPACK_ID = 'fasth3_dense_datafree_mlx_int4';
const RESOLUTION_OPTIONS = [
{ label: '832x480 (16:9 FastH3 default)', w: 832, h: 480 },
{ label: '1280x720 (16:9 HD)', w: 1280, h: 720 },
@@ -43,10 +46,10 @@ const NEW_ENTRIES = [
defaultWidth: 832,
defaultHeight: 480,
defaultFrames: 124,
- frameOptions: [...FRAME_OPTIONS],
+ frameOptions: FRAME_OPTIONS,
fpsOptions: [24],
resolutionStep: 32,
- resolutionOptions: RESOLUTION_OPTIONS.map((preset) => ({ ...preset })),
+ resolutionOptions: RESOLUTION_OPTIONS,
memoryGb,
steps: 4,
guidance: 1,
@@ -59,20 +62,8 @@ const NEW_ENTRIES = [
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) return;
- let config;
- try {
- config = JSON.parse(raw);
- } catch (err) {
- throw new Error(`Cannot migrate ${REL_PATH}: invalid JSON (${err.message})`, { cause: err });
- }
- const mlxEntries = readVideoBucket(config?.video, VIDEO_BUCKET_MLX);
- if (!Array.isArray(mlxEntries)) return;
+ const { ok, config, entries: mlxEntries, path } = await readMediaRegistry({ rootDir, bucket: VIDEO_BUCKET_MLX });
+ if (!ok) return;
let changed = false;
const present = new Set(mlxEntries.map((entry) => entry?.id));
@@ -82,6 +73,16 @@ export default {
present.add(entry.id);
changed = true;
}
+ // Repair the row 333 shipped, but only while it still holds 333's exact
+ // list — a user who edited their own frame options keeps them.
+ const repack = mlxEntries.find((entry) => entry?.id === REPACK_ID);
+ if (repack && Array.isArray(repack.frameOptions)
+ && repack.frameOptions.length === MIGRATION_333_FRAME_OPTIONS.length
+ && repack.frameOptions.every((frames, i) => frames === MIGRATION_333_FRAME_OPTIONS[i])) {
+ repack.frameOptions = [...FRAME_OPTIONS];
+ changed = true;
+ }
+
const shipped = readVideoBucket(config?._shippedDefaults?.video, VIDEO_BUCKET_MLX);
if (Array.isArray(shipped)) {
for (const entry of NEW_ENTRIES) {
@@ -92,8 +93,8 @@ export default {
}
}
if (changed) {
- await atomicWrite(path, `${JSON.stringify(config, null, 2)}\n`);
- console.log(`📝 ${REL_PATH}: added the upstream FastH3 Dense Data-Free MLX models`);
+ await writeMediaRegistry(path, config);
+ console.log('📝 data/media-models.json: added the upstream FastH3 Dense Data-Free MLX models');
}
},
};
diff --git a/scripts/migrations/334-fasth3-upstream-source-mlx.test.js b/scripts/migrations/334-fasth3-upstream-source-mlx.test.js
index d1ded4aa13..c0e5a85043 100644
--- a/scripts/migrations/334-fasth3-upstream-source-mlx.test.js
+++ b/scripts/migrations/334-fasth3-upstream-source-mlx.test.js
@@ -62,7 +62,7 @@ describe('334-fasth3-upstream-source-mlx migration', () => {
}
});
- it('leaves the pre-converted repack row from migration 333 in place', async () => {
+ it('leaves the pre-converted repack row from migration 333 otherwise in place', async () => {
write({ video: { mlx: [{ id: 'fasth3_dense_datafree_mlx_int4', repo: 'MrMofer/x' }] } });
await migration.up({ rootDir });
@@ -71,6 +71,35 @@ describe('334-fasth3-upstream-source-mlx migration', () => {
expect(packed).toEqual({ id: 'fasth3_dense_datafree_mlx_int4', repo: 'MrMofer/x' });
});
+ it('drops the two out-of-window frame counts migration 333 shipped', async () => {
+ // 107 is 4.46 s and 362 is 15.08 s at FastH3's fixed 24 fps; the pipeline
+ // refuses both, so they were a broken value at each end of the picker.
+ write({
+ video: {
+ mlx: [{
+ id: 'fasth3_dense_datafree_mlx_int4',
+ frameOptions: [107, 124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362],
+ }],
+ },
+ });
+
+ await migration.up({ rootDir });
+
+ const packed = read().video.mlx.find((m) => m.id === 'fasth3_dense_datafree_mlx_int4');
+ expect(packed.frameOptions).not.toContain(107);
+ expect(packed.frameOptions).not.toContain(362);
+ expect(packed.frameOptions.every((f) => f / 24 >= 5 && f / 24 <= 15)).toBe(true);
+ });
+
+ it('keeps a user own frame options rather than overwriting them', async () => {
+ write({ video: { mlx: [{ id: 'fasth3_dense_datafree_mlx_int4', frameOptions: [124, 141] }] } });
+
+ await migration.up({ rootDir });
+
+ expect(read().video.mlx.find((m) => m.id === 'fasth3_dense_datafree_mlx_int4').frameOptions)
+ .toEqual([124, 141]);
+ });
+
it('leaves the CUDA bucket untouched', async () => {
write({ video: { mlx: [], cuda: [{ id: 'ltx_video' }] } });
diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.js
index 6fffde0ded..d009001f69 100644
--- a/server/lib/mediaModels.js
+++ b/server/lib/mediaModels.js
@@ -134,13 +134,19 @@ const h3FrameGrid = (min, max) => {
// FastH3 Preview v1's output contract (#5860). It is a distilled MiniMax H3, so
// it inherits H3's 17n+5 VAE frame grid and 32px edge rounding — but NOT H3's
+// full frame range: the MLX pipeline hard-refuses anything outside 5-15 s at its
+// fixed 24 fps ("H3 generates 5-15 s at 24 fps", resolve_geometry in
+// fastvideo/mlx_runtime/minimax_h3_pipeline.py), so the grid is clamped to
+// 120..360 frames. The unclamped 107..362 this shipped with put a too-short AND
+// a too-long value at the two ends of the picker, each of which reached the
+// runtime and raised instead of rendering.
// canvas: the MLX FastH3 entry point is validated at 832x480 (its own default,
// and the resolution upstream's conversion manifest records a passing 124-frame
// generation at), and its docstring documents 1280x720 as the other supported
// request. `resolutionOptions` are presets rather than a whitelist, so a custom
// size still resolves through `resolutionStep`.
export const FASTH3_OUTPUT_PROFILE = Object.freeze({
- frameOptions: h3FrameGrid(107, 362),
+ frameOptions: h3FrameGrid(124, 345),
fpsOptions: Object.freeze([24]),
resolutionStep: 32,
resolutionOptions: Object.freeze([
@@ -164,7 +170,7 @@ const FASTH3_SOURCE_FORMATS = Object.freeze([
Object.freeze({ format: 'int4', memoryGb: 36, label: 'INT4 (smallest)' }),
]);
-export const fastH3SourceEntries = () => FASTH3_SOURCE_FORMATS.map(({ format, memoryGb, label }) => ({
+const FASTH3_SOURCE_ENTRIES = FASTH3_SOURCE_FORMATS.map(({ format, memoryGb, label }) => ({
id: `fasth3_dense_datafree_${format}`,
name: `FastH3 Preview v1 Dense Data-Free — MLX ${label} (video + audio, ~144 GB download, ${memoryGb}+ GB RAM, 4-step)`,
repo: FASTH3_SOURCE_REPO,
@@ -678,7 +684,7 @@ const DEFAULT_REGISTRY = {
// FastVideo's own FastH3 Dense / Data-Free snapshot, converted to MLX on
// this machine. Listed before the third-party repack below because it is
// the upstream checkpoint the repack is derived from.
- ...fastH3SourceEntries(),
+ ...FASTH3_SOURCE_ENTRIES,
// FastH3 Preview v1 Dense / Data-Free, packed for MLX (#5860). Same
// `fastvideo` venv and checkout as FastMetal above, but a different entry
// script and argv shape — `fastvideoFamily` is what routes it, see
diff --git a/server/lib/mediaModels.test.js b/server/lib/mediaModels.test.js
index f6753004e3..2d6ebc08b6 100644
--- a/server/lib/mediaModels.test.js
+++ b/server/lib/mediaModels.test.js
@@ -216,6 +216,28 @@ describe('mediaModels registry', () => {
}
});
+ it('offers FastH3 only frame counts its pipeline will accept', async () => {
+ const { loadMediaModels, FASTH3_OUTPUT_PROFILE } = await import('./mediaModels.js');
+ // mlx_fasth3.py renders at a fixed 24 fps and resolve_geometry hard-refuses
+ // anything outside 5-15 s, so a frame count off that window reaches the
+ // runtime and RAISES rather than rendering. 107 and 362 both did.
+ const FPS = 24;
+ for (const frames of FASTH3_OUTPUT_PROFILE.frameOptions) {
+ expect((frames - 5) % 17).toBe(0);
+ expect(frames / FPS).toBeGreaterThanOrEqual(5);
+ expect(frames / FPS).toBeLessThanOrEqual(15);
+ }
+ expect(FASTH3_OUTPUT_PROFILE.frameOptions).not.toContain(107);
+ expect(FASTH3_OUTPUT_PROFILE.frameOptions).not.toContain(362);
+ // Every shipped FastH3 row, not just the profile constant.
+ const rows = loadMediaModels().video.mlx.filter((m) => m.fastvideoFamily === 'fasth3');
+ expect(rows.length).toBeGreaterThan(1);
+ for (const row of rows) {
+ expect(row.frameOptions).toEqual([...FASTH3_OUTPUT_PROFILE.frameOptions]);
+ expect(row.frameOptions).toContain(row.defaultFrames);
+ }
+ });
+
it('ships MiniMax H3 as a pinned, keyframe-capable 128 GB BYOV profile', async () => {
const { loadMediaModels } = await import('./mediaModels.js');
// H3 is an Apple-silicon MLX runtime, so inspect the shipped macOS catalog