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(model-manager): stop filing VAEs without a decoder.conv_in weight as SD1 (#10029)

stanley43f6bdd3497a
diff --git a/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx b/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx
index df5eacb8b7..ded5fc7133 100644
--- a/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx
+++ b/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx
@@ -137,6 +137,8 @@ Qwen3.5 encoder, and other widths are not identified.
| Qwen-Image-2.1 | ✓ | ✓ | Qwen-Image-2.1 |
| CogView4, LTX-2, MiniMax H3 | – | bundled | taken from the model's own folder |
+A standalone single-file LTX-2 or MiniMax H3 VAE, video or audio, is not identified and stays Unknown.
+
Quantized VAE files (fp8, int8, nvfp4) are not supported; use the unquantized VAE. The SD 3, FLUX.2, Qwen-Image,
Qwen-Image-2.1, Wan, Anima and Ideogram 4 VAEs fail with a message when they load. The FLUX.1 and SD 1.x / SDXL single-file VAEs do
not check, so a quantized file there fails with an unclear error or decodes incorrectly.
diff --git a/invokeai/backend/model_manager/configs/vae.py b/invokeai/backend/model_manager/configs/vae.py
index bb75ecaca9..7389947ee2 100644
--- a/invokeai/backend/model_manager/configs/vae.py
+++ b/invokeai/backend/model_manager/configs/vae.py
@@ -214,11 +214,11 @@ class VAE_Checkpoint_Config_Base(Checkpoint_Config_Base):
if _is_qwen_image_vae(state_dict) or _wan_vae_z_dim(state_dict) is not None:
raise NotAMatchError("model is a Wan-family VAE, not a standard VAE")
- # A latent width no AutoencoderKL family has is not one of these VAEs, whatever its name says.
- # Without this, `_get_base_or_raise` falls through to the name and files a 64-channel
- # `qwen_image_2.1_vae.safetensors` as SD1 because the name contains "vae".
+ # The file name only separates SD1/SD2/SDXL; it cannot stand in for a latent width the weights do not give.
latent_channels = _latent_channels(state_dict)
- if latent_channels is not None and latent_channels not in _VAE_FAMILIES:
+ if latent_channels is None:
+ raise NotAMatchError("no decoder.conv_in.weight, so not a standard VAE")
+ if latent_channels not in _VAE_FAMILIES:
raise NotAMatchError(f"{latent_channels} latent channels is not a standard VAE")
@classmethod
@@ -232,21 +232,13 @@ class VAE_Checkpoint_Config_Base(Checkpoint_Config_Base):
# the weights and is ignored rather than obeyed.
named = backbone_from_components(name_components(mod, override_fields))
return named if named in _VAE_FAMILIES[16] else BaseModelType.Flux
- elif latent_channels == 4:
- # SD/SDXL VAE has 4-dimensional latent space
- # Try to distinguish SD1/SD2/SDXL by name, fallback to SD1
- for regexp, base in REGEX_TO_BASE.items():
- if re.search(regexp, mod.path.name, re.IGNORECASE):
- return base
- # Default to SD1 if we can't determine from name
- return BaseModelType.StableDiffusion1
-
- # Fallback: guess based on name
+ # SD/SDXL VAE has 4-dimensional latent space
+ # Try to distinguish SD1/SD2/SDXL by name, fallback to SD1
for regexp, base in REGEX_TO_BASE.items():
if re.search(regexp, mod.path.name, re.IGNORECASE):
return base
-
- raise NotAMatchError("cannot determine base type")
+ # Default to SD1 if we can't determine from name
+ return BaseModelType.StableDiffusion1
class VAE_Checkpoint_SD1_Config(VAE_Checkpoint_Config_Base, Config_Base):
diff --git a/tests/backend/model_manager/configs/test_vae_base_identification.py b/tests/backend/model_manager/configs/test_vae_base_identification.py
index ce3358ee8b..74a3550a9a 100644
--- a/tests/backend/model_manager/configs/test_vae_base_identification.py
+++ b/tests/backend/model_manager/configs/test_vae_base_identification.py
@@ -123,6 +123,30 @@ class TestASingleFile:
assert _identified_base(path) is BaseModelType.StableDiffusion1
assert _identified_base(path, base=BaseModelType.StableDiffusion2) is BaseModelType.StableDiffusion2
+ @pytest.mark.parametrize(
+ ("file_name", "encoder_conv_in", "decoder_conv_in"),
+ [
+ ("ltx-2.5-22b_video_vae_bf16.safetensors", (8, 3, 3, 3, 3), (8, 128, 3, 3, 3)),
+ ("ltx-2.5-22b_audio_vae_bf16.safetensors", (8, 2, 3, 3), (8, 8, 3, 3)),
+ ],
+ )
+ def test_a_vae_without_a_decoder_conv_in_weight_is_not_filed_under_any_base(
+ self,
+ tmp_path: Path,
+ file_name: str,
+ encoder_conv_in: tuple[int, ...],
+ decoder_conv_in: tuple[int, ...],
+ ) -> None:
+ path = tmp_path / file_name
+ save_file(
+ {
+ "encoder.conv_in.conv.weight": torch.zeros(encoder_conv_in),
+ "decoder.conv_in.conv.weight": torch.zeros(decoder_conv_in),
+ },
+ path,
+ )
+ assert _identified_base(path) is None
+
class TestAFolder:
@pytest.mark.parametrize("override", [None, FLUX, SD3])