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(ltx2): hide the negative prompt when the accelerator removes guidance
Lincoln Stein6f627333cff9
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.tsindex d22272e484..870c0c0c7b 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts@@ -225,6 +225,7 @@ describe('getVideoDimensions', () => {describe('getVideoPromptPolicy', () => {const promptSettings = (overrides: Partial<Parameters<typeof getVideoPromptPolicy>[1]> = {}) => ({+ acceleratorEnabled: false,audioCfgScale: null,cfgScale: 5,cfgScaleLowNoise: null,@@ -422,6 +423,84 @@ describe('LTX-2 distilled accelerator', () => {expect(off.loras).toEqual([]);});+ it('hides the negative prompt once guidance is gone, like the distilled checkpoint', () => {+ // The accelerator drives every scale to identity, so the negative prompt stops being used --+ // but LTX-2 is the only family that pre-fills it, so leaving it on screen shows a populated box+ // full of terms that silently do nothing, under a CFG of 1 the user never typed.+ const model = ltx2('ltx2_dev');+ const guided = getVideoPromptPolicy(model, {+ acceleratorEnabled: false,+ audioCfgScale: 7,+ cfgScale: 3,+ cfgScaleLowNoise: null,+ negativePromptEnabled: true,+ wanLowNoiseModel: null,+ });+ const accelerated = getVideoPromptPolicy(model, {+ acceleratorEnabled: true,+ audioCfgScale: 1,+ cfgScale: 1,+ cfgScaleLowNoise: null,+ negativePromptEnabled: true,+ wanLowNoiseModel: null,+ });++ expect(guided).toMatchObject({ negativeUsedInGraph: true, negativeVisible: true });+ expect(accelerated).toMatchObject({ negativeUsedInGraph: false, negativeVisible: false });+ // The same shape the distilled checkpoint presents, which is the model an accelerated Dev is.+ expect(accelerated.negativeVisible).toBe(+ getVideoPromptPolicy(ltx2('ltx2_distilled'), {+ acceleratorEnabled: false,+ audioCfgScale: null,+ cfgScale: 1,+ cfgScaleLowNoise: null,+ negativePromptEnabled: true,+ wanLowNoiseModel: null,+ }).negativeVisible+ );+ });++ it('brings the negative prompt back if a scale is raised with the toggle still on', () => {+ // Off-recipe but legal. What must not happen is the field staying hidden while the prompt+ // silently counts again -- the graph wires it whenever a scale is above 1, toggle or no toggle.+ const model = ltx2('ltx2_dev');+ const raisedVideoCfg = getVideoPromptPolicy(model, {+ acceleratorEnabled: true,+ audioCfgScale: 1,+ cfgScale: 3,+ cfgScaleLowNoise: null,+ negativePromptEnabled: true,+ wanLowNoiseModel: null,+ });+ // LTX-2's audio stream is guided on its own scale, so it alone is enough.+ const raisedAudioCfg = getVideoPromptPolicy(model, {+ acceleratorEnabled: true,+ audioCfgScale: 7,+ cfgScale: 1,+ cfgScaleLowNoise: null,+ negativePromptEnabled: true,+ wanLowNoiseModel: null,+ });++ expect(raisedVideoCfg).toMatchObject({ negativeUsedInGraph: true, negativeVisible: true });+ expect(raisedAudioCfg).toMatchObject({ negativeUsedInGraph: true, negativeVisible: true });+ });++ it('leaves families whose accelerator keeps guidance alone', () => {+ // Wan and H3 declare no guidance triple, so their accelerator drops CFG but does not make the+ // run guidance-free -- their negative prompt stays visible, exactly as before.+ const wan = getVideoPromptPolicy(wanModel('t2v_a14b'), {+ acceleratorEnabled: true,+ audioCfgScale: null,+ cfgScale: 1,+ cfgScaleLowNoise: null,+ negativePromptEnabled: true,+ wanLowNoiseModel: null,+ });++ expect(wan.negativeVisible).toBe(true);+ });+it('is not offered on the distilled checkpoint, which already is the fast path', () => {// Patching a distillation LoRA onto a model the distillation was not fitted to.const policy = getVideoModelPolicy(ltx2('ltx2_distilled'), getDefaultVideoSettings(ltx2('ltx2_distilled')));diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.tsindex e5e79f39f1..5ed00aa0ac 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts@@ -701,7 +701,12 @@ export const getVideoPromptPolicy = (model: MainModelConfig | undefined,settings: Pick<VideoSettings,- 'audioCfgScale' | 'cfgScale' | 'cfgScaleLowNoise' | 'negativePromptEnabled' | 'wanLowNoiseModel'+ | 'acceleratorEnabled'+ | 'audioCfgScale'+ | 'cfgScale'+ | 'cfgScaleLowNoise'+ | 'negativePromptEnabled'+ | 'wanLowNoiseModel'>) => {const config = getVideoConfig(model);@@ -716,13 +721,25 @@ export const getVideoPromptPolicy = (// And LTX-2's audio stream is guided on its own scale, off one shared unconditional pass// (`LTX2Guidance.passes`): audio CFG above 1 consumes the negative prompt even at video CFG 1.const audioCfgActive = config.guidance.audioVisible && settings.audioCfgScale !== null && settings.audioCfgScale > 1;+ // An accelerator that declares a guidance triple drives every scale to its identity, which makes+ // the run guidance-free -- the same model the family's distilled *checkpoint* variant is, and that+ // variant declares `usage: 'never'`. Presenting the accelerated model any differently leaves a+ // populated negative prompt on screen that silently stops mattering, and the user never typed the+ // CFG of 1 that disabled it: the toggle did. Families whose accelerator declares no guidance+ // (Wan, MiniMax H3) are unaffected.+ //+ // Gated on guidance being actually inactive, not merely on the toggle: raising a scale back above+ // 1 with the accelerator still on is off-recipe but legal, and it makes the negative prompt count+ // again -- so the field has to come back rather than stay hidden while silently taking effect.+ const guidanceActive = settings.cfgScale > 1 || lowNoiseCfgActive || audioCfgActive;+ const hiddenByAccelerator =+ settings.acceleratorEnabled && config.accelerator?.guidance !== undefined && !guidanceActive;const negativeUsedInGraph =settings.negativePromptEnabled &&- (config.negativePrompt.usage === 'always' ||- (config.negativePrompt.usage === 'cfg-gated' && (settings.cfgScale > 1 || lowNoiseCfgActive || audioCfgActive)));+ (config.negativePrompt.usage === 'always' || (config.negativePrompt.usage === 'cfg-gated' && guidanceActive));return {- negativeVisible: config.negativePrompt.visible,+ negativeVisible: config.negativePrompt.visible && !hiddenByAccelerator,negativeUsedInGraph,...(config.negativePrompt.usage === 'cfg-gated' ? { negativeHelpTextKey: 'widgets.video.negativeCfgHelp' } : {}),};