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
test(webv2): pin parity orchestration boundaries
joshistoast2282427a31a2
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.tsindex 651dca37f9..73bc15c681 100644--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts@@ -401,6 +401,28 @@ describe('component policies', () => {).toBe(incompatibleSource.key);});+ it('auto-selects complete FLUX.2 SDNQ component sources and rejects partial folders', () => {+ const model = createModel('flux2', { format: 'gguf_quantized', variant: 'klein_9b' });+ const completeSource = createModel('flux2', {+ format: 'sdnq_quantized',+ key: 'flux2-complete-sdnq-source',+ submodels: { text_encoder: {}, tokenizer: {}, transformer: {}, vae: {} },+ variant: 'klein_9b',+ });+ const partialSource = createModel('flux2', {+ format: 'sdnq_quantized',+ key: 'flux2-partial-sdnq-source',+ submodels: { text_encoder: {}, transformer: {}, vae: {} },+ variant: 'klein_9b',+ });+ const settings = createSettings(model);++ expect(getAutoFlux2ComponentSourceModel(model, settings, [partialSource, completeSource])?.key).toBe(+ completeSource.key+ );+ expect(getAutoFlux2ComponentSourceModel(model, settings, [partialSource])).toBeNull();+ });+it('validates Qwen Image Qwen-VL and VAE requirements', () => {const model = createModel('qwen-image', { format: 'checkpoint' });diff --git a/invokeai/frontend/webv2/src/features/generation/core/componentCompatibility.test.ts b/invokeai/frontend/webv2/src/features/generation/core/componentCompatibility.test.tsindex 632a300db2..f0a78c754d 100644--- a/invokeai/frontend/webv2/src/features/generation/core/componentCompatibility.test.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/componentCompatibility.test.ts@@ -31,6 +31,12 @@ const candidate = (overrides: Partial<GenerateComponentCandidate>): GenerateComp...overrides,});+const STANDARD_SDNQ_COMPONENTS = ['transformer', 'vae', 'text_encoder', 'tokenizer'] as const;+const FLUX1_SDNQ_COMPONENTS = [...STANDARD_SDNQ_COMPONENTS, 'text_encoder_2', 'tokenizer_2'] as const;++const submodelsWithout = (components: readonly string[], missing: string): Record<string, object> =>+ Object.fromEntries(components.filter((component) => component !== missing).map((component) => [component, {}]));+describe('Generate component compatibility', () => {it('only treats SDNQ folders with every required pipeline component as self-contained', () => {const complete = candidate({@@ -46,6 +52,14 @@ describe('Generate component compatibility', () => {expect(isSelfContainedSDNQPipeline(partial)).toBe(false);});+ it.each(STANDARD_SDNQ_COMPONENTS)('rejects a standard SDNQ pipeline missing %s', (missing) => {+ expect(+ isSelfContainedSDNQPipeline(+ candidate({ format: 'sdnq_quantized', submodels: submodelsWithout(STANDARD_SDNQ_COMPONENTS, missing) })+ )+ ).toBe(false);+ });+it('requires both text-encoder pairs before a FLUX.1 SDNQ folder is self-contained', () => {const complete = candidate({format: 'sdnq_quantized',@@ -67,6 +81,14 @@ describe('Generate component compatibility', () => {expect(isSelfContainedSDNQFlux1Pipeline(missingT5Pair)).toBe(false);});+ it.each(FLUX1_SDNQ_COMPONENTS)('rejects a FLUX.1 SDNQ pipeline missing %s', (missing) => {+ expect(+ isSelfContainedSDNQFlux1Pipeline(+ candidate({ format: 'sdnq_quantized', submodels: submodelsWithout(FLUX1_SDNQ_COMPONENTS, missing) })+ )+ ).toBe(false);+ });+it('separates Anima Qwen3 0.6B encoders from other Qwen3 encoders', () => {const qwen06b = candidate({ variant: 'qwen3_06b' });const qwen4b = candidate({ variant: 'qwen3_4b' });diff --git a/invokeai/frontend/webv2/src/features/generation/core/graph.test.ts b/invokeai/frontend/webv2/src/features/generation/core/graph.test.tsindex 31df4cc692..2429462990 100644--- a/invokeai/frontend/webv2/src/features/generation/core/graph.test.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/graph.test.ts@@ -451,6 +451,35 @@ describe('compileGenerateGraph', () => {expect(graph.nodes.model_loader?.vae_model).toBeUndefined();});+ it('uses a complete FLUX.2 SDNQ component source without standalone overrides', () => {+ const source: MainModelConfig = {+ ...flux2Klein9bModel,+ format: 'sdnq_quantized',+ key: 'flux2-klein-9b-sdnq-source',+ submodels: completeSdnqPipeline,+ };+ const graph = compile(flux2Klein9bModel, { componentSourceModel: source });++ expect(graph.nodes.model_loader).toMatchObject({+ qwen3_encoder_model: undefined,+ qwen3_source_model: source,+ vae_model: undefined,+ });+ });++ it('rejects a partial FLUX.2 SDNQ component source during graph compilation', () => {+ const source: MainModelConfig = {+ ...flux2Klein9bModel,+ format: 'sdnq_quantized',+ key: 'flux2-klein-9b-partial-sdnq-source',+ submodels: { text_encoder: {}, transformer: {}, vae: {} },+ };++ expect(() => compile(flux2Klein9bModel, { componentSourceModel: source })).toThrow(+ 'Generate needs a Qwen3 Encoder for non-Diffusers FLUX.2 models.'+ );+ });+it('does not enable FLUX.2 CFG without negative conditioning', () => {const graph = compile(flux2Model, { cfgScale: 4 });diff --git a/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.ts b/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.tsindex ad84e05b2a..54740d9454 100644--- a/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.ts+++ b/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.ts@@ -42,11 +42,11 @@ export const resolveRandDeviceMetadata = (useCpuNoise: boolean, options: readonl};/**- * Map device id → display label, disambiguating identically-named GPUs with a+ * Map device id → display label, disambiguating identically-named accelerators with a* 1-based `#N` suffix. A uniquely-named device gets no suffix.** The ordinal follows the order the options are given, and the backend returns- * every installed CUDA device in index order — not just the ones enabled in+ * every installed indexed accelerator in backend order — not just the ones enabled in* `generation_devices`. That matters: numbering off a filtered list would renumber* the survivors when a device is disabled, so `cuda:2` would stop being `#3`.*/diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.tsindex 9a494ddabf..ea33791a54 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts@@ -29,7 +29,41 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import type { RunCanvasInvocationDeps } from './prepareCanvasInvocation';import { DEFAULT_CANVAS_COMPOSITING } from './canvasCompositing';-import { resolveRegionalReferenceImages, runCanvasInvocation } from './prepareCanvasInvocation';+import {+ prepareCanvasInvocation,+ resolveRegionalReferenceImages,+ runCanvasInvocation,+} from './prepareCanvasInvocation';++const canvasBoundaryMocks = vi.hoisted(() => ({+ getCanvasEngine: vi.fn(),+ getCanvasOperations: vi.fn(),+ generationDeviceOptions: [] as { device: string; name: string }[],+}));++vi.mock('@workbench/canvas-operations/api', async (importOriginal) => {+ const original = (await importOriginal()) as Record<string, unknown>;++ return {+ ...original,+ getCanvasEngine: canvasBoundaryMocks.getCanvasEngine,+ getCanvasOperations: canvasBoundaryMocks.getCanvasOperations,+ };+});++vi.mock('@features/queue/devices', async (importOriginal) => {+ const original = (await importOriginal()) as Record<string, unknown>;++ return {+ ...original,+ getGenerationDevicesSnapshot: () => ({+ error: null,+ loadState: 'loaded' as const,+ options: canvasBoundaryMocks.generationDeviceOptions,+ setting: 'auto' as const,+ }),+ };+});const sd1Model: MainModelConfig = { base: 'sd-1', key: 'sd1-model', name: 'SD 1.5', type: 'main' };const externalModel: GenerateModelConfig = {@@ -286,6 +320,43 @@ const controlLayer = (withTransparencyEffect: true,});+describe('prepareCanvasInvocation generation-device boundary', () => {+ beforeEach(() => {+ vi.restoreAllMocks();+ canvasBoundaryMocks.getCanvasEngine.mockReset();+ canvasBoundaryMocks.getCanvasOperations.mockReset();+ canvasBoundaryMocks.generationDeviceOptions = [];+ });++ it('passes the XPU runtime snapshot into the compiled canvas graph metadata', async () => {+ const harness = makeHarness({ document: makeDoc([]) });+ canvasBoundaryMocks.generationDeviceOptions = [{ device: 'xpu:0', name: 'Intel Arc' }];+ canvasBoundaryMocks.getCanvasEngine.mockReturnValue({+ lifecycle: { flushPendingUploads: harness.flushPendingUploads },+ });+ canvasBoundaryMocks.getCanvasOperations.mockReturnValue({+ composeForGeneration: (options: Parameters<typeof composeForGeneration>[1]) =>+ composeForGeneration(harness.host, options),+ });++ await prepareCanvasInvocation({+ commands: harness.deps.commands,+ compositing: harness.deps.compositing,+ destination: harness.deps.destination,+ generateValues: harness.deps.generateValues,+ models: harness.deps.models,+ projectId: harness.deps.projectId,+ projectSettings: { useCpuNoise: false },+ strength: harness.deps.strength,+ });++ const nodes = harness.submittedGraphs()[0]?.graph.backendGraph?.nodes ?? {};+ const metadata = Object.values(nodes).find((node) => node.type === 'core_metadata');++ expect(metadata?.rand_device).toBe('xpu');+ });+});+describe('runCanvasInvocation', () => {beforeEach(() => {vi.restoreAllMocks();diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 6df961f90e..de90f6547e 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -1,5 +1,6 @@import type { GalleryImageItem, GalleryVideoItem, GeneratedImageContract } from '@features/gallery';import type { GenerateWidgetValues, MainModelConfig } from '@features/generation/contracts';+import type { ModelConfig } from '@features/models';import type {CanvasControlLayerContract,CanvasInpaintMaskLayerContract,@@ -12,7 +13,8 @@ import type { Project, WorkbenchState } from '@workbench/projectContracts';import { GALLERY_RECENT_IMAGE_LIMIT, legacyGeneratedImageToGalleryItem } from '@features/gallery/contracts';import { MAX_PROMPT_HISTORY } from '@features/generation/settings';-import { describe, expect, it, vi } from 'vitest';+import { createDefaultUpscaleWidgetValues } from '@features/upscale';+import { afterEach, describe, expect, it, vi } from 'vitest';import type { CanvasProjectMutation } from './canvasProjectMutations';@@ -30,6 +32,28 @@ import {workbenchReducer as reduceWorkbench,} from './workbenchState.testing';+const generationDeviceMock = vi.hoisted(() => ({+ options: [] as { device: string; name: string }[],+}));++vi.mock('@features/queue/devices', async (importOriginal) => {+ const original = (await importOriginal()) as Record<string, unknown>;++ return {+ ...original,+ getGenerationDevicesSnapshot: () => ({+ error: null,+ loadState: 'loaded' as const,+ options: generationDeviceMock.options,+ setting: 'auto' as const,+ }),+ };+});++afterEach(() => {+ generationDeviceMock.options = [];+});+type LegacyCanvasMutation = CanvasProjectMutation & { projectId?: string };const CANVAS_MUTATION_TYPES = new Set<CanvasProjectMutation['type']>(['commitStagedImage',@@ -356,6 +380,73 @@ const primeGenerate = (const submitGenerate = (state: WorkbenchState) =>workbenchReducer(state, { backendSupportsCancellation: true, type: 'submitInvocationSnapshot' });+const getQueuedRandDevice = (state: WorkbenchState): unknown => {+ const nodes = getActiveProject(state).queue.items[0]?.snapshot.graph.backendGraph?.nodes ?? {};+ const metadata = Object.values(nodes).find((node) => node.type === 'core_metadata');++ return metadata?.rand_device;+};++const createUpscaleModel = (key: string, type: string, base: string, name = key): ModelConfig => ({+ base,+ file_size: 1,+ format: 'checkpoint',+ hash: `${key}-hash`,+ key,+ name,+ path: key,+ source: key,+ source_type: 'path',+ type,+});++describe('generation-device orchestration metadata', () => {+ it('passes the XPU runtime snapshot through the generate submission boundary', () => {+ generationDeviceMock.options = [{ device: 'xpu:0', name: 'Intel Arc' }];+ const initial = workbenchReducer(createInitialWorkbenchState(), {+ settings: { useCpuNoise: false },+ type: 'setActiveProjectSettings',+ });++ const state = workbenchReducer(primeGenerate(initial), {+ backendSupportsCancellation: true,+ route: { destination: 'gallery', destinationLocked: false, sourceId: 'generate', sourceLocked: false },+ type: 'submitResolvedInvocationSnapshot',+ });++ expect(getQueuedRandDevice(state)).toBe('xpu');+ });++ it('passes the XPU runtime snapshot through the upscale submission boundary', () => {+ generationDeviceMock.options = [{ device: 'xpu:0', name: 'Intel Arc' }];+ const models = [+ createUpscaleModel('main', 'main', 'sd-1'),+ createUpscaleModel('spandrel', 'spandrel_image_to_image', 'any'),+ createUpscaleModel('tile', 'controlnet', 'sd-1', 'Tile ControlNet'),+ ];+ const values = {+ ...createDefaultUpscaleWidgetValues(models),+ inputImage: { height: 64, image_name: 'input.png', width: 64 },+ seed: 1,+ shouldRandomizeSeed: false,+ };+ let state = workbenchReducer(createInitialWorkbenchState(), {+ settings: { useCpuNoise: false },+ type: 'setActiveProjectSettings',+ });++ state = workbenchReducer(state, { type: 'patchWidgetValues', values, widgetId: 'upscale' });+ state = workbenchReducer(state, {+ backendSupportsCancellation: true,+ models,+ route: { destination: 'gallery', destinationLocked: false, sourceId: 'upscale', sourceLocked: false },+ type: 'submitResolvedInvocationSnapshot',+ });++ expect(getQueuedRandDevice(state)).toBe('xpu');+ });+});+describe('workbench widget region defaults', () => {it('starts new projects from the curated Compose widget defaults', () => {const state = createInitialWorkbenchState();