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
feat(webv2): show per-GPU progress for parallel sessions
joshistoasta34078fcc884
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 8ead7d4f47..485103f428 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1310,7 +1310,26 @@"settingsRecalledDescription": "Loaded these settings into Generate.","took": "Took","waiting_one": "{{count}} waiting",- "waiting_other": "{{count}} waiting"+ "waiting_other": "{{count}} waiting",+ "device": {+ "label": "GPU",+ "shortLabel": "GPU {{index}}",+ "tooltip": "Ran on {{name}}"+ },+ "devices": {+ "title": "Generation Devices",+ "description": "GPUs used for generation. With more than one selected, InvokeAI runs a session on each at the same time.",+ "restartRequired": "Restart InvokeAI for changes to take effect.",+ "auto": "Use every available GPU",+ "autoHint": "New GPUs are picked up automatically.",+ "custom": "Choose specific GPUs",+ "loadFailed": "Could not load generation devices.",+ "saveFailed": "Could not save generation devices.",+ "saved": "Generation devices updated",+ "atLeastOne": "Select at least one GPU.",+ "unavailable": "No CUDA GPUs were detected, so generation runs on a single device.",+ "adminOnly": "Only an administrator can change which GPUs are used."+ }},"autosaveStatus": {"chipLabel": "Autosave: {{status}}",diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.tsindex 83eaab3541..b0451f9578 100644--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts@@ -22,6 +22,7 @@ export {getGalleryCompareImage,getGalleryCurrentItem,getGalleryGenerationSequence,+ getGalleryLiveSlots,getGalleryPage,getGallerySelectedImagePage,getGallerySelectedImageQuery,diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.tsindex cb7a81e38d..3413d24fdb 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts@@ -7,6 +7,7 @@ import {getBoardCounts,getGalleryCurrentItem,getGalleryGenerationSequence,+ getGalleryLiveSlots,getGalleryQueuePlaceholders,getGallerySelectedBoardId,getGalleryStateView,@@ -282,6 +283,7 @@ describe('gallery state view', () => {it('uses one derived current item while live-follow is active', () => {const placeholder = {+ backendItemId: null,boardId: 'board-1',height: 768,id: 'queue-item:0',@@ -396,3 +398,47 @@ describe('gallery state view', () => {expect(gallery.settings.showPendingItems).toBe(false);});});++describe('getGalleryLiveSlots', () => {+ const slot = (queueItemId: string, itemIndex: number, backendItemId: number | null) => ({+ backendItemId,+ boardId: 'none',+ height: 512,+ id: `${queueItemId}:${itemIndex - 1}`,+ itemIndex,+ queueItemId,+ width: 512,+ });++ it('returns nothing when no session is live', () => {+ expect(getGalleryLiveSlots([slot('queue-1', 1, 10)], [])).toEqual([]);+ });++ it('returns one slot per live target', () => {+ const slots = [slot('queue-1', 1, 10), slot('queue-1', 2, 11), slot('queue-1', 3, 12)];++ expect(+ getGalleryLiveSlots(slots, [+ { itemIndex: 1, queueItemId: 'queue-1' },+ { itemIndex: 3, queueItemId: 'queue-1' },+ ])+ ).toEqual([slots[0], slots[2]]);+ });++ it('orders tiles chronologically, not by the order sessions started reporting', () => {+ // Tiles must keep a stable position, so ordering follows the chronological slot+ // list (sorted by backend item id) rather than the target list.+ const slots = [slot('queue-1', 1, 10), slot('queue-1', 2, 11)];++ expect(+ getGalleryLiveSlots(slots, [+ { itemIndex: 2, queueItemId: 'queue-1' },+ { itemIndex: 1, queueItemId: 'queue-1' },+ ])+ ).toEqual([slots[0], slots[1]]);+ });++ it('ignores targets with no matching slot', () => {+ expect(getGalleryLiveSlots([slot('queue-1', 1, 10)], [{ itemIndex: 4, queueItemId: 'queue-9' }])).toEqual([]);+ });+});diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.tsindex 0dbc50a7d8..43bf2593db 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts@@ -33,6 +33,13 @@ export interface GalleryQueuePlaceholder {itemIndex: number;width: number;height: number;+ /**+ * The backend queue item id, once the slot has been claimed by one — null while the+ * submission is still local-only. Progress keyed by *local* id cannot distinguish+ * two slots of the same batch running on two GPUs, so surfaces that need per-session+ * facts (which GPU is rendering this tile) resolve them through this id.+ */+ backendItemId: number | null;}export interface GalleryLiveTarget {@@ -124,6 +131,7 @@ export const getGalleryGenerationSequence = (sortableSlots.push({backendItemId,placeholder: {+ backendItemId,boardId,height,id: `${item.id}:${index}`,@@ -166,6 +174,24 @@ export const getGalleryGenerationSequence = (return { chronologicalSlots, liveSlot };};+/**+ * The slots for every concurrently-running session, in chronological order.+ *+ * Multi-GPU runs one session per GPU, so more than one slot can be live at once.+ * Ordering comes from `chronologicalSlots` (sorted by backend item id) rather than+ * from the order the targets happened to start reporting, so tiles keep a stable+ * left-to-right position for as long as they run.+ */+export const getGalleryLiveSlots = (+ chronologicalSlots: GalleryQueuePlaceholder[],+ liveTargets: readonly GalleryLiveTarget[]+): GalleryQueuePlaceholder[] =>+ liveTargets.length === 0+ ? []+ : chronologicalSlots.filter((slot) =>+ liveTargets.some((target) => target.queueItemId === slot.queueItemId && target.itemIndex === slot.itemIndex)+ );+export const getGalleryCurrentItem = ({activePlaceholder,isComparisonActive,diff --git a/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.test.ts b/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.test.tsnew file mode 100644index 0000000000..e883bb836a--- /dev/null+++ b/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.test.ts@@ -0,0 +1,89 @@+import { describe, expect, it } from 'vitest';++import { getCudaDeviceIndex, getDeviceLabel, getDeviceNameLabels } from './deviceLabels';++describe('getCudaDeviceIndex', () => {+ it('parses the index from a cuda device', () => {+ expect(getCudaDeviceIndex('cuda:0')).toBe(0);+ expect(getCudaDeviceIndex('cuda:7')).toBe(7);+ expect(getCudaDeviceIndex('cuda:12')).toBe(12);+ });++ it('returns null for non-cuda and missing devices', () => {+ expect(getCudaDeviceIndex('cpu')).toBeNull();+ expect(getCudaDeviceIndex('mps')).toBeNull();+ expect(getCudaDeviceIndex('cuda')).toBeNull();+ expect(getCudaDeviceIndex(null)).toBeNull();+ expect(getCudaDeviceIndex(undefined)).toBeNull();+ expect(getCudaDeviceIndex('')).toBeNull();+ });++ it('does not accept a device with trailing content', () => {+ expect(getCudaDeviceIndex('cuda:0:1')).toBeNull();+ expect(getCudaDeviceIndex('xcuda:0')).toBeNull();+ });+});++describe('getDeviceNameLabels', () => {+ it('leaves a uniquely-named device unsuffixed', () => {+ expect(getDeviceNameLabels([{ device: 'cuda:0', name: 'RTX 5090' }])).toEqual({ 'cuda:0': 'RTX 5090' });+ });++ it('suffixes identically-named devices with a 1-based ordinal', () => {+ expect(+ getDeviceNameLabels([+ { device: 'cuda:0', name: 'RTX 5090' },+ { device: 'cuda:1', name: 'RTX 5090' },+ ])+ ).toEqual({ 'cuda:0': 'RTX 5090 #1', 'cuda:1': 'RTX 5090 #2' });+ });++ it('suffixes only the names that repeat', () => {+ expect(+ getDeviceNameLabels([+ { device: 'cuda:0', name: 'RTX 5090' },+ { device: 'cuda:1', name: 'RTX 4090' },+ { device: 'cuda:2', name: 'RTX 5090' },+ ])+ ).toEqual({ 'cuda:0': 'RTX 5090 #1', 'cuda:1': 'RTX 4090', 'cuda:2': 'RTX 5090 #2' });+ });++ it('numbers by position in the full device set, so disabling a device does not renumber it', () => {+ // The backend reports every installed CUDA device regardless of `generation_devices`, so+ // cuda:2 stays #3 whether or not cuda:1 is enabled for generation. Numbering off a filtered+ // list would silently promote cuda:2 to #2 and disagree with the backend's startup log.+ const allDevices = [+ { device: 'cuda:0', name: 'RTX 5090' },+ { device: 'cuda:1', name: 'RTX 5090' },+ { device: 'cuda:2', name: 'RTX 5090' },+ ];++ expect(getDeviceNameLabels(allDevices)['cuda:2']).toBe('RTX 5090 #3');+ });+});++describe('getDeviceLabel', () => {+ const twoGpus = [+ { device: 'cuda:0', name: 'RTX 5090' },+ { device: 'cuda:1', name: 'RTX 4090' },+ ];++ it('returns the index and name for a known cuda device', () => {+ expect(getDeviceLabel('cuda:1', twoGpus)).toEqual({ index: 1, name: 'RTX 4090' });+ });++ it('returns null on a single-GPU install, where a badge is only noise', () => {+ expect(getDeviceLabel('cuda:0', [{ device: 'cuda:0', name: 'RTX 5090' }])).toBeNull();+ });++ it('returns null for non-cuda, missing, and unreported devices', () => {+ expect(getDeviceLabel('cpu', twoGpus)).toBeNull();+ expect(getDeviceLabel(null, twoGpus)).toBeNull();+ expect(getDeviceLabel(undefined, twoGpus)).toBeNull();+ expect(getDeviceLabel('cuda:9', twoGpus)).toBeNull();+ });++ it('returns null when no options have loaded yet', () => {+ expect(getDeviceLabel('cuda:0', [])).toBeNull();+ });+});diff --git a/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.ts b/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.tsnew file mode 100644index 0000000000..be3d346875--- /dev/null+++ b/invokeai/frontend/webv2/src/features/queue/core/deviceLabels.ts@@ -0,0 +1,90 @@+/**+ * Labels for the GPU a queue item ran on.+ *+ * With `generation_devices` (default `auto`) the backend runs one session per GPU+ * concurrently, and tags each queue item and progress event with the device that+ * processed it. These helpers turn `"cuda:1"` into something a person can read.+ */++/** One device the backend offers for generation, from `GET /api/v1/app/generation_device_options`. */+export interface GenerationDeviceOption {+ /** Device identifier, e.g. `cuda:0`, `mps`, `cpu`. */+ device: string;+ /** Human-readable device name, e.g. `NVIDIA GeForce RTX 5090`. */+ name: string;+}++/**+ * Parse the CUDA index out of a device string (`"cuda:1"` → `1`).+ *+ * Returns null for a missing device or a non-CUDA one (`"cpu"`, `"mps"`), both of+ * which mean there is no GPU number worth showing.+ */+export const getCudaDeviceIndex = (device: string | null | undefined): number | null => {+ if (!device) {+ return null;+ }++ const match = /^cuda:(\d+)$/.exec(device);++ return match ? Number(match[1]) : null;+};++/**+ * Map device id → display label, disambiguating identically-named GPUs 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+ * `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`.+ */+export const getDeviceNameLabels = (options: readonly GenerationDeviceOption[]): Record<string, string> => {+ const nameCounts = new Map<string, number>();++ for (const option of options) {+ nameCounts.set(option.name, (nameCounts.get(option.name) ?? 0) + 1);+ }++ const ordinals = new Map<string, number>();+ const labels: Record<string, string> = {};++ for (const option of options) {+ const ordinal = (ordinals.get(option.name) ?? 0) + 1;++ ordinals.set(option.name, ordinal);+ labels[option.device] = (nameCounts.get(option.name) ?? 0) > 1 ? `${option.name} #${ordinal}` : option.name;+ }++ return labels;+};++export interface DeviceLabel {+ /** CUDA index, for the compact badge (e.g. `0`). */+ index: number;+ /** Full name with disambiguating ordinal, for the tooltip (e.g. `NVIDIA GeForce RTX 5090 #1`). */+ name: string;+}++/**+ * Resolve a device string to the badge + tooltip pair, or null when there is+ * nothing worth showing.+ *+ * Null covers three cases: the device is not a CUDA GPU, only one GPU exists (no+ * ambiguity to resolve, so a badge would be noise), or the device is absent from+ * the reported options.+ */+export const getDeviceLabel = (+ device: string | null | undefined,+ options: readonly GenerationDeviceOption[]+): DeviceLabel | null => {+ const index = getCudaDeviceIndex(device);++ if (index === null || options.length <= 1 || !device) {+ return null;+ }++ const name = getDeviceNameLabels(options)[device];++ return name ? { index, name } : null;+};diff --git a/invokeai/frontend/webv2/src/features/queue/core/types.ts b/invokeai/frontend/webv2/src/features/queue/core/types.tsindex aa0195017c..9fc1f4929d 100644--- a/invokeai/frontend/webv2/src/features/queue/core/types.ts+++ b/invokeai/frontend/webv2/src/features/queue/core/types.ts@@ -133,6 +133,8 @@ export interface QueueItemReadModel {completedAt?: string | null;createdAt: string;destination?: string | null;+ /** The GPU that processed this item, e.g. `cuda:1`. Null on non-CUDA and single-device installs. */+ device?: string | null;errorMessage?: string | null;errorTraceback?: string | null;errorType?: string | null;diff --git a/invokeai/frontend/webv2/src/features/queue/data/activeProgressTargetStore.test.ts b/invokeai/frontend/webv2/src/features/queue/data/activeProgressTargetStore.test.tsnew file mode 100644index 0000000000..b347dac8c3--- /dev/null+++ b/invokeai/frontend/webv2/src/features/queue/data/activeProgressTargetStore.test.ts@@ -0,0 +1,68 @@+import { beforeEach, describe, expect, it } from 'vitest';++import { activeProgressTargetStore, getActiveProgressTargets } from './activeProgressTargetStore';++const target = (queueItemId: string, itemIndex: number) => ({ itemIndex, queueItemId });++describe('activeProgressTargetStore', () => {+ beforeEach(() => {+ activeProgressTargetStore.clear();+ });++ it('holds every concurrently-running target', () => {+ // Multi-GPU runs one session per GPU, so a batch of two across two GPUs has two+ // live slots. The previous single-value store dropped all but the latest.+ activeProgressTargetStore.set(target('queue-1', 1));+ activeProgressTargetStore.set(target('queue-1', 2));++ expect(getActiveProgressTargets()).toEqual([target('queue-1', 1), target('queue-1', 2)]);+ });++ it('keeps array identity when an already-tracked target reports again', () => {+ activeProgressTargetStore.set(target('queue-1', 1));+ const first = getActiveProgressTargets();++ activeProgressTargetStore.set(target('queue-1', 1));++ // Progress frames arrive many times a second; a new array per frame would+ // re-render every consumer.+ expect(getActiveProgressTargets()).toBe(first);+ });++ it('removes only the settled target', () => {+ activeProgressTargetStore.set(target('queue-1', 1));+ activeProgressTargetStore.set(target('queue-1', 2));++ activeProgressTargetStore.clear(target('queue-1', 1));++ expect(getActiveProgressTargets()).toEqual([target('queue-1', 2)]);+ });++ it('ignores clearing a target that is not tracked', () => {+ activeProgressTargetStore.set(target('queue-1', 1));+ const first = getActiveProgressTargets();++ activeProgressTargetStore.clear(target('queue-9', 9));++ expect(getActiveProgressTargets()).toBe(first);+ });++ it('clears everything when called with no target', () => {+ activeProgressTargetStore.set(target('queue-1', 1));+ activeProgressTargetStore.set(target('queue-2', 1));++ activeProgressTargetStore.clear();++ expect(getActiveProgressTargets()).toEqual([]);+ });++ it('preserves start order so the followed target does not change while it runs', () => {+ // The single-target accessor reads targets[0]. Following the most recent reporter+ // instead is what made the preview flip between concurrent sessions.+ activeProgressTargetStore.set(target('queue-1', 1));+ activeProgressTargetStore.set(target('queue-1', 2));+ activeProgressTargetStore.set(target('queue-1', 1));++ expect(getActiveProgressTargets()[0]).toEqual(target('queue-1', 1));+ });+});diff --git a/invokeai/frontend/webv2/src/features/queue/data/activeProgressTargetStore.ts b/invokeai/frontend/webv2/src/features/queue/data/activeProgressTargetStore.tsindex c09182266c..8d75b69491 100644--- a/invokeai/frontend/webv2/src/features/queue/data/activeProgressTargetStore.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/activeProgressTargetStore.ts@@ -3,28 +3,57 @@ import type { QueueItemProgressTarget } from '@features/queue/core/types';import { registerAccountOwnedResource } from '@platform/state/accountLifecycle';import { createExternalStore } from '@platform/state/externalStore';+/**+ * The slots currently reporting progress.+ *+ * A list rather than a single value because of multi-GPU: with `generation_devices`+ * (default `auto`) the backend runs one session per GPU, so a batch of four across+ * two GPUs has two slots live at once. Holding only the most recent target meant+ * concurrent sessions overwrote each other on every progress frame, and the preview+ * flipped between them several times a second.+ *+ * Order is the order sessions started, which keeps the single-target accessor below+ * stable for as long as that session runs.+ */export interface ActiveProgressTargetSink {clear(target?: QueueItemProgressTarget): void;set(target: QueueItemProgressTarget): void;}-const store = createExternalStore<{ target: QueueItemProgressTarget | null }>({ target: null });+const store = createExternalStore<{ targets: QueueItemProgressTarget[] }>({ targets: [] });-const isSameTarget = (left: QueueItemProgressTarget | null, right: QueueItemProgressTarget): boolean =>- left?.queueItemId === right.queueItemId && left.itemIndex === right.itemIndex;+const isSameTarget = (left: QueueItemProgressTarget, right: QueueItemProgressTarget): boolean =>+ left.queueItemId === right.queueItemId && left.itemIndex === right.itemIndex;export const activeProgressTargetStore: ActiveProgressTargetSink = {clear(target) {- const current = store.getSnapshot().target;+ const { targets } = store.getSnapshot();- if (current && (!target || isSameTarget(current, target))) {- store.patchSnapshot({ target: null });+ if (!target) {+ if (targets.length > 0) {+ store.patchSnapshot({ targets: [] });+ }++ return;+ }++ const remaining = targets.filter((candidate) => !isSameTarget(candidate, target));++ if (remaining.length !== targets.length) {+ store.patchSnapshot({ targets: remaining });}},set(target) {- if (!isSameTarget(store.getSnapshot().target, target)) {- store.patchSnapshot({ target });+ const { targets } = store.getSnapshot();++ // Progress frames arrive many times a second per session; re-appending an+ // already-tracked target would publish a fresh array identity every frame and+ // re-render every consumer.+ if (targets.some((candidate) => isSameTarget(candidate, target))) {+ return;}++ store.patchSnapshot({ targets: [...targets, target] });},};@@ -33,5 +62,19 @@ registerAccountOwnedResource({name: 'queue-active-progress-target',});+/**+ * The slot to follow where a surface can only show one.+ *+ * The oldest still-running slot rather than the most recent to report: following the+ * most recent is what made the preview flip between concurrent sessions. Behaviour is+ * identical to the previous single-value store whenever one session runs at a time,+ * which is every single-GPU install.+ */export const useActiveProgressTarget = (): QueueItemProgressTarget | null =>- store.useSelector((snapshot) => snapshot.target);+ store.useSelector((snapshot) => snapshot.targets[0] ?? null);++/** Every slot reporting progress, in the order its session started. */+export const useActiveProgressTargets = (): QueueItemProgressTarget[] =>+ store.useSelector((snapshot) => snapshot.targets);++export const getActiveProgressTargets = (): QueueItemProgressTarget[] => store.getSnapshot().targets;diff --git a/invokeai/frontend/webv2/src/features/queue/data/events.ts b/invokeai/frontend/webv2/src/features/queue/data/events.tsindex 6431b38126..a90c2167e0 100644--- a/invokeai/frontend/webv2/src/features/queue/data/events.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/events.ts@@ -94,6 +94,12 @@ export interface InvocationProgressEvent extends InvocationEventBase {percentage: number | null;/** Intermittent denoising preview, when the invocation produces one. */image?: { width: number; height: number; dataURL: string } | null;+ /**+ * The GPU running this session, e.g. `cuda:1` — null on CPU/MPS and in+ * single-device mode. With `generation_devices` set (default `auto`) several+ * sessions run at once, one per GPU, so progress must be attributable.+ */+ device?: string | null;}export interface InvocationCompleteEvent extends InvocationEventBase {diff --git a/invokeai/frontend/webv2/src/features/queue/data/generationDevicesStore.ts b/invokeai/frontend/webv2/src/features/queue/data/generationDevicesStore.tsnew file mode 100644index 0000000000..28205d85dc--- /dev/null+++ b/invokeai/frontend/webv2/src/features/queue/data/generationDevicesStore.ts@@ -0,0 +1,137 @@+import type { GenerationDeviceOption } from '@features/queue/core/deviceLabels';++import {+ assertAccountScopeCurrent,+ captureAccountScope,+ isAccountScopeCurrent,+ registerAccountOwnedResource,+} from '@platform/state/accountLifecycle';+import { createExternalStore } from '@platform/state/externalStore';+import { apiFetchJson, getApiErrorMessage } from '@platform/transport/http';++/**+ * The GPUs available for generation, and which of them the server is configured to+ * use. Pull-based like `modelCacheStore`: there are no socket events for app config.+ *+ * `generation_devices` is server-wide app config (admin-only, `PATCH+ * /api/v1/app/runtime_config`) and only takes effect after a restart, so this is+ * deliberately not treated as live state — nothing here re-reads on a timer.+ */++/** `auto` uses every available GPU; an explicit list pins generation to those devices. */+export type GenerationDevicesSetting = 'auto' | string[];++export interface GenerationDevicesSnapshot {+ /** Every installed device, in CUDA-index order. Empty until loaded. */+ options: GenerationDeviceOption[];+ /** The configured setting, or null while unknown. */+ setting: GenerationDevicesSetting | null;+ loadState: 'idle' | 'loading' | 'loaded' | 'error';+ error: string | null;+}++const EMPTY_SNAPSHOT: GenerationDevicesSnapshot = {+ error: null,+ loadState: 'idle',+ options: [],+ setting: null,+};++const store = createExternalStore<GenerationDevicesSnapshot>(EMPTY_SNAPSHOT);++let inflight: Promise<void> | null = null;++registerAccountOwnedResource({+ clear: () => {+ inflight = null;+ store.setSnapshot(EMPTY_SNAPSHOT);+ },+ name: 'generation-devices',+});++interface RuntimeConfigResponse {+ generation_devices?: GenerationDevicesSetting | null;+}++/**+ * Load the device options and the current setting together.+ *+ * The options endpoint is available to any authenticated user, but the runtime+ * config is admin-only. A non-admin therefore gets the options and a null setting+ * rather than an error, which is what the read-only view wants.+ */+export const refreshGenerationDevices = (): Promise<void> => {+ if (inflight) {+ return inflight;+ }++ const owner = captureAccountScope();++ if (store.getSnapshot().loadState === 'idle') {+ store.patchSnapshot({ loadState: 'loading' });+ }++ const refresh = Promise.all([+ apiFetchJson<GenerationDeviceOption[]>('/api/v1/app/generation_device_options', { signal: owner.signal }),+ apiFetchJson<RuntimeConfigResponse>('/api/v1/app/runtime_config', { signal: owner.signal }).catch(() => null),+ ])+ .then(([options, runtimeConfig]) => {+ if (!isAccountScopeCurrent(owner)) {+ return;+ }++ store.patchSnapshot({+ error: null,+ loadState: 'loaded',+ options,+ setting: runtimeConfig?.generation_devices ?? null,+ });+ })+ .catch((error: unknown) => {+ if (!isAccountScopeCurrent(owner)) {+ return;+ }++ store.patchSnapshot({+ error: getApiErrorMessage(error, 'Failed to load generation devices'),+ loadState: 'error',+ });+ })+ .finally(() => {+ if (inflight === refresh) {+ inflight = null;+ }+ });++ inflight = refresh;++ return inflight;+};++/**+ * Persist a new `generation_devices` setting. Admin-only; takes effect on restart.+ *+ * The backend validates that every device actually exists on the machine and 422s+ * otherwise, so a stale options list cannot write a config that fails at startup.+ */+export const updateGenerationDevices = async (setting: GenerationDevicesSetting): Promise<void> => {+ const owner = captureAccountScope();++ const runtimeConfig = await apiFetchJson<RuntimeConfigResponse>('/api/v1/app/runtime_config', {+ body: JSON.stringify({ generation_devices: setting }),+ method: 'PATCH',+ signal: owner.signal,+ });++ assertAccountScopeCurrent(owner);++ store.patchSnapshot({ error: null, setting: runtimeConfig?.generation_devices ?? setting });+};++export const getGenerationDevicesSnapshot = (): GenerationDevicesSnapshot => store.getSnapshot();++export const useGenerationDevices = (): GenerationDevicesSnapshot => store.useSnapshot();++/** Just the device options, for label lookups that do not care about the setting. */+export const useGenerationDeviceOptions = (): GenerationDeviceOption[] =>+ store.useSelector((snapshot) => snapshot.options);diff --git a/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.test.ts b/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.test.tsindex 91e23d338d..d49c90d79b 100644--- a/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.test.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.test.ts@@ -1,6 +1,6 @@import { beforeEach, describe, expect, it } from 'vitest';-import { itemProgressStore } from './itemProgressStore';+import { getActiveProgressItemIds, itemProgressStore } from './itemProgressStore';describe('itemProgressStore', () => {beforeEach(() => {@@ -46,3 +46,54 @@ describe('itemProgressStore', () => {});});});++describe('itemProgressStore multi-session tracking', () => {+ beforeEach(() => {+ itemProgressStore.clearAll();+ });++ it('tracks concurrent sessions independently, keyed by backend item id', () => {+ // Multi-GPU runs one session per GPU, so two items report progress at once.+ itemProgressStore.set(10, { device: 'cuda:0', message: 'Denoising 1/20', percentage: 0.05 });+ itemProgressStore.set(11, { device: 'cuda:1', message: 'Denoising 3/20', percentage: 0.15 });++ expect(itemProgressStore.get(10)?.device).toBe('cuda:0');+ expect(itemProgressStore.get(11)?.device).toBe('cuda:1');+ expect(getActiveProgressItemIds()).toEqual([10, 11]);+ });++ it('orders active ids ascending regardless of which session reported first', () => {+ itemProgressStore.set(21, { message: '', percentage: null });+ itemProgressStore.set(20, { message: '', percentage: null });+ itemProgressStore.set(22, { message: '', percentage: null });++ expect(getActiveProgressItemIds()).toEqual([20, 21, 22]);+ });++ it('drops an id when its session settles, leaving the others running', () => {+ itemProgressStore.set(10, { message: '', percentage: null });+ itemProgressStore.set(11, { message: '', percentage: null });++ itemProgressStore.clear(10);++ expect(getActiveProgressItemIds()).toEqual([11]);+ expect(itemProgressStore.get(10)).toBeNull();+ });++ it('keeps the active id list stable across repeated progress frames', () => {+ itemProgressStore.set(10, { message: 'step 1', percentage: 0.1 });+ const first = getActiveProgressItemIds();++ itemProgressStore.set(10, { message: 'step 2', percentage: 0.2 });++ // Identity must survive a same-id update, or every consumer re-renders per frame.+ expect(getActiveProgressItemIds()).toBe(first);+ });++ it('empties the active list on clearAll', () => {+ itemProgressStore.set(10, { message: '', percentage: null });+ itemProgressStore.clearAll();++ expect(getActiveProgressItemIds()).toEqual([]);+ });+});diff --git a/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.ts b/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.tsindex 04936854b5..12d38be1b6 100644--- a/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/itemProgressStore.ts@@ -1,6 +1,6 @@import { mergeQueueProgressImage, type QueueProgressImage } from '@features/queue/core/progressImage';import { registerAccountOwnedResource } from '@platform/state/accountLifecycle';-import { createKeyedTransientStore } from '@platform/state/externalStore';+import { createExternalStore, createKeyedTransientStore } from '@platform/state/externalStore';/*** Live progress for in-flight queue items keyed by the backend `item_id`. The@@ -8,6 +8,10 @@ import { createKeyedTransientStore } from '@platform/state/externalStore';* for items this client enqueued; the Queue widget shows the whole server queue,* so its NOW & NEXT card needs progress addressable by the backend id carried on* the socket's `invocation_started`/`invocation_progress` events.+ *+ * Being keyed by item id is also what makes multi-GPU work: with+ * `generation_devices` (default `auto`) the backend runs one session per GPU, so+ * several items report progress at once and each needs its own entry.*/export interface ItemProgress {@@ -15,10 +19,38 @@ export interface ItemProgress {/** 0..1, or null while indeterminate. */percentage: number | null;image?: QueueProgressImage | null;+ /** The GPU running this session, e.g. `cuda:1`. Null on non-CUDA and single-device installs. */+ device?: string | null;}const progressByItemId = createKeyedTransientStore<number, ItemProgress>();+/**+ * The ids with live progress, ascending — a stable top-to-bottom order for stacked+ * progress bars and tiled previews (ascending item id is submission order).+ *+ * Deliberately separate from the keyed store: consumers subscribe to *which* items+ * are running here, and to a single item's progress via `useItemProgress`, so one+ * session's step does not re-render another session's tile. Maintained from the+ * mutation points below rather than derived from the keyed store, whose `entries()`+ * allocates a fresh array per call and so cannot serve as a cached snapshot.+ */+const activeItemIdsStore = createExternalStore<{ itemIds: number[] }>({ itemIds: [] });++const syncActiveItemIds = (): void => {+ const itemIds = progressByItemId+ .entries()+ .map(([itemId]) => itemId)+ .sort((left, right) => left - right);+ const current = activeItemIdsStore.getSnapshot().itemIds;++ if (current.length === itemIds.length && current.every((itemId, index) => itemId === itemIds[index])) {+ return;+ }++ activeItemIdsStore.patchSnapshot({ itemIds });+};+export const itemProgressStore = {get(itemId: number): ItemProgress | null {return progressByItemId.get(itemId) ?? null;@@ -29,12 +61,15 @@ export const itemProgressStore = {const next = image === undefined ? progress : { ...progress, image };progressByItemId.set(itemId, next);+ syncActiveItemIds();},clear(itemId: number): void {progressByItemId.delete(itemId);+ syncActiveItemIds();},clearAll(): void {progressByItemId.clear();+ syncActiveItemIds();},};@@ -45,3 +80,9 @@ registerAccountOwnedResource({export const useItemProgress = (itemId: number | null | undefined): ItemProgress | null =>progressByItemId.useValue(itemId ?? -1) ?? null;++/** Backend item ids with live progress, ascending. Empty when nothing is running. */+export const useActiveProgressItemIds = (): number[] => activeItemIdsStore.useSelector((snapshot) => snapshot.itemIds);++/** Non-reactive read, for imperative callers and tests. */+export const getActiveProgressItemIds = (): number[] => activeItemIdsStore.getSnapshot().itemIds;diff --git a/invokeai/frontend/webv2/src/features/queue/data/mappers.test.ts b/invokeai/frontend/webv2/src/features/queue/data/mappers.test.tsindex f3a5709297..3e8482f9c9 100644--- a/invokeai/frontend/webv2/src/features/queue/data/mappers.test.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/mappers.test.ts@@ -10,6 +10,7 @@ describe('queue transport mappers', () => {completed_at: '2026-07-18T01:00:00Z',created_at: '2026-07-18T00:00:00Z',destination: 'gallery',+ device: 'cuda:1',error_message: null,error_traceback: null,error_type: null,@@ -39,6 +40,7 @@ describe('queue transport mappers', () => {completedAt: '2026-07-18T01:00:00Z',createdAt: '2026-07-18T00:00:00Z',destination: 'gallery',+ device: 'cuda:1',errorMessage: null,errorTraceback: null,errorType: null,diff --git a/invokeai/frontend/webv2/src/features/queue/data/mappers.ts b/invokeai/frontend/webv2/src/features/queue/data/mappers.tsindex ad37d2eb34..17e9413ed4 100644--- a/invokeai/frontend/webv2/src/features/queue/data/mappers.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/mappers.ts@@ -54,6 +54,7 @@ export const mapQueueItemDTO = (dto: QueueServerItemDTO): QueueItemReadModel =>completedAt: dto.completed_at,createdAt: dto.created_at,destination: dto.destination,+ device: dto.device,errorMessage: dto.error_message,errorTraceback: dto.error_traceback,errorType: dto.error_type,diff --git a/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.test.ts b/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.test.tsindex d6f541150f..4e3c1379fc 100644--- a/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.test.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.test.ts@@ -85,6 +85,30 @@ describe('queue realtime runtime', () => {runtime.dispose();});+ it('forwards the reporting GPU so concurrent sessions can be told apart', () => {+ const runtime = createQueueRealtimeRuntime({ backend, invalidate, progress, refreshModelCache });++ runtime.start();+ vi.advanceTimersByTime(50);++ // Multi-GPU emits one progress stream per running session, each tagged with its+ // device. Without the tag the UI cannot label a tile or row with its GPU.+ handlers.get('invocation_progress')?.({+ device: 'cuda:1',+ item_id: 42,+ message: 'Denoising',+ percentage: 0.5,+ } as never);++ expect(progress.set).toHaveBeenCalledWith(42, {+ device: 'cuda:1',+ image: undefined,+ message: 'Denoising',+ percentage: 0.5,+ });+ runtime.dispose();+ });+it('keeps completed previews until result hydration and clears failed previews immediately', () => {const runtime = createQueueRealtimeRuntime({ backend, invalidate, progress, refreshModelCache });diff --git a/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.ts b/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.tsindex 55de021ca6..df13c956ce 100644--- a/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/realtimeRuntime.ts@@ -14,6 +14,8 @@ export interface QueueItemProgressPort {set(itemId: number,progress: {+ /** The GPU running this session, e.g. `cuda:1`; null on non-CUDA and single-device installs. */+ device?: string | null;image?: { dataUrl: string; height: number; width: number };message: string;percentage: number | null;@@ -108,6 +110,7 @@ export const createQueueRealtimeRuntime = ({const event = payload as unknown as InvocationProgressEvent;progress.set(event.item_id, {+ device: event.device,image: event.image?.dataURL? { dataUrl: event.image.dataURL, height: event.image.height, width: event.image.width }: undefined,diff --git a/invokeai/frontend/webv2/src/features/queue/data/serverTypes.ts b/invokeai/frontend/webv2/src/features/queue/data/serverTypes.tsindex 6ada93a988..b13a8bac14 100644--- a/invokeai/frontend/webv2/src/features/queue/data/serverTypes.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/serverTypes.ts@@ -12,6 +12,8 @@ export interface QueueServerItemDTO {completed_at?: string | null;created_at: string;destination?: string | null;+ /** The GPU that processed this item, e.g. `cuda:1`. Null for pre-multi-GPU rows and non-CUDA. */+ device?: string | null;error_message?: string | null;error_traceback?: string | null;error_type?: string | null;diff --git a/invokeai/frontend/webv2/src/features/queue/react.ts b/invokeai/frontend/webv2/src/features/queue/react.tsindex 7899c49e0c..8628c6c3b5 100644--- a/invokeai/frontend/webv2/src/features/queue/react.ts+++ b/invokeai/frontend/webv2/src/features/queue/react.ts@@ -1,7 +1,16 @@/** React-facing Queue read models, kept separate from widget registration. */export type { QueueItemProgress } from './core/types';export { QueueUiProvider, type QueueUiAdapter } from './ui/QueueUiContext';-export { useActiveProgressTarget } from './data/activeProgressTargetStore';+export { type DeviceLabel, type GenerationDeviceOption } from './core/deviceLabels';+export { useActiveProgressTarget, useActiveProgressTargets } from './data/activeProgressTargetStore';+export { type ItemProgress, useActiveProgressItemIds, useItemProgress } from './data/itemProgressStore';+export {+ type GenerationDevicesSetting,+ type GenerationDevicesSnapshot,+ refreshGenerationDevices,+ updateGenerationDevices,+ useGenerationDevices,+} from './data/generationDevicesStore';export {type LatestProgressImageSnapshot,useProgressImage,@@ -9,3 +18,4 @@ export {} from './data/progressImageStore';export { type QueueItemProgressSink, useQueueItemProgress } from './data/progressStore';export { getQueueItemAccess } from './ui/queueOwnership';+export { useDeviceLabel } from './ui/useDeviceLabel';diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueDataRuntime.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueDataRuntime.tsxindex 4474b2e5f4..10230b8de1 100644--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueDataRuntime.tsx+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueDataRuntime.tsx@@ -1,3 +1,4 @@+import { refreshGenerationDevices } from '@features/queue/data/generationDevicesStore';import { itemProgressStore } from '@features/queue/data/itemProgressStore';import { createProductionQueueRealtimeRuntime } from '@features/queue/publicApi';import { queryClient } from '@platform/query/client';@@ -14,6 +15,11 @@ export const attachQueueDataRuntime = (): (() => void) => {refreshModelCache: refreshModelCacheStats,});+ // The device options never change without a restart, so one read at startup is+ // enough. Every surface that labels an item or a progress tile with its GPU reads+ // from this store, and on a single-GPU install the labels stay hidden.+ void refreshGenerationDevices();+runtime.start();return runtime.dispose;diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsxindex bacc9c5f11..063bd49109 100644--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsx+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsx@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';import { formatDuration } from './formatDuration';import { useQueueUi } from './QueueUiContext';+import { useDeviceLabel } from './useDeviceLabel';const DetailRow = ({ label, children }: { label: string; children: ReactNode }) => (<DataList.Item key={label} alignItems="start">@@ -25,6 +26,7 @@ export const QueueItemDetails = ({ item }: { item: QueueItemReadModel }) => {const { ItemActions } = useQueueUi();const meta = extractGenerationMeta(item);const duration = formatDuration(item.startedAt, item.completedAt);+ const deviceLabel = useDeviceLabel(item.device);return (<DataList.Root gap="1.5" orientation="horizontal" size="sm">@@ -50,6 +52,7 @@ export const QueueItemDetails = ({ item }: { item: QueueItemReadModel }) => {{item.userDisplayName || item.userEmail ? (<DetailRow label={t('users.user')}>{item.userDisplayName ?? item.userEmail}</DetailRow>) : null}+ {deviceLabel ? <DetailRow label={t('widgets.queue.device.label')}>{deviceLabel.name}</DetailRow> : null}{item.errorMessage ? (<DetailRow label={t('common.error')}><Text as="span" color="fg.error">diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsxindex 22948a3b50..2a80165497 100644--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx@@ -18,6 +18,7 @@ import { QueueStepProgress } from './QueueStepProgress';import { useQueueUi } from './QueueUiContext';import { clearPendingQueueItemReveal, type QueueItemRevealRequest } from './queueUiStore';import { getStatusMeta } from './statusMeta';+import { useDeviceLabel } from './useDeviceLabel';const CHEVRON_OPEN = { transform: 'rotate(90deg)' } as const;@@ -70,6 +71,9 @@ export const QueueItemRow = memo(const liveImage = progress?.image ?? null;const resultImageName = getResultImageName(item);const statusLabel = t(getStatusMeta(item.status).labelKey);+ // A running item's device arrives on the progress event before the row's DTO is+ // refetched, so prefer the live value and fall back to the persisted one.+ const deviceLabel = useDeviceLabel(progress?.device ?? item.device);const showBorder = expanded || isFailed;const borderColor = showBorder ? (isFailed ? 'fg.error' : 'border') : 'transparent';@@ -90,8 +94,20 @@ export const QueueItemRow = memo(</Text><HStack gap="1.5" minW="0"><QueueStatusDot status={item.status} />- <Text color="fg.muted" fontSize="2xs" fontVariantNumeric="tabular-nums" truncate>- {[statusLabel, ageLabel].filter(Boolean).join(' · ')}+ <Text+ color="fg.muted"+ fontSize="2xs"+ fontVariantNumeric="tabular-nums"+ title={deviceLabel ? t('widgets.queue.device.tooltip', { name: deviceLabel.name }) : undefined}+ truncate+ >+ {[+ statusLabel,+ ageLabel,+ deviceLabel ? t('widgets.queue.device.shortLabel', { index: deviceLabel.index }) : null,+ ]+ .filter(Boolean)+ .join(' · ')}</Text></HStack></Stack>diff --git a/invokeai/frontend/webv2/src/features/queue/ui/useDeviceLabel.ts b/invokeai/frontend/webv2/src/features/queue/ui/useDeviceLabel.tsnew file mode 100644index 0000000000..5da97f1336--- /dev/null+++ b/invokeai/frontend/webv2/src/features/queue/ui/useDeviceLabel.ts@@ -0,0 +1,18 @@+import type { DeviceLabel } from '@features/queue/core/deviceLabels';++import { getDeviceLabel } from '@features/queue/core/deviceLabels';+import { useGenerationDeviceOptions } from '@features/queue/data/generationDevicesStore';+import { useMemo } from 'react';++/**+ * Resolve a queue item's or progress event's device to a badge index + full name.+ *+ * Returns null whenever there is nothing worth showing — most importantly on a+ * single-GPU install, where every item runs on the same GPU and a label would be+ * pure noise. Callers can therefore render unconditionally on a non-null result.+ */+export const useDeviceLabel = (device: string | null | undefined): DeviceLabel | null => {+ const options = useGenerationDeviceOptions();++ return useMemo(() => getDeviceLabel(device, options), [device, options]);+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.tsindex f50fd6b35d..7a75740812 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.ts@@ -5,6 +5,7 @@ import { getMatchingProgressImage, mergePreviewBoardImages } from './PreviewWidgdescribe('getMatchingProgressImage', () => {const placeholder = {+ backendItemId: null,boardId: 'none',height: 768,id: 'queue-1:1',diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsxindex 9fbf494682..55e5e57252 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx@@ -1,7 +1,7 @@import type { QueueItem } from '@features/queue/contracts';import type { WidgetViewProps } from '@workbench/widgetContracts';-import { Box, Stack, Text } from '@chakra-ui/react';+import { Box, SimpleGrid, Stack, Text } from '@chakra-ui/react';import { useDndMonitor, type DragEndEvent } from '@dnd-kit/core';import {galleryImages,@@ -13,6 +13,7 @@ import {import {getGalleryCompareImage,getGalleryGenerationSequence,+ getGalleryLiveSlots,getGallerySelectedImageQuery,getGallerySettings,getBoundedRecentImages,@@ -27,7 +28,15 @@ import {galleryImagesInfiniteOptions,} from '@features/gallery/queries';import { createGenerateFormValuesSelector } from '@features/generation/react';-import { useActiveProgressTarget, useProgressImage, type LatestProgressImageSnapshot } from '@features/queue/react';+import {+ useActiveProgressTarget,+ useActiveProgressTargets,+ useDeviceLabel,+ useItemProgress,+ useProgressImage,+ useQueueItemProgressImage,+ type LatestProgressImageSnapshot,+} from '@features/queue/react';import { parseDateTokens } from '@platform/search/dateTokens';import {imageUrlToStreamingSource,@@ -239,6 +248,7 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {);const progressImage = useProgressImage();const activeProgressTarget = useActiveProgressTarget();+ const activeProgressTargets = useActiveProgressTargets();const { account, gallery, notifications, widgets } = useWorkbenchCommands();const { density, rootRef } = usePreviewDensity(region);const recentImages = galleryValues.recentImages;@@ -257,10 +267,17 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {const selectedImageName = selectedImage?.imageName ?? null;const isComparing =selectedImage !== null && compareImage !== null && compareImage.imageName !== selectedImage.imageName;- const activeGalleryPlaceholder = useMemo(- () => getGalleryGenerationSequence(queueItems, activeProgressTarget).liveSlot,+ const generationSequence = useMemo(+ () => getGalleryGenerationSequence(queueItems, activeProgressTarget),[activeProgressTarget, queueItems]);+ const activeGalleryPlaceholder = generationSequence.liveSlot;+ // Multi-GPU runs one session per GPU, so several slots can be live at once. One+ // live slot keeps the existing single-frame preview; two or more are tiled.+ const liveGalleryPlaceholders = useMemo(+ () => getGalleryLiveSlots(generationSequence.chronologicalSlots, activeProgressTargets),+ [activeProgressTargets, generationSequence.chronologicalSlots]+ );const matchingProgressImage = getMatchingProgressImage(progressImage, activeGalleryPlaceholder);const shouldFollowLive = showProgressImagesInViewer && activeGalleryPlaceholder !== null && !isComparing;const navigationBoardId = shouldFollowLive ? activeGalleryPlaceholder.boardId : selectedImageQuery.boardId;@@ -751,7 +768,12 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {w="full"onKeyDown={handleNavigationKeyDown}>- {shouldFollowLive && activeGalleryPlaceholder ? (+ {shouldFollowLive && liveGalleryPlaceholders.length > 1 ? (+ <LivePreviewTiles+ placeholders={liveGalleryPlaceholders}+ shouldAntialiasProgressImage={antialiasProgressImages}+ />+ ) : shouldFollowLive && activeGalleryPlaceholder ? (<LivePreviewplaceholder={activeGalleryPlaceholder}progressImage={matchingProgressImage}@@ -921,6 +943,70 @@ const LivePreview = ({);};+/**+ * One tile in the multi-session grid.+ *+ * Subscribes to its own slot's progress image rather than receiving it from the+ * parent, so a frame from one GPU's session re-renders only that tile.+ */+const LivePreviewTile = ({+ placeholder,+ shouldAntialiasProgressImage,+}: {+ placeholder: GalleryQueuePlaceholder;+ shouldAntialiasProgressImage: boolean;+}) => {+ const { t } = useTranslation();+ const progressImage = useQueueItemProgressImage(placeholder.queueItemId, placeholder.itemIndex);+ // Keyed by the backend item id, not the local one: two slots of the same batch can+ // be running on two GPUs, and the local-keyed store holds one entry for both.+ const itemProgress = useItemProgress(placeholder.backendItemId);+ const deviceLabel = useDeviceLabel(itemProgress?.device);+ const previewImage = useStreamingImageSource({+ liveImage: progressImageToStreamingSource(progressImage),+ });++ return (+ <PreviewFrame+ frameHeight={previewImage?.height ?? placeholder.height}+ frameWidth={previewImage?.width ?? placeholder.width}+ isLive+ liveBadgeLabel={+ deviceLabel ? t('widgets.queue.device.shortLabel', { index: deviceLabel.index }) : t('common.generating')+ }+ liveQueueItemId={placeholder.queueItemId}+ shouldAntialiasLiveImage={shouldAntialiasProgressImage}+ source={previewImage}+ variant="inset"+ />+ );+};++/**+ * Side-by-side previews for concurrent sessions (multi-GPU).+ *+ * Only mounted for two or more live slots; a single session keeps the full-size+ * single-frame preview so nothing changes on a single-GPU install. The grid is a+ * plain auto-fit so two GPUs sit side by side and four wrap to a 2×2.+ */+const LivePreviewTiles = ({+ placeholders,+ shouldAntialiasProgressImage,+}: {+ placeholders: GalleryQueuePlaceholder[];+ shouldAntialiasProgressImage: boolean;+}) => (+ <SimpleGrid gap="2" h="full" minH="0" columns={placeholders.length > 2 ? 2 : placeholders.length}>+ {placeholders.map((placeholder) => (+ <LivePreviewTile+ key={placeholder.id}+ placeholder={placeholder}+ shouldAntialiasProgressImage={shouldAntialiasProgressImage}+ />+ ))}+ </SimpleGrid>+);+const EmptyPreview = () => {const { t } = useTranslation();diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewNavigation.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewNavigation.test.tsindex ebb81260e1..c6cc334a2f 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewNavigation.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewNavigation.test.ts@@ -15,6 +15,7 @@ interface TestImage {}const placeholder: GalleryQueuePlaceholder = {+ backendItemId: null,boardId: 'none',height: 1024,id: 'queue-1:1',