The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(create): video latents decode tiled so a 12 GB card can finish
purple52dc809a426f
diff --git a/src/api/__tests__/video-decode-tiled.test.ts b/src/api/__tests__/video-decode-tiled.test.tsnew file mode 100644index 00000000..37a80281--- /dev/null+++ b/src/api/__tests__/video-decode-tiled.test.ts@@ -0,0 +1,129 @@+/**+ * Video latents decode TILED whenever the install has VAEDecodeTiled.+ *+ * Live on the 3060 (David 2026-08-02): NSFW Wan 14B GGUF sampled 12/12 steps+ * in 2:54, then the full-frame WanVAE decode sat at "GPU 100%" for 45++ * minutes. The resident 14B UNet left the VAE 312 MB of usable VRAM; CUDA on+ * the Windows driver pages instead of throwing, so ComfyUI's own OOM-based+ * tiled retry never fired. Tiling keeps the decode working set flat, which is+ * the difference between minutes and "is this thing hung" on the 12 GB cards+ * the GGUF catalog targets. Image decodes stay on plain VAEDecode, and a core+ * without the tiled node (very old installs) keeps validating.+ *+ * Run: npx vitest run src/api/__tests__/video-decode-tiled.test.ts+ */+import { describe, it, expect, vi } from 'vitest'++vi.mock('../comfyui-nodes', async (importOriginal) => {+ const actual = await importOriginal<typeof import('../comfyui-nodes')>()+ return { ...actual, getAllNodeInfo: vi.fn() }+})+vi.mock('../backend', async (importOriginal) => {+ const actual = await importOriginal<typeof import('../backend')>()+ return { ...actual, localFetch: vi.fn(), comfyuiUrl: (p: string) => `http://test${p}` }+})++import { buildDynamicWorkflow, videoDecodeNode } from '../dynamic-workflow'+import { getAllNodeInfo } from '../comfyui-nodes'+import { buildSDXLImgWorkflow } from '../comfyui'+import { localFetch } from '../backend'++const NSFW_WAN14B = 'nsfw_wan_14b_e15_q4_k.gguf'+const WAN22_5B_GGUF = 'wan2_2_ti2v_5b_q8.gguf'++const BASE_NODES = {+ UNETLoader: { input: { required: { unet_name: [['wan2.1_t2v_14B_fp8.safetensors']] } } },+ UnetLoaderGGUF: { input: { required: { unet_name: [[NSFW_WAN14B, WAN22_5B_GGUF]] } } },+ CLIPLoader: { input: { required: { clip_name: [['umt5_xxl_fp8_e4m3fn_scaled.safetensors']] } } },+ VAELoader: { input: { required: { vae_name: [['wan2.2_vae.safetensors', 'wan_2.1_vae.safetensors']] } } },+ Wan22ImageToVideoLatent: { input: { required: { vae: ['VAE'], width: ['INT'], height: ['INT'], length: ['INT'], batch_size: ['INT'] }, optional: { start_image: ['IMAGE', {}] } } },+ EmptyHunyuanLatentVideo: { input: { required: {} } },+ ModelSamplingSD3: { input: { required: { model: ['MODEL'], shift: ['FLOAT'] } } },+ KSampler: { input: { required: {} } },+ CLIPTextEncode: { input: { required: {} } },+ VAEDecode: { input: { required: {} } },+ ImageScale: { input: { required: {} } },+ LoadImage: { input: { required: {} } },+ VHS_VideoCombine: { input: { required: {} } },+ SaveAnimatedWEBP: { input: { required: {} } },+}+const NODES_WITH_TILED = {+ ...BASE_NODES,+ VAEDecodeTiled: { input: { required: { samples: ['LATENT'], vae: ['VAE'], tile_size: ['INT'], overlap: ['INT'], temporal_size: ['INT'], temporal_overlap: ['INT'] } } },+}++const serveComfy = (nodes: Record<string, unknown>) => {+ vi.mocked(getAllNodeInfo).mockResolvedValue(nodes as never)+ vi.mocked(localFetch).mockImplementation((async (url: string) => ({+ ok: true,+ status: 200,+ json: async () => (typeof url === 'string' && url.includes('object_info') ? nodes : {}),+ text: async () => JSON.stringify(nodes),+ })) as never)+}++const videoParams = {+ prompt: 'a red lighthouse by the sea at dusk', negativePrompt: '',+ sampler: 'euler', scheduler: 'simple',+ steps: 12, cfgScale: 5, width: 640, height: 384, seed: 42, batchSize: 1,+ frames: 9, fps: 16,+}++type WfNode = { class_type: string; inputs: Record<string, any> }+const nodeOf = (wf: Record<string, any>, klass: string): [string, WfNode] | undefined =>+ (Object.entries(wf) as [string, WfNode][]).find(([, n]) => n.class_type === klass)+const classTypes = (wf: Record<string, any>): string[] =>+ Object.values(wf as Record<string, WfNode>).map(n => n.class_type)++describe('videoDecodeNode', () => {+ it('emits VAEDecodeTiled with ONLY tile_size when the node exists (old cores lack the other fields)', () => {+ const node = videoDecodeNode(['7', 0], ['3', 0], true)+ expect(node.class_type).toBe('VAEDecodeTiled')+ expect(node.inputs).toEqual({ samples: ['7', 0], vae: ['3', 0], tile_size: 256 })+ })+ it('falls back to plain VAEDecode when the install has no tiled node', () => {+ const node = videoDecodeNode(['7', 0], ['3', 0], false)+ expect(node.class_type).toBe('VAEDecode')+ expect(node.inputs).toEqual({ samples: ['7', 0], vae: ['3', 0] })+ })+})++describe('generic wan video builder (the catalog GGUF path customers hit)', () => {+ it('decodes tiled when the install has the node, and the saver reads from it', async () => {+ serveComfy(NODES_WITH_TILED)+ const wf = await buildDynamicWorkflow({ ...videoParams, model: NSFW_WAN14B } as never)+ const tiled = nodeOf(wf, 'VAEDecodeTiled')+ expect(tiled).toBeDefined()+ expect(tiled![1].inputs.tile_size).toBe(256)+ expect(classTypes(wf)).not.toContain('VAEDecode')+ const saver = nodeOf(wf, 'VHS_VideoCombine') ?? nodeOf(wf, 'SaveAnimatedWEBP')+ expect(saver![1].inputs.images[0]).toBe(tiled![0])+ })+ it('keeps plain VAEDecode on a core without the tiled node', async () => {+ serveComfy(BASE_NODES)+ const wf = await buildDynamicWorkflow({ ...videoParams, model: NSFW_WAN14B } as never)+ expect(classTypes(wf)).toContain('VAEDecode')+ expect(classTypes(wf)).not.toContain('VAEDecodeTiled')+ })+})++describe('wan 2.2 builder', () => {+ it('decodes tiled too', async () => {+ serveComfy(NODES_WITH_TILED)+ const wf = await buildDynamicWorkflow({ ...videoParams, model: WAN22_5B_GGUF } as never)+ expect(classTypes(wf)).toContain('VAEDecodeTiled')+ expect(classTypes(wf)).not.toContain('VAEDecode')+ })+})++describe('image decodes are untouched', () => {+ it('the SDXL image graph stays on plain VAEDecode', () => {+ const wf = buildSDXLImgWorkflow({+ model: 'juggernaut_xl.safetensors', prompt: 'a red apple', negativePrompt: '',+ sampler: 'euler', scheduler: 'normal',+ steps: 20, cfgScale: 7, width: 1024, height: 1024, seed: 42, batchSize: 1,+ } as never)+ expect(classTypes(wf)).toContain('VAEDecode')+ expect(classTypes(wf)).not.toContain('VAEDecodeTiled')+ })+})diff --git a/src/api/__tests__/wrapper-node-names.test.ts b/src/api/__tests__/wrapper-node-names.test.tsindex 9d6d897a..480b8930 100644--- a/src/api/__tests__/wrapper-node-names.test.ts+++ b/src/api/__tests__/wrapper-node-names.test.ts@@ -54,7 +54,9 @@ const CORE_NODES = new Set([// lora'LoraLoader', 'LoraLoaderModelOnly',// decode + image ops- 'VAEDecode', 'VAEDecodeAudio', 'VAEEncode', 'VAEEncodeForInpaint', 'ImageScale',+ // VAEDecodeTiled: core nodes.py; answered /object_info/VAEDecodeTiled live+ // on the 2026-08-02 e2e box (full tile/overlap/temporal signature).+ 'VAEDecode', 'VAEDecodeTiled', 'VAEDecodeAudio', 'VAEEncode', 'VAEEncodeForInpaint', 'ImageScale','GetVideoComponents', 'CreateVideo',// output'SaveImage', 'SaveAnimatedWEBP', 'SaveVideo', 'SaveAudioMP3',diff --git a/src/api/comfyui.ts b/src/api/comfyui.tsindex 1e9be2d8..8f4991dd 100644--- a/src/api/comfyui.ts+++ b/src/api/comfyui.ts@@ -1455,6 +1455,8 @@ export async function buildWanVideoWorkflow(params: VideoParams): Promise<Recordconst vae = await findMatchingVAE('wan')const clip = await findMatchingCLIP('wan')+ const { videoDecodeNode } = await import('./dynamic-workflow')+ const hasTiledDecode = await nodeExists('VAEDecodeTiled')const workflow: Record<string, any> = {'1': { class_type: 'CLIPLoader', inputs: { clip_name: clip, type: 'wan', device: 'default' } },@@ -1471,7 +1473,7 @@ export async function buildWanVideoWorkflow(params: VideoParams): Promise<Recordsampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0,},},- '8': { class_type: 'VAEDecode', inputs: { samples: ['7', 0], vae: ['3', 0] } },+ '8': videoDecodeNode(['7', 0], ['3', 0], hasTiledDecode),}// Use SaveAnimatedWEBP if available, otherwise fall back to SaveImage (frame@@ -1503,6 +1505,8 @@ export async function buildAnimateDiffWorkflow(params: VideoParams): Promise<Rec// AnimateDiff: batch_size=1, motion model handles temporal dimensionconst hasVHS = await nodeExists('VHS_VideoCombine')+ const { videoDecodeNode } = await import('./dynamic-workflow')+ const hasTiledDecode = await nodeExists('VAEDecodeTiled')const workflow: Record<string, any> = {'1': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: params.model } },@@ -1520,7 +1524,7 @@ export async function buildAnimateDiffWorkflow(params: VideoParams): Promise<Recsampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0,},},- '9': { class_type: 'VAEDecode', inputs: { samples: ['8', 0], vae: ['1', 2] } },+ '9': videoDecodeNode(['8', 0], ['1', 2], hasTiledDecode),}// Use VHS_VideoCombine if available (produces MP4), otherwise SaveAnimatedWEBP, otherwise SaveImagediff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.tsindex 245ef9e2..ca278b2a 100644--- a/src/api/dynamic-workflow.ts+++ b/src/api/dynamic-workflow.ts@@ -933,13 +933,15 @@ export async function buildDynamicWorkflow(const decodeId = String(n++)- workflow[decodeId] = {- class_type: 'VAEDecode',- inputs: {- samples: [samplerId, 0],- vae: [vaeSourceId, vaeOutputSlot],- },- }+ workflow[decodeId] = isVideo+ ? videoDecodeNode([samplerId, 0], [vaeSourceId, vaeOutputSlot], nodes.decoders.includes('VAEDecodeTiled'))+ : {+ class_type: 'VAEDecode',+ inputs: {+ samples: [samplerId, 0],+ vae: [vaeSourceId, vaeOutputSlot],+ },+ }// ─── Phase 6: Output ───@@ -1055,6 +1057,24 @@ function rmbgWidgetDefault(name: string, spec: any): { set: boolean; value?: anyreturn { set: false }}+/** Decode node for video latents: tiled whenever the install has the node.+ * A full-frame WanVAE decode next to a resident 14B UNet left 312 MB of VRAM+ * on a 12 GB card; CUDA paged through the Windows driver instead of throwing,+ * so ComfyUI's own OOM-then-tiled retry never fired and the decode ran 45++ * minutes at "GPU 100%" (live, David 2026-08-02). Tiles keep the working set+ * flat for a quality-neutral overlap cost. Only tile_size is sent: older+ * cores lack the overlap/temporal fields, newer ones fill their declared+ * defaults for anything omitted. Image decodes stay on plain VAEDecode. */+export function videoDecodeNode(+ samplesRef: [string, number],+ vaeRef: [string, number],+ hasTiled: boolean,+): Record<string, any> {+ return hasTiled+ ? { class_type: 'VAEDecodeTiled', inputs: { samples: samplesRef, vae: vaeRef, tile_size: 256 } }+ : { class_type: 'VAEDecode', inputs: { samples: samplesRef, vae: vaeRef } }+}+function addVideoOutput(workflow: Record<string, any>, n: number, decodeId: string, fps: number, nodes: CategorizedNodes, prompt?: string): number {const saveId = String(n++)const prefix = promptFilenamePrefix(prompt, true)@@ -1123,7 +1143,7 @@ function buildSVDWorkflow(params: VideoParams, seed: number, nodes: CategorizedNclass_type: 'KSampler',inputs: { model: [guidanceId, 0], positive: [condId, 0], negative: [condId, 1], latent_image: [condId, 2], seed, steps: params.steps, cfg: params.cfgScale, sampler_name: params.sampler, scheduler: params.scheduler, denoise: 1.0 },}- workflow[decodeId] = { class_type: 'VAEDecode', inputs: { samples: [samplerId, 0], vae: [loaderId, 2] } }+ workflow[decodeId] = videoDecodeNode([samplerId, 0], [loaderId, 2], nodes.decoders.includes('VAEDecodeTiled'))addVideoOutput(workflow, n, decodeId, params.fps, nodes, params.prompt)return workflow@@ -1217,7 +1237,7 @@ function buildWan22Workflow(params: VideoParams, seed: number, nodes: Categorize},}const decodeId = String(n++)- workflow[decodeId] = { class_type: 'VAEDecode', inputs: { samples: [samplerId, 0], vae: [vaeId, 0] } }+ workflow[decodeId] = videoDecodeNode([samplerId, 0], [vaeId, 0], nodes.decoders.includes('VAEDecodeTiled'))addVideoOutput(workflow, n, decodeId, params.fps, nodes, params.prompt)return workflow@@ -1458,7 +1478,7 @@ export function buildS2VWorkflow(params: LocalOpParams, seed: number, allNodes:},}const decodeId = String(n++)- workflow[decodeId] = { class_type: 'VAEDecode', inputs: { samples: [samplerId, 0], vae: [vaeId, 0] } }+ workflow[decodeId] = videoDecodeNode([samplerId, 0], [vaeId, 0], 'VAEDecodeTiled' in allNodes)addVideoWithAudioOutput(workflow, n, decodeId, params.fps || 16, [audioLoadId, 0], allNodes, params.prompt)return workflow@@ -1561,7 +1581,7 @@ export function buildMotionWorkflow(params: LocalOpParams, seed: number, allNodeconst trimId = String(n++)workflow[trimId] = { class_type: 'TrimVideoLatent', inputs: { samples: [samplerId, 0], trim_amount: [condId, 3] } }const decodeId = String(n++)- workflow[decodeId] = { class_type: 'VAEDecode', inputs: { samples: [trimId, 0], vae: [vaeId, 0] } }+ workflow[decodeId] = videoDecodeNode([trimId, 0], [vaeId, 0], 'VAEDecodeTiled' in allNodes)addVideoWithAudioOutput(workflow, n, decodeId, params.fps || 16, [componentsId, 1], allNodes, params.prompt)return workflow@@ -1644,7 +1664,7 @@ function buildFramePackWorkflow(params: VideoParams, seed: number, nodes: Categouse_teacache: true, teacache_rel_l1_thresh: 0.15,},}- workflow[decodeId] = { class_type: 'VAEDecode', inputs: { samples: [samplerId, 0], vae: [vaeId, 0] } }+ workflow[decodeId] = videoDecodeNode([samplerId, 0], [vaeId, 0], nodes.decoders.includes('VAEDecodeTiled'))addVideoOutput(workflow, n, decodeId, params.fps, nodes, params.prompt)return workflow