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
fix(generation): record and recall SD 3 text encoders (#10228)
rnshinebceb4e3e629e
diff --git a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.ts b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.tsindex 5b6404a7b7..0383274379 100644--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.ts@@ -393,6 +393,45 @@ describe('compileCanvasGraph', () => {});+ it('records the SD 3 encoder overrides used for a Canvas image', () => {+ const clipL: ComponentModelConfig = {+ base: 'any',+ key: 'clip-l',+ name: 'CLIP L',+ type: 'clip_embed',+ variant: 'large',+ };+ const clipG = { ...clipL, key: 'clip-g', name: 'CLIP G', variant: 'gigantic' };+ const t5Encoder: ComponentModelConfig = { base: 'any', key: 't5', name: 'T5 Encoder', type: 't5_encoder' };+ const { backendGraph } = compile(sd3Model, 'img2img', {+ settings: { clipGEmbedModel: clipG, clipLEmbedModel: clipL, t5EncoderModel: t5Encoder },+ });++ expect(backendGraph.nodes.model_loader).toMatchObject({+ clip_g_model: clipG,+ clip_l_model: clipL,+ t5_encoder_model: t5Encoder,+ });+ const metadata = getNodeByType(backendGraph, 'core_metadata');+ expect(metadata).toMatchObject({+ clip_g_model: clipG,+ clip_l_model: clipL,+ generation_mode: 'sd3_img2img',+ t5_encoder: t5Encoder,+ });+ expect(getEdge(backendGraph, 'canvas_output', 'metadata')?.source.node_id).toBe(metadata?.id);+ });++ it('leaves bundled SD 3 encoders unrecorded when no override was selected', () => {+ const { backendGraph } = compile(sd3Model, 'img2img');+ const metadata = getNodeByType(backendGraph, 'core_metadata');++ expect(metadata).toBeDefined();+ expect(metadata?.clip_g_model).toBeUndefined();+ expect(metadata?.clip_l_model).toBeUndefined();+ expect(metadata?.t5_encoder).toBeUndefined();+ });+it('feeds the encode node from the same VAE source as the decode node', () => {const { backendGraph } = compile(sd1Model, 'img2img');const encode = getNodeByType(backendGraph, 'i2l');diff --git a/invokeai/frontend/webv2/src/features/generation/core/graph.ts b/invokeai/frontend/webv2/src/features/generation/core/graph.tsindex e7d1dcaf76..805caf0879 100644--- a/invokeai/frontend/webv2/src/features/generation/core/graph.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/graph.ts@@ -655,7 +655,10 @@ const buildSD3Graph = (addEdge(graph, negCond, 'conditioning', denoise, 'negative_conditioning');addEdge(graph, seed, 'value', denoise, 'seed');addMetadata(graph, output, settings, model, 'sd3_txt2img', projectSettings, {+ clip_g_model: modelLoader.clip_g_model,+ clip_l_model: modelLoader.clip_l_model,scheduler: undefined,+ t5_encoder: modelLoader.t5_encoder_model,vae: vaeModel ?? undefined,...(shouldUsePidDecode(settings, model.base) ? getPidMetadata(settings) : {}),});diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.tsindex c8c4df4c88..bf8ebec639 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts@@ -2433,6 +2433,61 @@ describe('FLUX.3 prompt upsampler recall', () => {});});+describe('SD 3 encoder recall', () => {+ const model: MainModelConfig = { base: 'sd-3', key: 'sd3-model', name: 'SD 3', type: 'main' };+ const t5: ComponentModelConfig = { base: 'any', key: 'sd3-t5', name: 'T5', type: 't5_encoder' };+ const clipL: ComponentModelConfig = {+ base: 'any',+ key: 'sd3-clip-l',+ name: 'CLIP L',+ type: 'clip_embed',+ variant: 'large',+ };+ const clipG: ComponentModelConfig = { ...clipL, key: 'sd3-clip-g', name: 'CLIP G', variant: 'gigantic' };+ const currentComponents = {+ clipGEmbedModel: { ...clipG, key: 'current-clip-g' },+ clipLEmbedModel: { ...clipL, key: 'current-clip-l' },+ t5EncoderModel: { ...t5, key: 'current-t5' },+ };+ const recall = (metadata: Record<string, unknown>, kind: ImageRecallKind = 'all') =>+ buildImageRecallSettings({+ currentValues: createValues({ model, modelKey: model.key, ...currentComponents }),+ image,+ kind,+ metadata: { model: { key: model.key }, ...metadata },+ models: [model, t5, clipL, clipG, ...Object.values(currentComponents)],+ supportedModels: [model],+ vaeModels: [],+ });++ it.each(['all', 'remix'] as const)('restores the recorded overrides with %s on the same main model', (kind) => {+ const result = recall(+ { clip_g_model: { key: clipG.key }, clip_l_model: { key: clipL.key }, t5_encoder: { key: t5.key } },+ kind+ );++ expect(result?.values).toMatchObject({+ clipGEmbedModel: clipG,+ clipLEmbedModel: clipL,+ model,+ t5EncoderModel: t5,+ });+ expect(result?.fields).toContain('components');+ });++ it.each([+ ['missing metadata', {}],+ ['unavailable encoders', { clip_g_model: { key: 'missing-g' }, clip_l_model: { key: 'missing-l' } }],+ ['a non-CLIP model', { clip_g_model: { key: t5.key }, clip_l_model: { key: t5.key } }],+ ['swapped CLIP variants', { clip_g_model: { key: clipL.key }, clip_l_model: { key: clipG.key } }],+ ] as const)('keeps the current compatible overrides with %s', (_label, metadata) => {+ const result = recall(metadata);++ expect(result?.values).toMatchObject(currentComponents);+ expect(result?.fields).not.toContain('components');+ });+});+describe('SDXL Refiner recall', () => {const refiner: MainModelConfig = {base: 'sdxl-refiner',diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.tsindex b10847dbbd..d8fccac723 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts@@ -906,6 +906,8 @@ type RecalledComponentSetting = keyof Pick<GenerateWidgetValues,| 'animaInpaintAdapterModel'| 'clipEmbedModel'+ | 'clipGEmbedModel'+ | 'clipLEmbedModel'| 'componentSourceModel'| 'flux3PromptUpsamplerModel'| 'gemma2EncoderModel'@@ -941,6 +943,8 @@ const RECALLED_COMPONENTS: readonly RecalledComponent[] = [{ isMainModel: true, metadataKey: 'wan_transformer_low_noise', setting: 'wanLowNoiseModel' },{ metadataKey: 'anima_inpaint_adapter', setting: 'animaInpaintAdapterModel' },{ metadataKey: 'clip_embed_model', setting: 'clipEmbedModel' },+ { metadataKey: 'clip_g_model', setting: 'clipGEmbedModel' },+ { metadataKey: 'clip_l_model', setting: 'clipLEmbedModel' },{ metadataKey: 'flux3_prompt_upsampler', setting: 'flux3PromptUpsamplerModel' },{ metadataKey: 'gemma2_encoder', setting: 'gemma2EncoderModel' },{ metadataKey: 'mistral_encoder', setting: 'mistralEncoderModel' },diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.tsindex 4be444d2ee..4faa9c4661 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.ts@@ -151,6 +151,8 @@ const IMAGE_RECALL_CONTRACT = {vae: { restores: ['vae'] },qwen_image_vae: { consumed: "Qwen-Image's VAE alias, read only from records without `vae`; the graph writes both." },clip_embed_model: { restores: ['clipEmbedModel'] },+ clip_g_model: { restores: ['clipGEmbedModel'] },+ clip_l_model: { restores: ['clipLEmbedModel'] },t5_encoder: { restores: ['t5EncoderModel'] },mistral_encoder: { restores: ['mistralEncoderModel'] },qwen3_encoder: { restores: ['qwen3EncoderModel'] },