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.

fix(ui): allow backend-valid cross-base links and helper types

Josh Corbetted86a14540bc
diff --git a/invokeai/frontend/webv2/src/features/models/core/relationships.test.ts b/invokeai/frontend/webv2/src/features/models/core/relationships.test.ts
index 378e65815f..821752bf27 100644
--- a/invokeai/frontend/webv2/src/features/models/core/relationships.test.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/relationships.test.ts
@@ -4,6 +4,7 @@ import type { RelatableModel } from './relationships';
import type { ModelBase, ModelTaxonomyType } from './types';
import {
+ CROSS_BASE_ALLOWANCES,
hasLinkableBase,
isBaseCompatible,
isLinkableType,
@@ -23,6 +24,45 @@ describe('isBaseCompatible', () => {
expect(isBaseCompatible(model('sdxl', 'main'), model('flux'))).toBe(false);
});
+ it('allows curated cross-base helpers with their consuming bases', () => {
+ // z_image_model_loader takes a FLUX VAE; krea2_model_loader takes Qwen-Image or Anima VAEs.
+ expect(isBaseCompatible(model('z-image', 'main'), model('flux', 'vae'))).toBe(true);
+ expect(isBaseCompatible(model('krea-2', 'main'), model('qwen-image', 'vae'))).toBe(true);
+ expect(isBaseCompatible(model('krea-2', 'main'), model('anima', 'vae'))).toBe(true);
+ // flux2_klein_model_loader takes a FLUX VAE; anima_model_loader takes Wan/Qwen-Image/FLUX VAEs.
+ expect(isBaseCompatible(model('flux2', 'main'), model('flux', 'vae'))).toBe(true);
+ expect(isBaseCompatible(model('anima', 'main'), model('wan', 'vae'))).toBe(true);
+ expect(isBaseCompatible(model('anima', 'main'), model('qwen-image', 'vae'))).toBe(true);
+ expect(isBaseCompatible(model('anima', 'main'), model('flux', 'vae'))).toBe(true);
+ // z_image_pid_decode reuses the FLUX PiD decoder.
+ expect(isBaseCompatible(model('z-image', 'main'), model('flux', 'pid_decoder'))).toBe(true);
+ });
+
+ it('limits cross-base allowances to the helper type and cited pairs', () => {
+ // The allowance belongs to the VAE type, not to the base pair.
+ expect(isBaseCompatible(model('z-image', 'main'), model('flux', 'lora'))).toBe(false);
+ expect(isBaseCompatible(model('z-image', 'main'), model('flux', 'main'))).toBe(false);
+ // No loader feeds an SD-3 VAE to a Z-Image pipeline.
+ expect(isBaseCompatible(model('z-image', 'main'), model('sd-3', 'vae'))).toBe(false);
+ // Only the FLUX decoder is shared; other PiD pairings must match exactly.
+ expect(isBaseCompatible(model('qwen-image', 'main'), model('flux', 'pid_decoder'))).toBe(false);
+ expect(isBaseCompatible(model('sdxl', 'main'), model('sdxl', 'pid_decoder'))).toBe(true);
+ });
+
+ it('is symmetric for every cross-base entry', () => {
+ for (const [type, byBase] of Object.entries(CROSS_BASE_ALLOWANCES)) {
+ for (const [helperBase, hosts] of Object.entries(byBase ?? {})) {
+ for (const hostBase of hosts ?? []) {
+ const helper = model(helperBase as ModelBase, type as ModelTaxonomyType);
+ const host = model(hostBase, 'main');
+
+ expect(isBaseCompatible(helper, host)).toBe(true);
+ expect(isBaseCompatible(host, helper)).toBe(true);
+ }
+ }
+ }
+ });
+
it('does not treat the null Any base as a universal wildcard', () => {
expect(isBaseCompatible(model('any'), model('sdxl'))).toBe(false);
expect(isBaseCompatible(model('sdxl'), model('any'))).toBe(false);
@@ -89,4 +129,11 @@ describe('LINKABLE_TYPES', () => {
expect(LINKABLE_TYPES).toContain('main');
expect(isLinkableType('onnx')).toBe(false);
});
+
+ it('includes the concrete-based helper types the backend loaders consume', () => {
+ // flux_control_lora_loader, flux_redux, and pid_decoder_loader.
+ expect(isLinkableType('control_lora')).toBe(true);
+ expect(isLinkableType('flux_redux')).toBe(true);
+ expect(isLinkableType('pid_decoder')).toBe(true);
+ });
});
diff --git a/invokeai/frontend/webv2/src/features/models/core/relationships.ts b/invokeai/frontend/webv2/src/features/models/core/relationships.ts
index 6a59c846c5..23e8459f56 100644
--- a/invokeai/frontend/webv2/src/features/models/core/relationships.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/relationships.ts
@@ -46,6 +46,31 @@ export const NULL_BASE_ALLOWANCES: Readonly<Partial<Record<ModelTaxonomyType, Re
wan_t5_encoder: new Set(['wan']),
};
+/**
+ * Curated cross-base allowances for concrete-based helper types: helper base
+ * mapped to the host bases whose pipelines consume it. Same sourcing rule as
+ * `NULL_BASE_ALLOWANCES` — each entry cites the backend invocation(s).
+ */
+export const CROSS_BASE_ALLOWANCES: Readonly<
+ Partial<Record<ModelTaxonomyType, Readonly<Partial<Record<ModelBase, ReadonlySet<ModelBase>>>>>>
+> = {
+ /** The 16-channel VAEs are shared across backbones. */
+ vae: {
+ /** krea2_model_loader (accepts QwenImage and Anima VAEs). */
+ anima: new Set(['krea-2']),
+ /** z_image_model_loader; flux2_klein_model_loader; anima_model_loader ("A FLUX VAE can also be used"). */
+ flux: new Set(['anima', 'flux2', 'z-image']),
+ /** krea2_model_loader; anima_model_loader ("Wan 2.1 / QwenImage VAE"). */
+ 'qwen-image': new Set(['anima', 'krea-2']),
+ /** anima_model_loader ("Wan 2.1 / QwenImage VAE"). */
+ wan: new Set(['anima']),
+ },
+ /** z_image_pid_decode reuses the FLUX decoder (assert_pid_decoder_matches_base). */
+ pid_decoder: {
+ flux: new Set(['z-image']),
+ },
+};
+
/**
* Types offered when linking related models. The concrete-based helper types,
* plus every `any`-based type with a curated allowance.
@@ -56,8 +81,11 @@ export const LINKABLE_TYPES: readonly ModelTaxonomyType[] = [
'embedding',
'vae',
'controlnet',
+ 'control_lora',
't2i_adapter',
'ip_adapter',
+ 'flux_redux',
+ 'pid_decoder',
...(Object.keys(NULL_BASE_ALLOWANCES) as ModelTaxonomyType[]),
];
@@ -78,14 +106,18 @@ const isAllowedHelperFor = (helper: RelatableModel, host: RelatableModel): boole
!NULL_BASES.has(String(host.base)) &&
(NULL_BASE_ALLOWANCES[helper.type]?.has(host.base) ?? false);
+const isAllowedCrossBaseHelperFor = (helper: RelatableModel, host: RelatableModel): boolean =>
+ CROSS_BASE_ALLOWANCES[helper.type]?.[helper.base]?.has(host.base) ?? false;
+
/**
* Symmetric base-compatibility for related-model links: concrete bases must
- * match exactly; a null base never wildcards — an `any`-based model links only
- * to concrete bases its type has a curated allowance for.
+ * match exactly unless the helper's type has a curated cross-base allowance;
+ * a null base never wildcards — an `any`-based model links only to concrete
+ * bases its type has a curated allowance for.
*/
export const isBaseCompatible = (a: RelatableModel, b: RelatableModel): boolean => {
if (!NULL_BASES.has(String(a.base)) && !NULL_BASES.has(String(b.base))) {
- return a.base === b.base;
+ return a.base === b.base || isAllowedCrossBaseHelperFor(a, b) || isAllowedCrossBaseHelperFor(b, a);
}
return isAllowedHelperFor(a, b) || isAllowedHelperFor(b, a);