Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): advisory badge for suspicious Wan A14B expert wiring
Lincoln Stein3b1669cd0b07
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 7c219064ce..4daeeca973 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3053,7 +3053,14 @@"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.",- "resetAllToModelDefaults": "Reset all settings to the model's defaults"+ "resetAllToModelDefaults": "Reset all settings to the model's defaults",+ "expertWiring": {+ "high-as-low": "\"{{lowName}}\" is tagged as the high-noise expert but is wired as the low-noise one. The wiring is authoritative — swap if unintended.",+ "low-as-main": "\"{{mainName}}\" is tagged as the low-noise expert but is wired as the main (high-noise) transformer. The wiring is authoritative — swap if unintended.",+ "single-low": "\"{{mainName}}\" is tagged as the low-noise expert. When running a single expert, the high-noise one is usually the better choice.",+ "swap": "Swap experts",+ "swapped": "The filename tags suggest these two experts are swapped. The wiring is authoritative — swap if unintended."+ }}},"workflowLibrary": {diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.tsindex fe171798f9..5158f58509 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts@@ -17,6 +17,7 @@ import {getVideoModes,getVideoPromptPolicy,getVideoValidationReasons,+ getWanExpertWiringWarning,isSupportedVideoModel,isValidVideoNumFrames,snapVideoNumFrames,@@ -549,6 +550,36 @@ describe('component section policy', () => {});});+describe('getWanExpertWiringWarning', () => {+ const tagged = (variant: string, expert: 'high' | 'low' | 'none', key: string): MainModelConfig => ({+ ...wanModel(variant, 'gguf_quantized', key),+ expert,+ });++ it('flags swapped, mislabeled, and single-low wirings on single-file A14B mains', () => {+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'low', 'm'), tagged('i2v_a14b', 'high', 'l'))).toEqual({+ kind: 'swapped',+ });+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'none', 'm'), tagged('i2v_a14b', 'high', 'l'))).toEqual({+ kind: 'high-as-low',+ });+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'low', 'm'), tagged('i2v_a14b', 'none', 'l'))).toEqual({+ kind: 'low-as-main',+ });+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'low', 'm'), null)).toEqual({ kind: 'single-low' });+ });++ it('stays silent for correct, untagged, Diffusers, TI2V-5B, and non-Wan wirings', () => {+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'high', 'm'), tagged('i2v_a14b', 'low', 'l'))).toBeNull();+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'none', 'm'), tagged('i2v_a14b', 'none', 'l'))).toBeNull();+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'high', 'm'), null)).toBeNull();+ expect(getWanExpertWiringWarning(wanModel('i2v_a14b', 'diffusers'), null)).toBeNull();+ expect(getWanExpertWiringWarning(tagged('ti2v_5b', 'low', 'm'), null)).toBeNull();+ expect(getWanExpertWiringWarning(h3Model(), null)).toBeNull();+ expect(getWanExpertWiringWarning(null, null)).toBeNull();+ });+});+describe('getVideoModelSelectionResult', () => {it('clears conditioning media the new model cannot consume', () => {const from = settingsFor(wanModel('i2v_a14b'), {diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.tsindex 9252a6dbb3..41fa842d7b 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts@@ -797,6 +797,65 @@ const getVideoComponentPolicyContext = (settings,});+// ---------------------------------------------------------------------------+// Wan A14B expert-wiring advisories++export type WanExpertWiringWarning =+ | { kind: 'swapped' }+ | { kind: 'high-as-low' }+ | { kind: 'low-as-main' }+ | { kind: 'single-low' }+ | null;++const getWanExpertTag = (model: MainModelConfig | null): 'high' | 'low' | 'none' => {+ const expert = (model as Record<string, unknown> | null)?.expert;++ return expert === 'high' || expert === 'low' ? expert : 'none';+};++/**+ * Advisory only — mirrors wan_model_loader's stance that explicit wiring is+ * authoritative and the expert tag is a filename heuristic ('none' is common+ * on community finetunes, and deliberate cross-wiring must stay expressible).+ * The panel surfaces this as a badge with a one-click swap; nothing blocks.+ */+export const getWanExpertWiringWarning = (+ model: MainModelConfig | null,+ wanLowNoiseModel: MainModelConfig | null+): WanExpertWiringWarning => {+ // Only single-file A14B mains run the explicit high/low wiring.+ if (!model || model.base !== 'wan' || model.format === 'diffusers') {+ return null;+ }++ const config = getVideoConfig(model);++ if (!config.cfg.lowNoiseVisible) {+ return null;+ }++ const mainTag = getWanExpertTag(model);+ const lowTag = getWanExpertTag(wanLowNoiseModel);++ if (wanLowNoiseModel) {+ if (mainTag === 'low' && lowTag === 'high') {+ return { kind: 'swapped' };+ }+ if (lowTag === 'high') {+ return { kind: 'high-as-low' };+ }+ if (mainTag === 'low') {+ return { kind: 'low-as-main' };+ }++ return null;+ }++ // Single expert running the whole schedule: fine for an untagged or+ // high-tagged file, but a low-tagged one is usually the wrong single pick.+ return mainTag === 'low' ? { kind: 'single-low' } : null;+};+// ---------------------------------------------------------------------------// Defaults & model-selection transitionsdiff --git a/invokeai/frontend/webv2/src/features/video/index.ts b/invokeai/frontend/webv2/src/features/video/index.tsindex 2fed5e8124..3d7fe70310 100644--- a/invokeai/frontend/webv2/src/features/video/index.ts+++ b/invokeai/frontend/webv2/src/features/video/index.ts@@ -58,6 +58,7 @@ export {getVideoModelPolicy,getVideoModelSelectionResult,getVideoTargetResolutionOptions,+ getWanExpertWiringWarning,getVideoModes,getVideoPromptPolicy,getVideoSettingsWithModelDefaults,@@ -81,6 +82,7 @@ export {type VideoModelPolicy,type VideoModelSelectionResult,type VideoTargetResolutionOption,+ type WanExpertWiringWarning,} from './core/videoPolicies';export { compileVideoGraph, type CompiledVideoGraph } from './core/graph';export {diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsxindex 1705b12932..b50b074ca5 100644--- a/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsx+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsx@@ -7,13 +7,19 @@ import type {VideoComponentValueKey,} from '@features/video/core/videoPolicies';-import { Stack } from '@chakra-ui/react';+import { HStack, Stack, Text } from '@chakra-ui/react';import { GenerationSettingsSection } from '@features/generation/components';import { isMainModelConfig, isModelIdentifierConfig, isVaeModelConfig } from '@features/generation/settings';+import { useModelsSelector } from '@features/models';import { ModelSelect } from '@features/models/react';-import { getVideoComponentSectionPolicy } from '@features/video/core/videoPolicies';+import {+ getVideoComponentSectionPolicy,+ getVideoModelSelectionResult,+ getWanExpertWiringWarning,+} from '@features/video/core/videoPolicies';import { Field } from '@platform/ui';-import { memo, useMemo } from 'react';+import { Button } from '@platform/ui/Button';+import { memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';/**@@ -84,6 +90,73 @@ const ComponentSlotRow = memo(function ComponentSlotRow({);});+/**+ * Advisory badge for suspicious Wan A14B expert wiring (a low-tagged file in+ * the main slot, a high-tagged one in the low-noise slot). The tags are a+ * filename heuristic and explicit wiring stays authoritative — mirroring the+ * backend loader — so this never blocks; it offers a one-click swap instead,+ * keeping deliberate cross-wiring expressible.+ */+// Spelled out rather than interpolated, so the translation-key scan can see+// them and fail the build if a string goes missing.+const EXPERT_WIRING_MESSAGE_KEYS = {+ 'high-as-low': 'widgets.video.expertWiring.high-as-low',+ 'low-as-main': 'widgets.video.expertWiring.low-as-main',+ 'single-low': 'widgets.video.expertWiring.single-low',+ swapped: 'widgets.video.expertWiring.swapped',+} as const;++const WanExpertWiringNotice = memo(function WanExpertWiringNotice({+ onPatch,+ values,+}: {+ onPatch: (patch: Partial<VideoWidgetValues>) => void;+ values: VideoWidgetValues;+}) {+ const { t } = useTranslation();+ const models = useModelsSelector((snapshot) => snapshot.models);+ const warning = useMemo(+ () => getWanExpertWiringWarning(values.model, values.wanLowNoiseModel),+ [values.model, values.wanLowNoiseModel]+ );+ const swapExperts = useCallback(() => {+ const previousMain = values.model;+ const nextMain = values.wanLowNoiseModel;++ if (!previousMain || !nextMain) {+ return;+ }++ // Same variant and both single-file (the slot filter guarantees it), so+ // the canonical transition is a same-family no-op apart from the swap.+ const result = getVideoModelSelectionResult({ currentSettings: values, model: nextMain, models });++ onPatch({ ...result.settings, model: nextMain, wanLowNoiseModel: previousMain });+ }, [models, onPatch, values]);++ if (!warning) {+ return null;+ }++ const message = t(EXPERT_WIRING_MESSAGE_KEYS[warning.kind], {+ lowName: values.wanLowNoiseModel?.name ?? '',+ mainName: values.model?.name ?? '',+ });++ return (+ <HStack bg="bg.subtle" borderColor="fg.warning" borderWidth="1px" gap="2" p="2" rounded="md">+ <Text color="fg.warning" flex="1" fontSize="2xs" textWrap="pretty">+ {message}+ </Text>+ {warning.kind !== 'single-low' ? (+ <Button flexShrink="0" size="2xs" variant="outline" onClick={swapExperts}>+ {t('widgets.video.expertWiring.swap')}+ </Button>+ ) : null}+ </HStack>+ );+});+export const VideoComponentsSection = memo(function VideoComponentsSection({onPatch,values,@@ -118,6 +191,7 @@ export const VideoComponentsSection = memo(function VideoComponentsSection({onPatch={onPatch}/>))}+ <WanExpertWiringNotice values={values} onPatch={onPatch} /></Stack></GenerationSettingsSection>);