Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(ui): resolve MiniMax H3 turbo steps per LoRA and accept either turbo LoRA
Lincoln Stein75a093eeab61
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 74bebc5af0..9c5659a855 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3139,6 +3139,8 @@"selectComponent": "Select a component model…","acceleratorBroken": "Accelerator turned off","acceleratorBrokenDescription": "One of its LoRAs was removed or disabled, so steps and CFG were restored to the model's defaults.",+ "acceleratorSwitched": "{{label}} now running on a different LoRA",+ "acceleratorSwitchedDescription": "The fast path follows {{name}}, so steps were set to {{steps}}.","resetAllToModelDefaults": "Reset all settings to the model's defaults","expertWiring": {"highAsLow": "\"{{lowName}}\" is tagged as the high-noise expert but is wired as the low-noise one. The wiring is authoritative — swap if unintended.",diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.tsindex f8aa98f950..776dea0d39 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts@@ -7,6 +7,7 @@ import type { VideoSettings } from './types';import {findMiniMaxH3TurboLora,findWanLightningLoraPair,+ getAcceleratorLoraChangeResult,getDefaultVideoSettings,getAcceleratorToggleResult,getVideoComponentSectionPolicy,@@ -353,6 +354,15 @@ describe('Lightning', () => {describe('MiniMax H3 Turbo', () => {const TURBO = { base: 'minimax-h3', key: 'turbo', name: 'MiniMax H3 Turbo LoRA', type: 'lora' as const };+ // The second installed Turbo LoRA: same family, a different step schedule,+ // and nothing but the org name in it to say so.+ const LIGHTX2V = {+ base: 'minimax-h3',+ key: 'lightx2v',+ name: 'MiniMax H3 LightX2V Turbo LoRA',+ type: 'lora' as const,+ };+ const H3_CATALOG = [TURBO, LIGHTX2V];it('finds the installed Turbo LoRA by name, ignoring Wan Lightning models', () => {expect(findMiniMaxH3TurboLora([LIGHTNING_T2V_HIGH, TURBO])).toMatchObject({ key: 'turbo' });@@ -397,6 +407,137 @@ describe('MiniMax H3 Turbo', () => {expect(off.acceleratorLoraKeys).toEqual([]);});+ it('runs the LightX2V release at the 8 steps it was distilled for, not the repack default of 6', () => {+ const model = h3Model();+ const on = getAcceleratorToggleResult(settingsFor(model), model, [LIGHTX2V], true).settings;++ expect(on).toMatchObject({ acceleratorEnabled: true, steps: 8 });+ expect(on.acceleratorLoraKeys).toEqual([LIGHTX2V.key]);+ // The help text quotes the running LoRA's count, not the family default.+ expect(getVideoModelPolicy(model, on).ui.accelerator).toMatchObject({ label: 'Turbo', steps: 8 });+ });++ it('re-anchors the fast path on the other Turbo LoRA instead of tearing it down', () => {+ const model = h3Model();+ // Both are installed, so the toggle picks one; the user then swaps in the+ // other by enabling it and switching the first off.+ const on = getAcceleratorToggleResult(settingsFor(model), model, H3_CATALOG, true).settings;++ expect(on.acceleratorLoraKeys).toEqual([LIGHTX2V.key]);++ const swapped = getAcceleratorLoraChangeResult(on, model, H3_CATALOG, [+ { isEnabled: false, model: LIGHTX2V as never, weight: 1 },+ { isEnabled: true, model: TURBO as never, weight: 1 },+ ]);++ expect(swapped.outcome).toBe('switched');+ expect(swapped.settings).toMatchObject({ acceleratorEnabled: true, cfgScale: 1, steps: 6 });+ expect(swapped.settings.acceleratorLoraKeys).toEqual([TURBO.key]);+ expect(swapped.acceleratorLoras?.map((entry) => entry.key)).toEqual([TURBO.key]);+ });++ it('adopts a Turbo LoRA the user enables on their own, and honors it on the next toggle', () => {+ const model = h3Model();+ const off = settingsFor(model);++ expect(off).toMatchObject({ acceleratorEnabled: false, steps: 50 });++ const adopted = getAcceleratorLoraChangeResult(off, model, H3_CATALOG, [+ { isEnabled: true, model: TURBO as never, weight: 1 },+ ]);++ expect(adopted.outcome).toBe('switched');+ expect(adopted.settings).toMatchObject({ acceleratorEnabled: true, steps: 6 });+ expect(adopted.settings.acceleratorLoraKeys).toEqual([TURBO.key]);++ // Toggling off drops the user's pick from the list, and toggling back on+ // is free to take the catalog's again.+ const cycled = getAcceleratorToggleResult(adopted.settings, model, H3_CATALOG, false).settings;++ expect(cycled).toMatchObject({ acceleratorEnabled: false, steps: 50 });+ expect(cycled.loras).toEqual([]);+ });++ it('honors a Turbo LoRA the user already has enabled when the toggle goes on', () => {+ const model = h3Model();+ const withTurbo = settingsFor(model, { loras: [{ isEnabled: true, model: TURBO as never, weight: 1 }] });+ const on = getAcceleratorToggleResult(withTurbo, model, H3_CATALOG, true).settings;++ expect(on.acceleratorLoraKeys).toEqual([TURBO.key]);+ expect(on.steps).toBe(6);+ });++ it('never adopts a look-alike LoRA, and never adopts at all on a background sync', () => {+ const model = h3Model();+ const turboRider = { base: 'minimax-h3', key: 'rider', name: 'Turbo Rider', type: 'lora' as const };+ const off = settingsFor(model);++ expect(+ getAcceleratorLoraChangeResult(off, model, H3_CATALOG, [+ { isEnabled: true, model: turboRider as never, weight: 0.8 },+ ]).outcome+ ).toBe('unchanged');+ expect(+ getAcceleratorLoraChangeResult(off, model, H3_CATALOG, [{ isEnabled: true, model: TURBO as never, weight: 1 }], {+ adopt: false,+ }).outcome+ ).toBe('unchanged');+ });++ it('keeps an oddly named Turbo LoRA running while it is the only one installed', () => {+ const model = h3Model();+ const turboRider = { base: 'minimax-h3', key: 'rider', name: 'Turbo Rider', type: 'lora' as const };+ const on = getDefaultVideoSettings(model, [turboRider]);++ expect(on.acceleratorLoraKeys).toEqual(['rider']);++ // An unrelated list edit must not tear down a fast path that is still on.+ const result = getAcceleratorLoraChangeResult(+ on,+ model,+ [turboRider],+ [...on.loras, { isEnabled: true, model: lora('Style LoRA') as never, weight: 0.5 }]+ );++ expect(result.outcome).toBe('unchanged');+ expect(result.settings.acceleratorEnabled).toBe(true);+ });++ it('turns the fast path off with the model defaults when no Turbo LoRA is left enabled', () => {+ const model = h3Model();+ const on = getDefaultVideoSettings(model, [TURBO]);+ const result = getAcceleratorLoraChangeResult(on, model, H3_CATALOG, []);++ expect(result.outcome).toBe('disabled');+ expect(result.settings).toMatchObject({ acceleratorEnabled: false, steps: 50 });+ });++ it('leaves user-tuned steps alone while its own LoRA is still enabled', () => {+ const model = h3Model();+ const on = { ...getDefaultVideoSettings(model, [TURBO]), steps: 9 };+ const result = getAcceleratorLoraChangeResult(on, model, H3_CATALOG, [+ ...on.loras,+ { isEnabled: true, model: lora('Style LoRA') as never, weight: 0.5 },+ ]);++ expect(result.outcome).toBe('unchanged');+ expect(result.settings).toMatchObject({ acceleratorEnabled: true, steps: 9 });+ });++ it('swaps a T2V Lightning pair for the I2V one when the main changes family', () => {+ const catalog = [LIGHTNING_T2V_HIGH, LIGHTNING_T2V_LOW, LIGHTNING_I2V_HIGH, LIGHTNING_I2V_LOW];+ const t2v = wanModel('t2v_a14b');+ const on = getAcceleratorToggleResult(settingsFor(t2v), t2v, catalog, true).settings;+ const result = getVideoModelSelectionResult({+ currentSettings: on,+ model: wanModel('i2v_a14b'),+ models: catalog,+ });++ expect(result.settings.acceleratorLoraKeys).toEqual([LIGHTNING_I2V_HIGH.key, LIGHTNING_I2V_LOW.key]);+ expect(result.clearedLabels).toContain('Acceleration');+ });+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];diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.tsindex eab726093d..7e5f9f3827 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts@@ -82,12 +82,20 @@ export interface VideoFpsPolicy {/*** 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).+ * high/low pair; MiniMax H3 uses a single Turbo LoRA.+ *+ * `steps` is the count the family's reference LoRA was distilled for (the+ * bundled H3 templates assume the 6-step repack). Releases trained for a+ * different schedule are resolved per-LoRA by `getAcceleratorSteps`.*/export interface VideoAcceleratorConfig {label: 'Lightning' | 'Turbo';steps: number;+ /**+ * Step counts for releases whose names carry no "N-step" token. First match+ * wins; consulted only when the name does not state the count itself.+ */+ stepOverrides?: readonly { pattern: RegExp; steps: number }[];cfgScale: number;cfgScaleLowNoise: number | null;}@@ -118,11 +126,17 @@ export const WAN_LIGHTNING_ACCELERATOR: VideoAcceleratorConfig = {steps: 4,};+// LightX2V's H3 release is distilled to 8 steps where the repack the templates+// assume is 6, and only its *file* name says so — the starter installs it as+// "MiniMax H3 LightX2V Turbo LoRA", so the org name is the signal that survives.+const LIGHTX2V_PATTERN = /(?:^|[^a-z0-9])lightx2v(?:[^a-z0-9]|$)/i;+export const MINIMAX_H3_TURBO_ACCELERATOR: VideoAcceleratorConfig = {cfgScale: 1,cfgScaleLowNoise: null,label: 'Turbo',steps: 6,+ stepOverrides: [{ pattern: LIGHTX2V_PATTERN, steps: 8 }],};const WAN_TARGET_RESOLUTION_OPTIONS: readonly VideoTargetResolutionOption[] = [@@ -413,6 +427,15 @@ export interface VideoModelPolicy {export const getVideoModelPolicy = (model: MainModelConfig | undefined, settings: VideoSettings): VideoModelPolicy => {const config = getVideoConfig(model);+ // The step count the help text quotes is the one the *running* accelerator+ // LoRA was distilled for, not the family's reference count — with the+ // 8-step LightX2V Turbo LoRA on, "6 steps" would be a lie.+ const accelerator = config.accelerator+ ? {+ ...config.accelerator,+ steps: getAcceleratorSteps(config.accelerator, getRecordedAcceleratorLoras(settings)),+ }+ : null;return {aspectRatioOptions: getVideoAspectRatioOptions(model),@@ -426,7 +449,7 @@ export const getVideoModelPolicy = (model: MainModelConfig | undefined, settingsprompt: getVideoPromptPolicy(model, settings),targetResolutions: config.targetResolutions,ui: {- accelerator: config.accelerator,+ accelerator,audioOutput: config.audioOutput,cfgLowNoiseVisible: config.cfg.lowNoiseVisible,cfgVisible: config.cfg.visible,@@ -443,6 +466,17 @@ export interface WanLightningLoraPair {low: LoraModelConfig;}+export interface FindAcceleratorLoraOptions {+ /**+ * Accept only LoRAs that also name the model family. Used when the candidate+ * list is the user's own Concepts list rather than the installed catalog:+ * there is no better-named release for a look-alike to lose to, so a+ * personal "Turbo …" LoRA — or a T2V Lightning pair sitting on an I2V main —+ * would otherwise be mistaken for a distillation fast path.+ */+ requireFamilyName?: boolean;+}+// "high"/"low" as standalone words. \b is useless here because release files// use underscores ("high_noise_model") where \w breaks no boundary, while a// plain word-suffix match swallows "Slow"/"Thigh" — so the token must be@@ -454,10 +488,16 @@ const LOW_NOISE_PATTERN = /(?:^|[^a-z0-9])low(?:[^a-z0-9]|$)/i;* The installed Lightning LoRA pair for a Wan A14B main, if any. When pairs for* more than one family are installed (e.g. T2V and I2V releases), the one* naming the main's family wins; noise assignment comes from the model names.+ *+ * `requireFamilyName` drops the fallback and demands the family token, so a+ * T2V pair is not read as a valid accelerator for an I2V main — the question+ * asked when the candidates are LoRAs already in the panel rather than the+ * catalog the toggle is free to pick from.*/export const findWanLightningLoraPair = (models: readonly ModelConfig[],- mainVariant: string | null | undefined+ mainVariant: string | null | undefined,+ { requireFamilyName = false }: FindAcceleratorLoraOptions = {}): WanLightningLoraPair | null => {const candidates = models.filter((model): model is ModelConfig & LoraModelConfig =>@@ -472,7 +512,9 @@ export const findWanLightningLoraPair = (const familyPattern = familyToken ? new RegExp(`(?:^|[^a-z0-9])${familyToken}(?:[^a-z0-9]|$)`, 'i') : null;const score = (model: LoraModelConfig): number => (familyPattern?.test(model.name) ? 0 : 1);const pick = (pattern: RegExp): LoraModelConfig | null =>- candidates.filter((model) => pattern.test(model.name)).sort((a, b) => score(a) - score(b))[0] ?? null;+ candidates+ .filter((model) => pattern.test(model.name) && (!requireFamilyName || !familyPattern || score(model) === 0))+ .sort((a, b) => score(a) - score(b))[0] ?? null;const high = pick(HIGH_NOISE_PATTERN);const low = pick(LOW_NOISE_PATTERN);@@ -490,35 +532,156 @@ const MINIMAX_H3_NAME_PATTERN = /(?:^|[^a-z0-9])(?:minimax|h3)(?:[^a-z0-9]|$)/i;* 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 => {+export const findMiniMaxH3TurboLora = (+ models: readonly ModelConfig[],+ { requireFamilyName = false }: FindAcceleratorLoraOptions = {}+): 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)+ isLoraModelConfig(model) &&+ model.base === 'minimax-h3' &&+ TURBO_PATTERN.test(model.name) &&+ (!requireFamilyName || MINIMAX_H3_NAME_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 => {+/**+ * The complete accelerator LoRA set contained in `candidates`, or null when it+ * is not all there. The candidates are the installed catalog when asking what+ * the toggle *would* run, and the user's own Concepts list when asking what is+ * actually running.+ */+export const findAcceleratorLorasIn = (+ model: MainModelConfig,+ candidates: readonly ModelConfig[],+ options: FindAcceleratorLoraOptions = {}+): LoraModelConfig[] | null => {if (model.base === 'minimax-h3') {- const turbo = findMiniMaxH3TurboLora(models);+ const turbo = findMiniMaxH3TurboLora(candidates, options);- return turbo ? [{ isEnabled: true, model: turbo, weight: 1 }] : null;+ return turbo ? [turbo] : null;}- const pair = findWanLightningLoraPair(models, model.variant);+ const pair = findWanLightningLoraPair(candidates, model.variant, options);- return pair- ? [- { isEnabled: true, model: pair.high, weight: 1 },- { isEnabled: true, model: pair.low, weight: 1 },- ]- : null;+ return pair ? [pair.high, pair.low] : null;+};++// "4-step", "8 steps", "6step" — how a distillation release states the schedule+// it was trained for. Two digits at most, so a checkpoint tag ("step600") or a+// rank cannot be read as a step count.+const STEP_COUNT_PATTERN = /(?:^|[^a-z0-9])(\d{1,2})[ _-]?steps?(?:[^a-z0-9]|$)/i;++/**+ * The step count one distillation LoRA was trained for. Its name is the only+ * record of it: an explicit "N-step" token wins, then the family's per-release+ * overrides, and failing both the family's reference count.+ */+const getLoraAcceleratorSteps = (config: VideoAcceleratorConfig, lora: LoraModelConfig): number => {+ const stated = Number(STEP_COUNT_PATTERN.exec(lora.name)?.[1] ?? 0);++ if (stated > 0) {+ return stated;+ }++ return config.stepOverrides?.find((override) => override.pattern.test(lora.name))?.steps ?? config.steps;+};++/**+ * The step count for a whole accelerator set. Both halves of a Wan Lightning+ * pair state the same schedule; if a mismatched pair is ever assembled, the+ * higher count is the safe pick — under-stepping is what reads as a broken+ * model.+ */+export const getAcceleratorSteps = (config: VideoAcceleratorConfig, loras: readonly LoraModelConfig[]): number =>+ loras.reduce((steps, lora) => Math.max(steps, getLoraAcceleratorSteps(config, lora)), 0) || config.steps;++/** The LoRA models the user currently has switched on in the Concepts list. */+const getEnabledLoraModels = (settings: Pick<VideoSettings, 'loras'>): LoraModelConfig[] =>+ settings.loras.filter((lora) => lora.isEnabled).map((lora) => lora.model);++/** The LoRA models the accelerator toggle recorded, as they stand in the list. */+const getRecordedAcceleratorLoras = (+ settings: Pick<VideoSettings, 'acceleratorEnabled' | 'acceleratorLoraKeys' | 'loras'>+): LoraModelConfig[] => {+ const recorded = new Set(settings.acceleratorLoraKeys);++ return settings.acceleratorEnabled+ ? settings.loras.filter((lora) => recorded.has(lora.model.key)).map((lora) => lora.model)+ : [];+};++/**+ * The complete accelerator set contained in `candidates`, judged the way the+ * panel has to judge LoRAs the user is holding: one that names the model's own+ * family, or failing that the very set the catalog would install. The+ * family-name requirement keeps a personal "Turbo …" LoRA — or a T2V Lightning+ * pair left over on an I2V main — from passing as a fast path; the catalog+ * pick is exempt from it because it is what the toggle itself installs, odd+ * name and all.+ */+const findAcceleratorAmong = (+ model: MainModelConfig,+ candidates: readonly LoraModelConfig[],+ models: readonly ModelConfig[]+): LoraModelConfig[] | null => {+ const named = findAcceleratorLorasIn(model, candidates, { requireFamilyName: true });++ if (named) {+ return named;+ }++ const catalogPick = findAcceleratorLorasIn(model, models);++ return catalogPick?.every((lora) => candidates.some((candidate) => candidate.key === lora.key)) ? catalogPick : null;+};++/**+ * Whether the settings' recorded accelerator keys still name a complete set of+ * enabled LoRAs that is a valid fast path *for this model* — the question both+ * the model-switch reconcile and the Concepts-list reconcile turn on. Asked of+ * the recorded keys alone, so with two Turbo LoRAs enabled the one the user+ * anchored on keeps the fast path instead of losing it to a tie-break.+ */+const isRecordedAcceleratorIntact = (+ settings: Pick<VideoSettings, 'acceleratorLoraKeys' | 'loras'>,+ model: MainModelConfig,+ models: readonly ModelConfig[],+ config: VideoVariantConfig+): boolean => {+ const recorded = new Set(settings.acceleratorLoraKeys);++ if (!config.accelerator || recorded.size === 0) {+ return false;+ }++ const live = getEnabledLoraModels(settings).filter((lora) => recorded.has(lora.key));++ return live.length === recorded.size && findAcceleratorAmong(model, live, models)?.length === recorded.size;+};++/**+ * The accelerator LoRA entries for a model, or null when they are not+ * installed. A complete set the user already has enabled in the Concepts list+ * wins over the catalog pick: with two Turbo LoRAs installed, the toggle must+ * honor the one the user chose rather than swapping in its own.+ */+const findAcceleratorLoraEntries = (+ model: MainModelConfig,+ models: readonly ModelConfig[],+ settings?: Pick<VideoSettings, 'loras'>+): GenerateLora[] | null => {+ const chosen =+ (settings ? findAcceleratorLorasIn(model, getEnabledLoraModels(settings), { requireFamilyName: true }) : null) ??+ findAcceleratorLorasIn(model, models);++ return chosen?.map((lora) => ({ isEnabled: true, model: lora, weight: 1 })) ?? null;};export interface AcceleratorToggleResult {@@ -559,7 +722,7 @@ export const getAcceleratorToggleResult = (};}- const entries = findAcceleratorLoraEntries(model, models);+ const entries = findAcceleratorLoraEntries(model, models, { loras: withoutAccelerators });if (!entries) {// Never leave the flag claiming a fast path that has no LoRAs behind it.@@ -583,7 +746,86 @@ export const getAcceleratorToggleResult = (...withoutAccelerators.filter((lora) => !entries.some((e) => e.model.key === lora.model.key)),...entries,],- steps: config.accelerator.steps,+ steps: getAcceleratorSteps(+ config.accelerator,+ entries.map((entry) => entry.model)+ ),+ },+ };+};++export type AcceleratorLoraChangeOutcome = 'unchanged' | 'switched' | 'disabled';++export interface AcceleratorLoraChangeResult {+ settings: VideoSettings;+ outcome: AcceleratorLoraChangeOutcome;+ /** The LoRA set now driving the fast path — only set when `outcome` is 'switched'. */+ acceleratorLoras: LoraModelConfig[] | null;+}++/**+ * Re-reads the fast path from the Concepts list after it changes. The flag has+ * to describe what is actually enabled, so swapping one Turbo LoRA for another+ * keeps the fast path — re-anchored on the new LoRA, at the step count *it*+ * was distilled for — instead of tearing it down. Only a list with no complete+ * accelerator left in it turns the toggle off and restores the model's own+ * sampling defaults: a silent 6-step run with no distillation LoRA behind it+ * just reads as a broken model.+ *+ * `adopt` lets an explicit user edit turn the fast path ON when the list gains+ * a complete accelerator set. Background catalog reconciliation passes false,+ * so a stored off-with-a-Turbo-LoRA state is never rewritten behind the user's+ * back — only repaired when it was on.+ */+export const getAcceleratorLoraChangeResult = (+ settings: VideoSettings,+ model: MainModelConfig,+ models: readonly ModelConfig[],+ loras: GenerateLora[],+ { adopt = true }: { adopt?: boolean } = {}+): AcceleratorLoraChangeResult => {+ const config = getVideoConfig(model);+ const next: VideoSettings = { ...settings, loras };++ // The recorded set is still running: leave everything the user tuned alone.+ if (isRecordedAcceleratorIntact(next, model, models, config)) {+ return { acceleratorLoras: null, outcome: 'unchanged', settings: next };+ }++ const replacement =+ config.accelerator && (settings.acceleratorEnabled || adopt)+ ? findAcceleratorAmong(model, getEnabledLoraModels(next), models)+ : null;++ if (replacement && config.accelerator) {+ return {+ acceleratorLoras: replacement,+ outcome: 'switched',+ settings: {+ ...next,+ acceleratorEnabled: true,+ acceleratorLoraKeys: replacement.map((lora) => lora.key),+ cfgScale: config.accelerator.cfgScale,+ cfgScaleLowNoise: config.accelerator.cfgScaleLowNoise,+ steps: getAcceleratorSteps(config.accelerator, replacement),+ },+ };+ }++ if (!settings.acceleratorEnabled) {+ return { acceleratorLoras: null, outcome: 'unchanged', settings: next };+ }++ return {+ acceleratorLoras: null,+ outcome: 'disabled',+ settings: {+ ...next,+ acceleratorEnabled: false,+ acceleratorLoraKeys: [],+ cfgScale: config.defaults.cfgScale,+ cfgScaleLowNoise: config.defaults.cfgScaleLowNoise,+ steps: config.defaults.steps,},};};@@ -1062,24 +1304,16 @@ export const getVideoModelSelectionResult = ({}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+ // Carry the "fast path" intent across model switches: when the LoRAs the+ // user is actually running are still a valid accelerator for the new model,+ // everything they may have tuned (steps, CFG, LoRA weights) is left alone.+ // Only when that set no longer applies (Lightning ↔ Turbo, or a Wan pair+ // aimed at the other expert family) 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);+ if (!isRecordedAcceleratorIntact(next, model, models, config)) {+ const targetEntries = config.accelerator ? findAcceleratorLoraEntries(model, models, next) : null;+ const result = getAcceleratorToggleResult(next, model, models, targetEntries !== null);Object.assign(next, result.settings);addClearedLabel(clearedLabels, 'Acceleration');diff --git a/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts b/invokeai/frontend/webv2/src/features/video/core/widgetValues.tsindex 65d3cb03a2..e8091c26ee 100644--- a/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts+++ b/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts@@ -9,10 +9,10 @@ import { isLoraCompatibleWithModel, isLoraModelConfig, SEED_MAX } from '@featureimport type { VideoWidgetValues } from './types';import {+ getAcceleratorLoraChangeResult,getDefaultVideoSettings,getVideoComponentSectionPolicy,getVideoModelAvailabilityReasons,- getVideoModelPolicy,getVideoModelSelectionResult,getVideoValidationReasons,isSupportedVideoModel,@@ -92,33 +92,38 @@ export const syncVideoWidgetValuesWithModels = (: [];}): [];- // The accelerator flag cannot outlive its recorded LoRAs.- const acceleratorAlive =- base.acceleratorEnabled &&- base.acceleratorLoraKeys.length > 0 &&- base.acceleratorLoraKeys.every((key) => loras.some((lora) => lora.model.key === key && lora.isEnabled));- // Reuse the stored array whenever the content is unchanged — the identity- // guarantee below depends on it.- const acceleratorLoraKeys = acceleratorAlive || base.acceleratorLoraKeys.length === 0 ? base.acceleratorLoraKeys : [];- // Losing a pair member through the catalog (uninstalled, dropped as- // incompatible) tears the fast path down the same way the Concepts setter- // does: flag off AND the model's own sampling defaults restored. Clearing- // only the flag would leave steps 4 / CFG 1 with no distillation pair — a- // silent run that reads as a broken model.- const samplingDefaults =- base.acceleratorEnabled && !acceleratorAlive && model ? getVideoModelPolicy(model, base).defaults : null;+ // Losing an accelerator LoRA through the catalog (uninstalled, dropped as+ // incompatible) goes through the same reconcile the Concepts setter uses:+ // another complete accelerator set still enabled in the list takes over,+ // otherwise the flag goes off AND the model's own sampling defaults come+ // back. Clearing only the flag would leave steps 4 / CFG 1 with no+ // distillation LoRA — a silent run that reads as a broken model.+ //+ // `adopt: false`: a catalog sync runs on every render and on mount, so it+ // may only repair a fast path the user turned on, never start one.+ const acceleratorSync = model ? getAcceleratorLoraChangeResult(base, model, models, loras, { adopt: false }) : null;+ const accelerator =+ acceleratorSync && acceleratorSync.outcome !== 'unchanged'+ ? {+ acceleratorEnabled: acceleratorSync.settings.acceleratorEnabled,+ acceleratorLoraKeys: acceleratorSync.settings.acceleratorLoraKeys,+ cfgScale: acceleratorSync.settings.cfgScale,+ cfgScaleLowNoise: acceleratorSync.settings.cfgScaleLowNoise,+ steps: acceleratorSync.settings.steps,+ }+ : // Reuse the stored values whenever nothing changed — the identity+ // guarantee below depends on `acceleratorLoraKeys` keeping its array.+ {+ acceleratorEnabled: base.acceleratorEnabled,+ acceleratorLoraKeys: base.acceleratorLoraKeys,+ cfgScale: base.cfgScale,+ cfgScaleLowNoise: base.cfgScaleLowNoise,+ steps: base.steps,+ };const next: VideoWidgetValues = {...base,- ...(samplingDefaults- ? {- cfgScale: samplingDefaults.cfgScale,- cfgScaleLowNoise: samplingDefaults.cfgScaleLowNoise,- steps: samplingDefaults.steps,- }- : {}),- acceleratorEnabled: acceleratorAlive,- acceleratorLoraKeys,+ ...accelerator,componentSourceModel: syncComponent('componentSourceModel', base.componentSourceModel),h3TextEncoderModel: syncComponent('h3TextEncoderModel', base.h3TextEncoderModel),h3TransformerModel: syncComponent('h3TransformerModel', base.h3TransformerModel),diff --git a/invokeai/frontend/webv2/src/features/video/index.ts b/invokeai/frontend/webv2/src/features/video/index.tsindex 3d7fe70310..e4b93d789f 100644--- a/invokeai/frontend/webv2/src/features/video/index.ts+++ b/invokeai/frontend/webv2/src/features/video/index.ts@@ -47,8 +47,11 @@ export {type VideoDimensions,} from './core/dimensions';export {+ findAcceleratorLorasIn,findMiniMaxH3TurboLora,findWanLightningLoraPair,+ getAcceleratorLoraChangeResult,+ getAcceleratorSteps,getAcceleratorToggleResult,getDefaultVideoSettings,getVideoComponentSectionPolicy,@@ -73,6 +76,8 @@ export {VIDEO_GENERATION,WAN_LIGHTNING_ACCELERATOR,type ResolvedVideoDimensions,+ type AcceleratorLoraChangeOutcome,+ type AcceleratorLoraChangeResult,type VideoAcceleratorConfig,type SupportedVideoBase,type VideoComponentSectionPolicy,diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsxindex e2ffa431e8..32b1d7e337 100644--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx@@ -10,6 +10,7 @@ import { ModelSelect } from '@features/models/react';import { getVideoDurationSeconds, invertVideoAspectRatioId } from '@features/video/core/dimensions';import { normalizeVideoWidgetValues, resolveVideoMode, VIDEO_ASPECT_RATIO_IDS } from '@features/video/core/settings';import {+ getAcceleratorLoraChangeResult,getAcceleratorToggleResult,getVideoDimensions,getVideoModelPolicy,@@ -246,35 +247,40 @@ export const VideoWidgetView = () => {);const setLoras = useCallback((loras: VideoWidgetValues['loras']) => {- // Removing or disabling one of the accelerator's LoRAs breaks the fast- // path: turn it off explicitly, restore the model's own sampling- // defaults (Lightning wrote steps/CFG), keep the user's list edit, and- // say so — a silent 4-step run without the distillation pair would just- // look like a broken model.- const acceleratorBroken =- values.acceleratorEnabled &&- !values.acceleratorLoraKeys.every((key) => loras.some((lora) => lora.model.key === key && lora.isEnabled));-- if (!acceleratorBroken) {+ // The fast path follows the list: a different complete accelerator set+ // in it re-anchors the toggle onto that set at its own step count, and+ // losing the last one turns the toggle off and restores the model's own+ // sampling defaults (the accelerator wrote steps/CFG). Either way the+ // user's list edit stands, and either way they are told — a silent+ // 6-step run with no distillation LoRA behind it just looks like a+ // broken model.+ if (!values.model) {patch({ loras });return;}- patch({- acceleratorEnabled: false,- acceleratorLoraKeys: [],- cfgScale: policy.defaults.cfgScale,- cfgScaleLowNoise: policy.defaults.cfgScaleLowNoise,- loras,- steps: policy.defaults.steps,- });- toaster.create({- description: t('widgets.video.acceleratorBrokenDescription'),- title: t('widgets.video.acceleratorBroken'),- type: 'info',- });+ const result = getAcceleratorLoraChangeResult(values, values.model, models, loras);++ patch({ ...result.settings });++ if (result.outcome === 'switched') {+ toaster.create({+ description: t('widgets.video.acceleratorSwitchedDescription', {+ name: result.acceleratorLoras?.map((lora) => lora.name).join(', ') ?? '',+ steps: result.settings.steps,+ }),+ title: t('widgets.video.acceleratorSwitched', { label: policy.ui.accelerator?.label ?? '' }),+ type: 'info',+ });+ } else if (result.outcome === 'disabled') {+ toaster.create({+ description: t('widgets.video.acceleratorBrokenDescription'),+ title: t('widgets.video.acceleratorBroken'),+ type: 'info',+ });+ }},- [patch, policy.defaults, t, values.acceleratorEnabled, values.acceleratorLoraKeys]+ [models, patch, policy.ui.accelerator?.label, t, values]);const clearFirstFrame = useCallback(() => patch({ firstFrameImage: null }), [patch]);const clearLastFrame = useCallback(() => patch({ lastFrameImage: null }), [patch]);diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.tsindex d75b55c739..d2e086d8e9 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts@@ -124,7 +124,6 @@ describe('getVideoSizeRecall', () => {});describe('deriveAcceleratorRecallState', () => {- const catalog = [WAN_T2V, LIGHTNING_HIGH, LIGHTNING_LOW];const settings = createDefaultVideoWidgetValues([WAN_T2V]);const pairEntries = [{ isEnabled: true, model: LIGHTNING_HIGH as never, weight: 1 },@@ -132,18 +131,18 @@ describe('deriveAcceleratorRecallState', () => {];it('re-enables the fast path when the recalled LoRAs are exactly the accelerator set at its steps', () => {- expect(deriveAcceleratorRecallState(WAN_T2V, catalog, pairEntries, 4, settings)).toEqual({+ expect(deriveAcceleratorRecallState(WAN_T2V, pairEntries, 4, settings)).toEqual({acceleratorEnabled: true,acceleratorLoraKeys: [LIGHTNING_HIGH.key, LIGHTNING_LOW.key],});});it('stays off at non-accelerator steps or with a partial pair', () => {- expect(deriveAcceleratorRecallState(WAN_T2V, catalog, pairEntries, 40, settings)).toEqual({+ expect(deriveAcceleratorRecallState(WAN_T2V, pairEntries, 40, settings)).toEqual({acceleratorEnabled: false,acceleratorLoraKeys: [],});- expect(deriveAcceleratorRecallState(WAN_T2V, catalog, [pairEntries[0]!], 4, settings)).toEqual({+ expect(deriveAcceleratorRecallState(WAN_T2V, [pairEntries[0]!], 4, settings)).toEqual({acceleratorEnabled: false,acceleratorLoraKeys: [],});diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.tsindex 638083a74b..1d46f175c6 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts@@ -8,8 +8,8 @@ import type { VideoAspectRatioId, VideoTargetResolution, VideoWidgetValues } froimport { isLoraCompatibleWithModel, isLoraModelConfig, SEED_MAX } from '@features/generation/settings';import {- findMiniMaxH3TurboLora,- findWanLightningLoraPair,+ findAcceleratorLorasIn,+ getAcceleratorSteps,getVideoAspectRatioOptions,getVideoDimensions,getVideoModelPolicy,@@ -265,35 +265,30 @@ export const getVideoSizeRecall = (};/**- * Whether the recalled LoRA list is exactly what the accelerator toggle would- * install for this model — if so the flag (and its recorded keys) come back- * on, so the panel shows the same fast-path state that produced the video.+ * Whether the recalled LoRA list is itself a complete accelerator set for this+ * model, run at the step count that set was distilled for — if so the flag+ * (and its recorded keys) come back on, so the panel shows the same fast-path+ * state that produced the video. Two Turbo LoRAs are both valid fast paths at+ * different step counts, so the set is read off the recalled list rather than+ * off whatever the catalog would pick today.*/export const deriveAcceleratorRecallState = (model: MainModelConfig,- models: readonly ModelConfig[],loras: readonly GenerateLora[],steps: number,settings: VideoWidgetValues): Pick<VideoWidgetValues, 'acceleratorEnabled' | 'acceleratorLoraKeys'> => {const accelerator = getVideoModelPolicy(model, settings).ui.accelerator;-- if (!accelerator || steps !== accelerator.steps) {- return { acceleratorEnabled: false, acceleratorLoraKeys: [] };- }-- const expected =- model.base === 'minimax-h3'- ? [findMiniMaxH3TurboLora(models)].flatMap((lora) => (lora ? [lora.key] : []))- : (() => {- const pair = findWanLightningLoraPair(models, model.variant);-- return pair ? [pair.high.key, pair.low.key] : [];- })();- const present = expected.length > 0 && expected.every((key) => loras.some((lora) => lora.model.key === key));-- return present- ? { acceleratorEnabled: true, acceleratorLoraKeys: expected }+ const recalled = accelerator+ ? findAcceleratorLorasIn(+ model,+ loras.map((lora) => lora.model),+ { requireFamilyName: true }+ )+ : null;++ return accelerator && recalled && steps === getAcceleratorSteps(accelerator, recalled)+ ? { acceleratorEnabled: true, acceleratorLoraKeys: recalled.map((lora) => lora.key) }: { acceleratorEnabled: false, acceleratorLoraKeys: [] };};@@ -497,7 +492,7 @@ export const buildVideoRecallSettings = ({values = {...values,loras: resolvedLoras,- ...deriveAcceleratorRecallState(model, models, resolvedLoras, values.steps, values),+ ...deriveAcceleratorRecallState(model, resolvedLoras, values.steps, values),};fields.push('loras');}