Skip to content

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.

fix(workflows): an own UNETLoader workflow is kept for an LTX 2.5 model (GitHub #196)

purple9b744a5a5dd9
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index 848a4fe8..c66cc9ab 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -122,6 +122,7 @@ import { defaultLoraStrength } from '../lib/lora-strength'
import { fetchGalleryItemBlob } from '../components/create/experimental/galleryUrl'
import { LongRunStopped, longVideoRequest, runLongVideo, type ClipItem } from '../lib/long-video-run'
import { settleSeams } from '../api/video-settle'
+import { ownWorkflowMisfit } from '../lib/own-workflow-fit'
import { loadImageRef } from '../components/create/experimental/loadImage'
import { listMlxLoras } from '../api/mlx-loras'
import {
@@ -1897,15 +1898,9 @@ export function useCreate() {
// Check for custom workflow assignment — but verify it's compatible with the model
let customWf = localOp || isUpscale ? null : useWorkflowStore.getState().getWorkflowForModel(activeModel, imageModelType)
if (customWf) {
- const wfNodes = apiNodes(customWf.workflow).map(([, n]) => n.class_type)
- const needsUnet = imageModelType === 'flux' || imageModelType === 'flux2' || imageModelType === 'zimage' || imageModelType === 'wan' || imageModelType === 'hunyuan'
- const hasUnet = wfNodes.includes('UNETLoader')
- const hasCheckpoint = wfNodes.includes('CheckpointLoaderSimple')
- if (needsUnet && !hasUnet && hasCheckpoint) {
- console.warn('[useCreate] Custom workflow incompatible: model needs UNETLoader but workflow has CheckpointLoaderSimple. Using auto.')
- customWf = null
- } else if (!needsUnet && hasUnet && !hasCheckpoint) {
- console.warn('[useCreate] Custom workflow incompatible: model needs CheckpointLoaderSimple but workflow has UNETLoader. Using auto.')
+ const misfit = ownWorkflowMisfit(apiNodes(customWf.workflow).map(([, n]) => n.class_type), imageModelType, listedModel?.source)
+ if (misfit) {
+ console.warn(`[useCreate] Custom workflow incompatible: ${misfit}. Using auto.`)
customWf = null
}
}
diff --git a/src/lib/__tests__/own-ltx25-workflow-is-not-dropped.test.ts b/src/lib/__tests__/own-ltx25-workflow-is-not-dropped.test.ts
new file mode 100644
index 00000000..15f6f671
--- /dev/null
+++ b/src/lib/__tests__/own-ltx25-workflow-is-not-dropped.test.ts
@@ -0,0 +1,43 @@
+/**
+ * GitHub #196 (P5, 3.0.9): with an LTX 2.5 model picked, LU set the user's own
+ * workflow aside before it ever reached injectParameters, because LTX 2.5 was
+ * not on a fixed list of UNETLoader families. The Comfy-Org template loads its
+ * transformer with UNETLoader, so LU rendered its own graph instead, silently.
+ *
+ * Run: npx vitest run src/lib/__tests__/own-ltx25-workflow-is-not-dropped.test.ts
+ */
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { modelNeedsUnetLoader, ownWorkflowMisfit } from '../own-workflow-fit'
+
+const template = JSON.parse(readFileSync(join(__dirname, '../../api/__tests__/fixtures/comfy-ui/templates/video_ltx2_5_i2v.json'), 'utf8')) as { nodes?: { type: string }[]; definitions?: { subgraphs?: { nodes?: { type: string }[] }[] } }
+const templateTypes = [
+ ...(template.nodes ?? []).map((n) => n.type),
+ ...(template.definitions?.subgraphs ?? []).flatMap((g) => (g.nodes ?? []).map((n) => n.type)),
+]
+
+describe('an own workflow with a UNETLoader and an LTX 2.5 model', () => {
+ it('the Comfy-Org template loads its model with UNETLoader', () => {
+ expect(templateTypes).toContain('UNETLoader')
+ expect(templateTypes).not.toContain('CheckpointLoaderSimple')
+ })
+
+ it('fits an LTX 2.5 model from the list (diffusion_models)', () => {
+ expect(ownWorkflowMisfit(templateTypes, 'ltx25', 'diffusion_model')).toBeNull()
+ })
+
+ it('fits an LTX 2.5 model no list holds', () => {
+ expect(ownWorkflowMisfit(templateTypes, 'ltx25')).toBeNull()
+ })
+
+ it('the folder decides over the family', () => {
+ expect(modelNeedsUnetLoader('sdxl', 'diffusion_model')).toBe(true)
+ expect(modelNeedsUnetLoader('flux', 'checkpoint')).toBe(false)
+ })
+
+ it('a wrong loader is still set aside', () => {
+ expect(ownWorkflowMisfit(['CheckpointLoaderSimple', 'KSampler'], 'ltx25', 'diffusion_model')).toMatch(/needs UNETLoader/)
+ expect(ownWorkflowMisfit(['UNETLoader', 'KSampler'], 'sdxl', 'checkpoint')).toMatch(/needs CheckpointLoaderSimple/)
+ })
+})
diff --git a/src/lib/own-workflow-fit.ts b/src/lib/own-workflow-fit.ts
new file mode 100644
index 00000000..7ad575cb
--- /dev/null
+++ b/src/lib/own-workflow-fit.ts
@@ -0,0 +1,31 @@
+// Whether a workflow of the user's own fits the model it is assigned to, by
+// the loader it brings: a file from diffusion_models needs a UNETLoader, a
+// checkpoint a CheckpointLoaderSimple. A workflow with the wrong loader is
+// set aside and LU's own builder runs instead.
+//
+// GitHub #196 (P5, 3.0.9): this used to be a fixed list of families (Flux,
+// Flux 2, Z-Image, Wan, Hunyuan). An LTX 2.5 model was not on it, so the
+// Comfy-Org LTX 2.5 template, which loads its transformer with UNETLoader,
+// was dropped without a word and LU rendered its own graph. The folder the
+// model list found the file in decides now; the list is only the fallback
+// for a model no list holds.
+
+import type { ComfyModelSource } from '../types/models'
+
+const UNET_FAMILIES = new Set(['flux', 'flux2', 'zimage', 'wan', 'wan22', 'hunyuan', 'ltx25'])
+
+export function modelNeedsUnetLoader(type: string, source?: ComfyModelSource): boolean {
+ if (source === 'diffusion_model') return true
+ if (source === 'checkpoint') return false
+ return UNET_FAMILIES.has(type)
+}
+
+/** Null when the workflow fits, else why it is set aside. */
+export function ownWorkflowMisfit(classTypes: readonly string[], type: string, source?: ComfyModelSource): string | null {
+ const needsUnet = modelNeedsUnetLoader(type, source)
+ const hasUnet = classTypes.includes('UNETLoader')
+ const hasCheckpoint = classTypes.includes('CheckpointLoaderSimple')
+ if (needsUnet && !hasUnet && hasCheckpoint) return 'model needs UNETLoader but workflow has CheckpointLoaderSimple'
+ if (!needsUnet && hasUnet && !hasCheckpoint) return 'model needs CheckpointLoaderSimple but workflow has UNETLoader'
+ return null
+}