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(video): support H3 hybrid task overrides (#10141)

jaffer1979181f60523922
diff --git a/docs/src/content/docs/Users Guide/05.Video Generation/minimax-h3.mdx b/docs/src/content/docs/Users Guide/05.Video Generation/minimax-h3.mdx
index c630d9e15f..883688a1bf 100644
--- a/docs/src/content/docs/Users Guide/05.Video Generation/minimax-h3.mdx
+++ b/docs/src/content/docs/Users Guide/05.Video Generation/minimax-h3.mdx
@@ -19,7 +19,9 @@ media's video, audio, or both video and audio.
MiniMax H3 ships as two task transformers that share every other component. **FL2VA** — *first/last-frame to video with audio* — covers text-to-video, first frame, last frame, both, and extend. **Ref2VA** — *reference to video with audio* — conditions a new clip on **reference media**: up to 3 videos and 9 images, in an order you choose (order changes the result). Every generation from either includes a **jointly generated stereo soundtrack**, muxed into the MP4 as AAC.
-The panel switches task by transformer: select the Ref2VA single-file transformer as the **Model** and the conditioning sections become the ordered **References** list; select the FL2VA transformer to get the five frame/extend modes back. A video reference can contribute its image track, its soundtrack, or both; soundtrack-only references can be used on their own. New image references use "Match generation size", which is several times faster than the high-detail 2048 px encoding ("Max detail") at some fidelity cost; switch a reference to "Max detail" when its fine detail matters.
+The panel defaults to the transformer's detected task: select a Ref2VA single-file transformer to get the ordered **References** list, or an FL2VA transformer for the frame/extend modes. Some community checkpoints combine both tasks in one file. For those, open the **Model** picker, select **Ref2VA** or **FL2VA** under **Load H3 checkpoint as**, and then choose the checkpoint. **Detected** follows the current catalog classification, including later re-identification or variant edits. Only an explicit **FL2VA** or **Ref2VA** choice is saved as a task override; **Reset all to model defaults** clears it. These picker choices appear only when a selectable H3 checkpoint is installed. Selecting a task limits H3 choices to checkpoints; choose **Detected** to select an H3 Diffusers main. The chosen task applies to the generation without changing the saved model record. You can also use **Switch mode** under the selected model; clear incompatible media and the optional hybrid quality base first. The Turbo toggle uses a task-specific adapter, so choose the appropriate Turbo again after switching tasks. An override changes the conditioning path; it cannot make a checkpoint support a task it was not designed for.
+
+A video reference can contribute its image track, its soundtrack, or both; soundtrack-only references can be used on their own. New image references use "Match generation size", which is several times faster than the high-detail 2048 px encoding ("Max detail") at some fidelity cost; switch a reference to "Max detail" when its fine detail matters.
What makes it different from Wan in practice:
diff --git a/invokeai/app/invocations/minimax_h3/minimax_h3_model_loader.py b/invokeai/app/invocations/minimax_h3/minimax_h3_model_loader.py
index 2feec6c76b..2667c95759 100644
--- a/invokeai/app/invocations/minimax_h3/minimax_h3_model_loader.py
+++ b/invokeai/app/invocations/minimax_h3/minimax_h3_model_loader.py
@@ -1,4 +1,4 @@
-from typing import Optional
+from typing import Literal, Optional
from invokeai.app.invocations.baseinvocation import (
BaseInvocation,
@@ -105,6 +105,14 @@ class MiniMaxH3ModelLoaderInvocation(BaseInvocation):
title="Text Encoder (single file)",
)
+ task_variant_override: Optional[Literal["fl2va", "ref2va"]] = InputField(
+ default=None,
+ description="Override the detected transformer task variant for this invocation. "
+ "The denoiser still validates conditioning against the selected variant.",
+ input=Input.Direct,
+ title="Task Variant Override",
+ )
+
def invoke(self, context: InvocationContext) -> MiniMaxH3ModelLoaderOutput:
if not context.models.exists(self.model.key):
raise ValueError(f"Unknown model: {self.model.key}")
@@ -142,6 +150,8 @@ class MiniMaxH3ModelLoaderInvocation(BaseInvocation):
# without references) instead of silently producing degraded output.
variant = getattr(transformer_config, "variant", None)
transformer_variant = variant.value if isinstance(variant, MiniMaxH3VariantType) else None
+ if self.task_variant_override is not None:
+ transformer_variant = self.task_variant_override
tokenizer = self.model.model_copy(update={"submodel_type": SubModelType.Tokenizer})
processor = self.model.model_copy(update={"submodel_type": SubModelType.Processor})
if self.text_encoder_model is not None:
diff --git a/invokeai/frontend/api/openapi.json b/invokeai/frontend/api/openapi.json
index 363f3244d1..bb04058ca0 100644
--- a/invokeai/frontend/api/openapi.json
+++ b/invokeai/frontend/api/openapi.json
@@ -93467,6 +93467,24 @@
"ui_model_format": ["checkpoint"],
"ui_model_type": ["qwen3_vl_encoder"]
},
+ "task_variant_override": {
+ "anyOf": [
+ {
+ "enum": ["fl2va", "ref2va"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Override the detected transformer task variant for this invocation. The denoiser still validates conditioning against the selected variant.",
+ "field_kind": "input",
+ "input": "direct",
+ "orig_default": null,
+ "orig_required": false,
+ "title": "Task Variant Override"
+ },
"type": {
"const": "minimax_h3_model_loader",
"default": "minimax_h3_model_loader",
diff --git a/invokeai/frontend/api/schema.ts b/invokeai/frontend/api/schema.ts
index 27bbfb3bec..1ecfc7417d 100644
--- a/invokeai/frontend/api/schema.ts
+++ b/invokeai/frontend/api/schema.ts
@@ -40304,6 +40304,12 @@ export type components = {
* @default null
*/
text_encoder_model?: components["schemas"]["ModelIdentifierField"] | null;
+ /**
+ * Task Variant Override
+ * @description Override the detected transformer task variant for this invocation. The denoiser still validates conditioning against the selected variant.
+ * @default null
+ */
+ task_variant_override?: ("fl2va" | "ref2va") | null;
/**
* type
* @default minimax_h3_model_loader
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 001a556b14..02d7c4b5b2 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -6739,6 +6739,16 @@
},
"switchModelTitle": "Switch model?",
"swapAspectRatio": "Swap orientation",
+ "h3LoadMode": "Load H3 checkpoint as",
+ "h3Detected": "Detected",
+ "h3OverrideHelp": "For checkpoints that support both tasks. This changes conditioning, not the model weights.",
+ "h3Mode": "H3 mode: {{mode}} ({{source}})",
+ "h3ModeOverride": "override",
+ "h3ModeDetected": "detected",
+ "h3SwitchMode": "Switch mode",
+ "h3TurboRemoved": "Turbo was removed and sampling steps were reset for the selected mode.",
+ "h3ClearModeInputs": "Clear mode-specific inputs first",
+ "h3ClearModeInputsDescription": "Remove reference media, frames, initial video, and hybrid quality base before switching modes.",
"targetResolution": "Target Resolution",
"twoStageHelp": "Two passes: generates at {{baseWidth}}×{{baseHeight}}, then upscales and refines to {{width}}×{{height}}. The refine pass runs at 4× the tokens, so it dominates the render time.",
"dimensionSource": {
diff --git a/invokeai/frontend/webv2/src/app/ConceptDraftCommits.browser.test.tsx b/invokeai/frontend/webv2/src/app/ConceptDraftCommits.browser.test.tsx
index 39464e01d6..be20d56e9a 100644
--- a/invokeai/frontend/webv2/src/app/ConceptDraftCommits.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/app/ConceptDraftCommits.browser.test.tsx
@@ -4,12 +4,14 @@ import type { Project } from '@workbench/projectContracts';
import type { WorkbenchInternalStore } from '@workbench/workbenchStore';
import { ChakraProvider } from '@chakra-ui/react';
+import { DndContext } from '@dnd-kit/core';
import { seedArchitectureCapabilities } from '@features/generation/core/architectureCapabilities.testing';
import { GenerationUiProvider, type GenerationUiAdapter } from '@features/generation/ui/GenerationUiContext';
import { createDefaultUpscaleWidgetValues } from '@features/upscale';
import { useUpscaleUi, type UpscaleUiAdapter } from '@features/upscale/ui/UpscaleUiContext';
import { UpscaleWidgetView } from '@features/upscale/ui/UpscaleWidgetView';
-import { createDefaultVideoWidgetValues } from '@features/video';
+import { createDefaultVideoWidgetValues, getVideoSettingsWithModelDefaults } from '@features/video';
+import { VideoHeaderActions } from '@features/video/ui/VideoHeaderActions';
import { useVideoUi, type VideoUiAdapter } from '@features/video/ui/VideoUiContext';
import { VideoWidgetView } from '@features/video/ui/VideoWidgetView';
import { flushWorkbenchDrafts } from '@platform/react/draftRegistry';
@@ -17,7 +19,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { system } from '@theme/system';
import { getProjectWidgetValues, getResolvedProjectWidgetValues } from '@workbench/widgetState';
import { createWorkbenchStore } from '@workbench/workbenchStore';
-import { act, useSyncExternalStore } from 'react';
+import { act, useState, useSyncExternalStore, type ReactNode } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -38,6 +40,7 @@ const model = (key: string, base: string, type: string, name = key): ModelConfig
});
const models = [
{ ...model('video-main', 'minimax-h3', 'main'), variant: 'fl2va' },
+ { ...model('unknown-h3', 'minimax-h3', 'main', 'Unknown H3'), format: 'checkpoint', variant: 'novel_task' },
model('video-first', 'minimax-h3', 'lora', 'MiniMax H3 Turbo LoRA'),
model('video-second', 'minimax-h3', 'lora', 'Video Ink Wash'),
model('upscale-main', 'sdxl', 'main'),
@@ -79,15 +82,75 @@ vi.mock('@features/models', async (importOriginal) => ({
// The concept picker hands over `picker.pick` unfiltered, as a stale picker would.
vi.mock('@features/models/react', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
- ModelSelect: ({ modelTypes, onChange }: { modelTypes?: readonly string[]; onChange: (model: unknown) => void }) =>
- modelTypes?.includes('lora') ? (
- <button
- aria-label="Add concept"
- data-testid="concept-picker"
- type="button"
- onClick={() => onChange(picker.pick)}
- />
- ) : null,
+ ModelSelect: ({
+ modelTypes,
+ filter,
+ onChange,
+ pickerHeader,
+ onPickerClose,
+ }: {
+ modelTypes?: readonly string[];
+ filter?: (model: ModelConfig) => boolean;
+ onChange: (model: unknown) => void;
+ pickerHeader?: ReactNode;
+ onPickerClose?: () => void;
+ }) => {
+ const [open, setOpen] = useState(false);
+ if (modelTypes?.includes('lora')) {
+ return (
+ <button
+ aria-label="Add concept"
+ data-testid="concept-picker"
+ type="button"
+ onClick={() => onChange(picker.pick)}
+ />
+ );
+ }
+ if (!modelTypes?.includes('main')) {
+ return null;
+ }
+ return (
+ <>
+ <button type="button" data-testid="open-model" onClick={() => setOpen(true)}>
+ Open
+ </button>
+ {open && (
+ <div>
+ {pickerHeader}
+ <button
+ type="button"
+ data-testid="pick-diffusers"
+ disabled={filter ? !filter(models[0]!) : false}
+ onClick={() => onChange(models[0])}
+ >
+ Diffusers
+ </button>
+ <button
+ type="button"
+ data-testid="dismiss-model"
+ onClick={() => {
+ setOpen(false);
+ onPickerClose?.();
+ }}
+ >
+ Cancel
+ </button>
+ <button
+ type="button"
+ data-testid="pick-unknown"
+ onClick={() => {
+ onChange(models.find((item) => item.key === 'unknown-h3'));
+ setOpen(false);
+ onPickerClose?.();
+ }}
+ >
+ Unknown H3
+ </button>
+ </div>
+ )}
+ </>
+ );
+ },
}));
vi.mock('@features/gallery/mediaSlot', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
@@ -141,12 +204,21 @@ const render = async (widget: Widget) => {
<QueryClientProvider client={queryClient}>
<ChakraProvider value={system}>
<GenerationUiProvider adapter={generationAdapter}>
- <VideoUiAdapterProvider>
- <UpscaleUiAdapterProvider>
- <CaptureAdapters />
- {widget === 'video' ? <VideoWidgetView /> : <UpscaleWidgetView />}
- </UpscaleUiAdapterProvider>
- </VideoUiAdapterProvider>
+ <DndContext>
+ <VideoUiAdapterProvider>
+ <UpscaleUiAdapterProvider>
+ <CaptureAdapters />
+ {widget === 'video' ? (
+ <>
+ <VideoHeaderActions />
+ <VideoWidgetView />
+ </>
+ ) : (
+ <UpscaleWidgetView />
+ )}
+ </UpscaleUiAdapterProvider>
+ </VideoUiAdapterProvider>
+ </DndContext>
</GenerationUiProvider>
</ChakraProvider>
</QueryClientProvider>
@@ -171,6 +243,7 @@ const step = (row: HTMLElement) =>
?.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'ArrowRight' }));
beforeEach(() => {
+ modelSnapshot.models = models;
store = createWorkbenchStore();
host = document.createElement('div');
document.body.append(host);
@@ -185,6 +258,67 @@ afterEach(async () => {
});
describe('concept drafts through widget adapters', () => {
+ it.each(['wan', 'ltx-2', 'diffusers-only', 'components-only'])(
+ 'hides the H3 picker header with %s and no selectable H3 checkpoint',
+ async (kind) => {
+ await render('video');
+ const catalogModel =
+ kind === 'components-only'
+ ? { ...models[0]!, components_only: true }
+ : kind === 'diffusers-only'
+ ? models[0]!
+ : model(kind, kind, 'main');
+ await act(() => {
+ modelSnapshot.models = [catalogModel];
+ store.commands.widgets.patchValues('video', { positivePrompt: 'refresh catalog' });
+ });
+ await act(() => host.querySelector<HTMLButtonElement>('[data-testid="open-model"]')!.click());
+ expect(host.textContent).not.toContain('widgets.video.h3LoadMode');
+ }
+ );
+
+ it('offers Diffusers only in Detected mode and retains catalog identity on selection', async () => {
+ await render('video');
+ await act(() => host.querySelector<HTMLButtonElement>('[data-testid="open-model"]')!.click());
+ expect(host.textContent).toContain('widgets.video.h3LoadMode');
+ const diffusers = host.querySelector<HTMLButtonElement>('[data-testid="pick-diffusers"]')!;
+ expect(diffusers.disabled).toBe(false);
+ await act(() =>
+ [...host.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent === 'Ref2VA')!.click()
+ );
+ expect(diffusers.disabled).toBe(true);
+ await act(() =>
+ [...host.querySelectorAll<HTMLButtonElement>('button')]
+ .find((button) => button.textContent === 'widgets.video.h3Detected')!
+ .click()
+ );
+ expect(diffusers.disabled).toBe(false);
+ await act(() => diffusers.click());
+ expect(getProjectWidgetValues(store.getSnapshot().activeProject, 'video')).toMatchObject({
+ model: models[0],
+ h3TaskOverride: undefined,
+ });
+ });
+
+ it('enables Reset for an explicit task choice and clears it back to Detected', async () => {
+ await render('video');
+ const checkpoint = { ...models[1]!, variant: 'fl2va', type: 'main' as const };
+ modelSnapshot.models = [...models.filter((entry) => entry.key !== checkpoint.key), checkpoint];
+ const defaults = createDefaultVideoWidgetValues([checkpoint, ...modelSnapshot.models]);
+ await act(() =>
+ store.commands.widgets.patchValues('video', {
+ ...getVideoSettingsWithModelDefaults(defaults, checkpoint, modelSnapshot.models),
+ model: checkpoint,
+ h3TaskOverride: 'fl2va',
+ })
+ );
+ const reset = host.querySelector<HTMLButtonElement>('[aria-label="widgets.video.resetAllToModelDefaults"]')!;
+ expect(reset.disabled).toBe(false);
+ await act(() => reset.click());
+ expect(getProjectWidgetValues(store.getSnapshot().activeProject, 'video').h3TaskOverride).toBeUndefined();
+ expect(reset.disabled).toBe(true);
+ });
+
it.each(['upscale', 'video'] as const)(
'flushes sibling %s drafts without losing same-turn settings changes',
async (widget) => {
@@ -290,4 +424,80 @@ describe('concept drafts through widget adapters', () => {
expect(store.getSnapshot().activeProject).toBe(project);
}
);
+ it('resets the picker choice on dismiss and selects unknown detected H3 as FL2VA', async () => {
+ await render('video');
+ await act(() => host.querySelector<HTMLButtonElement>('[data-testid="open-model"]')!.click());
+ const ref = [...host.querySelectorAll('button')].find((button) => button.textContent === 'Ref2VA')!;
+ await act(() => ref.click());
+ expect(ref.getAttribute('aria-pressed')).toBe('true');
+ await act(() => host.querySelector<HTMLButtonElement>('[data-testid="dismiss-model"]')!.click());
+ await act(() => host.querySelector<HTMLButtonElement>('[data-testid="open-model"]')!.click());
+ expect(
+ [...host.querySelectorAll('button')]
+ .find((button) => button.textContent === 'widgets.video.h3Detected')
+ ?.getAttribute('aria-pressed')
+ ).toBe('true');
+ await act(() => host.querySelector<HTMLButtonElement>('[data-testid="pick-unknown"]')!.click());
+ expect(getProjectWidgetValues(store.getSnapshot().activeProject, 'video')).toMatchObject({
+ h3TaskOverride: undefined,
+ model: { variant: 'novel_task' },
+ });
+ });
+
+ it('flushes pending concept edits and preserves a same-turn edit when switching H3 task', async () => {
+ await render('video');
+ const checkpoint = models.find((item) => item.key === 'unknown-h3')!;
+ await act(() =>
+ store.commands.widgets.patchValues('video', {
+ model: checkpoint,
+ modelKey: checkpoint.key,
+ h3TaskOverride: undefined,
+ componentSourceModel: models[0],
+ })
+ );
+ const currentRows = [...host.querySelectorAll<HTMLElement>('[role="listitem"]')];
+ expect(currentRows.length).toBe(2);
+ await act(() => step(currentRows[1]!));
+ await act(() => {
+ store.commands.widgets.patchValues('video', { positivePrompt: 'newest prompt' });
+ const label = [...host.querySelectorAll('label')].find((item) =>
+ item.textContent?.includes('widgets.video.h3SwitchMode')
+ );
+ expect(label).toBeTruthy();
+ label!.querySelector<HTMLInputElement>('input')!.click();
+ });
+ const current = getProjectWidgetValues(store.getSnapshot().activeProject, 'video');
+ expect(current).toMatchObject({
+ positivePrompt: 'newest prompt',
+ h3TaskOverride: 'ref2va',
+ acceleratorEnabled: false,
+ });
+ expect(currentLoras('video').find((lora) => lora.model.key === 'video-second')?.weight).toBe(0.55);
+ expect(notify).toHaveBeenCalledWith(expect.objectContaining({ description: 'widgets.video.h3TurboRemoved' }));
+ });
+ it('blocks a stale switch callback when a reference was just added', async () => {
+ await render('video');
+ const checkpoint = models.find((item) => item.key === 'unknown-h3')!;
+ await act(() =>
+ store.commands.widgets.patchValues('video', {
+ model: checkpoint,
+ modelKey: checkpoint.key,
+ h3TaskOverride: undefined,
+ componentSourceModel: models[0],
+ })
+ );
+ const reference = { kind: 'image', detail: 'match', image: { image_name: 'new.png', width: 512, height: 512 } };
+ await act(() => {
+ store.commands.widgets.patchValues('video', { references: [reference] });
+ const label = [...host.querySelectorAll('label')].find((item) =>
+ item.textContent?.includes('widgets.video.h3SwitchMode')
+ )!;
+ label.querySelector<HTMLInputElement>('input')!.click();
+ });
+ expect(getProjectWidgetValues(store.getSnapshot().activeProject, 'video')).toMatchObject({
+ h3TaskOverride: undefined,
+ references: [reference],
+ });
+ expect(notify).toHaveBeenCalledWith(expect.objectContaining({ title: 'widgets.video.h3ClearModeInputs' }));
+ });
});
diff --git a/invokeai/frontend/webv2/src/app/VideoModelPicker.browser.test.tsx b/invokeai/frontend/webv2/src/app/VideoModelPicker.browser.test.tsx
new file mode 100644
index 0000000000..b0129b839f
--- /dev/null
+++ b/invokeai/frontend/webv2/src/app/VideoModelPicker.browser.test.tsx
@@ -0,0 +1,160 @@
+import type { ModelConfig } from '@features/models';
+import type { VideoUiAdapter } from '@features/video/ui/VideoUiContext';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { seedArchitectureCapabilities } from '@features/generation/core/architectureCapabilities.testing';
+import { setModelsSnapshotForTests } from '@features/models/data/modelsStore';
+import { ModelsUiProvider, NO_SCHEDULER_POLICY } from '@features/models/ui/ModelsUiContext';
+import { createDefaultVideoWidgetValues } from '@features/video';
+import { VideoModelField } from '@features/video/ui/VideoModelField';
+import { VideoUiProvider } from '@features/video/ui/VideoUiContext';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { page, userEvent } from 'vitest/browser';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ i18n: { resolvedLanguage: 'en' }, t: (key: string) => key }),
+}));
+// Only navigation out to the manager is outside this picker integration.
+vi.mock('@tanstack/react-router', async (importOriginal) => ({
+ ...(await importOriginal<Record<string, unknown>>()),
+ Link: () => null,
+}));
+
+seedArchitectureCapabilities();
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const checkpoint = {
+ base: 'minimax-h3',
+ file_size: 1024,
+ format: 'checkpoint',
+ key: 'unknown-h3',
+ name: 'Unknown H3',
+ type: 'main',
+ variant: 'novel_task',
+} as ModelConfig;
+const diffusers = { ...checkpoint, key: 'full-h3', name: 'Full H3', format: 'diffusers', variant: 'fl2va' };
+const components = { ...diffusers, key: 'components-h3', name: 'Components H3', components_only: true };
+const models = [checkpoint, diffusers, components];
+const modelsAdapter = {
+ canManageModels: false,
+ enableModelDescriptions: true,
+ installInPlace: true,
+ isProjectActive: () => true,
+ managerProjectId: null,
+ schedulerPolicy: NO_SCHEDULER_POLICY,
+ setInstallInPlace: () => undefined,
+};
+
+let host: HTMLDivElement;
+let root: Root;
+let values: ReturnType<typeof createDefaultVideoWidgetValues>;
+const patchValues = vi.fn<VideoUiAdapter['patchValues']>((patch) => {
+ values = { ...values, ...(typeof patch === 'function' ? patch(values) : patch) };
+});
+const adapter = { patchValues } as unknown as VideoUiAdapter;
+const search = () => document.querySelector<HTMLInputElement>('input[role="combobox"]')!;
+const trigger = () => host.querySelector<HTMLButtonElement>('[aria-haspopup="listbox"]')!;
+const optionNames = () => [...document.querySelectorAll('[role="option"]')].map((option) => option.textContent);
+const openWithKeyboard = async () => {
+ await act(() => trigger().focus());
+ await userEvent.keyboard('{Enter}');
+ await expect.poll(() => document.activeElement).toBe(search());
+};
+
+beforeEach(async () => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ setModelsSnapshotForTests({ error: null, models, status: 'loaded' });
+ values = createDefaultVideoWidgetValues(models);
+ patchValues.mockClear();
+ await act(() =>
+ root.render(
+ <ChakraProvider value={system}>
+ <ModelsUiProvider adapter={modelsAdapter}>
+ <VideoUiProvider adapter={adapter}>
+ <VideoModelField models={models} modelsLoaded projectId="picker-test" values={values} />
+ </VideoUiProvider>
+ </ModelsUiProvider>
+ </ChakraProvider>
+ )
+ );
+});
+
+afterEach(async () => {
+ await act(() => root.unmount());
+ host.remove();
+ setModelsSnapshotForTests({ error: null, models: [], status: 'idle' });
+});
+
+describe('H3 task header through the real model picker', () => {
+ it('starts in search, navigates filtered options, and restores focus on Escape without selecting', async () => {
+ await openWithKeyboard();
+ expect(optionNames().join(' ')).toContain('Full H3');
+ expect(optionNames().join(' ')).not.toContain('Components H3');
+ await userEvent.keyboard('{ArrowUp}');
+ await expect.poll(() => document.querySelector('[data-active]')?.textContent).toContain('Full H3');
+ await userEvent.keyboard('{ArrowDown}');
+ await expect.poll(() => document.querySelector('[data-active]')?.textContent).toContain('Unknown H3');
+ await userEvent.keyboard('Unknown');
+ await expect.poll(optionNames).toHaveLength(1);
+ await userEvent.keyboard('{ArrowDown}');
+ await expect.poll(() => document.querySelector('[data-active]')?.textContent).toContain('Unknown H3');
+ expect(search().getAttribute('aria-activedescendant')).toBe(document.querySelector('[data-active]')?.id);
+ await userEvent.keyboard('{Escape}');
+ await expect.poll(() => trigger().getAttribute('aria-expanded')).toBe('false');
+ await expect.poll(() => document.activeElement).toBe(trigger());
+ expect(patchValues).not.toHaveBeenCalled();
+ });
+
+ it.each(['Ref2VA', 'FL2VA'] as const)(
+ 'selects %s explicitly using header and search keyboard navigation',
+ async (task) => {
+ await openWithKeyboard();
+ // Header remains in natural tab order before search, without taking initial focus.
+ await userEvent.keyboard('{Shift>}{Tab}{/Shift}');
+ await expect.element(page.getByRole('button', { name: 'FL2VA', exact: true })).toHaveFocus();
+ if (task === 'Ref2VA') {
+ await userEvent.keyboard('{Shift>}{Tab}{/Shift}');
+ }
+ await userEvent.keyboard('{Enter}');
+ await expect
+ .element(page.getByRole('button', { name: task, exact: true }))
+ .toHaveAttribute('aria-pressed', 'true');
+ await expect.poll(optionNames).toHaveLength(1);
+ expect(optionNames().join(' ')).toContain('Unknown H3');
+ await userEvent.keyboard(task === 'Ref2VA' ? '{Tab}{Tab}' : '{Tab}');
+ await expect.poll(() => document.activeElement).toBe(search());
+ await userEvent.keyboard('Unknown{ArrowDown}{Enter}');
+ await expect.poll(() => trigger().getAttribute('aria-expanded')).toBe('false');
+ expect(values.h3TaskOverride).toBe(task === 'Ref2VA' ? 'ref2va' : 'fl2va');
+ expect(values.model).toBe(checkpoint);
+ expect(values.model?.variant).toBe('novel_task');
+ await expect.poll(() => document.activeElement).toBe(trigger());
+ }
+ );
+
+ it('discards a pending task on Escape and reopens in Detected with an empty search', async () => {
+ await openWithKeyboard();
+ await page.getByRole('button', { name: 'Ref2VA', exact: true }).click();
+ await userEvent.keyboard('{Tab}{Tab}Unknown');
+ expect(search().value).toBe('Unknown');
+ await userEvent.keyboard('{Escape}');
+ await expect.poll(() => document.activeElement).toBe(trigger());
+ expect(patchValues).not.toHaveBeenCalled();
+ // Wait for the exit animation to unmount the picker before starting a fresh search session.
+ await expect.poll(() => document.querySelector('input[role="combobox"]')).toBeNull();
+ await openWithKeyboard();
+ await expect
+ .element(page.getByRole('button', { name: 'widgets.video.h3Detected', exact: true }))
+ .toHaveAttribute('aria-pressed', 'true');
+ expect(search().value).toBe('');
+ await expect.poll(optionNames).toHaveLength(2);
+ await userEvent.keyboard('Unknown{ArrowDown}{Enter}');
+ expect(values.h3TaskOverride).toBeUndefined();
+ expect(values.model).toBe(checkpoint);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx b/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
index c669e69f53..707b2ba6da 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
@@ -1,6 +1,7 @@
/* eslint-disable react-perf/jsx-no-new-object-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-jsx-as-prop */
import type { ModelConfig, ModelTaxonomyType } from '@features/models/core/types';
import type { PickerGroup, PickerOptionState } from '@platform/ui/Picker';
+import type { ReactNode } from 'react';
import {
Badge,
@@ -44,7 +45,7 @@ import {
RotateCcwIcon,
XIcon,
} from 'lucide-react';
-import { useCallback, useEffect, useId, useMemo, useState } from 'react';
+import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
const EMPTY_BASES: ReadonlySet<string> = new Set();
@@ -106,6 +107,8 @@ export const ModelSelect = ({
isClearable = false,
modelTypes,
onChange,
+ onPickerClose,
+ pickerHeader,
placeholder,
relatedTo = null,
scopeLabel: scopeLabelOverride,
@@ -127,6 +130,8 @@ export const ModelSelect = ({
isClearable?: boolean;
modelTypes: readonly ModelTaxonomyType[];
onChange: (model: ModelConfig | null) => void;
+ onPickerClose?: () => void;
+ pickerHeader?: ReactNode;
placeholder?: string;
/** Key of the model whose links rank this picker: its related models come first and carry a link icon. */
relatedTo?: string | null;
@@ -142,6 +147,7 @@ export const ModelSelect = ({
const loadError = useModelsSelector((snapshot) => snapshot.error);
const loadStatus = useModelsSelector((snapshot) => snapshot.status);
const [isOpen, setIsOpen] = useState(false);
+ const contentRef = useRef<HTMLDivElement>(null);
// Like Select, an enclosing Field names the trigger and supplies its description, invalid and disabled states.
const field = useFieldContext();
const insideLabel = useInsideFieldLabel();
@@ -246,6 +252,7 @@ export const ModelSelect = ({
const selectModel = (model: ModelConfig) => {
onChange(model);
setIsOpen(false);
+ onPickerClose?.();
};
const canClear = isClearable && Boolean(value);
@@ -266,6 +273,7 @@ export const ModelSelect = ({
return (
<Box className={className} minW="0" w="full">
<Popover.Root
+ initialFocusEl={() => contentRef.current?.querySelector<HTMLInputElement>('input[role="combobox"]') ?? null}
ids={id ? { trigger: id } : undefined}
// Like Select: closed pickers hold no list, virtualizer or observers, and each open starts a fresh search.
lazyMount
@@ -287,6 +295,9 @@ export const ModelSelect = ({
}
setIsOpen(event.open);
+ if (!event.open) {
+ onPickerClose?.();
+ }
}}
>
<Box minW="0" position="relative" w="full">
@@ -365,6 +376,7 @@ export const ModelSelect = ({
<Portal>
<Popover.Positioner>
<PopoverContent
+ ref={contentRef}
aria-label={listLabel}
css={dropdownContent}
maxH="min(24rem, var(--available-height))"
@@ -374,6 +386,7 @@ export const ModelSelect = ({
p="0"
showArrow={false}
>
+ {pickerHeader}
<Picker<ModelConfig>
emptyMessage={emptyMessage}
getOptionId={getOptionId}
diff --git a/invokeai/frontend/webv2/src/features/video/core/graph.test.ts b/invokeai/frontend/webv2/src/features/video/core/graph.test.ts
index 2a43728ab2..4a9c025bb3 100644
--- a/invokeai/frontend/webv2/src/features/video/core/graph.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/graph.test.ts
@@ -265,6 +265,15 @@ describe('compileVideoGraph — MiniMax H3 Ref2VA', () => {
],
});
+ it('passes an explicit override only for an overridden job', () => {
+ const catalogModel = { ...model, variant: 'fl2va' };
+ const { backendGraph } = compileVideoGraph({ ...referenceSettings, h3TaskOverride: 'ref2va' }, catalogModel);
+ expect(nodeOfType(backendGraph, 'minimax_h3_model_loader').transformer_model).toMatchObject({ variant: 'fl2va' });
+ expect(nodeOfType(backendGraph, 'minimax_h3_model_loader').task_variant_override).toBe('ref2va');
+ const baseline = compileVideoGraph(referenceSettings, model);
+ expect(nodeOfType(baseline.backendGraph, 'minimax_h3_model_loader').task_variant_override).toBeUndefined();
+ });
+
it('builds the reference graph: ordered chained collect into conditioning AND prompt, no frame conditioning', () => {
const { backendGraph } = compileVideoGraph(referenceSettings, model);
@@ -314,53 +323,83 @@ describe('compileVideoGraph — MiniMax H3 Ref2VA', () => {
]);
});
- it('hybrid: loads the FL2VA base, overlays the Ref2VA main from the start block, and records both', () => {
- const fl2vaBase: MainModelConfig = {
- base: 'minimax-h3',
- format: 'checkpoint',
- key: 'h3-fl2va-ckpt',
- name: 'MiniMax H3 FL2VA Transformer (int8, pruned)',
- type: 'main',
- variant: 'fl2va',
- };
- const turbo = {
- base: 'minimax-h3',
- key: 'ref2v-turbo',
- name: 'MiniMax H3 Ref2V Turbo LoRA',
- type: 'lora' as const,
- };
+ it.each([undefined, 'ref2va'] as const)(
+ 'hybrid: loads, overlays and records a Ref2VA main with override %s',
+ (h3TaskOverride) => {
+ const fl2vaBase: MainModelConfig = {
+ base: 'minimax-h3',
+ format: 'checkpoint',
+ key: 'h3-fl2va-ckpt',
+ name: 'MiniMax H3 FL2VA Transformer (int8, pruned)',
+ type: 'main',
+ variant: 'fl2va',
+ };
+ const turbo = {
+ base: 'minimax-h3',
+ key: 'ref2v-turbo',
+ name: 'MiniMax H3 Ref2V Turbo LoRA',
+ type: 'lora' as const,
+ };
+ const settings: VideoSettings = {
+ ...referenceSettings,
+ h3TaskOverride,
+ h3HybridBaseModel: fl2vaBase,
+ h3HybridStartBlock: 30,
+ loras: [{ isEnabled: true, model: turbo, weight: 1 }],
+ };
+ const { backendGraph } = compileVideoGraph(settings, model);
+
+ // The loader loads the FL2VA base; the selected Ref2VA main becomes the overlay.
+ expect(nodeOfType(backendGraph, 'minimax_h3_model_loader')).toMatchObject({
+ model: { key: componentSource.key },
+ transformer_model: { key: fl2vaBase.key },
+ });
+ expect(nodeOfType(backendGraph, 'minimax_h3_hybrid_overlay')).toMatchObject({
+ end_block: 49,
+ id: 'hybrid_overlay',
+ include_final_layer: false,
+ overlay_model: { key: model.key },
+ start_block: 30,
+ });
+ expect(hasEdge(backendGraph, 'model_loader', 'transformer', 'hybrid_overlay', 'transformer')).toBe(true);
+
+ // LoRAs apply on top of the hybrid, and the denoise reads the LoRA-patched hybrid.
+ const loraLoader = nodeOfType(backendGraph, 'minimax_h3_lora_collection_loader');
+
+ expect(hasEdge(backendGraph, 'hybrid_overlay', 'transformer', loraLoader.id, 'transformer')).toBe(true);
+ expect(hasEdge(backendGraph, loraLoader.id, 'transformer', 'denoise_latents', 'transformer')).toBe(true);
+ expect(hasEdge(backendGraph, 'model_loader', 'transformer', 'denoise_latents', 'transformer')).toBe(false);
+
+ // Metadata keeps the Ref2VA main as the model and records the hybrid for recall.
+ expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({
+ minimax_h3_hybrid_base_model: { key: fl2vaBase.key },
+ minimax_h3_hybrid_start_block: 30,
+ model: { key: model.key },
+ });
+ }
+ );
+
+ it.each([
+ ['fl2va', undefined],
+ ['fl2va', 'ref2va'],
+ ['ref2va', 'fl2va'],
+ ] as const)('hybrid: ignores a stale quality base for catalog %s with override %s', (variant, h3TaskOverride) => {
+ const fl2vaMain: MainModelConfig = { ...h3Model('h3-fl2va-main'), format: 'checkpoint', variant };
const settings: VideoSettings = {
- ...referenceSettings,
- h3HybridBaseModel: fl2vaBase,
- h3HybridStartBlock: 30,
- loras: [{ isEnabled: true, model: turbo, weight: 1 }],
+ ...settingsFor(fl2vaMain, { componentSourceModel: componentSource }),
+ h3TaskOverride,
+ references: h3TaskOverride === 'ref2va' ? referenceSettings.references : [],
+ h3HybridBaseModel: { ...h3Model('h3-other-fl2va'), format: 'checkpoint' },
+ h3HybridStartBlock: 10,
};
- const { backendGraph } = compileVideoGraph(settings, model);
+ const { backendGraph } = compileVideoGraph(settings, fl2vaMain);
+ expect(nodesOfType(backendGraph, 'minimax_h3_hybrid_overlay')).toHaveLength(0);
expect(nodeOfType(backendGraph, 'minimax_h3_model_loader')).toMatchObject({
- model: { key: componentSource.key },
- transformer_model: { key: fl2vaBase.key },
- });
- expect(nodeOfType(backendGraph, 'minimax_h3_hybrid_overlay')).toMatchObject({
- end_block: 49,
- id: 'hybrid_overlay',
- include_final_layer: false,
- overlay_model: { key: model.key },
- start_block: 30,
- });
- expect(hasEdge(backendGraph, 'model_loader', 'transformer', 'hybrid_overlay', 'transformer')).toBe(true);
-
- const loraLoader = nodeOfType(backendGraph, 'minimax_h3_lora_collection_loader');
-
- expect(hasEdge(backendGraph, 'hybrid_overlay', 'transformer', loraLoader.id, 'transformer')).toBe(true);
- expect(hasEdge(backendGraph, loraLoader.id, 'transformer', 'denoise_latents', 'transformer')).toBe(true);
- expect(hasEdge(backendGraph, 'model_loader', 'transformer', 'denoise_latents', 'transformer')).toBe(false);
-
- expect(nodeOfType(backendGraph, 'core_metadata')).toMatchObject({
- minimax_h3_hybrid_base_model: { key: fl2vaBase.key },
- minimax_h3_hybrid_start_block: 30,
- model: { key: model.key },
+ transformer_model: { key: fl2vaMain.key },
});
+ expect(hasEdge(backendGraph, 'model_loader', 'transformer', 'denoise_latents', 'transformer')).toBe(true);
+ expect(nodeOfType(backendGraph, 'core_metadata').minimax_h3_hybrid_base_model).toBeUndefined();
});
it('reference-extend: appends the new clip to the initial video without frame conditioning', () => {
diff --git a/invokeai/frontend/webv2/src/features/video/core/graph.ts b/invokeai/frontend/webv2/src/features/video/core/graph.ts
index 2c4c59dc18..b57a446623 100644
--- a/invokeai/frontend/webv2/src/features/video/core/graph.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/graph.ts
@@ -28,6 +28,7 @@ import type { SupportedVideoBase } from './videoPolicies';
import { getLtx2StageCanvases, isLtx2TwoStage, MINIMAX_H3_FPS } from './dimensions';
import { MINIMAX_H3_HYBRID_BLOCK_RANGE, resolveVideoMode } from './settings';
import {
+ getEffectiveVideoModel,
getEffectiveVideoTiming,
getVideoDimensions,
getVideoModelPolicy,
@@ -424,7 +425,8 @@ const buildWanVideoGraph = (settings: VideoSettings, model: MainModelConfig): Ba
return graph;
};
-const buildMiniMaxH3VideoGraph = (settings: VideoSettings, model: MainModelConfig): BackendGraphContract => {
+const buildMiniMaxH3VideoGraph = (settings: VideoSettings, catalogModel: MainModelConfig): BackendGraphContract => {
+ const model = getEffectiveVideoModel(catalogModel, settings);
const mode = resolveVideoMode(settings);
const dimensions = getVideoDimensions(model, settings);
@@ -440,8 +442,12 @@ const buildMiniMaxH3VideoGraph = (settings: VideoSettings, model: MainModelConfi
throw new Error('A single-file MiniMax H3 transformer needs a Diffusers install selected under Model Components.');
}
- // Guard stale settings so an unsupported main cannot silently load the hybrid's wrong file.
- const hybridBase = isSingleFileMain && model.variant === 'ref2va' ? settings.h3HybridBaseModel : null;
+ // Hybrid loading overlays Ref2VA AdaLN blocks onto FL2VA; guard stale settings so unsupported mains cannot
+ // silently load the wrong file.
+ const hybridBase =
+ isSingleFileMain && catalogModel.variant === 'ref2va' && model.variant === 'ref2va'
+ ? settings.h3HybridBaseModel
+ : null;
const graph: BackendGraphContract = { edges: [], id: createId('minimax_h3_video_graph'), nodes: {} };
const { positivePrompt, seed } = addPromptAndSeedNodes(graph);
@@ -449,7 +455,8 @@ const buildMiniMaxH3VideoGraph = (settings: VideoSettings, model: MainModelConfi
id: 'model_loader',
model: componentSource ?? model,
text_encoder_model: settings.h3TextEncoderModel ?? undefined,
- transformer_model: isSingleFileMain ? (hybridBase ?? model) : undefined,
+ task_variant_override: model.variant !== catalogModel.variant ? model.variant : undefined,
+ transformer_model: isSingleFileMain ? (hybridBase ?? catalogModel) : undefined,
type: 'minimax_h3_model_loader',
});
let transformerSource: BackendInvocationContract = modelLoader;
diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
index 94790dfd4d..b30a588a25 100644
--- a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
@@ -49,6 +49,32 @@ const createSettings = (overrides: Partial<VideoSettings> = {}): VideoSettings =
...overrides,
});
+describe('H3 task override normalization', () => {
+ it.each([undefined, 'fl2va', 'ref2va'] as const)(
+ 'preserves explicit intent %s without rewriting the catalog model',
+ (h3TaskOverride) => {
+ const model = {
+ base: 'minimax-h3',
+ format: 'checkpoint',
+ type: 'main' as const,
+ key: 'h3',
+ name: 'H3',
+ variant: 'fl2va',
+ };
+ const values = { ...createSettings({ h3TaskOverride }), model };
+ expect(isVideoSettings(values)).toBe(true);
+ expect(normalizeVideoWidgetValues(values)).toMatchObject({ model, h3TaskOverride });
+ expect(normalizeVideoWidgetValues(values)?.model).toBe(model);
+ }
+ );
+
+ it('rejects invalid overrides as canonical and normalizes them to Detected', () => {
+ const values = { ...createSettings(), h3TaskOverride: 'unknown' };
+ expect(isVideoSettings(values)).toBe(false);
+ expect(normalizeVideoSettings(values)?.h3TaskOverride).toBeUndefined();
+ });
+});
+
describe('resolveVideoMode', () => {
it('infers the mode from which inputs are filled', () => {
expect(resolveVideoMode(createSettings())).toBe('txt2vid');
diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.ts b/invokeai/frontend/webv2/src/features/video/core/settings.ts
index 25b15dd2e4..6562eda695 100644
--- a/invokeai/frontend/webv2/src/features/video/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.ts
@@ -353,6 +353,8 @@ export const normalizeVideoSettings = (values: unknown): VideoSettings | null =>
stgScale: hasFiniteNumber(values, 'stgScale') ? (values.stgScale as number) : null,
firstFrameImage,
fps: hasFiniteNumber(values, 'fps') ? (values.fps as number) : SETTINGS_FALLBACKS.fps,
+ h3TaskOverride:
+ values.h3TaskOverride === 'fl2va' || values.h3TaskOverride === 'ref2va' ? values.h3TaskOverride : undefined,
h3HybridBaseModel: isMainModelConfig(values.h3HybridBaseModel) ? values.h3HybridBaseModel : null,
h3HybridStartBlock: Math.round(
getClampedNumber(
@@ -431,6 +433,7 @@ export const isVideoSettings = (values: unknown): values is VideoSettings => {
// Strict only over the keys normalize would have to invent.
return (
+ values.h3TaskOverride === normalized.h3TaskOverride &&
isSeedMode(values.seedMode) &&
isVideoAspectRatioId(values.aspectRatioId) &&
isVideoTargetResolution(values.targetResolution) &&
diff --git a/invokeai/frontend/webv2/src/features/video/core/types.ts b/invokeai/frontend/webv2/src/features/video/core/types.ts
index 3b40d11dd6..ccc9178136 100644
--- a/invokeai/frontend/webv2/src/features/video/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/types.ts
@@ -132,6 +132,8 @@ export interface VideoSettings extends DynamicPromptsSettings {
ltx2DurationHeadModel: ModelIdentifierConfig | null;
/** Healed against the head only, not the transient mode, or a source clip round trip would lose it. */
autoDuration: boolean;
+ /** Explicit checkpoint task choice; absent follows the catalog classification. */
+ h3TaskOverride?: 'fl2va' | 'ref2va';
/** Hybrid: FL2VA base weights with Ref2VA AdaLN from h3HybridStartBlock onward. */
h3HybridBaseModel: MainModelConfig | null;
/** First transformer block (0-49) whose AdaLN projection stays Ref2VA's under the hybrid. */
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
index 0d9119fa96..9391c72ccf 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
@@ -10,7 +10,9 @@ import {
findMiniMaxH3TurboLora,
findWanLightningLoraPair,
getAcceleratorToggleResult,
+ getH3ModeSwitchSettings,
getDefaultVideoSettings,
+ getVideoSettingsWithModelDefaults,
getEffectiveVideoTiming,
getVideoComponentSectionPolicy,
getVideoDimensions,
@@ -1024,6 +1026,95 @@ describe('what a model switch discards', () => {
});
});
+describe('H3 picker preselection', () => {
+ it('reset clears the override and restores detected-task Turbo without losing prompt or user LoRAs', () => {
+ const model = h3Model('checkpoint', 'hybrid');
+ const turbo = { base: 'minimax-h3', key: 'turbo-fl', name: 'MiniMax H3 Turbo LoRA', type: 'lora' as const };
+ const refTurbo = { ...turbo, key: 'turbo-ref', name: 'MiniMax H3 Ref2V Turbo LoRA' };
+ const style = { ...turbo, key: 'style', name: 'Ink wash' };
+ const models = [model, turbo, refTurbo, style];
+ const initial = {
+ ...getDefaultVideoSettings(model),
+ positivePrompt: 'keep me',
+ loras: [{ model: style, weight: 0.7, isEnabled: true }],
+ h3TaskOverride: 'ref2va' as const,
+ };
+ const accelerated = getAcceleratorToggleResult(initial, model, models, true).settings;
+ expect(accelerated.acceleratorLoraKeys).toEqual([refTurbo.key]);
+ const reset = getVideoSettingsWithModelDefaults(accelerated, model, models);
+ expect(reset.h3TaskOverride).toBeUndefined();
+ expect(reset.acceleratorLoraKeys).toEqual([turbo.key]);
+ expect(reset.positivePrompt).toBe('keep me');
+ expect(reset.loras).toContainEqual(initial.loras[0]);
+ expect(reset.loras.some((entry) => entry.model.key === refTurbo.key)).toBe(false);
+ });
+
+ it.each(['fl2va', 'ref2va'])('restores normal sampling after switching a Turbo %s task', (variant) => {
+ const model: MainModelConfig = { ...h3Model('checkpoint', `h3-${variant}`), variant };
+ const owned = {
+ model: { base: 'minimax-h3', key: 'turbo', name: 'Turbo', type: 'lora' as const },
+ weight: 1,
+ isEnabled: true,
+ };
+ const settings = {
+ ...getDefaultVideoSettings(model),
+ acceleratorEnabled: true,
+ acceleratorLoraKeys: ['turbo'],
+ loras: [owned],
+ steps: 8,
+ };
+ const switched = getH3ModeSwitchSettings(settings, model, [model, owned.model], true);
+ expect(switched).toMatchObject({
+ acceleratorEnabled: false,
+ acceleratorLoraKeys: [],
+ loras: [],
+ steps: 50,
+ h3TaskOverride: variant === 'ref2va' ? 'fl2va' : 'ref2va',
+ });
+ });
+
+ it('preserves three references when a detected-FL2VA hybrid is selected as Ref2VA', () => {
+ const previous: MainModelConfig = { ...h3Model('checkpoint', 'old-ref'), variant: 'ref2va' };
+ const candidate: MainModelConfig = { ...h3Model('checkpoint', 'hybrid'), variant: 'fl2va' };
+ const references = [1, 2, 3].map((n) => ({
+ kind: 'image' as const,
+ detail: 'match' as const,
+ image: { image_name: `ref${n}.png`, width: 512, height: 512 },
+ }));
+ const settings = { ...getDefaultVideoSettings(previous), references };
+ const switched = getVideoModelSelectionResult({
+ currentSettings: settings,
+ model: candidate,
+ h3TaskOverride: 'ref2va',
+ models: [previous, candidate],
+ });
+ expect(switched.settings.references).toEqual(references);
+ expect(switched.losses.some((loss) => loss.key === 'references')).toBe(false);
+ const defaultSwitch = getVideoModelSelectionResult({
+ currentSettings: settings,
+ model: candidate,
+ models: [previous, candidate],
+ });
+ expect(defaultSwitch.losses.some((loss) => loss.key === 'references')).toBe(true);
+ });
+
+ it('reports a selected overlay as lost before applying a task override', () => {
+ const previous: MainModelConfig = { ...h3Model('checkpoint', 'old-ref'), variant: 'ref2va', pruned: true };
+ const target: MainModelConfig = { ...h3Model('checkpoint', 'hybrid'), variant: 'fl2va', pruned: true };
+ const base: MainModelConfig = { ...h3Model('checkpoint', 'quality-base'), variant: 'fl2va', pruned: true };
+ const settings = { ...getDefaultVideoSettings(previous), h3HybridBaseModel: base };
+ const result = getVideoModelSelectionResult({
+ currentSettings: settings,
+ model: target,
+ models: [previous, target, base],
+ h3TaskOverride: 'ref2va',
+ });
+ expect(result.settings.h3TaskOverride).toBe('ref2va');
+ expect(result.settings.h3HybridBaseModel).toBeNull();
+ expect(result.losses).toContainEqual({ key: 'h3HybridBaseModel', count: 1 });
+ });
+});
+
describe('the Video sections an issue is fixed from', () => {
const t2v = wanModel('t2v_a14b', 'diffusers');
const i2v = wanModel('i2v_a14b', 'diffusers');
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
index e2eda25040..857f330eb6 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
@@ -78,6 +78,18 @@ import {
export type SupportedVideoBase = 'wan' | 'minimax-h3' | 'ltx-2';
+/** Catalog records stay untouched; only task-dependent consumers use this derived model. */
+export const getEffectiveVideoModel = <T extends MainModelConfig | undefined | null>(
+ model: T,
+ settings: Pick<VideoSettings, 'h3TaskOverride'>
+): T => {
+ if (model?.base !== 'minimax-h3' || model.format !== 'checkpoint') {
+ return model;
+ }
+ const variant = settings.h3TaskOverride ?? (model.variant === 'ref2va' ? 'ref2va' : 'fl2va');
+ return (variant === model.variant ? model : { ...model, variant }) as T;
+};
+
export type VideoNegativePromptUsage = 'always' | 'cfg-gated' | 'never';
export interface VideoTargetResolutionOption {
@@ -499,9 +511,16 @@ export const getVideoDimensions = (
model: MainModelConfig | undefined,
settings: Pick<
VideoSettings,
- 'aspectRatioId' | 'targetResolution' | 'firstFrameImage' | 'lastFrameImage' | 'sourceVideo' | 'conditioningClip'
+ | 'aspectRatioId'
+ | 'targetResolution'
+ | 'firstFrameImage'
+ | 'lastFrameImage'
+ | 'sourceVideo'
+ | 'conditioningClip'
+ | 'h3TaskOverride'
>
): ResolvedVideoDimensions | null => {
+ model = getEffectiveVideoModel(model, settings);
const config = getVideoConfig(model);
const targetResolution = coerceTargetResolution(config, settings.targetResolution);
@@ -744,6 +763,7 @@ export const getAutoDurationBounds = (
};
export const getVideoModelPolicy = (model: MainModelConfig | undefined, settings: VideoSettings): VideoModelPolicy => {
+ model = getEffectiveVideoModel(model, settings);
const config = getVideoConfig(model);
const guidanceDistilled = isGuidanceDistilled(config, settings);
// Only for LTX-2 extend with a source picked: the ceiling is the source's.
@@ -1033,6 +1053,7 @@ export const getAcceleratorToggleResult = (
models: readonly ModelConfig[],
enabled: boolean
): AcceleratorToggleResult => {
+ model = getEffectiveVideoModel(model, settings);
const config = getVideoConfig(model);
// Remove only the entries the previous toggle added, never a user's own Lightning-style LoRA.
const previousKeys = new Set(settings.acceleratorLoraKeys);
@@ -1094,6 +1115,19 @@ export const getAcceleratorToggleResult = (
};
};
+/** Switch H3 tasks without leaving Turbo's sampling recipe behind when its adapter is removed. */
+export const getH3ModeSwitchSettings = (
+ settings: VideoSettings,
+ model: MainModelConfig,
+ models: readonly ModelConfig[],
+ override: boolean
+): VideoSettings => {
+ const detected = getEffectiveVideoModel(model, {}).variant;
+ const h3TaskOverride = override ? (detected === 'ref2va' ? 'fl2va' : 'ref2va') : undefined;
+ const next: VideoSettings = { ...settings, h3TaskOverride };
+ return settings.acceleratorEnabled ? getAcceleratorToggleResult(next, model, models, false).settings : next;
+};
+
export type AcceleratorLoraChangeOutcome = 'unchanged' | 'switched' | 'disabled';
export interface AcceleratorLoraChangeResult {
@@ -1110,6 +1144,7 @@ export const getAcceleratorLoraChangeResult = (
models: readonly ModelConfig[],
loras: GenerateLora[]
): AcceleratorLoraChangeResult => {
+ model = getEffectiveVideoModel(model, settings);
const config = getVideoConfig(model);
const next: VideoSettings = { ...settings, loras };
@@ -1432,8 +1467,9 @@ export const getVideoComponentSectionPolicy = (
required: (ctx) => !isH3TextEncoderSatisfied(ctx),
valueKind: 'component',
},
- // The hybrid replaces non-AdaLN weights with an FL2VA base while retaining Ref2VA task identity and projections.
- ...(model.variant === 'ref2va'
+ // The hybrid replaces non-AdaLN weights with an FL2VA base while retaining Ref2VA task identity and
+ // projections.
+ ...(model.variant === 'ref2va' && getEffectiveVideoModel(model, _settings).variant === 'ref2va'
? [
{
filter: isH3HybridBaseCandidate,
@@ -1592,6 +1628,7 @@ export const getDefaultVideoSettings = (
: null,
firstFrameImage: null,
fps: config.fps.defaultValue,
+ h3TaskOverride: undefined,
h3HybridBaseModel: null,
h3HybridStartBlock: MINIMAX_H3_HYBRID_BLOCK_RANGE.defaultStart,
h3TextEncoderModel: null,
@@ -1651,6 +1688,7 @@ export const getVideoSettingsWithModelDefaults = (
cfgScaleLowNoise: modelDefaults.cfgScaleLowNoise,
componentSourceModel: modelDefaults.componentSourceModel,
fps: modelDefaults.fps,
+ h3TaskOverride: undefined,
h3HybridBaseModel: modelDefaults.h3HybridBaseModel,
h3HybridStartBlock: modelDefaults.h3HybridStartBlock,
h3TextEncoderModel: modelDefaults.h3TextEncoderModel,
@@ -1713,22 +1751,35 @@ export const getVideoModelSelectionResult = ({
currentSettings,
model,
models,
+ h3TaskOverride,
}: {
currentSettings: VideoSettings;
model: MainModelConfig;
models: readonly ModelConfig[];
+ /** Task override for the incoming H3 model, applied before the loss preview. */
+ h3TaskOverride?: VideoSettings['h3TaskOverride'];
}): VideoModelSelectionResult => {
+ const catalogModel = model;
+ h3TaskOverride = model.base === 'minimax-h3' && model.format === 'checkpoint' ? h3TaskOverride : undefined;
+ model = getEffectiveVideoModel(model, { h3TaskOverride });
const config = getVideoConfig(model);
// No modelKey means healing defaults, not user choices: bootstrap the model's defaults first.
const start = currentSettings.modelKey
? currentSettings
: getVideoSettingsWithModelDefaults(currentSettings, model, models);
- const next: VideoSettings = { ...start, modelKey: model.key };
+ const next: VideoSettings = {
+ ...start,
+ modelKey: model.key,
+ h3TaskOverride,
+ };
const losses: VideoModelSwitchLoss[] = [];
const adjustments = new Set<VideoModelSwitchAdjustment>();
const modes = config.modes;
const previousModel = models.find((entry) => entry.key === currentSettings.modelKey);
- const previousConfig = previousModel && isSupportedVideoModel(previousModel) ? getVideoConfig(previousModel) : null;
+ const previousConfig =
+ previousModel && isSupportedVideoModel(previousModel)
+ ? getVideoConfig(getEffectiveVideoModel(previousModel, currentSettings))
+ : null;
if (next.references.length > 0 && !modes.includes('reference')) {
// An untouched Initial Video anchor is re-derived on the way back; a set trim or conditioning on it is not.
@@ -1887,7 +1938,7 @@ export const getVideoModelSelectionResult = ({
// Concepts stay, as in Generate: the graph loads only compatible ones (`getActiveCompatibleLoras`).
- const policy = getVideoComponentSectionPolicy(model, next);
+ const policy = getVideoComponentSectionPolicy(catalogModel, next);
const slotsByKey = new Map(policy.slots.map((slotPolicy) => [slotPolicy.key, slotPolicy]));
// A component the previous model seeds again on the way back is not a loss.
let previousSeeds: VideoSettings | null | undefined;
@@ -2108,6 +2159,8 @@ export const getVideoModelAvailabilityIssues = (
/** Why Video cannot run with this model, each with the controls that fix it, in the order Invoke lists them. */
export const getVideoValidationIssues = (model: MainModelConfig, settings: VideoSettings): VideoValidationIssue[] => {
+ const catalogModel = model;
+ model = getEffectiveVideoModel(model, settings);
// The model picker fixes these, and it sits in no section.
if (!isSupportedVideoModel(model)) {
return [{ message: 'Video needs a supported video model before it can be invoked.', fields: [] }];
@@ -2431,7 +2484,7 @@ export const getVideoValidationIssues = (model: MainModelConfig, settings: Video
});
}
- const componentPolicy = getVideoComponentSectionPolicy(model, settings);
+ const componentPolicy = getVideoComponentSectionPolicy(catalogModel, settings);
issues.push(
...componentPolicy
.validate(getVideoComponentPolicyContext(model, settings))
diff --git a/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.ts b/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.ts
index fdae36947c..8cd2de702d 100644
--- a/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.ts
@@ -2,8 +2,14 @@ import type { GenerationModelCatalogItem, MainModelConfig } from '@features/gene
import { describe, expect, it } from 'vitest';
+import { compileVideoGraph } from './graph';
import { normalizeVideoWidgetValues } from './settings';
-import { getAcceleratorToggleResult } from './videoPolicies';
+import {
+ getAcceleratorToggleResult,
+ getVideoModelPolicy,
+ getVideoComponentSectionPolicy,
+ getVideoModelSelectionResult,
+} from './videoPolicies';
import {
createDefaultVideoWidgetValues,
getVideoWidgetValidationReasons,
@@ -62,6 +68,106 @@ describe('createDefaultVideoWidgetValues', () => {
});
describe('syncVideoWidgetValuesWithModels', () => {
+ it.each([
+ ['ref2va', undefined, true],
+ ['ref2va', 'ref2va', true],
+ ['fl2va', 'ref2va', false],
+ ['ref2va', 'fl2va', false],
+ ['fl2va', undefined, false],
+ ] as const)(
+ 'hybrid eligibility survives restore, sync and selection: catalog %s, override %s',
+ (variant, h3TaskOverride, eligible) => {
+ const checkpoint = { ...h3Model('checkpoint', 'main'), variant };
+ const component = h3Model();
+ const hybrid = h3Model('checkpoint', 'quality-base');
+ const catalog = [checkpoint, component, hybrid];
+ const values = {
+ ...createDefaultVideoWidgetValues(catalog),
+ h3TaskOverride,
+ h3HybridBaseModel: hybrid,
+ h3HybridStartBlock: 30,
+ };
+ const restored = normalizeVideoWidgetValues(JSON.parse(JSON.stringify(values)))!;
+ expect(restored.h3TaskOverride).toBe(h3TaskOverride);
+ expect(restored.h3HybridBaseModel).toEqual(hybrid);
+ expect(
+ getVideoComponentSectionPolicy(checkpoint, restored).slots.some((slot) => slot.key === 'h3HybridBaseModel')
+ ).toBe(eligible);
+ const synced = syncVideoWidgetValuesWithModels(restored, catalog);
+ expect(synced.h3HybridBaseModel).toBe(eligible ? hybrid : null);
+ expect(synced.h3HybridStartBlock).toBe(30);
+ expect(syncVideoWidgetValuesWithModels(synced, catalog)).toBe(synced);
+ const selected = getVideoModelSelectionResult({
+ currentSettings: restored,
+ model: checkpoint,
+ models: catalog,
+ h3TaskOverride,
+ });
+ expect(selected.settings.h3HybridBaseModel).toEqual(eligible ? hybrid : null);
+ expect(selected.losses.filter((loss) => loss.key === 'h3HybridBaseModel')).toEqual(
+ eligible ? [] : [{ count: 1, key: 'h3HybridBaseModel' }]
+ );
+ expect(selected.settings.h3TaskOverride).toBe(h3TaskOverride);
+ }
+ );
+
+ it.each([
+ ['fl2va', 'ref2va', true],
+ ['fl2va', 'ref2va', false],
+ ['ref2va', 'fl2va', true],
+ ['ref2va', 'fl2va', false],
+ ] as const)(
+ 'reconciles task-specific Turbo on a detected %s → %s reclassification (replacement installed: %s)',
+ (from, to, installed) => {
+ const checkpoint = { ...h3Model('checkpoint', 'stable'), variant: from };
+ const component = h3Model();
+ const flTurbo = lora('MiniMax H3 Turbo LoRA', 'minimax-h3', null);
+ const refTurbo = lora('MiniMax H3 Ref2V Turbo LoRA', 'minimax-h3', null);
+ const frame = { image_name: 'keep.png', width: 512, height: 512 };
+ const values = {
+ ...createDefaultVideoWidgetValues([checkpoint, component, flTurbo, refTurbo]),
+ firstFrameImage: frame,
+ };
+ const reclassified = { ...checkpoint, variant: to };
+ const originalTurbo = from === 'fl2va' ? flTurbo : refTurbo;
+ const replacementTurbo = to === 'fl2va' ? flTurbo : refTurbo;
+ const catalog = [reclassified, component, originalTurbo, ...(installed ? [replacementTurbo] : [])];
+ const after = syncVideoWidgetValuesWithModels(values, catalog);
+ expect(after.h3TaskOverride).toBeUndefined();
+ expect(after.model).toBe(reclassified);
+ expect(after.acceleratorEnabled).toBe(installed);
+ expect(after.acceleratorLoraKeys).toEqual(installed ? [replacementTurbo.key] : []);
+ expect(after.loras.map((entry) => entry.model.key)).toEqual(installed ? [replacementTurbo.key] : []);
+ expect(after.firstFrameImage).toBe(frame);
+ expect(after.steps).toBe(installed ? (to === 'fl2va' ? 6 : 4) : 50);
+ expect(syncVideoWidgetValuesWithModels(after, catalog)).toBe(after);
+ }
+ );
+
+ it('Detected follows same-key catalog reclassification without creating an override', () => {
+ const checkpoint = h3Model('checkpoint', 'stable');
+ const component = h3Model('diffusers', 'components');
+ const detected = syncVideoWidgetValuesWithModels(createDefaultVideoWidgetValues([checkpoint, component]), [
+ checkpoint,
+ component,
+ ]);
+ const reclassified = { ...checkpoint, variant: 'ref2va' };
+ const after = syncVideoWidgetValuesWithModels(detected, [reclassified, component]);
+ expect(after.model).toEqual(reclassified);
+ expect(after.h3TaskOverride).toBeUndefined();
+ expect(getVideoModelPolicy(after.model!, after).modes).toEqual(['reference']);
+ expect(
+ getVideoComponentSectionPolicy(after.model!, after).slots.some((slot) => slot.key === 'h3HybridBaseModel')
+ ).toBe(true);
+ const graph = compileVideoGraph(
+ {
+ ...after,
+ references: [{ kind: 'image', detail: 'match', image: { image_name: 'ref.png', width: 512, height: 512 } }],
+ },
+ after.model!
+ ).backendGraph;
+ expect(graph.nodes.model_loader?.task_variant_override).toBeUndefined();
+ });
const model = wanModel('i2v_a14b', 'gguf_quantized');
it('promotes a legacy transformer override to the top model slot', () => {
@@ -258,3 +364,121 @@ describe('resolveVideoSeed', () => {
expect(randomized).toBeGreaterThanOrEqual(0);
});
});
+
+describe('H3 per-job mode override', () => {
+ it('uses the opposite effective variant without changing the catalog and resets on model replacement', () => {
+ const checkpoint = h3Model('checkpoint', 'hybrid');
+ const other = h3Model('checkpoint', 'other');
+ const source = h3Model();
+ const catalog = [checkpoint, source];
+ const base = createDefaultVideoWidgetValues(catalog);
+ const changed = syncVideoWidgetValuesWithModels(
+ {
+ ...base,
+ h3TaskOverride: 'ref2va',
+ references: [{ kind: 'image', detail: 'match', image: { image_name: 'r.png', width: 512, height: 512 } }],
+ },
+ catalog
+ );
+ expect(checkpoint.variant).toBe('fl2va');
+ expect(changed.model).toBe(checkpoint);
+ expect(changed.h3TaskOverride).toBe('ref2va');
+ expect(syncVideoWidgetValuesWithModels(changed, catalog)).toBe(changed);
+ const refreshed = syncVideoWidgetValuesWithModels(changed, [
+ { ...checkpoint, name: 'Renamed model', hash: 'newhash' },
+ source,
+ ]);
+ expect(refreshed.model).toMatchObject({ name: 'Renamed model', hash: 'newhash', variant: 'fl2va' });
+ const replaced = syncVideoWidgetValuesWithModels(changed, [other, source]);
+ expect(replaced.model?.key).toBe(other.key);
+ expect(replaced.model?.variant).toBe('fl2va');
+ expect(replaced.h3TaskOverride).toBeUndefined();
+ });
+});
+
+describe('H3 override queue readiness', () => {
+ it('validates persisted classified FL2VA as Ref2VA when override is selected', () => {
+ const model = h3Model('checkpoint', 'hybrid-readiness');
+ const component = h3Model('diffusers', 'h3-components');
+ const image = { image_name: 'reference.png', width: 512, height: 512 };
+ const values = {
+ ...createDefaultVideoWidgetValues([model, component]),
+ model,
+ h3TaskOverride: 'ref2va' as const,
+ componentSourceModel: component,
+ references: [{ kind: 'image' as const, detail: 'match' as const, image }],
+ };
+ const reasons = getVideoWidgetValidationReasons(values, [model, component]);
+ expect(reasons.some((reason) => reason.includes('does not support reference-conditioned generation'))).toBe(false);
+ const detectedReasons = getVideoWidgetValidationReasons({ ...values, h3TaskOverride: undefined }, [
+ model,
+ component,
+ ]);
+ expect(detectedReasons.some((reason) => reason.includes('does not support reference-conditioned generation'))).toBe(
+ true
+ );
+ });
+});
+
+describe('H3 explicit task persistence', () => {
+ it('reconciles deleted components and LoRAs without inferring intent from media', () => {
+ const model = h3Model('checkpoint');
+ const component = h3Model();
+ const style = { ...lora('deleted', 'minimax-h3', null), type: 'lora' as const };
+ const values = {
+ ...createDefaultVideoWidgetValues([model, component]),
+ h3TaskOverride: 'ref2va' as const,
+ loras: [{ model: style, weight: 1, isEnabled: true }],
+ references: [
+ {
+ kind: 'image' as const,
+ detail: 'match' as const,
+ image: { image_name: 'keep.png', width: 512, height: 512 },
+ },
+ ],
+ };
+ const result = syncVideoWidgetValuesWithModels(values, [model]);
+ expect(result.componentSourceModel).toBeNull();
+ expect(result.loras).toEqual([]);
+ expect(result.references).toEqual(values.references);
+ expect(result.h3TaskOverride).toBe('ref2va');
+ expect(result.model).toBe(model);
+ });
+
+ it('preserves references across same-key catalog reclassification', () => {
+ const model = h3Model('checkpoint', 'stable');
+ const component = h3Model();
+ const image = { image_name: 'reference.png', width: 512, height: 512 };
+ const values = syncVideoWidgetValuesWithModels(
+ {
+ ...createDefaultVideoWidgetValues([model, component]),
+ h3TaskOverride: 'ref2va',
+ references: [{ kind: 'image', detail: 'match', image }],
+ },
+ [model, component]
+ );
+ const reclassified = syncVideoWidgetValuesWithModels(values, [{ ...model, variant: 'ref2va' }, component]);
+ expect(reclassified.model?.variant).toBe('ref2va');
+ expect(reclassified.references).toEqual(values.references);
+ expect(reclassified.h3TaskOverride).toBe('ref2va');
+ const restored = normalizeVideoWidgetValues(JSON.parse(JSON.stringify(reclassified)))!;
+ expect(restored.model).toEqual(reclassified.model);
+ expect(restored.h3TaskOverride).toBe('ref2va');
+ });
+
+ it('does not invert an effective persisted model without a catalog', () => {
+ const model = { ...h3Model('checkpoint'), variant: 'ref2va' };
+ const values = {
+ ...createDefaultVideoWidgetValues([model]),
+ h3TaskOverride: 'ref2va' as const,
+ references: [
+ { kind: 'image' as const, detail: 'match' as const, image: { image_name: 'r.png', width: 512, height: 512 } },
+ ],
+ };
+ expect(
+ getVideoWidgetValidationReasons(values).some((reason) =>
+ reason.includes('does not support reference-conditioned generation')
+ )
+ ).toBe(false);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts b/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts
index 0dde5c375d..21f4116272 100644
--- a/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts
@@ -11,6 +11,8 @@ import type { VideoWidgetValues } from './types';
import {
getAcceleratorLoraChangeResult,
+ getAcceleratorToggleResult,
+ getEffectiveVideoModel,
getDefaultVideoSettings,
getVideoComponentSectionPolicy,
getVideoIssueSections,
@@ -64,20 +66,38 @@ export const syncVideoWidgetValuesWithModels = (
const modelsByKey = new Map(models.map((model) => [model.key, model]));
const storedMain = values.model ? modelsByKey.get(values.model.key) : undefined;
- // Preserve supported legacy nonselectable mains for repair guidance; automatic choices use the stricter selectable
- // filter.
- const model: MainModelConfig | null =
+ // Preserve supported legacy nonselectable mains for repair guidance; automatic choices use the stricter
+ // selectable filter.
+ const registered: MainModelConfig | null =
storedMain && isSupportedVideoModel(storedMain)
? storedMain
: ((models.find((candidate) => isVideoModelSelectable(candidate)) as MainModelConfig | undefined) ?? null);
+ const sameH3 =
+ registered?.base === 'minimax-h3' && registered.format === 'checkpoint' && registered.key === values.modelKey;
+ const model = registered;
- // Run canonical selection transitions after model replacement so family-specific fps, frames, and resolution cannot
- // remain stale.
- const base: VideoWidgetValues =
+ // Run canonical selection transitions after model replacement so family-specific fps, frames, and resolution
+ // cannot remain stale.
+ let base: VideoWidgetValues =
model && model.key !== values.model?.key
? { ...getVideoModelSelectionResult({ currentSettings: values, model, models }).settings, model }
: values;
+ // Catalog reclassification changes Detected's task, not user intent. Replace only toggle-owned Turbo
+ // adapters; retain media for validation instead of silently discarding it in a model-selection transition.
+ if (
+ sameH3 &&
+ base.acceleratorEnabled &&
+ model &&
+ getEffectiveVideoModel(values.model, values)?.variant !== getEffectiveVideoModel(model, base).variant
+ ) {
+ const enabled = getAcceleratorToggleResult(base, model, models, true);
+ base = {
+ ...base,
+ ...(enabled.missingLoras ? getAcceleratorToggleResult(base, model, models, false).settings : enabled.settings),
+ };
+ }
+
const componentPolicy = model ? getVideoComponentSectionPolicy(model, base) : null;
const slotsByKey = new Map(componentPolicy?.slots.map((slot) => [slot.key, slot]) ?? []);
const componentContext: VideoComponentPolicyContext | null = model
@@ -163,6 +183,7 @@ export const syncVideoWidgetValuesWithModels = (
ltx2TextEncoderModel: syncComponent('ltx2TextEncoderModel', base.ltx2TextEncoderModel),
model,
modelKey: model?.key ?? base.modelKey,
+ h3TaskOverride: sameH3 ? base.h3TaskOverride : undefined,
vae: syncComponent('vae', base.vae),
wanLowNoiseModel: syncComponent('wanLowNoiseModel', base.wanLowNoiseModel),
wanT5EncoderModel: syncComponent('wanT5EncoderModel', base.wanT5EncoderModel),
@@ -175,7 +196,7 @@ export const syncVideoWidgetValuesWithModels = (
}
// Drop orphaned references when the replacement model lacks reference mode, preserving identity otherwise.
- if (next.references.length > 0 && model && !getVideoModes(model).includes('reference')) {
+ if (next.references.length > 0 && model && !sameH3 && !getVideoModes(model).includes('reference')) {
next.references = [];
}
@@ -183,6 +204,7 @@ export const syncVideoWidgetValuesWithModels = (
base === values &&
next.model === values.model &&
next.modelKey === values.modelKey &&
+ next.h3TaskOverride === values.h3TaskOverride &&
next.acceleratorEnabled === values.acceleratorEnabled &&
next.acceleratorLoraKeys === values.acceleratorLoraKeys &&
next.vae === values.vae &&
@@ -212,10 +234,15 @@ export const getVideoWidgetValidationIssues = (
return [{ fields: [], message: 'Video needs a Wan 2.2, MiniMax H3 or LTX-2 main model.' }];
}
- const issues = getVideoValidationIssues(values.model, values);
+ // Readiness may receive the persisted (classified) record before the view's catalog sync.
+ // Resolve the same effective H3 task the graph compiler will use, without changing any media.
+ const registered = models?.find((item) => item.key === values.model?.key);
+ const source = registered && isSupportedVideoModel(registered) ? registered : values.model;
+ const effectiveModel = getEffectiveVideoModel(source, values);
+ const issues = getVideoValidationIssues(source, values);
if (models) {
- issues.push(...getVideoModelAvailabilityIssues(values.model, values, models));
+ issues.push(...getVideoModelAvailabilityIssues(effectiveModel, values, models));
}
return issues;
diff --git a/invokeai/frontend/webv2/src/features/video/index.ts b/invokeai/frontend/webv2/src/features/video/index.ts
index ca0373f28d..e6608cf5e5 100644
--- a/invokeai/frontend/webv2/src/features/video/index.ts
+++ b/invokeai/frontend/webv2/src/features/video/index.ts
@@ -74,6 +74,7 @@ export {
getAcceleratorSteps,
getAcceleratorToggleResult,
getDefaultVideoSettings,
+ getEffectiveVideoModel,
getVideoComponentSectionPolicy,
getVideoAspectRatioOptions,
getVideoDimensions,
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoModelField.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoModelField.tsx
index a0a35fa450..4d052a2894 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoModelField.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoModelField.tsx
@@ -1,4 +1,4 @@
-/* oxlint-disable react-perf/jsx-no-new-function-as-prop -- the React Compiler memoizes these handlers, as in GenerateModelCard. */
+/* oxlint-disable react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-jsx-as-prop -- the React Compiler memoizes these handlers and elements, as in GenerateModelCard. */
import type { MainModelConfig } from '@features/generation/contracts';
import type { ModelConfig, ModelTaxonomyType } from '@features/models';
import type { VideoWidgetValues } from '@features/video/core/types';
@@ -8,13 +8,14 @@ import type {
VideoModelSwitchLossKey,
} from '@features/video/core/videoPolicies';
-import { Box, Text } from '@chakra-ui/react';
+import { Box, HStack, Text } from '@chakra-ui/react';
import { isMainModelConfig } from '@features/generation/settings';
import { ModelSelect, useHasModelPickerCandidates } from '@features/models/react';
import { getVideoModelSelectionResult, isVideoModelSelectable } from '@features/video/core/videoPolicies';
import { syncVideoWidgetValuesWithModels } from '@features/video/core/widgetValues';
import { flushWorkbenchDrafts } from '@platform/react/draftRegistry';
import { Field } from '@platform/ui';
+import { Button } from '@platform/ui/Button';
import { ConfirmDialog } from '@platform/ui/ConfirmDialog';
import { toaster } from '@platform/ui/toaster';
import { useRef, useState } from 'react';
@@ -82,7 +83,18 @@ export const VideoModelField = ({
// The picker keeps its default id, which keys its remembered view and base filter; focus returns through this.
const pickerRef = useRef<HTMLDivElement>(null);
// Retain only the target and its project; the dialog previews, and confirmation applies, against live settings.
- const [pendingSwitch, setPendingSwitch] = useState<{ modelKey: string; projectId: string } | null>(null);
+ const [loadMode, setLoadMode] = useState<'auto' | 'ref2va' | 'fl2va'>('auto');
+ const [pendingSwitch, setPendingSwitch] = useState<{
+ modelKey: string;
+ projectId: string;
+ mode: 'auto' | 'ref2va' | 'fl2va';
+ } | null>(null);
+ const hasH3Checkpoints = models.some(
+ (model) => isVideoModelSelectable(model) && model.base === 'minimax-h3' && model.format === 'checkpoint'
+ );
+ const pickerFilter = (model: ModelConfig) =>
+ isVideoModelSelectable(model) &&
+ (loadMode === 'auto' || model.base !== 'minimax-h3' || model.format === 'checkpoint');
const pendingModel =
pendingSwitch?.projectId === projectId ? findSelectableModel(models, pendingSwitch.modelKey) : null;
@@ -93,13 +105,16 @@ export const VideoModelField = ({
// One transition for the preview, the decision, and the confirmed write, so they cannot disagree. The view shows
// panel values reconciled with the catalog; stored values are judged the same way.
- const getTransition = (current: VideoWidgetValues, model: MainModelConfig) =>
- getVideoModelSelectionResult({
+ const getTransition = (current: VideoWidgetValues, model: MainModelConfig, mode: 'auto' | 'ref2va' | 'fl2va') => {
+ const h3TaskOverride = mode === 'auto' ? undefined : mode;
+ return getVideoModelSelectionResult({
currentSettings: modelsLoaded ? syncVideoWidgetValuesWithModels(current, models) : current,
model,
models,
+ h3TaskOverride,
});
- const preview = pendingModel ? getTransition(values, pendingModel) : null;
+ };
+ const preview = pendingModel ? getTransition(values, pendingModel, pendingSwitch?.mode ?? 'auto') : null;
const formatList = (labels: string[]) =>
new Intl.ListFormat(i18n.resolvedLanguage, { style: 'long', type: 'conjunction' }).format(labels);
@@ -107,7 +122,7 @@ export const VideoModelField = ({
formatList(adjustments.map((adjustment) => t(ADJUSTMENT_LABELS[adjustment].labelKey)));
const selectModel = (candidate: ModelConfig | null) => {
- if (!isMainModelConfig(candidate) || !isVideoModelSelectable(candidate)) {
+ if (!isMainModelConfig(candidate) || !pickerFilter(candidate)) {
return;
}
@@ -118,17 +133,23 @@ export const VideoModelField = ({
// Decide and apply in one functional patch, against the latest stored values rather than this render's.
patchValues((current) => {
- result = getTransition(current, candidate);
+ result = getTransition(current, candidate, loadMode);
- return result.losses.length > 0 ? {} : { ...result.settings, model: candidate };
+ return result.losses.length > 0
+ ? {}
+ : {
+ ...result.settings,
+ model: candidate,
+ };
});
if (!result) {
return;
}
+ setLoadMode('auto');
if (result.losses.length > 0) {
- setPendingSwitch({ modelKey: candidate.key, projectId });
+ setPendingSwitch({ modelKey: candidate.key, projectId, mode: loadMode });
} else if (result.adjustments.length > 0) {
toaster.create({
description: t('widgets.video.settingsAdjustedDescription', { labels: formatAdjustments(result.adjustments) }),
@@ -147,7 +168,10 @@ export const VideoModelField = ({
// Close before writing, so the dialog animates out showing the list that was confirmed, not the switched panel.
setPendingSwitch(null);
// Recompute against the settings as they stand now: they may have changed while the dialog was open.
- patchValues((current) => ({ ...getTransition(current, pendingModel).settings, model: pendingModel }));
+ patchValues((current) => ({
+ ...getTransition(current, pendingModel, pendingSwitch?.mode ?? 'auto').settings,
+ model: pendingModel,
+ }));
};
return (
@@ -165,13 +189,39 @@ export const VideoModelField = ({
>
<Box ref={pickerRef} minW="0" w="full">
<ModelSelect
- filter={isVideoModelSelectable}
+ filter={pickerFilter}
installAction
invalid={!values.model}
modelTypes={MAIN_MODEL_TYPES}
placeholder={t('widgets.video.selectModel')}
value={values.model?.key ?? null}
+ pickerHeader={
+ hasH3Checkpoints ? (
+ <Box px="2" pt="2" pb="1">
+ <Text fontSize="xs" color="fg.muted">
+ {t('widgets.video.h3LoadMode')}
+ </Text>
+ <HStack gap="1" mt="1">
+ {(['auto', 'ref2va', 'fl2va'] as const).map((mode) => (
+ <Button
+ key={mode}
+ size="sm"
+ variant={loadMode === mode ? 'solid' : 'outline'}
+ aria-pressed={loadMode === mode}
+ onClick={() => setLoadMode(mode)}
+ >
+ {mode === 'auto' ? t('widgets.video.h3Detected') : mode === 'ref2va' ? 'Ref2VA' : 'FL2VA'}
+ </Button>
+ ))}
+ </HStack>
+ <Text fontSize="xs" color="fg.muted" mt="1">
+ {t('widgets.video.h3OverrideHelp')}
+ </Text>
+ </Box>
+ ) : undefined
+ }
onChange={selectModel}
+ onPickerClose={() => setLoadMode('auto')}
/>
</Box>
</Field>
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
index d20ee4e71e..f03eaea107 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
@@ -17,6 +17,7 @@ import {
import {
getDynamicPromptsConfig,
getLockedAspectRatioSettings,
+ isMainModelConfig,
normalizeDynamicPromptsSettings,
sanitizeBatchCount,
} from '@features/generation/settings';
@@ -45,6 +46,8 @@ import {
import {
getAcceleratorLoraChangeResult,
getAcceleratorToggleResult,
+ getH3ModeSwitchSettings,
+ getEffectiveVideoModel,
getEffectiveVideoTiming,
getVideoDimensions,
getAutoDurationBounds,
@@ -59,6 +62,7 @@ import {
getVideoPanelIssueSections,
syncVideoWidgetValuesWithModels,
} from '@features/video/core/widgetValues';
+import { flushWorkbenchDrafts } from '@platform/react/draftRegistry';
import { useMountEffect } from '@platform/react/useMountEffect';
import { Field, IconButton, Select } from '@platform/ui';
import { Button } from '@platform/ui/Button';
@@ -203,6 +207,49 @@ export const VideoWidgetView = ({ instance }: { instance?: { id: string } }) =>
const patch = useCallback((next: Partial<VideoWidgetValues>) => patchValues(next), [patchValues]);
+ const toggleH3Mode = useCallback(
+ ({ checked }: { checked: boolean }) => {
+ flushWorkbenchDrafts();
+ let blocked = false;
+ let removedTurbo = false;
+ patchValues((current) => {
+ if (
+ current.references.length ||
+ current.firstFrameImage ||
+ current.lastFrameImage ||
+ current.sourceVideo ||
+ current.h3HybridBaseModel
+ ) {
+ blocked = true;
+ return {};
+ }
+ const latest = modelsStatus === 'loaded' ? syncVideoWidgetValuesWithModels(current, models) : current;
+ if (latest.model?.base !== 'minimax-h3' || latest.model.format !== 'checkpoint') {
+ return {};
+ }
+ const registered = models.find((item) => item.key === latest.model?.key && item.type === 'main');
+ const detected = registered && isMainModelConfig(registered) ? registered : latest.model;
+ removedTurbo = latest.acceleratorEnabled;
+ const next = getH3ModeSwitchSettings(latest, detected, models, checked);
+ return next;
+ });
+ if (blocked) {
+ toaster.create({
+ title: t('widgets.video.h3ClearModeInputs'),
+ description: t('widgets.video.h3ClearModeInputsDescription'),
+ type: 'warning',
+ });
+ } else if (removedTurbo) {
+ toaster.create({
+ title: t('widgets.video.settingsAdjusted'),
+ description: t('widgets.video.h3TurboRemoved'),
+ type: 'info',
+ });
+ }
+ },
+ [models, modelsStatus, patchValues, t]
+ );
+
// Hidden Activity panels stop syncing and old callbacks target their project; drop writes then to avoid stale lists.
const referencesRef = useRef({ live: true, projectId, references: values.references });
@@ -544,6 +591,28 @@ export const VideoWidgetView = ({ instance }: { instance?: { id: string } }) =>
/>
</Stack>
+ {values.model?.base === 'minimax-h3' && values.model.format === 'checkpoint' ? (
+ <HStack px="2" py="1" justify="space-between">
+ <Text fontSize="sm">
+ {t('widgets.video.h3Mode', {
+ mode: getEffectiveVideoModel(values.model, values).variant === 'ref2va' ? 'Ref2VA' : 'FL2VA',
+ source: values.h3TaskOverride ? t('widgets.video.h3ModeOverride') : t('widgets.video.h3ModeDetected'),
+ })}
+ </Text>
+ <Switch.Root
+ checked={values.h3TaskOverride !== undefined}
+ disabled={modelsStatus !== 'loaded'}
+ onCheckedChange={toggleH3Mode}
+ >
+ <Switch.HiddenInput />
+ <Switch.Control _checked={SWITCH_CHECKED_PROPS}>
+ <Switch.Thumb />
+ </Switch.Control>
+ <Switch.Label>{t('widgets.video.h3SwitchMode')}</Switch.Label>
+ </Switch.Root>
+ </HStack>
+ ) : null}
+
<VideoPromptFields
batchCount={values.batchCount}
dynamicPrompts={dynamicPrompts}
diff --git a/invokeai/frontend/webv2/src/features/video/ui/videoComparators.test.ts b/invokeai/frontend/webv2/src/features/video/ui/videoComparators.test.ts
index bb088eb090..d49197d53d 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/videoComparators.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/ui/videoComparators.test.ts
@@ -16,6 +16,12 @@ describe('areVideoValuesEqual', () => {
};
const values = createDefaultVideoWidgetValues();
+ it('counts an explicit task override as nondefault even when it matches the catalog', () => {
+ const defaults = { ...createDefaultVideoWidgetValues([fl2vaBase]), model: fl2vaBase };
+ expect(areVideoValuesEqual(defaults, { ...defaults, h3TaskOverride: 'fl2va' })).toBe(false);
+ expect(areVideoValuesEqual(defaults, { ...defaults, model: { ...fl2vaBase, variant: 'ref2va' } })).toBe(false);
+ });
+
it('treats the hybrid quality base and its start block as part of the values', () => {
expect(areVideoValuesEqual(values, { ...values })).toBe(true);
expect(areVideoValuesEqual(values, { ...values, h3HybridBaseModel: fl2vaBase })).toBe(false);
diff --git a/invokeai/frontend/webv2/src/features/video/ui/videoComparators.ts b/invokeai/frontend/webv2/src/features/video/ui/videoComparators.ts
index 348207088d..df91b5d038 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/videoComparators.ts
+++ b/invokeai/frontend/webv2/src/features/video/ui/videoComparators.ts
@@ -27,6 +27,8 @@ export const areVideoValuesEqual = (left: VideoWidgetValues, right: VideoWidgetV
return (
left.modelKey === right.modelKey &&
+ left.h3TaskOverride === right.h3TaskOverride &&
+ left.model?.variant === right.model?.variant &&
areVideoModelsEquivalent(left.model, right.model) &&
left.positivePrompt === right.positivePrompt &&
left.negativePrompt === right.negativePrompt &&
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
index 907ade78e6..07782465c0 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
@@ -1,8 +1,17 @@
import type { GenerationModelCatalogItem, MainModelConfig } from '@features/generation/contracts';
-import { createDefaultVideoWidgetValues, getVideoDimensions, type VideoWidgetValues } from '@features/video';
+import {
+ compileVideoGraph,
+ createDefaultVideoWidgetValues,
+ getAcceleratorToggleResult,
+ getDefaultVideoSettings,
+ getVideoDimensions,
+ syncVideoWidgetValuesWithModels,
+ type VideoWidgetValues,
+} from '@features/video';
import { describe, expect, it } from 'vitest';
+import { recordOf } from './recallContract.testing';
import {
buildVideoRecallSettings,
deriveAcceleratorRecallState,
@@ -489,6 +498,33 @@ describe('model-position recall shapes', () => {
expect(result?.values.modelKey).toBe(checkpoint.key);
expect(result?.values).toMatchObject({ acceleratorEnabled: true, acceleratorLoraKeys: [ref2vTurbo.key] });
});
+
+ it('preserves an explicitly matching Ref2VA hybrid through partial recall and catalog sync', () => {
+ const hybrid = { ...checkpoint, key: 'quality-base', variant: 'fl2va' };
+ const models = [...catalog, hybrid];
+ const holding: VideoWidgetValues = {
+ ...currentValues,
+ model: checkpoint,
+ modelKey: checkpoint.key,
+ h3TaskOverride: 'ref2va',
+ h3HybridBaseModel: hybrid,
+ h3HybridStartBlock: 30,
+ };
+ const result = buildVideoRecallSettings({
+ currentValues: holding,
+ kind: 'seed',
+ metadata: { generation_mode: 'minimax_h3_ref2v', seed: 123 },
+ models,
+ });
+ expect(result).not.toBeNull();
+ const synced = syncVideoWidgetValuesWithModels(result!.values, models);
+ expect(synced).toMatchObject({
+ seed: 123,
+ h3TaskOverride: 'ref2va',
+ h3HybridBaseModel: hybrid,
+ h3HybridStartBlock: 30,
+ });
+ });
});
describe('portable records (metadata_version 1.0.0)', () => {
@@ -676,6 +712,84 @@ it('reads the legacy Wan VAE slot', () => {
});
});
+describe('H3 overridden task recall', () => {
+ it.each(['fl2va', 'ref2va'] as const)('round-trips a %s override with its Turbo through graph metadata', (task) => {
+ const model = { ...h3Model('hybrid'), format: 'checkpoint', variant: task === 'ref2va' ? 'fl2va' : 'ref2va' };
+ const component = h3Model('components');
+ const flTurbo = lora('MiniMax H3 Turbo LoRA', 'minimax-h3', null);
+ const refTurbo = lora('MiniMax H3 Ref2V Turbo LoRA', 'minimax-h3', null);
+ const catalog = [model, component, flTurbo, refTurbo];
+ const references = [
+ { kind: 'image' as const, detail: 'match' as const, image: { image_name: 'ref.png', width: 512, height: 512 } },
+ ];
+ const settings = getAcceleratorToggleResult(
+ {
+ ...getDefaultVideoSettings(model, catalog),
+ h3TaskOverride: task,
+ references: task === 'ref2va' ? references : [],
+ },
+ model,
+ catalog,
+ true
+ ).settings;
+ const selectedTurbo = task === 'ref2va' ? refTurbo : flTurbo;
+ expect(settings.acceleratorLoraKeys).toEqual([selectedTurbo.key]);
+ const graph = compileVideoGraph(settings, model).backendGraph;
+ expect(graph.nodes.model_loader).toMatchObject({ task_variant_override: task });
+ const metadata = recordOf(compileVideoGraph(settings, model), settings);
+ const result = buildVideoRecallSettings({
+ currentValues: createDefaultVideoWidgetValues(catalog),
+ kind: 'all',
+ metadata,
+ models: catalog,
+ })!;
+ expect(result.values.h3TaskOverride).toBe(task);
+ expect(result.values.model).toBe(model);
+ expect(result.values.acceleratorEnabled).toBe(true);
+ expect(result.values.acceleratorLoraKeys).toEqual([selectedTurbo.key]);
+ // Hydration supplies the media returned separately by recall.
+ const restored = syncVideoWidgetValuesWithModels({ ...result.values, references: settings.references }, catalog);
+ expect(compileVideoGraph(restored, restored.model!).backendGraph.nodes.model_loader).toMatchObject({
+ task_variant_override: task,
+ });
+ expect(restored.steps).toBe(settings.steps);
+ });
+
+ it('restores the effective task from generation_mode for the same checkpoint', () => {
+ const model = { ...h3Model('hybrid'), format: 'checkpoint', variant: 'fl2va' };
+ const values = createDefaultVideoWidgetValues([model]);
+ const result = buildVideoRecallSettings({
+ currentValues: values,
+ kind: 'all',
+ metadata: {
+ generation_mode: 'minimax_h3_ref2v',
+ model: { base: 'minimax-h3', key: model.key, name: model.name, type: 'main' },
+ },
+ models: [model],
+ });
+ expect(result?.values.h3TaskOverride).toBe('ref2va');
+ expect(result?.values.model).toBe(model);
+ expect(model.variant).toBe('fl2va');
+ });
+
+ it('does not apply the recorded task to an unrelated model when the recorded model is unavailable', () => {
+ const current = { ...h3Model('current'), format: 'checkpoint', variant: 'fl2va' };
+ const values = createDefaultVideoWidgetValues([current]);
+ const result = buildVideoRecallSettings({
+ currentValues: values,
+ kind: 'all',
+ metadata: {
+ generation_mode: 'minimax_h3_ref2v',
+ positive_prompt: 'test scene',
+ model: { base: 'minimax-h3', key: 'uninstalled', name: 'Missing model', type: 'main' },
+ },
+ models: [current],
+ });
+ expect(result?.values.h3TaskOverride).toBeUndefined();
+ expect(result?.values.model?.variant).toBe('fl2va');
+ });
+});
+
describe('legacy H3 duration recall', () => {
const model = h3Model();
const currentValues = { ...createDefaultVideoWidgetValues([model]), numFrames: 175 };
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
index 842da0443e..63822d02e4 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
@@ -17,6 +17,7 @@ import {
findAcceleratorLorasIn,
getAcceleratorToggleResult,
getAcceleratorSteps,
+ getEffectiveVideoModel,
getVideoAspectRatioOptions,
getVideoDimensions,
getVideoModelPolicy,
@@ -510,7 +511,7 @@ export const deriveAcceleratorRecallState = (
steps: number,
settings: VideoWidgetValues
): Pick<VideoWidgetValues, 'acceleratorEnabled' | 'acceleratorLoraKeys'> => {
- // Promote legacy H3 transformer overrides before deriving accelerators: fl2va and ref2v use different sets and steps.
+ model = getEffectiveVideoModel(model, settings);
const accelerator = getVideoModelPolicy(model, settings).ui.accelerator;
const recalled = accelerator
? findAcceleratorLorasIn(
@@ -694,6 +695,22 @@ export const buildVideoRecallSettings = ({
return fields.length > 0 ? { fields, mediaNames, values: { ...values, ...promptPatch } } : null;
}
+ // The existing generation_mode records the effective H3 task, including an override.
+ // Restore an override only against the recorded, installed checkpoint.
+ const recordedMode = isRecord(metadata) ? getString(metadata, 'generation_mode') : null;
+ if (
+ model?.base === 'minimax-h3' &&
+ model.format === 'checkpoint' &&
+ recalledModel &&
+ recordedMode?.startsWith('minimax_h3_')
+ ) {
+ const task = recordedMode === 'minimax_h3_ref2v' ? 'ref2va' : 'fl2va';
+ const h3TaskOverride = task !== getEffectiveVideoModel(recalledModel, {}).variant ? task : undefined;
+ values = { ...values, model: recalledModel, h3TaskOverride };
+ }
+
+ model = getEffectiveVideoModel(model, values);
+
const { numFrames } = record;
if (numFrames !== null) {
diff --git a/tests/app/invocations/test_minimax_h3_model_loader.py b/tests/app/invocations/test_minimax_h3_model_loader.py
index 414628ae7f..53e3e239b6 100644
--- a/tests/app/invocations/test_minimax_h3_model_loader.py
+++ b/tests/app/invocations/test_minimax_h3_model_loader.py
@@ -10,6 +10,7 @@ actionable message instead of an opaque loader stack trace minutes later.
from unittest.mock import MagicMock
import pytest
+from pydantic import ValidationError
from invokeai.app.invocations.minimax_h3.minimax_h3_model_loader import MiniMaxH3ModelLoaderInvocation
from invokeai.app.invocations.model import ModelIdentifierField
@@ -101,3 +102,33 @@ def test_variant_stamp_is_none_for_untyped_configs():
node = MiniMaxH3ModelLoaderInvocation(id="loader", model=_identifier())
output = node.invoke(_context(_config()))
assert output.transformer.variant is None
+
+
+ "detected, override",
+ [(MiniMaxH3VariantType.FL2VA, "ref2va"), (MiniMaxH3VariantType.REF2VA, "fl2va")],
+)
[email protected]("use_checkpoint", [False, True])
+def test_task_variant_override_takes_precedence(detected, override, use_checkpoint):
+ main = _config()
+ checkpoint = _config(format_=ModelFormat.Checkpoint)
+ selected = checkpoint if use_checkpoint else main
+ selected.variant = detected
+ kwargs = {"transformer_model": _identifier("h3-ckpt")} if use_checkpoint else {}
+ node = MiniMaxH3ModelLoaderInvocation(id="loader", model=_identifier(), task_variant_override=override, **kwargs)
+ output = node.invoke(_context_with_override(main, checkpoint))
+ assert output.transformer.variant == override
+ assert output.transformer.transformer.key == ("h3-ckpt" if use_checkpoint else "h3-main")
+ assert selected.variant == detected
+
+
+def test_explicit_none_preserves_detected_variant():
+ main = _config()
+ main.variant = MiniMaxH3VariantType.FL2VA
+ node = MiniMaxH3ModelLoaderInvocation(id="loader", model=_identifier(), task_variant_override=None)
+ assert node.invoke(_context(main)).transformer.variant == "fl2va"
+
+
+def test_invalid_task_variant_override_is_rejected():
+ with pytest.raises(ValidationError):
+ MiniMaxH3ModelLoaderInvocation(id="loader", model=_identifier(), task_variant_override="invalid")