Skip to content

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.

feat: add support for 'ernie-image' model in generation framework

Alexander Eichhorn47ffa9d30c79
diff --git a/invokeai/frontend/webv2/src/features/generation/core/__snapshots__/generateGraphNodeTypes.json b/invokeai/frontend/webv2/src/features/generation/core/__snapshots__/generateGraphNodeTypes.json
new file mode 100644
index 0000000000..3c1c73027c
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/generation/core/__snapshots__/generateGraphNodeTypes.json
@@ -0,0 +1,791 @@
+{
+ "_comment": "Generated by src/features/generation/core/graphCoverage.test.ts. Update with `vitest -u`. Consumed by tests/app/invocations/test_frontend_graph_node_types.py, which checks every node type and field below against the backend invocation registry.",
+ "byBase": {
+ "sd-1": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": []
+ },
+ "nodeTypes": [
+ "clip_skip",
+ "collect",
+ "compel",
+ "core_metadata",
+ "denoise_latents",
+ "integer",
+ "l2i",
+ "main_model_loader",
+ "noise",
+ "string"
+ ]
+ },
+ "sd-2": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": []
+ },
+ "nodeTypes": [
+ "clip_skip",
+ "collect",
+ "compel",
+ "core_metadata",
+ "denoise_latents",
+ "integer",
+ "l2i",
+ "main_model_loader",
+ "noise",
+ "string"
+ ]
+ },
+ "sdxl": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": []
+ },
+ "nodeTypes": [
+ "collect",
+ "core_metadata",
+ "denoise_latents",
+ "integer",
+ "l2i",
+ "noise",
+ "sdxl_compel_prompt",
+ "sdxl_model_loader",
+ "string"
+ ]
+ },
+ "sd-3": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": []
+ },
+ "nodeTypes": [
+ "core_metadata",
+ "integer",
+ "sd3_denoise",
+ "sd3_l2i",
+ "sd3_model_loader",
+ "sd3_text_encoder",
+ "string"
+ ]
+ },
+ "flux": {
+ "componentsFilled": {
+ "diffusers": [
+ "clipEmbedModel",
+ "t5EncoderModel",
+ "vae"
+ ],
+ "standalone-components": [
+ "clipEmbedModel",
+ "t5EncoderModel",
+ "vae"
+ ]
+ },
+ "nodeTypes": [
+ "collect",
+ "core_metadata",
+ "flux_denoise",
+ "flux_model_loader",
+ "flux_text_encoder",
+ "flux_vae_decode",
+ "integer",
+ "string"
+ ]
+ },
+ "flux2": {
+ "componentsFilled": {
+ "dev-diffusers": [],
+ "dev-standalone": [
+ "mistralEncoderModel",
+ "vae"
+ ],
+ "klein-9b-standalone": [
+ "qwen3EncoderModel",
+ "vae"
+ ]
+ },
+ "nodeTypes": [
+ "collect",
+ "core_metadata",
+ "flux2_denoise",
+ "flux2_dev_model_loader",
+ "flux2_dev_text_encoder",
+ "flux2_klein_model_loader",
+ "flux2_klein_text_encoder",
+ "flux2_vae_decode",
+ "integer",
+ "string"
+ ]
+ },
+ "cogview4": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": []
+ },
+ "nodeTypes": [
+ "cogview4_denoise",
+ "cogview4_l2i",
+ "cogview4_model_loader",
+ "cogview4_text_encoder",
+ "core_metadata",
+ "integer",
+ "string"
+ ]
+ },
+ "ernie-image": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": []
+ },
+ "nodeTypes": [
+ "core_metadata",
+ "ernie_image_denoise",
+ "ernie_image_model_loader",
+ "ernie_image_text_encoder",
+ "ernie_image_vae_decode",
+ "integer",
+ "string"
+ ]
+ },
+ "qwen-image": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": [
+ "qwenVLEncoderModel",
+ "vae"
+ ]
+ },
+ "nodeTypes": [
+ "core_metadata",
+ "integer",
+ "qwen_image_denoise",
+ "qwen_image_l2i",
+ "qwen_image_model_loader",
+ "qwen_image_text_encoder",
+ "string"
+ ]
+ },
+ "z-image": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": [
+ "qwen3EncoderModel",
+ "vae"
+ ]
+ },
+ "nodeTypes": [
+ "collect",
+ "core_metadata",
+ "integer",
+ "string",
+ "z_image_denoise",
+ "z_image_l2i",
+ "z_image_model_loader",
+ "z_image_text_encoder"
+ ]
+ },
+ "ideogram-4": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": []
+ },
+ "nodeTypes": [
+ "core_metadata",
+ "ideogram4_caption_builder",
+ "ideogram4_denoise",
+ "ideogram4_l2i",
+ "ideogram4_model_loader",
+ "ideogram4_text_encoder",
+ "integer",
+ "string"
+ ]
+ },
+ "krea-2": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": [
+ "qwen3VLEncoderModel",
+ "vae"
+ ]
+ },
+ "nodeTypes": [
+ "collect",
+ "core_metadata",
+ "integer",
+ "krea2_denoise",
+ "krea2_model_loader",
+ "krea2_text_encoder",
+ "qwen_image_l2i",
+ "string"
+ ]
+ },
+ "wan": {
+ "componentsFilled": {
+ "diffusers": [],
+ "standalone-components": [
+ "vae",
+ "wanT5EncoderModel"
+ ]
+ },
+ "nodeTypes": [
+ "core_metadata",
+ "integer",
+ "string",
+ "wan_denoise",
+ "wan_l2i",
+ "wan_model_loader",
+ "wan_text_encoder"
+ ]
+ },
+ "anima": {
+ "componentsFilled": {
+ "diffusers": [
+ "qwen3EncoderModel",
+ "vae"
+ ],
+ "standalone-components": [
+ "qwen3EncoderModel",
+ "vae"
+ ]
+ },
+ "nodeTypes": [
+ "anima_denoise",
+ "anima_l2i",
+ "anima_model_loader",
+ "anima_text_encoder",
+ "collect",
+ "core_metadata",
+ "integer",
+ "string"
+ ]
+ }
+ },
+ "fieldsByNodeType": {
+ "anima_denoise": {
+ "inputs": [
+ "negative_conditioning",
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "anima_l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "anima_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "qwen3_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "anima_text_encoder": {
+ "inputs": [
+ "prompt",
+ "qwen3_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "clip_skip": {
+ "inputs": [
+ "clip"
+ ],
+ "outputs": [
+ "clip"
+ ]
+ },
+ "cogview4_denoise": {
+ "inputs": [
+ "negative_conditioning",
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "cogview4_l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "cogview4_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "glm_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "cogview4_text_encoder": {
+ "inputs": [
+ "glm_encoder",
+ "prompt"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "collect": {
+ "inputs": [
+ "item"
+ ],
+ "outputs": [
+ "collection"
+ ]
+ },
+ "compel": {
+ "inputs": [
+ "clip",
+ "prompt"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "core_metadata": {
+ "inputs": [
+ "negative_prompt",
+ "positive_prompt",
+ "seed"
+ ],
+ "outputs": [
+ "metadata"
+ ]
+ },
+ "denoise_latents": {
+ "inputs": [
+ "negative_conditioning",
+ "noise",
+ "positive_conditioning",
+ "unet"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "ernie_image_denoise": {
+ "inputs": [
+ "negative_conditioning",
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "ernie_image_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "text_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "ernie_image_text_encoder": {
+ "inputs": [
+ "prompt",
+ "text_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "ernie_image_vae_decode": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "flux_denoise": {
+ "inputs": [
+ "controlnet_vae",
+ "positive_text_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "flux_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "clip",
+ "max_seq_len",
+ "t5_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "flux_text_encoder": {
+ "inputs": [
+ "clip",
+ "prompt",
+ "t5_encoder",
+ "t5_max_seq_len"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "flux_vae_decode": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "flux2_denoise": {
+ "inputs": [
+ "positive_text_conditioning",
+ "seed",
+ "transformer",
+ "vae"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "flux2_dev_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "max_seq_len",
+ "mistral_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "flux2_dev_text_encoder": {
+ "inputs": [
+ "max_seq_len",
+ "mistral_encoder",
+ "prompt"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "flux2_klein_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "max_seq_len",
+ "qwen3_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "flux2_klein_text_encoder": {
+ "inputs": [
+ "max_seq_len",
+ "prompt",
+ "qwen3_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "flux2_vae_decode": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "ideogram4_caption_builder": {
+ "inputs": [
+ "prompt"
+ ],
+ "outputs": [
+ "value"
+ ]
+ },
+ "ideogram4_denoise": {
+ "inputs": [
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "ideogram4_l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "ideogram4_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "qwen3_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "ideogram4_text_encoder": {
+ "inputs": [
+ "prompt",
+ "qwen3_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "integer": {
+ "inputs": [],
+ "outputs": [
+ "value"
+ ]
+ },
+ "krea2_denoise": {
+ "inputs": [
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "krea2_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "qwen3_vl_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "krea2_text_encoder": {
+ "inputs": [
+ "prompt",
+ "qwen3_vl_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "main_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "clip",
+ "unet",
+ "vae"
+ ]
+ },
+ "noise": {
+ "inputs": [
+ "seed"
+ ],
+ "outputs": [
+ "noise"
+ ]
+ },
+ "qwen_image_denoise": {
+ "inputs": [
+ "negative_conditioning",
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "qwen_image_l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "qwen_image_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "qwen_vl_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "qwen_image_text_encoder": {
+ "inputs": [
+ "prompt",
+ "qwen_vl_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "sd3_denoise": {
+ "inputs": [
+ "negative_conditioning",
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "sd3_l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "sd3_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "clip_g",
+ "clip_l",
+ "t5_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "sd3_text_encoder": {
+ "inputs": [
+ "clip_g",
+ "clip_l",
+ "prompt",
+ "t5_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "sdxl_compel_prompt": {
+ "inputs": [
+ "clip",
+ "clip2",
+ "prompt",
+ "style"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "sdxl_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "clip",
+ "clip2",
+ "unet",
+ "vae"
+ ]
+ },
+ "string": {
+ "inputs": [],
+ "outputs": [
+ "value"
+ ]
+ },
+ "wan_denoise": {
+ "inputs": [
+ "negative_conditioning",
+ "positive_conditioning",
+ "seed",
+ "transformer"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "wan_l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "wan_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "transformer",
+ "vae",
+ "wan_t5_encoder"
+ ]
+ },
+ "wan_text_encoder": {
+ "inputs": [
+ "prompt",
+ "wan_t5_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ },
+ "z_image_denoise": {
+ "inputs": [
+ "positive_conditioning",
+ "seed",
+ "transformer",
+ "vae"
+ ],
+ "outputs": [
+ "latents"
+ ]
+ },
+ "z_image_l2i": {
+ "inputs": [
+ "latents",
+ "metadata",
+ "vae"
+ ],
+ "outputs": []
+ },
+ "z_image_model_loader": {
+ "inputs": [],
+ "outputs": [
+ "qwen3_encoder",
+ "transformer",
+ "vae"
+ ]
+ },
+ "z_image_text_encoder": {
+ "inputs": [
+ "prompt",
+ "qwen3_encoder"
+ ],
+ "outputs": [
+ "conditioning"
+ ]
+ }
+ }
+}
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts
index 73bc15c681..bfafee5810 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts
@@ -242,6 +242,7 @@ describe('BASE_GENERATION', () => {
'flux',
'flux2',
'cogview4',
+ 'ernie-image',
'qwen-image',
'z-image',
'ideogram-4',
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
index f7155cd1c4..f15fddb332 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
@@ -258,6 +258,21 @@ export const BASE_GENERATION = {
negativePrompt: { visible: true, usage: 'always' },
ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
+ 'ernie-image': {
+ // ernie_image_denoise carries multiple_of=16 on width/height.
+ dimensions: { grid: 16, optimalSide: 1024 },
+ // The base model's numbers. ERNIE-Image-Turbo wants 8 steps at guidance 1.0, which arrives
+ // through the model's own default_settings rather than a second entry here: Turbo and the
+ // base model share an architecture and a config, so no variant discriminates them.
+ defaults: { steps: 50, cfgScale: 4, scheduler: 'euler' },
+ // ERNIE_IMAGE_SCHEDULER_MAP is euler/heun/lcm, and the denoise node takes the choice.
+ schedulerSet: 'flow',
+ schedulerAppliesToGraph: true,
+ guidanceLabel: 'CFG',
+ // negative_conditioning is 'required when guidance_scale != 1.0'.
+ negativePrompt: { visible: true, usage: 'cfg-gated' },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ },
'qwen-image': {
dimensions: { grid: 16, optimalSide: 1024 },
defaults: { steps: 40, cfgScale: 4, scheduler: 'euler_a' },
diff --git a/invokeai/frontend/webv2/src/features/generation/core/contracts.ts b/invokeai/frontend/webv2/src/features/generation/core/contracts.ts
index 7eb00f4861..a35dd0a01a 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/contracts.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/contracts.ts
@@ -61,6 +61,7 @@ export type KnownGenerationModelBase =
| 'flux'
| 'flux2'
| 'cogview4'
+ | 'ernie-image'
| 'qwen-image'
| 'z-image'
| 'ideogram-4'
diff --git a/invokeai/frontend/webv2/src/features/generation/core/graph.ts b/invokeai/frontend/webv2/src/features/generation/core/graph.ts
index 35e9980e8c..83cafce0d6 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/graph.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/graph.ts
@@ -837,6 +837,61 @@ const buildCogView4Graph = (
return graph;
};
+const buildErnieImageGraph = (
+ settings: GenerateSettings,
+ model: MainModelConfig,
+ outputIsIntermediate: boolean,
+ projectSettings: GenerationProjectSettings
+): BackendGraphContract => {
+ // No component slots: ernie_image_model_loader reads the transformer, VAE, text encoder and
+ // optional prompt enhancer out of one diffusers pipeline directory, so there is nothing for the
+ // user to supply separately and nothing to validate here.
+ const graph: BackendGraphContract = { edges: [], id: createId('ernie_image_graph'), nodes: {} };
+ const { negativePrompt, positivePrompt, seed } = addPromptAndSeedNodes(graph);
+ const scheduler = coerceSchedulerForGraph(model, settings.scheduler);
+ const useCfg = settings.cfgScale > 1;
+ const modelLoader = addNode(graph, {
+ id: 'model_loader',
+ model,
+ type: 'ernie_image_model_loader',
+ // The enhancer is a separate node with its own prompt rewriting and cannot be idle-offloaded;
+ // Generate does not surface it, so the loader is told not to hold it resident.
+ use_prompt_enhancer: false,
+ });
+ const posCond = addNode(graph, { id: 'pos_cond', type: 'ernie_image_text_encoder' });
+ const negCond = useCfg ? addNode(graph, { id: 'neg_cond', type: 'ernie_image_text_encoder' }) : null;
+ const denoise = addNode(graph, {
+ denoising_end: 1,
+ denoising_start: 0,
+ guidance_scale: settings.cfgScale,
+ height: settings.height,
+ id: 'denoise_latents',
+ scheduler,
+ steps: settings.steps,
+ type: 'ernie_image_denoise',
+ width: settings.width,
+ });
+ const output = addImageOutputNode(graph, 'ernie_image_vae_decode', outputIsIntermediate);
+
+ addEdge(graph, modelLoader, 'transformer', denoise, 'transformer');
+ addEdge(graph, modelLoader, 'text_encoder', posCond, 'text_encoder');
+ addEdge(graph, modelLoader, 'vae', output, 'vae');
+ addEdge(graph, positivePrompt, 'value', posCond, 'prompt');
+ addEdge(graph, posCond, 'conditioning', denoise, 'positive_conditioning');
+
+ if (negCond) {
+ addEdge(graph, modelLoader, 'text_encoder', negCond, 'text_encoder');
+ addEdge(graph, negativePrompt, 'value', negCond, 'prompt');
+ addEdge(graph, negCond, 'conditioning', denoise, 'negative_conditioning');
+ }
+
+ addEdge(graph, seed, 'value', denoise, 'seed');
+ addEdge(graph, denoise, 'latents', output, 'latents');
+ addMetadata(graph, output, settings, model, 'ernie_image_txt2img', projectSettings);
+
+ return graph;
+};
+
const buildQwenImageGraph = (
settings: GenerateSettings,
model: MainModelConfig,
@@ -1408,6 +1463,7 @@ export const GRAPH_BUILDERS = {
flux: buildFluxGraph,
flux2: buildFlux2Graph,
cogview4: buildCogView4Graph,
+ 'ernie-image': buildErnieImageGraph,
'qwen-image': buildQwenImageGraph,
'z-image': buildZImageGraph,
'ideogram-4': buildIdeogram4Graph,
diff --git a/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts b/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
new file mode 100644
index 0000000000..a7ad5376d7
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
@@ -0,0 +1,275 @@
+/**
+ * Every supported base compiles a graph — the systematic counterpart to `graph.test.ts`.
+ *
+ * `graph.test.ts` asserts *what* individual families wire up, one hand-written case at a time. That
+ * leaves a base added to `BASE_GENERATION` and `GRAPH_BUILDERS` but never given a case silently
+ * untested. This file instead iterates `SUPPORTED_GENERATE_BASES`, so a new architecture is covered
+ * the moment it is registered, and asserts the properties that hold for *all* of them: the
+ * component policy is satisfiable, the builder runs, and the resulting graph is structurally sound.
+ *
+ * It also writes the node types each base emits to a file snapshot. That file is the frontend half
+ * of a cross-stack contract — `tests/app/invocations/test_frontend_graph_node_types.py` reads it and
+ * checks every type against the backend's `InvocationRegistry`. A node moved between modules and
+ * accidentally renamed shows up there, which no frontend-only assertion can see.
+ */
+
+import type { BackendGraphContract } from '@features/generation/core/contracts';
+
+import { describe, expect, it } from 'vitest';
+
+import type {
+ ComponentPolicyContext,
+ ComponentSlotPolicy,
+ GenerateComponentValueKey,
+ SupportedGenerateBase,
+} from './baseGenerationPolicies';
+import type { GenerateSettings, MainModelConfig, ModelIdentifierConfig } from './types';
+
+import {
+ getComponentSectionPolicy,
+ getDefaultGenerateSettings,
+ getGenerationValidationReasons,
+ SUPPORTED_GENERATE_BASES,
+} from './baseGenerationPolicies';
+import { compileGenerateGraph, GRAPH_BUILDERS } from './graph';
+
+/**
+ * Main-model shapes to compile per base.
+ *
+ * `diffusers` bundles its submodels, so the component slots go optional and the builder takes the
+ * bundled path; a quantized single-file main carries only the transformer and forces the standalone
+ * -component path. Both paths produce different graphs, so both are worth compiling.
+ */
+interface ModelShape {
+ label: string;
+ overrides: Partial<MainModelConfig>;
+}
+
+const DEFAULT_SHAPES: readonly ModelShape[] = [
+ { label: 'diffusers', overrides: { format: 'diffusers' } },
+ { label: 'standalone-components', overrides: { format: 'gguf_quantized' } },
+];
+
+/**
+ * Bases whose builder needs more than a format to pick a path. Keys are checked against
+ * `SUPPORTED_GENERATE_BASES` below, so a renamed or removed base cannot leave a stale entry here.
+ */
+const SHAPE_OVERRIDES: Partial<Record<SupportedGenerateBase, readonly ModelShape[]>> = {
+ // The two FLUX.2 lines take different encoders: [dev] wants Mistral, Klein wants a Qwen3 whose
+ // variant is pinned to the Klein size by KLEIN_TO_QWEN3_VARIANT.
+ flux2: [
+ { label: 'dev-diffusers', overrides: { format: 'diffusers', variant: 'dev' } },
+ { label: 'dev-standalone', overrides: { format: 'gguf_quantized', variant: 'dev' } },
+ { label: 'klein-9b-standalone', overrides: { format: 'gguf_quantized', variant: 'klein_9b' } },
+ ],
+};
+
+const shapesForBase = (base: SupportedGenerateBase): readonly ModelShape[] => SHAPE_OVERRIDES[base] ?? DEFAULT_SHAPES;
+
+/**
+ * Candidate components the slot filters get to choose from.
+ *
+ * Deliberately a search over a pool rather than a hand-written model per slot: the filters
+ * (`isAnimaQwen3Encoder`, `isKrea2Vae`, `isFlux2Qwen3EncoderForModel`, ...) encode which base and
+ * variant a component must carry, and duplicating that knowledge here would make the test agree
+ * with itself instead of with the policy.
+ */
+const CANDIDATE_BASES = ['any', ...SUPPORTED_GENERATE_BASES] as const;
+const CANDIDATE_VARIANTS = [
+ undefined,
+ 'qwen3_06b',
+ 'qwen3_4b',
+ 'qwen3_8b',
+ 'large',
+ 'gigantic',
+ 'dev',
+ 'klein_4b',
+ 'klein_9b',
+] as const;
+
+const candidatesForSlot = (slot: ComponentSlotPolicy): ModelIdentifierConfig[] => {
+ const candidates: ModelIdentifierConfig[] = [];
+
+ for (const type of slot.modelTypes) {
+ for (const base of CANDIDATE_BASES) {
+ for (const variant of CANDIDATE_VARIANTS) {
+ candidates.push({
+ base,
+ // A component source is a main model, and only a bundled one can stand in for the slots
+ // it satisfies — `isDiffusersMainForBase` and `isBundledMainForBase` both demand it.
+ format: slot.valueKind === 'main' ? 'diffusers' : undefined,
+ key: `${base}-${type}-${variant ?? 'novariant'}`,
+ name: `${base} ${type} ${variant ?? ''}`.trim(),
+ type,
+ variant: variant ?? null,
+ });
+ }
+ }
+ }
+
+ return candidates;
+};
+
+const buildContext = (
+ model: MainModelConfig,
+ settings: GenerateSettings,
+ slots: readonly ComponentSlotPolicy[]
+): ComponentPolicyContext => {
+ // Derived from the slots rather than from a hand-kept key list: a new slot key is picked up here
+ // automatically, and a key that no slot uses cannot go stale.
+ const keys = new Set<GenerateComponentValueKey>(slots.map((slot) => slot.key));
+ const selectedComponents = {} as ComponentPolicyContext['selectedComponents'];
+
+ for (const key of keys) {
+ selectedComponents[key] = settings[key] as never;
+ }
+
+ return { model, settings, selectedComponents };
+};
+
+/**
+ * Fill every required component slot with something the slot's own filter accepts.
+ *
+ * Iterated to a fixpoint because slots are interdependent: selecting a component source can make
+ * the VAE and encoder slots stop being required, so one pass is not enough to reach a stable answer.
+ */
+const satisfyRequiredComponents = (
+ model: MainModelConfig,
+ initial: GenerateSettings
+): { settings: GenerateSettings; filled: GenerateComponentValueKey[] } => {
+ let settings = initial;
+ const filled: GenerateComponentValueKey[] = [];
+
+ for (let pass = 0; pass < 5; pass++) {
+ const { slots } = getComponentSectionPolicy(model, settings);
+ const context = buildContext(model, settings, slots);
+ let changed = false;
+
+ for (const slot of slots) {
+ if (!slot.required?.(context) || settings[slot.key]) {
+ continue;
+ }
+
+ const candidate = candidatesForSlot(slot).find((c) => !slot.filter || slot.filter(c, context));
+
+ if (candidate) {
+ settings = { ...settings, [slot.key]: candidate };
+ filled.push(slot.key);
+ changed = true;
+ }
+ }
+
+ if (!changed) {
+ break;
+ }
+ }
+
+ return { filled: filled.sort(), settings };
+};
+
+const createModel = (base: SupportedGenerateBase, shape: ModelShape): MainModelConfig => ({
+ base,
+ key: `${base}-${shape.label}`,
+ name: `${base} (${shape.label})`,
+ type: 'main',
+ ...shape.overrides,
+});
+
+const compileForShape = (
+ base: SupportedGenerateBase,
+ shape: ModelShape
+): { filled: GenerateComponentValueKey[]; graph: BackendGraphContract } => {
+ const model = createModel(base, shape);
+ const { filled, settings } = satisfyRequiredComponents(model, {
+ ...getDefaultGenerateSettings(model),
+ positivePrompt: 'a test prompt',
+ seed: 1,
+ shouldRandomizeSeed: false,
+ });
+
+ // Compiling an invalid selection throws the first reason, which makes for a poor failure message.
+ // Asserting here reports every unmet requirement at once, and doubles as the check that the
+ // base's component policy is satisfiable at all.
+ expect(getGenerationValidationReasons(model, settings), `${base}/${shape.label} is not satisfiable`).toEqual([]);
+
+ return { filled, graph: compileGenerateGraph(settings, model, 'gallery', { useCpuNoise: true }).backendGraph };
+};
+
+const cases = SUPPORTED_GENERATE_BASES.flatMap((base) =>
+ shapesForBase(base).map((shape) => ({ base, label: `${base} / ${shape.label}`, shape }))
+);
+
+describe('generate graph coverage', () => {
+ it('has a builder for every supported base and no builder for anything else', () => {
+ expect(Object.keys(GRAPH_BUILDERS).sort()).toEqual([...SUPPORTED_GENERATE_BASES].sort());
+ });
+
+ it('declares shape overrides only for bases that exist', () => {
+ expect(Object.keys(SHAPE_OVERRIDES).filter((base) => !SUPPORTED_GENERATE_BASES.includes(base as never))).toEqual(
+ []
+ );
+ });
+
+ it.each(cases)('compiles a structurally sound graph for $label', ({ base, shape }) => {
+ const { graph } = compileForShape(base, shape);
+ const nodeIds = new Set(Object.keys(graph.nodes));
+
+ expect(nodeIds.size).toBeGreaterThan(0);
+
+ for (const [id, node] of Object.entries(graph.nodes)) {
+ expect(node.id, `node keyed '${id}' carries a mismatched id`).toBe(id);
+ expect(node.type, `node '${id}' has no type`).toBeTruthy();
+ }
+
+ for (const edge of graph.edges) {
+ const description = `${edge.source.node_id}.${edge.source.field} -> ${edge.destination.node_id}.${edge.destination.field}`;
+
+ expect(nodeIds.has(edge.source.node_id), `dangling source in edge ${description}`).toBe(true);
+ expect(nodeIds.has(edge.destination.node_id), `dangling destination in edge ${description}`).toBe(true);
+ expect(edge.source.field, `edge ${description} has no source field`).toBeTruthy();
+ expect(edge.destination.field, `edge ${description} has no destination field`).toBeTruthy();
+ }
+ });
+
+ it('emits the node types and fields the backend has to provide', async () => {
+ const byBase: Record<string, { componentsFilled: Record<string, string[]>; nodeTypes: string[] }> = {};
+ const fields: Record<string, { inputs: Set<string>; outputs: Set<string> }> = {};
+
+ const fieldsFor = (nodeType: string) => (fields[nodeType] ??= { inputs: new Set(), outputs: new Set() });
+
+ for (const { base, shape } of cases) {
+ const { filled, graph } = compileForShape(base, shape);
+ const entry = (byBase[base] ??= { componentsFilled: {}, nodeTypes: [] });
+
+ entry.componentsFilled[shape.label] = filled;
+ entry.nodeTypes = [
+ ...new Set([...entry.nodeTypes, ...Object.values(graph.nodes).map((node) => node.type)]),
+ ].sort();
+
+ for (const edge of graph.edges) {
+ fieldsFor(graph.nodes[edge.source.node_id]!.type).outputs.add(edge.source.field);
+ fieldsFor(graph.nodes[edge.destination.node_id]!.type).inputs.add(edge.destination.field);
+ }
+ }
+
+ const contract = {
+ _comment:
+ 'Generated by src/features/generation/core/graphCoverage.test.ts. Update with `vitest -u`. ' +
+ 'Consumed by tests/app/invocations/test_frontend_graph_node_types.py, which checks every ' +
+ 'node type and field below against the backend invocation registry.',
+ byBase,
+ fieldsByNodeType: Object.fromEntries(
+ Object.entries(fields)
+ .sort(([a], [b]) => a.localeCompare(b))
+ .map(([nodeType, { inputs, outputs }]) => [
+ nodeType,
+ { inputs: [...inputs].sort(), outputs: [...outputs].sort() },
+ ])
+ ),
+ };
+
+ await expect(`${JSON.stringify(contract, null, 2)}\n`).toMatchFileSnapshot(
+ './__snapshots__/generateGraphNodeTypes.json'
+ );
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.test.ts b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.test.ts
index 6795e28c2a..ca09899156 100644
--- a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.test.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.test.ts
@@ -75,6 +75,7 @@ describe('MODEL_BASES', () => {
'flux',
'flux2',
'cogview4',
+ 'ernie-image',
'qwen-image',
'z-image',
'ideogram-4',
diff --git a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts
index fc30aecb62..44932406fb 100644
--- a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts
@@ -69,6 +69,11 @@ export const MODEL_BASES = {
label: 'CogView4',
colorPalette: 'red',
},
+ 'ernie-image': {
+ base: 'ernie-image',
+ label: 'ERNIE-Image',
+ colorPalette: 'orange',
+ },
'qwen-image': {
base: 'qwen-image',
label: 'Qwen Image',
diff --git a/invokeai/frontend/webv2/src/features/models/core/types.ts b/invokeai/frontend/webv2/src/features/models/core/types.ts
index ded0992f27..8fb39556b7 100644
--- a/invokeai/frontend/webv2/src/features/models/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/types.ts
@@ -17,6 +17,7 @@ export type ModelBase =
| 'flux'
| 'flux2'
| 'cogview4'
+ | 'ernie-image'
| 'qwen-image'
| 'z-image'
| 'ideogram-4'
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.ts b/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.ts
index 1233c60167..7b3f55ce87 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.ts
@@ -37,6 +37,7 @@ const BASE_LABELS: Record<string, string> = {
any: 'Any',
anima: 'Anima',
cogview4: 'CogView4',
+ 'ernie-image': 'ERNIE-Image',
external: 'External',
flux: 'FLUX',
flux2: 'FLUX.2',
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/bboxGrid.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/bboxGrid.ts
index fd01aabc8e..7d0513024b 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/bboxGrid.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/bboxGrid.ts
@@ -11,7 +11,7 @@ export const DEFAULT_MODEL_GRID = 8;
/**
* The bbox grid size for a model base:
* - `cogview4` → 32
- * - `flux` / `flux2` / `sd-3` / `qwen-image` / `z-image` → 16
+ * - `flux` / `flux2` / `sd-3` / `qwen-image` / `z-image` / `ernie-image` → 16
* - everything else (sd-1/sd-2/sdxl/anima/unknown) → 8
*/
export const gridSizeForModelBase = (base: string | null | undefined): number => {
@@ -23,6 +23,7 @@ export const gridSizeForModelBase = (base: string | null | undefined): number =>
case 'sd-3':
case 'qwen-image':
case 'z-image':
+ case 'ernie-image':
return 16;
default:
return DEFAULT_MODEL_GRID;
diff --git a/tests/app/invocations/test_frontend_graph_node_types.py b/tests/app/invocations/test_frontend_graph_node_types.py
new file mode 100644
index 0000000000..87101c92e4
--- /dev/null
+++ b/tests/app/invocations/test_frontend_graph_node_types.py
@@ -0,0 +1,92 @@
+"""The graphs webv2 compiles must be buildable from the invocations this backend registers.
+
+The frontend builds generation graphs from its own per-base tables and never imports a backend
+schema, so a node type or field that moves, is renamed, or loses its module import fails at
+*enqueue* time with a validation error against a graph the user cannot edit. Nothing in either test
+suite sees that on its own: the frontend only knows the strings it emits, and the backend only knows
+the invocations it has.
+
+The contract in between is `generateGraphNodeTypes.json`, written by
+`src/features/generation/core/graphCoverage.test.ts` (regenerate with `vitest -u`). It records every
+node type and every edge field that webv2's `compileGenerateGraph` produces for every supported
+architecture. This module checks all of it against the real registry.
+"""
+
+import json
+from pathlib import Path
+from typing import Any
+
+import pytest
+
+from invokeai.app.invocations.baseinvocation import BaseInvocation, InvocationRegistry
+from invokeai.app.services.shared.graph import * # noqa: F401 F403 -- imports all invocations, populating the registry
+
+CONTRACT_PATH = (
+ Path(__file__).parents[3]
+ / "invokeai"
+ / "frontend"
+ / "webv2"
+ / "src"
+ / "features"
+ / "generation"
+ / "core"
+ / "__snapshots__"
+ / "generateGraphNodeTypes.json"
+)
+
+
+def _contract() -> dict[str, Any]:
+ return json.loads(CONTRACT_PATH.read_text(encoding="utf-8"))
+
+
+CONTRACT = _contract()
+BY_BASE: dict[str, dict[str, Any]] = CONTRACT["byBase"]
+FIELDS_BY_NODE_TYPE: dict[str, dict[str, list[str]]] = CONTRACT["fieldsByNodeType"]
+
+
+def _invocation(node_type: str) -> type[BaseInvocation]:
+ cls = InvocationRegistry.get_invocations_map().get(node_type)
+ assert cls is not None, (
+ f"webv2 compiles '{node_type}' into a generation graph but no invocation is registered under "
+ f"that type. Either the node was renamed, or its module is no longer imported — see "
+ f"tests/app/invocations/test_node_discovery.py."
+ )
+ return cls
+
+
+def test_the_contract_covers_every_supported_base() -> None:
+ """Guard against a contract that silently stopped being regenerated.
+
+ An empty or truncated file would make every assertion below vacuous. 14 is the current length of
+ webv2's `SUPPORTED_GENERATE_BASES`; a new architecture should update this number and the file in
+ the same commit.
+ """
+ assert len(BY_BASE) == 14
+ assert all(entry["nodeTypes"] for entry in BY_BASE.values())
+
+
[email protected]("base", sorted(BY_BASE), ids=lambda base: base)
+def test_every_node_type_a_base_compiles_is_registered(base: str) -> None:
+ missing = [
+ node_type
+ for node_type in BY_BASE[base]["nodeTypes"]
+ if node_type not in InvocationRegistry.get_invocations_map()
+ ]
+ assert missing == [], f"webv2's '{base}' graph uses unregistered node types: {missing}"
+
+
[email protected]("node_type", sorted(FIELDS_BY_NODE_TYPE), ids=lambda node_type: node_type)
+def test_edge_destination_fields_are_real_invocation_fields(node_type: str) -> None:
+ """An edge into a field the invocation does not have is rejected when the graph is enqueued."""
+ cls = _invocation(node_type)
+ unknown = sorted(set(FIELDS_BY_NODE_TYPE[node_type]["inputs"]) - set(cls.model_fields))
+ assert unknown == [], f"webv2 wires edges into unknown inputs on '{node_type}': {unknown}"
+
+
[email protected]("node_type", sorted(FIELDS_BY_NODE_TYPE), ids=lambda node_type: node_type)
+def test_edge_source_fields_are_real_output_fields(node_type: str) -> None:
+ """The other half: an edge out of a field the invocation's output does not expose."""
+ cls = _invocation(node_type)
+ output_fields = set(cls.get_output_annotation().model_fields)
+ unknown = sorted(set(FIELDS_BY_NODE_TYPE[node_type]["outputs"]) - output_fields)
+ assert unknown == [], f"webv2 wires edges out of unknown outputs on '{node_type}': {unknown}"