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.

fix(webv2): reject PiD on the canvas with an actionable message

joshistoast724e38799745
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.ts
index b5734de5c7..98d91bada1 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
@@ -384,6 +384,23 @@ describe('compileCanvasGraph', () => {
it('rejects external image generators for img2img', () => {
expect(() => compile(externalModel, 'img2img')).toThrow('does not support canvas generation');
});
+
+ it('rejects PiD with an actionable message rather than an internal VAE error', () => {
+ // Canvas compilation resolves the VAE from a `canvas_output.vae` edge and renames
+ // that node when compositing back; a PiD chain has neither, so without the guard
+ // this surfaces as "could not resolve a VAE source in the base graph".
+ for (const mode of ['txt2img', 'img2img'] as const) {
+ expect(() =>
+ compile(sdxlModel, mode, {
+ settings: {
+ gemma2EncoderModel: { base: 'any', key: 'g', name: 'Gemma 2', type: 'gemma2_encoder' },
+ pidDecoderModel: { base: 'sdxl', key: 'pid', name: 'PiD SDXL', type: 'pid_decoder' },
+ pidMode: 'fit',
+ },
+ })
+ ).toThrow('PiD decoding is not supported on the canvas yet.');
+ }
+ });
});
describe('validation', () => {
diff --git a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
index 66fe57f905..b31598dbf7 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
@@ -30,6 +30,7 @@ import type { GenerateModelConfig, GenerateSettings } from '@features/generation
import { getGenerationValidationReasons } from '@features/generation/core/baseGenerationPolicies';
import { GRAPH_BUILDERS } from '@features/generation/core/graph';
import { addEdge, addNode, toGraphContract } from '@features/generation/core/graphBuilder';
+import { getIsPidSupportedBase } from '@features/generation/core/pid';
import type {
CanvasCompositingSettings,
@@ -101,6 +102,14 @@ const getCanvasValidationReasons = (input: CompileCanvasGraphInput): string[] =>
return reasons;
}
+ // PiD is wired for text-to-image only. Canvas compilation finds the VAE by looking for
+ // a `canvas_output.vae` edge and renames that node when compositing back; a PiD chain
+ // has neither, so without this guard the user would get an internal
+ // "could not resolve a VAE source" error instead of an actionable one.
+ if (input.settings.pidMode !== 'off' && getIsPidSupportedBase(model.base)) {
+ reasons.push('PiD decoding is not supported on the canvas yet. Turn PiD off to generate here.');
+ }
+
if (!Number.isFinite(bbox.width) || !Number.isFinite(bbox.height) || bbox.width <= 0 || bbox.height <= 0) {
reasons.push('Canvas bounding box must have a positive area.');
}