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(minimax-h3): fail fast when a single-file checkpoint lands in the loader's Model field
Lincoln Steinde361168f514
diff --git a/invokeai/app/invocations/minimax_h3_model_loader.py b/invokeai/app/invocations/minimax_h3_model_loader.pyindex 2321b0f97f..3940192daf 100644--- a/invokeai/app/invocations/minimax_h3_model_loader.py+++ b/invokeai/app/invocations/minimax_h3_model_loader.py@@ -84,6 +84,26 @@ class MiniMaxH3ModelLoaderInvocation(BaseInvocation):if not context.models.exists(self.model.key):raise ValueError(f"Unknown model: {self.model.key}")+ # Fail fast, and with a usable message, when a single-file main (e.g. the pruned int8+ # transformer repack) lands in the Model field — a checkpoint main carries none of the+ # folder submodels this node fans out, so letting it through would surface minutes+ # later as an opaque loader stack trace. The picker filters on ui_model_format, but+ # hand-authored workflows and clients that ignore the hint can still send one.+ main_config = context.models.get_config(self.model.key)+ if main_config.base is not BaseModelType.MiniMaxH3 or main_config.type is not ModelType.Main:+ raise ValueError(+ f"Model '{self.model.key}' is not a MiniMax H3 main model (resolved to "+ f"type={getattr(main_config.type, 'value', main_config.type)}, "+ f"base={getattr(main_config.base, 'value', main_config.base)})."+ )+ if main_config.format is not ModelFormat.Diffusers:+ raise ValueError(+ f"'{main_config.name}' is a single-file checkpoint and cannot be the Model input — that "+ "field needs the diffusers-folder install (e.g. 'MiniMax H3 Components'), which supplies "+ "the tokenizer, processor and VAEs. Single-file transformer/text-encoder repacks go in "+ "this node's 'Transformer (single file)' / 'Text Encoder (single file)' fields instead."+ )+if self.transformer_model is not None:if not context.models.exists(self.transformer_model.key):raise ValueError(f"Unknown transformer model: {self.transformer_model.key}")diff --git a/tests/app/invocations/test_minimax_h3_model_loader.py b/tests/app/invocations/test_minimax_h3_model_loader.pynew file mode 100644index 0000000000..c2f49f493f--- /dev/null+++ b/tests/app/invocations/test_minimax_h3_model_loader.py@@ -0,0 +1,59 @@+"""MiniMax H3 model loader input validation.++The Model field needs the diffusers-folder install — a single-file checkpoint main+(e.g. the pruned int8 transformer repack) carries none of the folder submodels this+node fans out. The picker filters on ui_model_format, but hand-authored workflows and+clients that ignore the hint can still send one; the node must fail fast with an+actionable message instead of an opaque loader stack trace minutes later.+"""++from unittest.mock import MagicMock++import pytest++from invokeai.app.invocations.minimax_h3_model_loader import MiniMaxH3ModelLoaderInvocation+from invokeai.app.invocations.model import ModelIdentifierField+from invokeai.backend.model_manager.taxonomy import BaseModelType, ModelFormat, ModelType+++def _identifier(key: str = "h3-main") -> ModelIdentifierField:+ return ModelIdentifierField(+ key=key, hash="test-hash", name="MiniMax H3", base=BaseModelType.MiniMaxH3, type=ModelType.Main+ )+++def _context(config: MagicMock) -> MagicMock:+ context = MagicMock()+ context.models.exists.return_value = True+ context.models.get_config.return_value = config+ return context+++def _config(base=BaseModelType.MiniMaxH3, type_=ModelType.Main, format_=ModelFormat.Diffusers) -> MagicMock:+ config = MagicMock()+ config.base = base+ config.type = type_+ config.format = format_+ config.name = "MiniMax H3 FL2VA Transformer (int8, pruned)"+ return config+++def test_rejects_single_file_checkpoint_as_main_model():+ node = MiniMaxH3ModelLoaderInvocation(id="loader", model=_identifier())+ with pytest.raises(ValueError, match="single-file checkpoint.*Transformer \\(single file\\)"):+ node.invoke(_context(_config(format_=ModelFormat.Checkpoint)))+++def test_rejects_wrong_base_or_type():+ node = MiniMaxH3ModelLoaderInvocation(id="loader", model=_identifier())+ with pytest.raises(ValueError, match="not a MiniMax H3 main model"):+ node.invoke(_context(_config(base=BaseModelType.Wan)))+ with pytest.raises(ValueError, match="not a MiniMax H3 main model"):+ node.invoke(_context(_config(type_=ModelType.LoRA)))+++def test_accepts_diffusers_folder_main():+ node = MiniMaxH3ModelLoaderInvocation(id="loader", model=_identifier())+ output = node.invoke(_context(_config()))+ assert output.transformer.transformer.key == "h3-main"+ assert output.vae.vae.key == "h3-main"