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(backend): reject duplicate Wan expert phases

joshistoastb1d667629503
diff --git a/invokeai/app/invocations/wan_model_loader.py b/invokeai/app/invocations/wan_model_loader.py
index 1e109d4b74..c0a9aa33c4 100644
--- a/invokeai/app/invocations/wan_model_loader.py
+++ b/invokeai/app/invocations/wan_model_loader.py
@@ -172,10 +172,18 @@ class WanModelLoaderInvocation(BaseInvocation):
if getattr(low_config, "variant", None) != main_variant:
raise ValueError("The high-noise and low-noise GGUF models must use the same Wan variant.")
- # Expert tags come from filenames and may be absent or wrong on
- # community models. Explicit graph wiring is authoritative:
+ # Expert tags are usually inferred from filenames, but may be
+ # explicit config overrides. Two models claiming the same
+ # non-empty phase cannot form a valid A14B expert pair.
+ if primary_expert == low_expert != "none":
+ raise ValueError(
+ f"Both selected GGUF models are tagged as the {primary_expert}-noise expert. "
+ "A Wan A14B expert pair must contain one high and one low expert."
+ )
+
+ # Explicit graph wiring remains authoritative for ordering:
# Transformer is high-noise and Transformer (Low Noise) is
- # low-noise. Tags can only trigger an advisory warning.
+ # low-noise. Reversed or missing tags are advisory only.
if primary_expert == "none" and low_expert == "none":
context.logger.warning(
"Neither Wan A14B GGUF filename identifies its expert, so 'Transformer' is assumed to "
@@ -183,7 +191,7 @@ class WanModelLoaderInvocation(BaseInvocation):
"output looks wrong, swap the two models."
)
- elif primary_expert == "low" or low_expert == "high" or primary_expert == low_expert:
+ elif primary_expert == "low" or low_expert == "high":
context.logger.warning(
"The Wan A14B GGUF filename tags disagree with the explicit transformer wiring. "
"The wiring is authoritative: 'Transformer' runs as the high-noise expert and "
diff --git a/tests/app/invocations/test_wan_model_loader.py b/tests/app/invocations/test_wan_model_loader.py
index 0a120af301..d5945865b1 100644
--- a/tests/app/invocations/test_wan_model_loader.py
+++ b/tests/app/invocations/test_wan_model_loader.py
@@ -94,7 +94,7 @@ def _warnings(context: MagicMock) -> list[str]:
@pytest.mark.parametrize("variant", [WanVariantType.T2V_A14B, WanVariantType.I2V_A14B])
@pytest.mark.parametrize(
"main_expert,low_expert",
- [("high", "low"), ("low", "high"), ("high", "high"), ("low", "low"), ("none", "none")],
+ [("high", "low"), ("low", "high"), ("none", "none")],
)
def test_gguf_loader_preserves_explicit_slot_wiring_regardless_of_filename_tags(
variant: WanVariantType, main_expert: str, low_expert: str
@@ -110,6 +110,15 @@ def test_gguf_loader_preserves_explicit_slot_wiring_regardless_of_filename_tags(
assert output.transformer.transformer_low_noise.key == "low"
[email protected]("expert", ["high", "low"])
+def test_gguf_loader_rejects_same_phase_expert_pairs(expert: str) -> None:
+ with pytest.raises(ValueError, match="one high and one low"):
+ _invoke(
+ _config("main", WanVariantType.T2V_A14B, expert),
+ _config("low", WanVariantType.T2V_A14B, expert),
+ )
+
+
@pytest.mark.parametrize(
"main_config,low_config",
[