Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): video graph compilation for Wan 2.2 and MiniMax H3
Lincoln Steinf136c7e8572e
diff --git a/invokeai/app/invocations/metadata.py b/invokeai/app/invocations/metadata.pyindex cb8e351c64..9e725c1098 100644--- a/invokeai/app/invocations/metadata.py+++ b/invokeai/app/invocations/metadata.py@@ -185,7 +185,10 @@ GENERATION_MODES = Literal["wan_img2img","wan_inpaint","wan_outpaint",+ "wan_t2v","wan_i2v",+ "wan_interpolate",+ "wan_extend_video","minimax_h3_t2v","minimax_h3_i2v","minimax_h3_lf2v",@@ -200,7 +203,7 @@ GENERATION_MODES = Literal[title="Core Metadata",tags=["metadata"],category="metadata",- version="2.3.0",+ version="2.4.0",classification=Classification.Internal,)class CoreMetadataInvocation(BaseInvocation):diff --git a/invokeai/app/services/workflow_records/default_workflows/Extend Video - MiniMax H3.json b/invokeai/app/services/workflow_records/default_workflows/Extend Video - MiniMax H3.jsonindex 5c495f6b84..441efb8e65 100644--- a/invokeai/app/services/workflow_records/default_workflows/Extend Video - MiniMax H3.json+++ b/invokeai/app/services/workflow_records/default_workflows/Extend Video - MiniMax H3.json@@ -338,7 +338,7 @@"type": "invocation","data": {"id": "9e2b5033-4c5d-4e7f-a081-9c0d1e2f3a04",- "version": "2.3.0",+ "version": "2.4.0","nodePack": "invokeai","label": "Core Metadata","notes": "Everything except the generation mode arrives over an edge from the node that used the value, so the record cannot go stale.",diff --git a/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.json b/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.jsonindex 19163c24a7..4cd0ce9418 100644--- a/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.json+++ b/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.json@@ -330,7 +330,7 @@"type": "invocation","data": {"id": "9e2b5033-4c5d-4e7f-a081-9c0d1e2f3a04",- "version": "2.3.0",+ "version": "2.4.0","nodePack": "invokeai","label": "Core Metadata","notes": "Everything except the generation mode arrives over an edge from the node that used the value, so the record cannot go stale.",diff --git a/invokeai/app/services/workflow_records/default_workflows/First and Last Frame to Video - MiniMax H3.json b/invokeai/app/services/workflow_records/default_workflows/First and Last Frame to Video - MiniMax H3.jsonindex 5593f33545..357969c4fd 100644--- a/invokeai/app/services/workflow_records/default_workflows/First and Last Frame to Video - MiniMax H3.json+++ b/invokeai/app/services/workflow_records/default_workflows/First and Last Frame to Video - MiniMax H3.json@@ -334,7 +334,7 @@"type": "invocation","data": {"id": "9e2b5033-4c5d-4e7f-a081-9c0d1e2f3a04",- "version": "2.3.0",+ "version": "2.4.0","nodePack": "invokeai","label": "Core Metadata","notes": "Everything except the generation mode arrives over an edge from the node that used the value, so the record cannot go stale.",diff --git a/invokeai/app/services/workflow_records/default_workflows/Last Frame to Video - MiniMax H3.json b/invokeai/app/services/workflow_records/default_workflows/Last Frame to Video - MiniMax H3.jsonindex 4d9b9d3825..2a0eaea7cb 100644--- a/invokeai/app/services/workflow_records/default_workflows/Last Frame to Video - MiniMax H3.json+++ b/invokeai/app/services/workflow_records/default_workflows/Last Frame to Video - MiniMax H3.json@@ -330,7 +330,7 @@"type": "invocation","data": {"id": "9e2b5033-4c5d-4e7f-a081-9c0d1e2f3a04",- "version": "2.3.0",+ "version": "2.4.0","nodePack": "invokeai","label": "Core Metadata","notes": "Everything except the generation mode arrives over an edge from the node that used the value, so the record cannot go stale.",diff --git a/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.json b/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.jsonindex b3bc4135ef..bfd3ff0ac1 100644--- a/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.json+++ b/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.json@@ -334,7 +334,7 @@"type": "invocation","data": {"id": "9e2b5033-4c5d-4e7f-a081-9c0d1e2f3a04",- "version": "2.3.0",+ "version": "2.4.0","nodePack": "invokeai","label": "Core Metadata","notes": "Everything except the generation mode arrives over an edge from the node that used the value, so the record cannot go stale.",diff --git a/invokeai/frontend/web/openapi.json b/invokeai/frontend/web/openapi.jsonindex 53d717d319..e3bce43e61 100644--- a/invokeai/frontend/web/openapi.json+++ b/invokeai/frontend/web/openapi.json@@ -23775,7 +23775,10 @@"wan_img2img","wan_inpaint","wan_outpaint",+ "wan_t2v","wan_i2v",+ "wan_interpolate",+ "wan_extend_video","minimax_h3_t2v","minimax_h3_i2v","minimax_h3_lf2v",@@ -24525,7 +24528,7 @@"tags": ["metadata"],"title": "Core Metadata","type": "object",- "version": "2.3.0",+ "version": "2.4.0","output": {"$ref": "#/components/schemas/MetadataOutput"}diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.tsindex 391ee3083c..72c545fd01 100644--- a/invokeai/frontend/web/src/services/api/schema.ts+++ b/invokeai/frontend/web/src/services/api/schema.ts@@ -8828,7 +8828,7 @@ export type components = {* @description The generation mode that output this image* @default null*/- generation_mode?: ("txt2img" | "img2img" | "inpaint" | "outpaint" | "sdxl_txt2img" | "sdxl_img2img" | "sdxl_inpaint" | "sdxl_outpaint" | "flux_txt2img" | "flux_img2img" | "flux_inpaint" | "flux_outpaint" | "flux2_txt2img" | "flux2_img2img" | "flux2_inpaint" | "flux2_outpaint" | "sd3_txt2img" | "sd3_img2img" | "sd3_inpaint" | "sd3_outpaint" | "cogview4_txt2img" | "cogview4_img2img" | "cogview4_inpaint" | "cogview4_outpaint" | "z_image_txt2img" | "z_image_img2img" | "z_image_inpaint" | "z_image_outpaint" | "ernie_image_txt2img" | "ideogram4_txt2img" | "qwen_image_txt2img" | "qwen_image_img2img" | "qwen_image_inpaint" | "qwen_image_outpaint" | "anima_txt2img" | "anima_img2img" | "anima_inpaint" | "anima_outpaint" | "krea2_txt2img" | "krea2_img2img" | "krea2_inpaint" | "krea2_outpaint" | "wan_txt2img" | "wan_img2img" | "wan_inpaint" | "wan_outpaint" | "wan_i2v" | "minimax_h3_t2v" | "minimax_h3_i2v" | "minimax_h3_lf2v" | "minimax_h3_flf2v" | "minimax_h3_extend_video" | "minimax_h3_txt2img") | null;+ generation_mode?: ("txt2img" | "img2img" | "inpaint" | "outpaint" | "sdxl_txt2img" | "sdxl_img2img" | "sdxl_inpaint" | "sdxl_outpaint" | "flux_txt2img" | "flux_img2img" | "flux_inpaint" | "flux_outpaint" | "flux2_txt2img" | "flux2_img2img" | "flux2_inpaint" | "flux2_outpaint" | "sd3_txt2img" | "sd3_img2img" | "sd3_inpaint" | "sd3_outpaint" | "cogview4_txt2img" | "cogview4_img2img" | "cogview4_inpaint" | "cogview4_outpaint" | "z_image_txt2img" | "z_image_img2img" | "z_image_inpaint" | "z_image_outpaint" | "ernie_image_txt2img" | "ideogram4_txt2img" | "qwen_image_txt2img" | "qwen_image_img2img" | "qwen_image_inpaint" | "qwen_image_outpaint" | "anima_txt2img" | "anima_img2img" | "anima_inpaint" | "anima_outpaint" | "krea2_txt2img" | "krea2_img2img" | "krea2_inpaint" | "krea2_outpaint" | "wan_txt2img" | "wan_img2img" | "wan_inpaint" | "wan_outpaint" | "wan_t2v" | "wan_i2v" | "wan_interpolate" | "wan_extend_video" | "minimax_h3_t2v" | "minimax_h3_i2v" | "minimax_h3_lf2v" | "minimax_h3_flf2v" | "minimax_h3_extend_video" | "minimax_h3_txt2img") | null;/*** Positive Prompt* @description The positive prompt parameterdiff --git a/invokeai/frontend/webv2/src/features/generation/core/graph.ts b/invokeai/frontend/webv2/src/features/generation/core/graph.tsindex 35e9980e8c..79325964c9 100644--- a/invokeai/frontend/webv2/src/features/generation/core/graph.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/graph.ts@@ -280,7 +280,7 @@ export const addLoraCollectionLoader = (return loader;};-const addTransformerLoraCollectionLoader = (+export const addTransformerLoraCollectionLoader = (graph: BackendGraphContract,loras: GenerateLora[],loaderType: string,diff --git a/invokeai/frontend/webv2/src/features/generation/graph.ts b/invokeai/frontend/webv2/src/features/generation/graph.tsindex 3cc9edc737..b83aab7726 100644--- a/invokeai/frontend/webv2/src/features/generation/graph.ts+++ b/invokeai/frontend/webv2/src/features/generation/graph.ts@@ -3,8 +3,20 @@* the graph-builder primitives shared with other invocation sources.* Curated, caller-driven export list — add a symbol only when a consumer needs it.*/-export { addLoraCollectionLoader, compileGenerateGraph, resolveGenerateSeed } from './core/graph';-export { addEdge, addNode, getActiveCompatibleLoras, toGraphContract, toModelIdentifier } from './core/graphBuilder';+export {+ addLoraCollectionLoader,+ addTransformerLoraCollectionLoader,+ compileGenerateGraph,+ resolveGenerateSeed,+} from './core/graph';+export {+ addEdge,+ addNode,+ createId,+ getActiveCompatibleLoras,+ toGraphContract,+ toModelIdentifier,+} from './core/graphBuilder';export { compileCanvasGraph } from './core/canvas/compileCanvasGraph';export { detectCanvasMode } from './core/canvas/canvasMode';export {diff --git a/invokeai/frontend/webv2/src/features/video/core/graph.test.ts b/invokeai/frontend/webv2/src/features/video/core/graph.test.tsnew file mode 100644index 0000000000..3bead64aab--- /dev/null+++ b/invokeai/frontend/webv2/src/features/video/core/graph.test.ts@@ -0,0 +1,387 @@+import type { BackendGraphContract, MainModelConfig } from '@features/generation/contracts';++import { describe, expect, it } from 'vitest';++import type { VideoSettings } from './types';++import { compileVideoGraph } from './graph';+import { getDefaultVideoSettings } from './videoPolicies';++const wanModel = (variant: string, format = 'diffusers', key = `wan-${variant}-${format}`): MainModelConfig => ({+ base: 'wan',+ format,+ key,+ name: `Wan 2.2 ${variant}`,+ type: 'main',+ variant,+});++const h3Model = (key = 'h3-main'): MainModelConfig => ({+ base: 'minimax-h3',+ format: 'diffusers',+ key,+ name: 'MiniMax H3',+ type: 'main',+ variant: 'fl2va',+});++const WAN_VAE = { base: 'wan', key: 'wan-vae', latent_channels: 16, name: 'Wan 2.1 VAE', type: 'vae' as const };+const WAN_T5 = { base: 'any', key: 'umt5', name: 'UMT5-XXL', type: 'wan_t5_encoder' as const };++const FIRST_FRAME = { height: 1080, image_name: 'first.png', width: 1920 };+const LAST_FRAME = { height: 1080, image_name: 'last.png', width: 1920 };+const SOURCE_VIDEO = {+ endFrame: -2,+ fps: 16,+ height: 480,+ numFrames: 81,+ startFrame: 0,+ video_name: 'clip.mp4',+ width: 832,+};++const settingsFor = (model: MainModelConfig, overrides: Partial<VideoSettings> = {}): VideoSettings => ({+ ...getDefaultVideoSettings(model),+ positivePrompt: 'a red fox',+ ...overrides,+});++const nodesOfType = (graph: BackendGraphContract, type: string) =>+ Object.values(graph.nodes).filter((node) => node.type === type);++const nodeOfType = (graph: BackendGraphContract, type: string) => {+ const nodes = nodesOfType(graph, type);++ expect(nodes, `expected exactly one ${type} node`).toHaveLength(1);++ return nodes[0] as Record<string, unknown> & { id: string; type: string };+};++const hasEdge = (+ graph: BackendGraphContract,+ sourceId: string,+ sourceField: string,+ targetId: string,+ targetField: string+) =>+ graph.edges.some(+ (edge) =>+ edge.source.node_id === sourceId &&+ edge.source.field === sourceField &&+ edge.destination.node_id === targetId &&+ edge.destination.field === targetField+ );++describe('compileVideoGraph — Wan 2.2', () => {+ it('builds a text-to-video graph ending in wan_l2v', () => {+ const model = wanModel('t2v_a14b');+ const settings = settingsFor(model, { aspectRatioId: '16:9', targetResolution: '720p' });+ const { backendGraph, negativePromptNodeId, positivePromptNodeId, seedNodeId } = compileVideoGraph(settings, model);++ expect(positivePromptNodeId).toBe('positive_prompt');+ expect(negativePromptNodeId).toBe('negative_prompt');+ expect(seedNodeId).toBe('seed');++ const denoise = nodeOfType(backendGraph, 'wan_video_denoise');++ expect(denoise).toMatchObject({+ guidance_scale: settings.cfgScale,+ height: 720,+ num_frames: settings.numFrames,+ steps: settings.steps,+ width: 1280,+ });+ // A14B: null low-noise CFG falls back to the primary, not the node default.+ expect(denoise.guidance_scale_low_noise).toBe(settings.cfgScaleLowNoise ?? settings.cfgScale);++ const output = nodeOfType(backendGraph, 'wan_l2v');++ expect(output).toMatchObject({ fps: settings.fps, id: 'video_output', is_intermediate: false });+ expect(hasEdge(backendGraph, 'model_loader', 'vae', 'video_output', 'vae')).toBe(true);+ expect(hasEdge(backendGraph, 'denoise_latents', 'latents', 'video_output', 'latents')).toBe(true);+ expect(hasEdge(backendGraph, 'seed', 'value', 'denoise_latents', 'seed')).toBe(true);+ expect(hasEdge(backendGraph, 'positive_prompt', 'value', 'pos_cond', 'prompt')).toBe(true);+ expect(hasEdge(backendGraph, 'negative_prompt', 'value', 'neg_cond', 'prompt')).toBe(true);++ expect(nodesOfType(backendGraph, 'wan_ref_image_encoder')).toHaveLength(0);+ expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({+ generation_mode: 'wan_t2v',+ height: 720,+ num_frames: settings.numFrames,+ width: 1280,+ });+ expect(hasEdge(backendGraph, 'core_metadata', 'metadata', 'video_output', 'metadata')).toBe(true);+ expect(hasEdge(backendGraph, 'negative_prompt', 'value', 'core_metadata', 'negative_prompt')).toBe(true);+ });++ it('splices the transformer LoRA collection loader when LoRAs are active', () => {+ const model = wanModel('t2v_a14b');+ const lightning = {+ isEnabled: true,+ model: { base: 'wan', key: 'lit-high', name: 'Wan Lightning High Noise', type: 'lora' as const, variant: 'a14b' },+ weight: 1,+ };+ const { backendGraph } = compileVideoGraph(settingsFor(model, { loras: [lightning] }), model);+ const loader = nodeOfType(backendGraph, 'wan_lora_collection_loader');++ expect(hasEdge(backendGraph, 'model_loader', 'transformer', loader.id, 'transformer')).toBe(true);+ expect(hasEdge(backendGraph, loader.id, 'transformer', 'denoise_latents', 'transformer')).toBe(true);+ expect(nodeOfType(backendGraph, 'core_metadata').loras).toEqual([+ { model: expect.objectContaining({ key: 'lit-high' }), weight: 1 },+ ]);+ });++ it('wires first-frame conditioning through wan_ref_image_encoder with matching canvas and frames', () => {+ const model = wanModel('i2v_a14b');+ const settings = settingsFor(model, { firstFrameImage: FIRST_FRAME, targetResolution: '480p' });+ const { backendGraph } = compileVideoGraph(settings, model);+ const refEncoder = nodeOfType(backendGraph, 'wan_ref_image_encoder');+ const denoise = nodeOfType(backendGraph, 'wan_video_denoise');++ expect(refEncoder).toMatchObject({+ height: denoise.height,+ image: { image_name: 'first.png' },+ num_frames: settings.numFrames,+ width: denoise.width,+ });+ expect(refEncoder.end_image).toBeUndefined();+ expect(hasEdge(backendGraph, 'model_loader', 'vae', 'ref_image_encoder', 'vae')).toBe(true);+ expect(hasEdge(backendGraph, 'ref_image_encoder', 'ref_image', 'denoise_latents', 'ref_image')).toBe(true);+ // 1920x1080 at 480p on the ×16 grid.+ expect(denoise).toMatchObject({ height: 480, width: 848 });+ expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({+ first_frame_image: { image_name: 'first.png' },+ generation_mode: 'wan_i2v',+ });+ });++ it('adds the end frame for first-to-last interpolation', () => {+ const model = wanModel('i2v_a14b');+ const settings = settingsFor(model, { firstFrameImage: FIRST_FRAME, lastFrameImage: LAST_FRAME });+ const { backendGraph } = compileVideoGraph(settings, model);++ expect(nodeOfType(backendGraph, 'wan_ref_image_encoder')).toMatchObject({+ end_image: { image_name: 'last.png' },+ image: { image_name: 'first.png' },+ });+ expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({+ generation_mode: 'wan_interpolate',+ last_frame_image: { image_name: 'last.png' },+ });+ });++ it('builds the extend graph: trim, last-frame conditioning, concat at the source fps', () => {+ const model = wanModel('i2v_a14b');+ const settings = settingsFor(model, { sourceVideo: SOURCE_VIDEO });+ const { backendGraph } = compileVideoGraph(settings, model);++ expect(nodeOfType(backendGraph, 'extract_video_range')).toMatchObject({+ end_frame: -2,+ is_intermediate: true,+ start_frame: 0,+ video: { video_name: 'clip.mp4' },+ });+ expect(nodeOfType(backendGraph, 'video_frame_extract')).toMatchObject({ frame_index: -1, is_intermediate: true });+ // The extracted last frame conditions the new clip via an edge, not a literal.+ expect(hasEdge(backendGraph, 'source_last_frame', 'image', 'ref_image_encoder', 'image')).toBe(true);+ expect(nodeOfType(backendGraph, 'wan_ref_image_encoder').image).toBeUndefined();++ // The freshly generated clip stays out of the gallery; the concat is the output.+ expect(nodeOfType(backendGraph, 'wan_l2v')).toMatchObject({ id: 'extension_clip', is_intermediate: true });+ expect(nodeOfType(backendGraph, 'video_concat')).toMatchObject({+ id: 'video_output',+ is_intermediate: false,+ size_mismatch: 'match_first',+ transition: 'crossfade',+ transition_frames: 2,+ });++ // Join order: [trimmed source, new clip] via the chained collectors.+ expect(hasEdge(backendGraph, 'source_video', 'video', 'source_clip_collect', 'item')).toBe(true);+ expect(hasEdge(backendGraph, 'source_clip_collect', 'collection', 'clips_to_join', 'collection')).toBe(true);+ expect(hasEdge(backendGraph, 'extension_clip', 'video', 'clips_to_join', 'item')).toBe(true);+ expect(hasEdge(backendGraph, 'clips_to_join', 'collection', 'video_output', 'videos')).toBe(true);++ // The extension inherits the source clip's frame rate.+ expect(hasEdge(backendGraph, 'source_video', 'fps', 'source_fps', 'value')).toBe(true);+ expect(hasEdge(backendGraph, 'source_fps', 'value', 'extension_clip', 'fps')).toBe(true);+ expect(hasEdge(backendGraph, 'source_fps', 'value', 'video_output', 'fps')).toBe(true);++ expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({+ generation_mode: 'wan_extend_video',+ source_video: { video_name: 'clip.mp4' },+ });+ // Metadata rides both the final concat and the intermediate clip, and the+ // run-time conditioning frame is recorded via an edge (template behavior).+ expect(hasEdge(backendGraph, 'core_metadata', 'metadata', 'video_output', 'metadata')).toBe(true);+ expect(hasEdge(backendGraph, 'core_metadata', 'metadata', 'extension_clip', 'metadata')).toBe(true);+ expect(hasEdge(backendGraph, 'source_last_frame', 'image', 'core_metadata', 'first_frame_image')).toBe(true);+ });++ it('refuses fractional trim bounds — extract_video_range takes integers', () => {+ const model = wanModel('i2v_a14b');+ const settings = settingsFor(model, { sourceVideo: { ...SOURCE_VIDEO, endFrame: -1.5 } });++ expect(() => compileVideoGraph(settings, model)).toThrow(/whole frame numbers/);+ });++ it('extends toward a destination image via the FLF2V end-frame channel', () => {+ const model = wanModel('i2v_a14b');+ const settings = settingsFor(model, { lastFrameImage: LAST_FRAME, sourceVideo: SOURCE_VIDEO });+ const { backendGraph } = compileVideoGraph(settings, model);++ expect(nodeOfType(backendGraph, 'wan_ref_image_encoder')).toMatchObject({+ end_image: { image_name: 'last.png' },+ });+ });++ it('passes standalone components for single-file mains and omits the low-noise expert for Diffusers', () => {+ const gguf = wanModel('i2v_a14b', 'gguf_quantized');+ const lowExpert = wanModel('i2v_a14b', 'checkpoint', 'low-expert');+ const settings = settingsFor(gguf, {+ firstFrameImage: FIRST_FRAME,+ vae: WAN_VAE,+ wanLowNoiseModel: lowExpert,+ wanT5EncoderModel: WAN_T5,+ });+ const { backendGraph } = compileVideoGraph(settings, gguf);++ expect(nodeOfType(backendGraph, 'wan_model_loader')).toMatchObject({+ transformer_low_noise_model: { key: 'low-expert' },+ vae_model: { key: 'wan-vae' },+ wan_t5_encoder_model: { key: 'umt5' },+ });+ expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({+ transformer_low_noise: { key: 'low-expert' },+ vae: { key: 'wan-vae' },+ wan_t5_encoder: { key: 'umt5' },+ });++ const diffusers = wanModel('i2v_a14b', 'diffusers');+ const diffusersGraph = compileVideoGraph(+ settingsFor(diffusers, { firstFrameImage: FIRST_FRAME, wanLowNoiseModel: lowExpert }),+ diffusers+ ).backendGraph;++ // Diffusers mains bundle transformer_2; the loader input would be ignored.+ expect(nodeOfType(diffusersGraph, 'wan_model_loader').transformer_low_noise_model).toBeUndefined();+ });++ it('omits the low-noise guidance for TI2V-5B and snaps to its ×32 grid', () => {+ const model = wanModel('ti2v_5b');+ const settings = settingsFor(model, { aspectRatioId: '16:9', targetResolution: '720p' });+ const { backendGraph } = compileVideoGraph(settings, model);+ const denoise = nodeOfType(backendGraph, 'wan_video_denoise');++ expect(denoise.guidance_scale_low_noise).toBeUndefined();+ // 16:9 at 720p with banker's rounding on the ×32 grid: 1280×704.+ expect(denoise).toMatchObject({ height: 704, width: 1280 });+ });++ it('refuses to compile invalid settings', () => {+ const t2v = wanModel('t2v_a14b');++ expect(() => compileVideoGraph(settingsFor(t2v, { firstFrameImage: FIRST_FRAME }), t2v)).toThrow(+ /does not support/+ );+ expect(() => compileVideoGraph(settingsFor(t2v, { numFrames: 80 }), t2v)).toThrow(/Frame count/);+ });+});++describe('compileVideoGraph — MiniMax H3', () => {+ const model = h3Model();++ it('builds a text-to-video graph with audio, no negative prompt, and string frame counts', () => {+ const settings = settingsFor(model, { aspectRatioId: '16:9' });+ const { backendGraph } = compileVideoGraph(settings, model);+ const denoise = nodeOfType(backendGraph, 'minimax_h3_denoise');++ // The H3 canvas policy: 16:9 caps at 1344×768; frame counts are string literals.+ expect(denoise).toMatchObject({ height: 768, num_frames: '124', steps: settings.steps, width: 1344 });++ const output = nodeOfType(backendGraph, 'minimax_h3_latents_to_video');++ expect(output.id).toBe('video_output');+ expect(hasEdge(backendGraph, 'denoise_latents', 'video_latents', 'video_output', 'video_latents')).toBe(true);+ expect(hasEdge(backendGraph, 'denoise_latents', 'audio_latents', 'video_output', 'audio_latents')).toBe(true);+ expect(hasEdge(backendGraph, 'model_loader', 'vae', 'video_output', 'vae')).toBe(true);+ expect(hasEdge(backendGraph, 'model_loader', 'audio_vae', 'video_output', 'audio_vae')).toBe(true);++ expect(nodesOfType(backendGraph, 'minimax_h3_frame_conditioning')).toHaveLength(0);+ expect(nodeOfType(backendGraph, 'core_metadata').generation_mode).toBe('minimax_h3_t2v');+ // H3 has no negative prompt; the metadata must not claim one.+ expect(hasEdge(backendGraph, 'negative_prompt', 'value', 'core_metadata', 'negative_prompt')).toBe(false);+ });++ it('mirrors keyframes into both the text encoder and the frame conditioning', () => {+ const settings = settingsFor(model, { firstFrameImage: FIRST_FRAME });+ const { backendGraph } = compileVideoGraph(settings, model);+ const posCond = nodeOfType(backendGraph, 'minimax_h3_text_encoder');+ const frameCond = nodeOfType(backendGraph, 'minimax_h3_frame_conditioning');+ const denoise = nodeOfType(backendGraph, 'minimax_h3_denoise');++ for (const node of [posCond, frameCond]) {+ expect(node).toMatchObject({+ first_image: { image_name: 'first.png' },+ height: denoise.height,+ width: denoise.width,+ });+ expect(node.last_image).toBeUndefined();+ }++ expect(hasEdge(backendGraph, 'model_loader', 'vae', 'frame_conditioning', 'vae')).toBe(true);+ expect(+ hasEdge(backendGraph, 'frame_conditioning', 'frame_conditioning', 'denoise_latents', 'frame_conditioning')+ ).toBe(true);+ expect(nodeOfType(backendGraph, 'core_metadata').generation_mode).toBe('minimax_h3_i2v');+ });++ it('supports last-frame-only conditioning', () => {+ const settings = settingsFor(model, { lastFrameImage: LAST_FRAME });+ const { backendGraph } = compileVideoGraph(settings, model);++ expect(nodeOfType(backendGraph, 'minimax_h3_frame_conditioning')).toMatchObject({+ last_image: { image_name: 'last.png' },+ });+ expect(nodeOfType(backendGraph, 'minimax_h3_frame_conditioning').first_image).toBeUndefined();+ expect(nodeOfType(backendGraph, 'core_metadata').generation_mode).toBe('minimax_h3_lf2v');+ });++ it('builds the extend graph with the source resampled to 24 fps', () => {+ const settings = settingsFor(model, { sourceVideo: { ...SOURCE_VIDEO, endFrame: -1 } });+ const { backendGraph } = compileVideoGraph(settings, model);++ // H3 renders at a fixed 24 fps; the source is retimed up front so the+ // concat (which inherits the first clip's rate) joins at one speed.+ expect(nodeOfType(backendGraph, 'extract_video_range')).toMatchObject({ fps: 24 });+ expect(hasEdge(backendGraph, 'source_last_frame', 'image', 'pos_cond', 'first_image')).toBe(true);+ expect(hasEdge(backendGraph, 'source_last_frame', 'image', 'frame_conditioning', 'first_image')).toBe(true);+ expect(nodeOfType(backendGraph, 'minimax_h3_latents_to_video')).toMatchObject({+ id: 'extension_clip',+ is_intermediate: true,+ });+ expect(nodeOfType(backendGraph, 'video_concat').id).toBe('video_output');+ expect(nodesOfType(backendGraph, 'float_to_int')).toHaveLength(0);+ expect(nodeOfType(backendGraph, 'core_metadata').generation_mode).toBe('minimax_h3_extend_video');+ });++ it('passes the single-file overrides to the loader and the metadata', () => {+ const transformer = { ...h3Model('h3-int8'), format: 'checkpoint' };+ const encoder = { base: 'minimax-h3', key: 'h3-te', name: 'H3 TE int8', type: 'qwen3_vl_encoder' as const };+ const settings = settingsFor(model, { h3TextEncoderModel: encoder, h3TransformerModel: transformer });+ const { backendGraph } = compileVideoGraph(settings, model);++ expect(nodeOfType(backendGraph, 'minimax_h3_model_loader')).toMatchObject({+ text_encoder_model: { key: 'h3-te' },+ transformer_model: { key: 'h3-int8' },+ });+ expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({+ minimax_h3_text_encoder_model: { key: 'h3-te' },+ minimax_h3_transformer_model: { key: 'h3-int8' },+ });+ });++ it('refuses to compile fractional or off-grid frame counts', () => {+ expect(() => compileVideoGraph(settingsFor(model, { numFrames: 100 }), model)).toThrow(/17·n \+ 5/);+ });+});diff --git a/invokeai/frontend/webv2/src/features/video/core/graph.ts b/invokeai/frontend/webv2/src/features/video/core/graph.tsnew file mode 100644index 0000000000..6b0d48d246--- /dev/null+++ b/invokeai/frontend/webv2/src/features/video/core/graph.ts@@ -0,0 +1,474 @@+import type {+ BackendGraphContract,+ BackendInvocationContract,+ GraphContract,+ MainModelConfig,+} from '@features/generation/contracts';++import {+ addEdge,+ addNode,+ addTransformerLoraCollectionLoader,+ createId,+ getActiveCompatibleLoras,+ toGraphContract,+ toModelIdentifier,+} from '@features/generation/graph';+import { getCompatibleDiffusersComponentSource } from '@features/generation/settings';++import type { VideoGenerationMode, VideoSettings } from './types';++import { resolveVideoMode } from './settings';+import { getVideoDimensions, getVideoModelPolicy, getVideoValidationReasons } from './videoPolicies';++/**+ * Video graph compilation: one builder per model family, mirroring the shape+ * of the bundled video workflow templates (which are the reference wiring for+ * conditioning fan-out and metadata). Every graph exposes the same three fixed+ * node ids so the submit pipeline can inject expanded prompts and batch seeds+ * exactly as it does for image generation.+ */++export interface CompiledVideoGraph {+ backendGraph: BackendGraphContract;+ graph: GraphContract;+ negativePromptNodeId: string;+ positivePromptNodeId: string;+ seedNodeId: string;+}++const WAN_GENERATION_MODES: Partial<Record<VideoGenerationMode, string>> = {+ extend: 'wan_extend_video',+ 'first-frame': 'wan_i2v',+ 'first-last': 'wan_interpolate',+ txt2vid: 'wan_t2v',+};++const MINIMAX_H3_GENERATION_MODES: Record<VideoGenerationMode, string> = {+ extend: 'minimax_h3_extend_video',+ 'first-frame': 'minimax_h3_i2v',+ 'first-last': 'minimax_h3_flf2v',+ 'last-frame': 'minimax_h3_lf2v',+ txt2vid: 'minimax_h3_t2v',+};++const addPromptAndSeedNodes = (graph: BackendGraphContract) => ({+ negativePrompt: addNode(graph, { id: 'negative_prompt', type: 'string' }),+ positivePrompt: addNode(graph, { id: 'positive_prompt', type: 'string' }),+ seed: addNode(graph, { id: 'seed', type: 'integer' }),+});++const toImageField = (image: { image_name: string }) => ({ image_name: image.image_name });++/**+ * The extend-mode front end shared by both families, mirroring the bundled+ * extend templates: trim the source clip, pull its last frame as the new+ * clip's conditioning frame, and set up the concat that joins the trimmed+ * source with the freshly generated clip (2-frame crossfade over the seam).+ * Both intermediate video artifacts stay out of the gallery.+ */+const addExtendScaffolding = (+ graph: BackendGraphContract,+ sourceVideo: NonNullable<VideoSettings['sourceVideo']>,+ newClip: BackendInvocationContract,+ options: { extractFps?: number } = {}+) => {+ const extract = addNode(graph, {+ end_frame: sourceVideo.endFrame,+ id: 'source_video',+ is_intermediate: true,+ start_frame: sourceVideo.startFrame,+ type: 'extract_video_range',+ use_cache: false,+ video: { video_name: sourceVideo.video_name },+ ...(options.extractFps === undefined ? {} : { fps: options.extractFps }),+ });+ const lastFrame = addNode(graph, {+ frame_index: -1,+ id: 'source_last_frame',+ is_intermediate: true,+ type: 'video_frame_extract',+ use_cache: false,+ });+ const sourceCollect = addNode(graph, { id: 'source_clip_collect', type: 'collect' });+ const clipsCollect = addNode(graph, { id: 'clips_to_join', type: 'collect' });+ const concat = addNode(graph, {+ id: 'video_output',+ is_intermediate: false,+ size_mismatch: 'match_first',+ transition: 'crossfade',+ transition_frames: 2,+ type: 'video_concat',+ use_cache: false,+ });++ addEdge(graph, extract, 'video', lastFrame, 'video');+ // Chained collectors keep the join order deterministic: [trimmed source, new clip].+ addEdge(graph, extract, 'video', sourceCollect, 'item');+ addEdge(graph, sourceCollect, 'collection', clipsCollect, 'collection');+ addEdge(graph, newClip, 'video', clipsCollect, 'item');+ addEdge(graph, clipsCollect, 'collection', concat, 'videos');++ return { concat, extract, lastFrame };+};++interface VideoMetadataInput {+ graph: BackendGraphContract;+ /** Every video-emitting node that should carry the metadata (in extend mode: the concat AND the intermediate clip). */+ outputs: BackendInvocationContract[];+ settings: VideoSettings;+ model: MainModelConfig;+ generationMode: string;+ width: number;+ height: number;+ /** Whether the negative prompt participates in this family's graphs at all. */+ negativeWired: boolean;+ extras?: Record<string, unknown>;+}++const addVideoMetadata = ({+ graph,+ outputs,+ settings,+ model,+ generationMode,+ width,+ height,+ negativeWired,+ extras = {},+}: VideoMetadataInput) => {+ const activeLoras = getActiveCompatibleLoras(settings, model);+ const metadata = addNode(graph, {+ generation_mode: generationMode,+ height,+ id: 'core_metadata',+ model,+ num_frames: settings.numFrames,+ steps: settings.steps,+ type: 'core_metadata',+ width,+ ...(settings.firstFrameImage ? { first_frame_image: toImageField(settings.firstFrameImage) } : {}),+ ...(settings.lastFrameImage ? { last_frame_image: toImageField(settings.lastFrameImage) } : {}),+ ...(settings.sourceVideo ? { source_video: { video_name: settings.sourceVideo.video_name } } : {}),+ ...(activeLoras.length+ ? { loras: activeLoras.map((lora) => ({ model: toModelIdentifier(lora.model), weight: lora.weight })) }+ : {}),+ ...extras,+ });++ addEdge(graph, graph.nodes.seed, 'value', metadata, 'seed');+ addEdge(graph, graph.nodes.positive_prompt, 'value', metadata, 'positive_prompt');+ if (negativeWired) {+ addEdge(graph, graph.nodes.negative_prompt, 'value', metadata, 'negative_prompt');+ }+ for (const output of outputs) {+ addEdge(graph, metadata, 'metadata', output, 'metadata');+ }++ return metadata;+};++const buildWanVideoGraph = (settings: VideoSettings, model: MainModelConfig): BackendGraphContract => {+ const mode = resolveVideoMode(settings);+ const policy = getVideoModelPolicy(model, settings);+ const dimensions = getVideoDimensions(model, settings);++ if (!dimensions) {+ throw new Error('Video dimensions could not be derived from the current settings.');+ }++ // A GGUF/checkpoint Wan main carries only the transformer; the VAE and+ // UMT5-XXL encoder come from standalone models or a Diffusers component+ // source. A Diffusers main bundles everything, including the second expert.+ const isSingleFileMain = model.format !== 'diffusers';+ const sourceModel = isSingleFileMain+ ? getCompatibleDiffusersComponentSource(model, settings.componentSourceModel)+ : undefined;++ const graph: BackendGraphContract = { edges: [], id: createId('wan_video_graph'), nodes: {} };+ const { negativePrompt, positivePrompt, seed } = addPromptAndSeedNodes(graph);+ const modelLoader = addNode(graph, {+ component_source: sourceModel,+ id: 'model_loader',+ model,+ transformer_low_noise_model: (isSingleFileMain ? settings.wanLowNoiseModel : null) ?? undefined,+ type: 'wan_model_loader',+ vae_model: settings.vae ?? undefined,+ wan_t5_encoder_model: settings.wanT5EncoderModel ?? undefined,+ });+ // Wan LoRAs patch only the transformer; expert routing ('auto') reads each+ // LoRA's probed high/low tag, which is how the Lightning pair lands on the+ // right experts.+ const activeLoras = getActiveCompatibleLoras(settings, model);+ const loraSource = activeLoras.length+ ? addTransformerLoraCollectionLoader(graph, activeLoras, 'wan_lora_collection_loader', modelLoader, ['transformer'])+ : modelLoader;+ const posCond = addNode(graph, { id: 'pos_cond', type: 'wan_text_encoder' });+ const negCond = addNode(graph, { id: 'neg_cond', type: 'wan_text_encoder' });+ const denoise = addNode(graph, {+ guidance_scale: settings.cfgScale,+ // Only the A14B expert pairs run a low-noise phase; null falls back to the+ // primary guidance rather than the node's own 4.0 default.+ ...(policy.ui.cfgLowNoiseVisible+ ? { guidance_scale_low_noise: settings.cfgScaleLowNoise ?? settings.cfgScale }+ : {}),+ height: dimensions.height,+ id: 'denoise_latents',+ num_frames: settings.numFrames,+ steps: settings.steps,+ type: 'wan_video_denoise',+ width: dimensions.width,+ });++ addEdge(graph, loraSource, 'transformer', denoise, 'transformer');+ addEdge(graph, modelLoader, 'wan_t5_encoder', posCond, 'wan_t5_encoder');+ addEdge(graph, modelLoader, 'wan_t5_encoder', negCond, 'wan_t5_encoder');+ addEdge(graph, positivePrompt, 'value', posCond, 'prompt');+ addEdge(graph, negativePrompt, 'value', negCond, 'prompt');+ addEdge(graph, posCond, 'conditioning', denoise, 'positive_conditioning');+ addEdge(graph, negCond, 'conditioning', denoise, 'negative_conditioning');+ addEdge(graph, seed, 'value', denoise, 'seed');++ // The reference-image conditioning: the canvas and frame count must match+ // the denoise exactly, so the same literals fan out to both nodes.+ const addRefEncoder = (inputs: Record<string, unknown>) => {+ const refEncoder = addNode(graph, {+ height: dimensions.height,+ id: 'ref_image_encoder',+ num_frames: settings.numFrames,+ type: 'wan_ref_image_encoder',+ width: dimensions.width,+ ...inputs,+ });++ addEdge(graph, modelLoader, 'vae', refEncoder, 'vae');+ addEdge(graph, refEncoder, 'ref_image', denoise, 'ref_image');++ return refEncoder;+ };++ let output: BackendInvocationContract;+ let extendParts: { lastFrame: BackendInvocationContract; newClip: BackendInvocationContract } | null = null;++ if (mode === 'extend' && settings.sourceVideo) {+ const refEncoder = addRefEncoder(+ settings.lastFrameImage ? { end_image: toImageField(settings.lastFrameImage) } : {}+ );+ const newClip = addNode(graph, {+ id: 'extension_clip',+ is_intermediate: true,+ type: 'wan_l2v',+ use_cache: false,+ });+ const { concat, extract, lastFrame } = addExtendScaffolding(graph, settings.sourceVideo, newClip);+ // The extension inherits the source clip's frame rate, template-style, so+ // the joined halves play at one speed.+ const fpsToInt = addNode(graph, { id: 'source_fps', method: 'Nearest', multiple: 1, type: 'float_to_int' });++ addEdge(graph, lastFrame, 'image', refEncoder, 'image');+ addEdge(graph, modelLoader, 'vae', newClip, 'vae');+ addEdge(graph, denoise, 'latents', newClip, 'latents');+ addEdge(graph, extract, 'fps', fpsToInt, 'value');+ addEdge(graph, fpsToInt, 'value', newClip, 'fps');+ addEdge(graph, fpsToInt, 'value', concat, 'fps');+ output = concat;+ extendParts = { lastFrame, newClip };+ } else {+ if (mode === 'first-frame' || mode === 'first-last') {+ if (!settings.firstFrameImage) {+ throw new Error('A first frame is required for image-to-video generation.');+ }++ addRefEncoder({+ image: toImageField(settings.firstFrameImage),+ ...(mode === 'first-last' && settings.lastFrameImage+ ? { end_image: toImageField(settings.lastFrameImage) }+ : {}),+ });+ }++ output = addNode(graph, {+ fps: settings.fps,+ id: 'video_output',+ is_intermediate: false,+ type: 'wan_l2v',+ use_cache: false,+ });+ addEdge(graph, modelLoader, 'vae', output, 'vae');+ addEdge(graph, denoise, 'latents', output, 'latents');+ }++ const metadata = addVideoMetadata({+ extras: {+ cfg_scale: settings.cfgScale,+ ...(policy.ui.cfgLowNoiseVisible && settings.cfgScaleLowNoise !== null+ ? { guidance_scale_low_noise: settings.cfgScaleLowNoise }+ : {}),+ ...(settings.vae ? { vae: settings.vae } : {}),+ ...(settings.wanT5EncoderModel ? { wan_t5_encoder: settings.wanT5EncoderModel } : {}),+ ...(sourceModel ? { wan_component_source: sourceModel } : {}),+ ...(isSingleFileMain && settings.wanLowNoiseModel ? { transformer_low_noise: settings.wanLowNoiseModel } : {}),+ },+ generationMode: WAN_GENERATION_MODES[mode] ?? 'wan_t2v',+ graph,+ height: dimensions.height,+ model,+ negativeWired: true,+ outputs: extendParts ? [output, extendParts.newClip] : [output],+ settings,+ width: dimensions.width,+ });++ if (extendParts) {+ // The extracted conditioning frame is only known at run time; record it+ // via an edge, like the bundled extend templates do.+ addEdge(graph, extendParts.lastFrame, 'image', metadata, 'first_frame_image');+ }++ return graph;+};++const buildMiniMaxH3VideoGraph = (settings: VideoSettings, model: MainModelConfig): BackendGraphContract => {+ const mode = resolveVideoMode(settings);+ const dimensions = getVideoDimensions(model, settings);++ if (!dimensions) {+ throw new Error('Video dimensions could not be derived from the current settings.');+ }++ const graph: BackendGraphContract = { edges: [], id: createId('minimax_h3_video_graph'), nodes: {} };+ const { positivePrompt, seed } = addPromptAndSeedNodes(graph);+ const modelLoader = addNode(graph, {+ id: 'model_loader',+ model,+ text_encoder_model: settings.h3TextEncoderModel ?? undefined,+ transformer_model: settings.h3TransformerModel ?? undefined,+ type: 'minimax_h3_model_loader',+ });+ const activeLoras = getActiveCompatibleLoras(settings, model);+ const transformerSource = activeLoras.length+ ? addTransformerLoraCollectionLoader(graph, activeLoras, 'minimax_h3_lora_collection_loader', modelLoader, [+ 'transformer',+ ])+ : modelLoader;++ // The canvas and the keyframes must match across text encoder, frame+ // conditioning, and denoise — the same literals (and, in extend mode, the+ // same extracted-frame edge) fan out to all of them.+ const keyframeLiterals = {+ ...(mode !== 'extend' && settings.firstFrameImage ? { first_image: toImageField(settings.firstFrameImage) } : {}),+ ...(settings.lastFrameImage ? { last_image: toImageField(settings.lastFrameImage) } : {}),+ };+ const posCond = addNode(graph, {+ height: dimensions.height,+ id: 'pos_cond',+ type: 'minimax_h3_text_encoder',+ width: dimensions.width,+ ...keyframeLiterals,+ });+ const denoise = addNode(graph, {+ height: dimensions.height,+ id: 'denoise_latents',+ // The node's frame counts are a string Literal choice list.+ num_frames: String(settings.numFrames),+ steps: settings.steps,+ type: 'minimax_h3_denoise',+ width: dimensions.width,+ });++ addEdge(graph, modelLoader, 'text_encoder', posCond, 'text_encoder');+ addEdge(graph, positivePrompt, 'value', posCond, 'prompt');+ addEdge(graph, transformerSource, 'transformer', denoise, 'transformer');+ addEdge(graph, posCond, 'conditioning', denoise, 'positive_conditioning');+ addEdge(graph, seed, 'value', denoise, 'seed');++ const needsFrameConditioning = mode !== 'txt2vid';+ let frameConditioning: BackendInvocationContract | null = null;++ if (needsFrameConditioning) {+ frameConditioning = addNode(graph, {+ height: dimensions.height,+ id: 'frame_conditioning',+ type: 'minimax_h3_frame_conditioning',+ width: dimensions.width,+ ...keyframeLiterals,+ });+ addEdge(graph, modelLoader, 'vae', frameConditioning, 'vae');+ addEdge(graph, frameConditioning, 'frame_conditioning', denoise, 'frame_conditioning');+ }++ const addLatentsToVideo = (id: string, isIntermediate: boolean) => {+ const node = addNode(graph, {+ id,+ is_intermediate: isIntermediate,+ type: 'minimax_h3_latents_to_video',+ use_cache: false,+ });++ addEdge(graph, denoise, 'video_latents', node, 'video_latents');+ addEdge(graph, denoise, 'audio_latents', node, 'audio_latents');+ addEdge(graph, modelLoader, 'vae', node, 'vae');+ addEdge(graph, modelLoader, 'audio_vae', node, 'audio_vae');++ return node;+ };++ let output: BackendInvocationContract;+ let extendParts: { lastFrame: BackendInvocationContract; newClip: BackendInvocationContract } | null = null;++ if (mode === 'extend' && settings.sourceVideo && frameConditioning) {+ const newClip = addLatentsToVideo('extension_clip', true);+ // H3 generates at a fixed 24 fps, so the source is resampled to 24 up+ // front (template behavior) and the concat inherits it from the first clip.+ const { concat, lastFrame } = addExtendScaffolding(graph, settings.sourceVideo, newClip, { extractFps: 24 });++ addEdge(graph, lastFrame, 'image', posCond, 'first_image');+ addEdge(graph, lastFrame, 'image', frameConditioning, 'first_image');+ output = concat;+ extendParts = { lastFrame, newClip };+ } else {+ output = addLatentsToVideo('video_output', false);+ }++ const metadata = addVideoMetadata({+ extras: {+ ...(settings.h3TransformerModel ? { minimax_h3_transformer_model: settings.h3TransformerModel } : {}),+ ...(settings.h3TextEncoderModel ? { minimax_h3_text_encoder_model: settings.h3TextEncoderModel } : {}),+ },+ generationMode: MINIMAX_H3_GENERATION_MODES[mode],+ graph,+ height: dimensions.height,+ model,+ negativeWired: false,+ outputs: extendParts ? [output, extendParts.newClip] : [output],+ settings,+ width: dimensions.width,+ });++ if (extendParts) {+ // The extracted conditioning frame is only known at run time; record it+ // via an edge, like the bundled extend templates do.+ addEdge(graph, extendParts.lastFrame, 'image', metadata, 'first_frame_image');+ }++ return graph;+};++export const compileVideoGraph = (settings: VideoSettings, model: MainModelConfig): CompiledVideoGraph => {+ const validationReasons = getVideoValidationReasons(model, settings);++ if (validationReasons.length > 0) {+ throw new Error(validationReasons[0]);+ }++ const backendGraph =+ model.base === 'minimax-h3' ? buildMiniMaxH3VideoGraph(settings, model) : buildWanVideoGraph(settings, model);++ return {+ backendGraph,+ graph: toGraphContract(backendGraph, `${model.name} video`),+ negativePromptNodeId: 'negative_prompt',+ positivePromptNodeId: 'positive_prompt',+ seedNodeId: 'seed',+ };+};diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.tsindex b8c7b88c53..40f6abf02f 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts@@ -1103,6 +1103,15 @@ export const getVideoValidationReasons = (model: MainModelConfig, settings: Videreasons.push(`${model.name} has no distillation fast path. Turn the accelerator off to generate with it.`);}+ // The trim bounds are integer fields on extract_video_range; a fractional+ // persisted value would fail pydantic coercion at enqueue.+ if (+ settings.sourceVideo &&+ (!Number.isInteger(settings.sourceVideo.startFrame) || !Number.isInteger(settings.sourceVideo.endFrame))+ ) {+ reasons.push('The initial video trim bounds must be whole frame numbers.');+ }+if (!getVideoDimensions(model, settings)) {reasons.push(model.base === 'minimax-h3'diff --git a/invokeai/frontend/webv2/src/features/video/index.ts b/invokeai/frontend/webv2/src/features/video/index.tsindex 65bbb4337f..95a41fe456 100644--- a/invokeai/frontend/webv2/src/features/video/index.ts+++ b/invokeai/frontend/webv2/src/features/video/index.ts@@ -78,3 +78,4 @@ export {type VideoModelSelectionResult,type VideoTargetResolutionOption,} from './core/videoPolicies';+export { compileVideoGraph, type CompiledVideoGraph } from './core/graph';