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(webv2): generalize the video fast path to Lightning (Wan) and Turbo (H3)

Lincoln Steinf1064ddf18a0
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 b8e5167d13..319b634d82 100644
--- a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
@@ -79,7 +79,7 @@ describe('normalizeVideoSettings', () => {
expect(normalized?.firstFrameImage).toBeNull();
expect(normalized?.sourceVideo).toBeNull();
expect(normalized?.loras).toEqual([]);
- expect(normalized?.lightningEnabled).toBe(false);
+ expect(normalized?.acceleratorEnabled).toBe(false);
expect(normalized?.positivePrompt).toBe('a dog');
});
@@ -94,29 +94,50 @@ describe('normalizeVideoSettings', () => {
expect(normalized?.sourceVideo).toBeNull();
});
- it('clears a Lightning flag whose LoRAs are gone — the flag means the pair is active', () => {
- const styleLora = {
- isEnabled: true,
- model: { base: 'wan', key: 'style', name: 'Style LoRA', type: 'lora' as const },
- weight: 1,
- };
+ it('clears an accelerator flag whose recorded LoRAs are gone — the flag means they are active', () => {
const lightningLora = {
isEnabled: true,
model: { base: 'wan', key: 'lit', name: 'Wan Lightning High Noise', type: 'lora' as const },
weight: 1,
};
- expect(normalizeVideoSettings({ ...createSettings(), lightningEnabled: true, loras: [] })?.lightningEnabled).toBe(
- false
- );
+ // Flag without recorded keys, or with a recorded key missing from the list, clears.
expect(
- normalizeVideoSettings({ ...createSettings(), lightningEnabled: true, loras: [styleLora] })?.lightningEnabled
+ normalizeVideoSettings({ ...createSettings(), acceleratorEnabled: true, loras: [lightningLora] })
+ ?.acceleratorEnabled
).toBe(false);
expect(
- normalizeVideoSettings({ ...createSettings(), lightningEnabled: true, loras: [lightningLora] })?.lightningEnabled
+ normalizeVideoSettings({
+ ...createSettings(),
+ acceleratorEnabled: true,
+ acceleratorLoraKeys: ['lit', 'gone'],
+ loras: [lightningLora],
+ })
+ ).toMatchObject({ acceleratorEnabled: false, acceleratorLoraKeys: [] });
+ // Flag with all recorded keys present survives.
+ expect(
+ normalizeVideoSettings({
+ ...createSettings(),
+ acceleratorEnabled: true,
+ acceleratorLoraKeys: ['lit'],
+ loras: [lightningLora],
+ })
+ ).toMatchObject({ acceleratorEnabled: true, acceleratorLoraKeys: ['lit'] });
+ expect(isVideoSettings({ ...createSettings(), acceleratorEnabled: true, acceleratorLoraKeys: [], loras: [] })).toBe(
+ false
+ );
+ expect(
+ isVideoSettings({
+ ...createSettings(),
+ acceleratorEnabled: true,
+ acceleratorLoraKeys: ['lit'],
+ loras: [lightningLora],
+ })
).toBe(true);
- expect(isVideoSettings({ ...createSettings(), lightningEnabled: true, loras: [] })).toBe(false);
- expect(isVideoSettings({ ...createSettings(), lightningEnabled: true, loras: [lightningLora] })).toBe(true);
+ // A disabled flag must not carry stale keys.
+ expect(isVideoSettings({ ...createSettings(), acceleratorEnabled: false, acceleratorLoraKeys: ['lit'] })).toBe(
+ false
+ );
});
it('resolves an illegal first-frame + source-video combination in favor of the first frame', () => {
@@ -135,7 +156,7 @@ describe('isVideoSettings', () => {
it('is strict over the keys normalize would invent', () => {
expect(isVideoSettings({ ...createSettings(), aspectRatioId: 'Free' })).toBe(false);
expect(isVideoSettings({ ...createSettings(), targetResolution: '4k' })).toBe(false);
- expect(isVideoSettings({ ...createSettings(), lightningEnabled: 'yes' })).toBe(false);
+ expect(isVideoSettings({ ...createSettings(), acceleratorEnabled: 'yes' })).toBe(false);
expect(isVideoSettings({ ...createSettings(), firstFrameImage: FIRST_FRAME, sourceVideo: SOURCE_VIDEO })).toBe(
false
);
diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.ts b/invokeai/frontend/webv2/src/features/video/core/settings.ts
index 7e3a5e14fa..830302f3ec 100644
--- a/invokeai/frontend/webv2/src/features/video/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.ts
@@ -78,12 +78,12 @@ const isVideoLora = (value: unknown): value is GenerateLora =>
hasFiniteNumber(value, 'weight') &&
typeof value.isEnabled === 'boolean';
-/** A Wan Lightning distillation LoRA, identified by name (they carry no dedicated taxonomy). */
-export const isWanLightningLora = (model: { base: string; name: string }): boolean =>
- model.base === 'wan' && /lightning/i.test(model.name);
+const getStringArray = (value: unknown): string[] =>
+ Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : [];
-const hasLightningLora = (loras: readonly GenerateLora[]): boolean =>
- loras.some((lora) => isWanLightningLora(lora.model));
+/** Whether every key the accelerator toggle recorded is still present in the LoRA list. */
+const areAcceleratorLorasPresent = (keys: readonly string[], loras: readonly GenerateLora[]): boolean =>
+ keys.length > 0 && keys.every((key) => loras.some((lora) => lora.model.key === key));
/**
* Which inputs are filled decides the mode; there is no mode selector. A first
@@ -143,6 +143,12 @@ export const normalizeVideoSettings = (values: unknown): VideoSettings | null =>
// project somehow holds both, the first frame wins deterministically.
const sourceVideo = !firstFrameImage && isVideoSourceClip(values.sourceVideo) ? values.sourceVideo : null;
const loras = Array.isArray(values.loras) ? values.loras.filter(isVideoLora) : [];
+ const acceleratorLoraKeys = getStringArray(values.acceleratorLoraKeys);
+ // The flag means "the accelerator LoRAs the toggle added are active": if any
+ // of them is gone (deleted from Concepts, dropped as incompatible), the flag
+ // clears rather than claiming a fast path that has nothing behind it.
+ const acceleratorEnabled =
+ values.acceleratorEnabled === true && areAcceleratorLorasPresent(acceleratorLoraKeys, loras);
return {
aspectRatioId: isVideoAspectRatioId(values.aspectRatioId) ? values.aspectRatioId : '16:9',
@@ -153,11 +159,9 @@ export const normalizeVideoSettings = (values: unknown): VideoSettings | null =>
fps: values.fps as number,
h3TextEncoderModel: isModelIdentifierConfig(values.h3TextEncoderModel) ? values.h3TextEncoderModel : null,
h3TransformerModel: isMainModelConfig(values.h3TransformerModel) ? values.h3TransformerModel : null,
+ acceleratorEnabled,
+ acceleratorLoraKeys: acceleratorEnabled ? acceleratorLoraKeys : [],
lastFrameImage: isImageWithDims(values.lastFrameImage) ? values.lastFrameImage : null,
- // The flag means "the Lightning pair is active": if the LoRAs are gone
- // (deleted from Concepts, dropped as incompatible), the flag clears with
- // them rather than claiming a fast path that has nothing behind it.
- lightningEnabled: values.lightningEnabled === true && hasLightningLora(loras),
loras,
modelKey: values.modelKey as string,
negativePrompt: values.negativePrompt as string,
@@ -202,9 +206,13 @@ export const isVideoSettings = (values: unknown): values is VideoSettings => {
isVideoAspectRatioId(values.aspectRatioId) &&
isVideoTargetResolution(values.targetResolution) &&
typeof values.negativePromptEnabled === 'boolean' &&
- typeof values.lightningEnabled === 'boolean' &&
- (values.lightningEnabled === false ||
- (Array.isArray(values.loras) && hasLightningLora(values.loras.filter(isVideoLora)))) &&
+ typeof values.acceleratorEnabled === 'boolean' &&
+ Array.isArray(values.acceleratorLoraKeys) &&
+ values.acceleratorLoraKeys.every((key) => typeof key === 'string') &&
+ (values.acceleratorEnabled === false
+ ? (values.acceleratorLoraKeys as string[]).length === 0
+ : Array.isArray(values.loras) &&
+ areAcceleratorLorasPresent(values.acceleratorLoraKeys as string[], values.loras.filter(isVideoLora))) &&
hasFiniteNumber(values, 'negativePromptHeightPx') &&
hasFiniteNumber(values, 'positivePromptHeightPx') &&
(values.cfgScaleLowNoise === null || hasFiniteNumber(values, 'cfgScaleLowNoise')) &&
@@ -238,6 +246,7 @@ export const isVideoWidgetValues = (values: unknown): values is VideoWidgetValue
export const cloneVideoWidgetValues = (values: VideoWidgetValues): VideoWidgetValues & Record<string, unknown> => ({
...values,
+ acceleratorLoraKeys: [...values.acceleratorLoraKeys],
componentSourceModel: values.componentSourceModel ? { ...values.componentSourceModel } : null,
firstFrameImage: values.firstFrameImage ? { ...values.firstFrameImage } : null,
h3TextEncoderModel: values.h3TextEncoderModel ? { ...values.h3TextEncoderModel } : null,
diff --git a/invokeai/frontend/webv2/src/features/video/core/types.ts b/invokeai/frontend/webv2/src/features/video/core/types.ts
index 78e4008108..9d92239c5d 100644
--- a/invokeai/frontend/webv2/src/features/video/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/types.ts
@@ -64,11 +64,19 @@ export interface VideoSettings {
/** Guidance for the low-noise half of a Wan A14B schedule; null reuses `cfgScale`. */
cfgScaleLowNoise: number | null;
/**
- * Wan A14B fast path: the Lightning distillation LoRA pair at 4 steps and
- * CFG 1. Toggling it patches steps/CFG and the `loras` list — see
- * `getLightningToggleResult` — so the flag records intent, not hidden state.
+ * The family's distillation fast path: the Lightning LoRA pair at 4 steps /
+ * CFG 1 for Wan A14B, the Turbo LoRA at 6 steps for MiniMax H3. Toggling it
+ * patches steps/CFG and the `loras` list — see `getAcceleratorToggleResult`
+ * — so the flag records intent, not hidden state.
*/
- lightningEnabled: boolean;
+ acceleratorEnabled: boolean;
+ /**
+ * The keys of the LoRA entries the accelerator toggle added. Turning the
+ * fast path off (or switching families) removes exactly these — never a
+ * user's own LoRA that happens to be named like one — and the enabled flag
+ * cannot outlive them.
+ */
+ acceleratorLoraKeys: string[];
seed: number;
shouldRandomizeSeed: boolean;
loras: GenerateLora[];
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 219380f480..16520fb07a 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
@@ -5,9 +5,10 @@ import { describe, expect, it } from 'vitest';
import type { VideoSettings } from './types';
import {
+ findMiniMaxH3TurboLora,
findWanLightningLoraPair,
getDefaultVideoSettings,
- getLightningToggleResult,
+ getAcceleratorToggleResult,
getVideoComponentSectionPolicy,
getVideoDimensions,
getVideoModelAvailabilityReasons,
@@ -19,7 +20,7 @@ import {
isSupportedVideoModel,
isValidVideoNumFrames,
snapVideoNumFrames,
- WAN_LIGHTNING_SAMPLING,
+ WAN_LIGHTNING_ACCELERATOR,
} from './videoPolicies';
const wanModel = (variant: string, format = 'gguf_quantized', key = `wan-${variant}-${format}`): MainModelConfig => ({
@@ -113,18 +114,18 @@ describe('capabilities matrix', () => {
const h3 = getVideoModelPolicy(h3Model(), settingsFor(h3Model()));
expect(a14b.ui).toMatchObject({ cfgLowNoiseVisible: true, cfgVisible: true, fpsVisible: true });
- expect(a14b.ui.lightningAvailable).toBe(true);
+ expect(a14b.ui.accelerator).toMatchObject({ label: 'Lightning', steps: 4 });
expect(a14b.frames).toMatchObject({ defaultValue: 81, kind: 'grid', step: 4 });
- expect(ti2v.ui).toMatchObject({ cfgLowNoiseVisible: false, cfgVisible: true, lightningAvailable: false });
+ expect(ti2v.ui).toMatchObject({ accelerator: null, cfgLowNoiseVisible: false, cfgVisible: true });
expect(h3.ui).toMatchObject({
audioOutput: true,
cfgLowNoiseVisible: false,
cfgVisible: false,
fpsVisible: false,
- lightningAvailable: false,
});
+ expect(h3.ui.accelerator).toMatchObject({ label: 'Turbo', steps: 6 });
expect(h3.frames.kind).toBe('choices');
expect(h3.fps).toMatchObject({ defaultValue: 24, editable: false });
expect(h3.defaults.steps).toBe(50);
@@ -297,14 +298,14 @@ describe('Lightning', () => {
const base = settingsFor(model, {
cfgScale: 5,
cfgScaleLowNoise: 4,
- lightningEnabled: false,
+ acceleratorEnabled: false,
loras: [],
steps: 40,
});
- const result = getLightningToggleResult(base, model, catalog, true);
+ const result = getAcceleratorToggleResult(base, model, catalog, true);
expect(result.missingLoras).toBe(false);
- expect(result.settings).toMatchObject({ ...WAN_LIGHTNING_SAMPLING, lightningEnabled: true });
+ expect(result.settings).toMatchObject({ acceleratorEnabled: true, cfgScale: 1, cfgScaleLowNoise: 1, steps: 4 });
expect(result.settings.loras.map((entry) => entry.model.key)).toEqual([
LIGHTNING_T2V_HIGH.key,
LIGHTNING_T2V_LOW.key,
@@ -312,28 +313,28 @@ describe('Lightning', () => {
});
it('toggling off removes only the Lightning LoRAs and restores model defaults', () => {
- const on = getLightningToggleResult(settingsFor(model), model, catalog, true).settings;
+ const on = getAcceleratorToggleResult(settingsFor(model), model, catalog, true).settings;
const withStyle = { ...on, loras: [...on.loras, { isEnabled: true, model: lora('Style LoRA'), weight: 0.5 }] };
- const off = getLightningToggleResult(withStyle as VideoSettings, model, catalog, false).settings;
+ const off = getAcceleratorToggleResult(withStyle as VideoSettings, model, catalog, false).settings;
- expect(off.lightningEnabled).toBe(false);
+ expect(off.acceleratorEnabled).toBe(false);
expect(off).toMatchObject({ cfgScale: 5, cfgScaleLowNoise: 4, steps: 40 });
expect(off.loras.map((entry) => entry.model.name)).toEqual(['Style LoRA']);
});
it('reports a missing pair instead of enabling silently', () => {
- const result = getLightningToggleResult(settingsFor(model), model, [], true);
+ const result = getAcceleratorToggleResult(settingsFor(model), model, [], true);
expect(result.missingLoras).toBe(true);
- expect(result.settings.lightningEnabled).toBe(false);
+ expect(result.settings.acceleratorEnabled).toBe(false);
});
it('clears a stale enabled flag when the pair has vanished from the catalog', () => {
- const stale = settingsFor(model, { lightningEnabled: true, steps: 4 });
- const result = getLightningToggleResult(stale, model, [], true);
+ const stale = settingsFor(model, { acceleratorEnabled: true, steps: 4 });
+ const result = getAcceleratorToggleResult(stale, model, [], true);
expect(result.missingLoras).toBe(true);
- expect(result.settings.lightningEnabled).toBe(false);
+ expect(result.settings.acceleratorEnabled).toBe(false);
});
it('defaults Lightning on for A14B when the pair is installed, off otherwise', () => {
@@ -341,10 +342,70 @@ describe('Lightning', () => {
const withoutPair = getDefaultVideoSettings(model, []);
const h3Defaults = getDefaultVideoSettings(h3Model(), catalog);
- expect(withPair.lightningEnabled).toBe(true);
- expect(withPair.steps).toBe(WAN_LIGHTNING_SAMPLING.steps);
- expect(withoutPair).toMatchObject({ cfgScale: 5, lightningEnabled: false, steps: 40 });
- expect(h3Defaults).toMatchObject({ fps: 24, lightningEnabled: false, numFrames: 124, steps: 50 });
+ expect(withPair.acceleratorEnabled).toBe(true);
+ expect(withPair.steps).toBe(WAN_LIGHTNING_ACCELERATOR.steps);
+ expect(withoutPair).toMatchObject({ cfgScale: 5, acceleratorEnabled: false, steps: 40 });
+ // The catalog holds no H3 Turbo LoRA, so H3 falls back to its slow defaults.
+ expect(h3Defaults).toMatchObject({ fps: 24, acceleratorEnabled: false, numFrames: 124, steps: 50 });
+ });
+});
+
+describe('MiniMax H3 Turbo', () => {
+ const TURBO = { base: 'minimax-h3', key: 'turbo', name: 'MiniMax H3 Turbo LoRA', type: 'lora' as const };
+
+ it('finds the installed Turbo LoRA by name, ignoring Wan Lightning models', () => {
+ expect(findMiniMaxH3TurboLora([LIGHTNING_T2V_HIGH, TURBO])).toMatchObject({ key: 'turbo' });
+ expect(findMiniMaxH3TurboLora([LIGHTNING_T2V_HIGH, LIGHTNING_T2V_LOW])).toBeNull();
+ });
+
+ it('defaults Turbo on for H3 when installed, matching the bundled templates (steps 6)', () => {
+ const defaults = getDefaultVideoSettings(h3Model(), [TURBO]);
+
+ expect(defaults).toMatchObject({ acceleratorEnabled: true, steps: 6 });
+ expect(defaults.loras.map((entry) => entry.model.key)).toEqual(['turbo']);
+ });
+
+ it('toggling off restores the slow 50-step default and removes the Turbo LoRA', () => {
+ const on = getDefaultVideoSettings(h3Model(), [TURBO]);
+ const off = getAcceleratorToggleResult(on, h3Model(), [TURBO], false).settings;
+
+ expect(off).toMatchObject({ acceleratorEnabled: false, steps: 50 });
+ expect(off.loras).toEqual([]);
+ });
+
+ it('prefers the family-named Turbo repack over a look-alike, deterministically', () => {
+ const turboRider = { base: 'minimax-h3', key: 'rider', name: 'Turbo Rider', type: 'lora' as const };
+
+ expect(findMiniMaxH3TurboLora([turboRider, TURBO])).toMatchObject({ key: 'turbo' });
+ expect(findMiniMaxH3TurboLora([TURBO, turboRider])).toMatchObject({ key: 'turbo' });
+ });
+
+ it('never strips a user LoRA that merely shares an accelerator-style name', () => {
+ const turboRider = { base: 'minimax-h3', key: 'rider', name: 'Turbo Rider', type: 'lora' as const };
+ const model = h3Model();
+ const catalog = [TURBO, turboRider];
+ const on = getAcceleratorToggleResult(settingsFor(model), model, catalog, true).settings;
+ const withRider = {
+ ...on,
+ loras: [...on.loras, { isEnabled: true, model: turboRider as never, weight: 0.8 }],
+ };
+ const off = getAcceleratorToggleResult(withRider as VideoSettings, model, catalog, false).settings;
+
+ // Only the recorded Turbo entry is removed; "Turbo Rider" is the user's.
+ expect(off.loras.map((entry) => entry.model.key)).toEqual(['rider']);
+ expect(off.acceleratorLoraKeys).toEqual([]);
+ });
+
+ it('carries the fast-path intent across a family switch (Lightning → Turbo)', () => {
+ const wan = wanModel('t2v_a14b');
+ const catalog = [LIGHTNING_T2V_HIGH, LIGHTNING_T2V_LOW, TURBO];
+ const lightningOn = getAcceleratorToggleResult(settingsFor(wan), wan, catalog, true).settings;
+ const result = getVideoModelSelectionResult({ currentSettings: lightningOn, model: h3Model(), models: catalog });
+
+ expect(result.settings.acceleratorEnabled).toBe(true);
+ expect(result.settings.steps).toBe(6);
+ expect(result.settings.loras.map((entry) => entry.model.key)).toEqual(['turbo']);
+ expect(result.clearedLabels).toContain('Acceleration');
});
});
@@ -474,7 +535,7 @@ describe('getVideoModelSelectionResult', () => {
const from = settingsFor(wanModel('i2v_a14b'), {
firstFrameImage: FIRST_FRAME,
lastFrameImage: LAST_FRAME,
- lightningEnabled: false,
+ acceleratorEnabled: false,
});
const result = getVideoModelSelectionResult({
currentSettings: from,
@@ -513,7 +574,7 @@ describe('getVideoModelSelectionResult', () => {
it('re-fits presets, frames, fps, Lightning, and components when crossing families', () => {
const wan = wanModel('t2v_a14b');
const catalog = [LIGHTNING_T2V_HIGH, LIGHTNING_T2V_LOW];
- const lightningOn = getLightningToggleResult(settingsFor(wan), wan, catalog, true).settings;
+ const lightningOn = getAcceleratorToggleResult(settingsFor(wan), wan, catalog, true).settings;
const from = settingsFor(wan, {
...lightningOn,
loras: [...lightningOn.loras, { isEnabled: true, model: lora('Style LoRA') as never, weight: 0.5 }],
@@ -526,19 +587,46 @@ describe('getVideoModelSelectionResult', () => {
expect(result.settings.targetResolution).toBe('768 highres');
expect(result.settings.numFrames).toBe(90); // 81 snapped onto the H3 grid
expect(result.settings.fps).toBe(24);
- expect(result.settings.lightningEnabled).toBe(false);
+ expect(result.settings.acceleratorEnabled).toBe(false);
expect(result.settings.steps).toBe(50);
expect(result.settings.loras).toEqual([]); // wan LoRAs are incompatible with H3
expect(result.settings.vae).toBeNull();
expect(result.settings.wanT5EncoderModel).toBeNull();
expect(result.clearedLabels).toEqual(
- expect.arrayContaining(['Target resolution', 'Frames', 'FPS', 'Lightning', 'LoRAs', 'VAE', 'Wan T5 Encoder'])
+ expect.arrayContaining(['Target resolution', 'Frames', 'FPS', 'Acceleration', 'LoRAs', 'VAE', 'Wan T5 Encoder'])
);
});
+ it('leaves user-tuned sampling and LoRA weights alone when the accelerator carries over unchanged', () => {
+ const wan = wanModel('t2v_a14b');
+ const catalog = [LIGHTNING_T2V_HIGH, LIGHTNING_T2V_LOW];
+ const on = getAcceleratorToggleResult(settingsFor(wan), wan, catalog, true).settings;
+ const tuned = {
+ ...on,
+ cfgScale: 2,
+ loras: [
+ { ...on.loras[0]!, weight: 0.5 },
+ on.loras[1]!,
+ { isEnabled: true, model: lora('Style LoRA') as never, weight: 0.7 },
+ ],
+ steps: 8,
+ };
+ const result = getVideoModelSelectionResult({
+ currentSettings: tuned,
+ model: wanModel('t2v_a14b', 'checkpoint'),
+ models: catalog,
+ });
+
+ // Same accelerator LoRA set on the new model: nothing is re-applied.
+ expect(result.settings).toMatchObject({ acceleratorEnabled: true, cfgScale: 2, steps: 8 });
+ expect(result.settings.loras[0]?.weight).toBe(0.5);
+ expect(result.settings.loras.map((entry) => entry.model.name)).toContain('Style LoRA');
+ expect(result.clearedLabels).toEqual([]);
+ });
+
it('returns no cleared labels when everything carries over', () => {
const model = wanModel('i2v_a14b');
- const from = settingsFor(model, { firstFrameImage: FIRST_FRAME, lightningEnabled: false });
+ const from = settingsFor(model, { firstFrameImage: FIRST_FRAME, acceleratorEnabled: false });
const result = getVideoModelSelectionResult({
currentSettings: from,
model: 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 f713f98b4f..b8c7b88c53 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
@@ -1,4 +1,5 @@
import type {
+ GenerateLora,
GenerationModelCatalogItem as ModelConfig,
GenerationModelTaxonomyType as ModelTaxonomyType,
LoraModelConfig,
@@ -37,7 +38,7 @@ import {
WAN_TI2V_PIXEL_MULTIPLE,
type VideoDimensions,
} from './dimensions';
-import { isWanLightningLora, resolveVideoMode, VIDEO_ASPECT_RATIO_IDS } from './settings';
+import { resolveVideoMode, VIDEO_ASPECT_RATIO_IDS } from './settings';
// Video capabilities registry keyed by model base AND variant: unlike still-image
// generation, Wan's variants differ structurally (which conditioning modes exist,
@@ -78,6 +79,19 @@ export interface VideoFpsPolicy {
max: number;
}
+/**
+ * The family's distillation fast path: which LoRA(s) it runs on and the
+ * sampling parameters they were trained for. Wan A14B uses the Lightning
+ * high/low pair; MiniMax H3 uses the single Turbo LoRA (the bundled H3
+ * templates default to it at 6 steps).
+ */
+export interface VideoAcceleratorConfig {
+ label: 'Lightning' | 'Turbo';
+ steps: number;
+ cfgScale: number;
+ cfgScaleLowNoise: number | null;
+}
+
interface VideoVariantConfig {
modes: readonly VideoGenerationMode[];
pixelMultiple: number;
@@ -93,10 +107,24 @@ interface VideoVariantConfig {
fps: VideoFpsPolicy;
cfg: { visible: boolean; lowNoiseVisible: boolean };
negativePrompt: { visible: boolean; usage: VideoNegativePromptUsage };
- lightningAvailable: boolean;
+ accelerator: VideoAcceleratorConfig | null;
audioOutput: boolean;
}
+export const WAN_LIGHTNING_ACCELERATOR: VideoAcceleratorConfig = {
+ cfgScale: 1,
+ cfgScaleLowNoise: 1,
+ label: 'Lightning',
+ steps: 4,
+};
+
+export const MINIMAX_H3_TURBO_ACCELERATOR: VideoAcceleratorConfig = {
+ cfgScale: 1,
+ cfgScaleLowNoise: null,
+ label: 'Turbo',
+ steps: 6,
+};
+
const WAN_TARGET_RESOLUTION_OPTIONS: readonly VideoTargetResolutionOption[] = [
{ id: '480p', label: '480p (Wan native)' },
{ id: '720p', label: '720p (Wan native)' },
@@ -120,11 +148,11 @@ const WAN_FPS: VideoFpsPolicy = { defaultValue: WAN_FPS_DEFAULT, editable: true,
// wan_video_denoise defaults: guidance_scale=5.0 (high), guidance_scale_low_noise=4.0.
const WAN_A14B_COMMON = {
+ accelerator: WAN_LIGHTNING_ACCELERATOR,
cfg: { lowNoiseVisible: true, visible: true },
defaults: { cfgScale: 5, cfgScaleLowNoise: 4, steps: 40, targetResolution: '720p' as const },
fps: WAN_FPS,
frames: WAN_FRAMES,
- lightningAvailable: true,
minSteps: 1,
audioOutput: false,
negativePrompt: { usage: 'cfg-gated' as const, visible: true },
@@ -144,9 +172,9 @@ const WAN_VARIANTS: Record<string, VideoVariantConfig> = {
// Lightning LoRAs).
ti2v_5b: {
...WAN_A14B_COMMON,
+ accelerator: null,
cfg: { lowNoiseVisible: false, visible: true },
defaults: { cfgScale: 5, cfgScaleLowNoise: null, steps: 40, targetResolution: '720p' },
- lightningAvailable: false,
modes: ['txt2vid', 'first-frame', 'extend'],
pixelMultiple: WAN_TI2V_PIXEL_MULTIPLE,
},
@@ -161,12 +189,12 @@ const WAN_FALLBACK_VARIANT: VideoVariantConfig = {
// Guidance-distilled: no CFG, no negative prompt, fixed 24 fps, audio included.
const MINIMAX_H3_FL2VA: VideoVariantConfig = {
+ accelerator: MINIMAX_H3_TURBO_ACCELERATOR,
audioOutput: true,
cfg: { lowNoiseVisible: false, visible: false },
defaults: { cfgScale: 1, cfgScaleLowNoise: null, steps: 50, targetResolution: '768 highres' },
fps: { defaultValue: MINIMAX_H3_FPS, editable: false, max: MINIMAX_H3_FPS, min: MINIMAX_H3_FPS },
frames: { choices: MINIMAX_H3_NUM_FRAMES_CHOICES, defaultValue: MINIMAX_H3_NUM_FRAMES_DEFAULT, kind: 'choices' },
- lightningAvailable: false,
minSteps: 2,
modes: ['txt2vid', 'first-frame', 'last-frame', 'first-last', 'extend'],
negativePrompt: { usage: 'never', visible: false },
@@ -363,7 +391,8 @@ export interface VideoModelPolicy {
cfgVisible: boolean;
cfgLowNoiseVisible: boolean;
fpsVisible: boolean;
- lightningAvailable: boolean;
+ /** The family's distillation fast path, or null when it has none. */
+ accelerator: VideoAcceleratorConfig | null;
audioOutput: boolean;
};
}
@@ -382,20 +411,17 @@ export const getVideoModelPolicy = (model: MainModelConfig | undefined, settings
prompt: getVideoPromptPolicy(model, settings),
targetResolutions: config.targetResolutions,
ui: {
+ accelerator: config.accelerator,
audioOutput: config.audioOutput,
cfgLowNoiseVisible: config.cfg.lowNoiseVisible,
cfgVisible: config.cfg.visible,
fpsVisible: config.fps.editable,
- lightningAvailable: config.lightningAvailable,
},
};
};
// ---------------------------------------------------------------------------
-// Wan Lightning fast path
-
-/** The sampling parameters the Lightning distillation LoRAs are trained for. */
-export const WAN_LIGHTNING_SAMPLING = { cfgScale: 1, cfgScaleLowNoise: 1, steps: 4 } as const;
+// Distillation fast paths (Wan Lightning, MiniMax H3 Turbo)
export interface WanLightningLoraPair {
high: LoraModelConfig;
@@ -420,7 +446,10 @@ export const findWanLightningLoraPair = (
): WanLightningLoraPair | null => {
const candidates = models.filter(
(model): model is ModelConfig & LoraModelConfig =>
- isLoraModelConfig(model) && isWanLightningLora(model) && isWanLoraTargetingMain(model.variant, mainVariant)
+ isLoraModelConfig(model) &&
+ model.base === 'wan' &&
+ /lightning/i.test(model.name) &&
+ isWanLoraTargetingMain(model.variant, mainVariant)
);
// Delimited-token match so 'i2v' cannot score inside "TI2V".
@@ -436,47 +465,94 @@ export const findWanLightningLoraPair = (
return high && low && high.key !== low.key ? { high, low } : null;
};
-export interface LightningToggleResult {
+const TURBO_PATTERN = /(?:^|[^a-z0-9])turbo(?:[^a-z0-9]|$)/i;
+const MINIMAX_H3_NAME_PATTERN = /(?:^|[^a-z0-9])(?:minimax|h3)(?:[^a-z0-9]|$)/i;
+
+/**
+ * The installed MiniMax H3 Turbo distillation LoRA, if any. Distillation LoRAs
+ * carry no dedicated taxonomy, so this is a name heuristic: a delimited
+ * "turbo" token, preferring names that also name the model family, with a
+ * deterministic tie-break — a user's own "Turbo …" style LoRA loses to the
+ * real repack whenever one is installed.
+ */
+export const findMiniMaxH3TurboLora = (models: readonly ModelConfig[]): LoraModelConfig | null => {
+ const score = (model: LoraModelConfig): number => (MINIMAX_H3_NAME_PATTERN.test(model.name) ? 0 : 1);
+
+ return (
+ models
+ .filter(
+ (model): model is ModelConfig & LoraModelConfig =>
+ isLoraModelConfig(model) && model.base === 'minimax-h3' && TURBO_PATTERN.test(model.name)
+ )
+ .sort((a, b) => score(a) - score(b) || a.name.localeCompare(b.name))[0] ?? null
+ );
+};
+
+/** The accelerator LoRA entries for a model, or null when they are not installed. */
+const findAcceleratorLoraEntries = (model: MainModelConfig, models: readonly ModelConfig[]): GenerateLora[] | null => {
+ if (model.base === 'minimax-h3') {
+ const turbo = findMiniMaxH3TurboLora(models);
+
+ return turbo ? [{ isEnabled: true, model: turbo, weight: 1 }] : null;
+ }
+
+ const pair = findWanLightningLoraPair(models, model.variant);
+
+ return pair
+ ? [
+ { isEnabled: true, model: pair.high, weight: 1 },
+ { isEnabled: true, model: pair.low, weight: 1 },
+ ]
+ : null;
+};
+
+export interface AcceleratorToggleResult {
settings: VideoSettings;
- /** True when enabling was requested but no installed Lightning pair was found. */
+ /** True when enabling was requested but the accelerator LoRA(s) are not installed. */
missingLoras: boolean;
}
/**
- * Applies the Lightning toggle as a plain settings transition: the LoRA pair
- * appears in (or leaves) the Concepts list and steps/CFG are patched, so the
+ * Applies the accelerator toggle as a plain settings transition: the LoRA(s)
+ * appear in (or leave) the Concepts list and steps/CFG are patched, so the
* graph builder needs no hidden behavior and the user sees exactly what runs.
*/
-export const getLightningToggleResult = (
+export const getAcceleratorToggleResult = (
settings: VideoSettings,
model: MainModelConfig,
models: readonly ModelConfig[],
enabled: boolean
-): LightningToggleResult => {
+): AcceleratorToggleResult => {
const config = getVideoConfig(model);
- const withoutLightning = settings.loras.filter((lora) => !isWanLightningLora(lora.model));
+ // Remove exactly the entries a previous toggle added — never a user's own
+ // LoRA that happens to share a Lightning/Turbo-style name.
+ const previousKeys = new Set(settings.acceleratorLoraKeys);
+ const withoutAccelerators = settings.loras.filter((lora) => !previousKeys.has(lora.model.key));
- if (!enabled || !config.lightningAvailable) {
+ if (!enabled || !config.accelerator) {
return {
missingLoras: false,
settings: {
...settings,
+ acceleratorEnabled: false,
+ acceleratorLoraKeys: [],
cfgScale: config.defaults.cfgScale,
cfgScaleLowNoise: config.defaults.cfgScaleLowNoise,
- lightningEnabled: false,
- loras: withoutLightning,
+ loras: withoutAccelerators,
steps: config.defaults.steps,
},
};
}
- const pair = findWanLightningLoraPair(models, model.variant);
+ const entries = findAcceleratorLoraEntries(model, models);
- if (!pair) {
+ if (!entries) {
// Never leave the flag claiming a fast path that has no LoRAs behind it.
return {
missingLoras: true,
- settings: settings.lightningEnabled ? { ...settings, lightningEnabled: false } : settings,
+ settings: settings.acceleratorEnabled
+ ? { ...settings, acceleratorEnabled: false, acceleratorLoraKeys: [] }
+ : settings,
};
}
@@ -484,13 +560,15 @@ export const getLightningToggleResult = (
missingLoras: false,
settings: {
...settings,
- ...WAN_LIGHTNING_SAMPLING,
- lightningEnabled: true,
+ acceleratorEnabled: true,
+ acceleratorLoraKeys: entries.map((entry) => entry.model.key),
+ cfgScale: config.accelerator.cfgScale,
+ cfgScaleLowNoise: config.accelerator.cfgScaleLowNoise,
loras: [
- ...withoutLightning,
- { isEnabled: true, model: pair.high, weight: 1 },
- { isEnabled: true, model: pair.low, weight: 1 },
+ ...withoutAccelerators.filter((lora) => !entries.some((e) => e.model.key === lora.model.key)),
+ ...entries,
],
+ steps: config.accelerator.steps,
},
};
};
@@ -721,6 +799,8 @@ export const getDefaultVideoSettings = (
const config = getVideoConfig(model);
const base: VideoSettings = {
+ acceleratorEnabled: false,
+ acceleratorLoraKeys: [],
aspectRatioId: '16:9',
batchCount: 1,
cfgScale: config.defaults.cfgScale,
@@ -731,7 +811,6 @@ export const getDefaultVideoSettings = (
h3TextEncoderModel: null,
h3TransformerModel: null,
lastFrameImage: null,
- lightningEnabled: false,
loras: [],
modelKey: model?.key ?? '',
negativePrompt: '',
@@ -750,10 +829,11 @@ export const getDefaultVideoSettings = (
wanT5EncoderModel: null,
};
- // Lightning defaults ON for Wan A14B when the LoRA pair is installed: the
- // plain 40-step CFG-5 path is prohibitively slow as an out-of-the-box default.
- if (model && config.lightningAvailable) {
- const result = getLightningToggleResult(base, model, models, true);
+ // The accelerator defaults ON when its LoRA(s) are installed: the plain
+ // 40/50-step paths are prohibitively slow as out-of-the-box defaults, and
+ // the bundled video templates make the same choice.
+ if (model && config.accelerator) {
+ const result = getAcceleratorToggleResult(base, model, models, true);
if (!result.missingLoras) {
return result.settings;
@@ -770,15 +850,21 @@ export const getVideoSettingsWithModelDefaults = (
): VideoSettings => {
const modelDefaults = getDefaultVideoSettings(model, models);
+ const previousKeys = new Set(settings.acceleratorLoraKeys);
+
return {
...settings,
+ acceleratorEnabled: modelDefaults.acceleratorEnabled,
+ acceleratorLoraKeys: modelDefaults.acceleratorLoraKeys,
cfgScale: modelDefaults.cfgScale,
cfgScaleLowNoise: modelDefaults.cfgScaleLowNoise,
fps: modelDefaults.fps,
- lightningEnabled: modelDefaults.lightningEnabled,
- loras: [...settings.loras.filter((lora) => !isWanLightningLora(lora.model)), ...modelDefaults.loras].map((lora) =>
- isLoraCompatibleWithModel(lora.model, model) ? lora : { ...lora, isEnabled: false }
- ),
+ loras: [
+ ...settings.loras.filter(
+ (lora) => !previousKeys.has(lora.model.key) && !modelDefaults.loras.some((d) => d.model.key === lora.model.key)
+ ),
+ ...modelDefaults.loras,
+ ].map((lora) => (isLoraCompatibleWithModel(lora.model, model) ? lora : { ...lora, isEnabled: false })),
modelKey: model.key,
numFrames: modelDefaults.numFrames,
steps: modelDefaults.steps,
@@ -861,11 +947,29 @@ export const getVideoModelSelectionResult = ({
addClearedLabel(clearedLabels, 'FPS');
}
- if (next.lightningEnabled && !config.lightningAvailable) {
- // Lightning wrote steps/CFG, so clearing it restores the new model's own defaults.
- const result = getLightningToggleResult(next, model, models, false);
- Object.assign(next, result.settings);
- addClearedLabel(clearedLabels, 'Lightning');
+ if (next.acceleratorEnabled) {
+ // Carry the "fast path" intent across model switches: when the new model
+ // resolves to the SAME accelerator LoRA set, everything the user may have
+ // tuned (steps, CFG, LoRA weights) is left alone. Only when the identity
+ // changes (Lightning ↔ Turbo) is the toggle re-applied, and when the new
+ // model has no accelerator — or its LoRAs are not installed — the fast
+ // path turns off, restoring the model's own steps/CFG.
+ const targetEntries = config.accelerator ? findAcceleratorLoraEntries(model, models) : null;
+ const targetKeys = targetEntries?.map((entry) => entry.model.key).sort() ?? null;
+ const currentKeys = [...next.acceleratorLoraKeys].sort();
+ const sameAccelerator =
+ targetKeys !== null &&
+ targetKeys.length === currentKeys.length &&
+ targetKeys.every((key, index) => key === currentKeys[index]);
+
+ if (!sameAccelerator) {
+ const result = targetEntries
+ ? getAcceleratorToggleResult(next, model, models, true)
+ : getAcceleratorToggleResult(next, model, models, false);
+
+ Object.assign(next, result.settings);
+ addClearedLabel(clearedLabels, 'Acceleration');
+ }
}
if (next.cfgScaleLowNoise !== null && !config.cfg.lowNoiseVisible) {
@@ -995,8 +1099,8 @@ export const getVideoValidationReasons = (model: MainModelConfig, settings: Vide
reasons.push('CFG (Low Noise) must be at least 0.');
}
- if (settings.lightningEnabled && !config.lightningAvailable) {
- reasons.push('Lightning is only available for Wan A14B models.');
+ if (settings.acceleratorEnabled && !config.accelerator) {
+ reasons.push(`${model.name} has no distillation fast path. Turn the accelerator off to generate with it.`);
}
if (!getVideoDimensions(model, settings)) {
diff --git a/invokeai/frontend/webv2/src/features/video/index.ts b/invokeai/frontend/webv2/src/features/video/index.ts
index 61ec6ac25e..65bbb4337f 100644
--- a/invokeai/frontend/webv2/src/features/video/index.ts
+++ b/invokeai/frontend/webv2/src/features/video/index.ts
@@ -22,7 +22,6 @@ export {
isVideoSourceClip,
isVideoTargetResolution,
isVideoWidgetValues,
- isWanLightningLora,
MINIMAX_H3_TARGET_RESOLUTIONS,
normalizeVideoSettings,
normalizeVideoWidgetValues,
@@ -46,9 +45,10 @@ export {
type VideoDimensions,
} from './core/dimensions';
export {
+ findMiniMaxH3TurboLora,
findWanLightningLoraPair,
+ getAcceleratorToggleResult,
getDefaultVideoSettings,
- getLightningToggleResult,
getVideoComponentSectionPolicy,
getVideoDimensions,
getVideoModelAvailabilityReasons,
@@ -62,11 +62,13 @@ export {
isValidVideoNumFrames,
isVideoModelSelectable,
isVideoModeSupported,
+ MINIMAX_H3_TURBO_ACCELERATOR,
snapVideoNumFrames,
SUPPORTED_VIDEO_BASES,
VIDEO_GENERATION,
- WAN_LIGHTNING_SAMPLING,
+ WAN_LIGHTNING_ACCELERATOR,
type ResolvedVideoDimensions,
+ type VideoAcceleratorConfig,
type SupportedVideoBase,
type VideoComponentSectionPolicy,
type VideoComponentSlotPolicy,