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
fix(model-manager): classify MiniMax H3 hybrid checkpoints by their reference task (#10375)
Shanmukh Dheekondaebbca7776976
diff --git a/invokeai/backend/model_manager/configs/main.py b/invokeai/backend/model_manager/configs/main.pyindex 69184066e3..a66f8d0aa7 100644--- a/invokeai/backend/model_manager/configs/main.py+++ b/invokeai/backend/model_manager/configs/main.py@@ -2078,13 +2078,27 @@ class Main_Checkpoint_MiniMaxH3_Config(Checkpoint_Config_Base, Main_Config_Base,if _has_ggml_tensors(state_dict):raise NotAMatchError("GGUF-quantized MiniMax H3 checkpoints are not supported yet")- variant = override_fields.pop("variant", None) or (- MiniMaxH3VariantType.REF2VA if "ref2va" in mod.path.name.lower() else MiniMaxH3VariantType.FL2VA- )+ variant = MiniMaxH3VariantType(override_fields.pop("variant", None) or cls._get_variant(mod))pruned = "adaln_t_table" in state_dictreturn cls(**override_fields, variant=variant, pruned=pruned)+ @classmethod+ def _get_variant(cls, mod: ModelOnDisk) -> MiniMaxH3VariantType:+ """Determine the task variant from the file name, the only signal these files carry.++ A community hybrid merge (``minimax_h3_hybrid_fl2va_ref2va_b25-49``) keeps FL2VA's body+ but takes the AdaLN projections of blocks X..49 - the ones that route reference modality -+ from Ref2VA, so it needs Ref2VA's reference rows and identifies as REF2VA. Under FL2VA the+ reference workflow it exists for stays locked away.+ """+ name = mod.path.name.lower()+ return (+ MiniMaxH3VariantType.REF2VA+ if any(marker in name for marker in ("ref2va", "hybrid"))+ else MiniMaxH3VariantType.FL2VA+ )+# ---------------------------------------------------------------------------------------------# LTX-2diff --git a/tests/backend/model_manager/configs/test_minimax_h3_checkpoint_variant.py b/tests/backend/model_manager/configs/test_minimax_h3_checkpoint_variant.pynew file mode 100644index 0000000000..54918b9ed1--- /dev/null+++ b/tests/backend/model_manager/configs/test_minimax_h3_checkpoint_variant.py@@ -0,0 +1,65 @@+"""Task-variant identification for MiniMax H3 single-file transformer checkpoints.++The two H3 task transformers are key-for-key (and mostly byte-size) identical, so the probe reads+the variant from the file name. Community hybrid merges (#10354) keep FL2VA's body but take the+AdaLN projections of the last blocks from Ref2VA; those projections carry the reference modality,+so such a file has to register as REF2VA or the reference workflow it was built for stays locked.+"""++from pathlib import Path++import pytest+import torch+from safetensors.torch import save_file++from invokeai.backend.model_manager.configs.main import Main_Checkpoint_MiniMaxH3_Config+from invokeai.backend.model_manager.model_on_disk import ModelOnDisk+from invokeai.backend.model_manager.taxonomy import MiniMaxH3VariantType+++def _probe(tmp_path: Path, filename: str, **overrides: object) -> Main_Checkpoint_MiniMaxH3_Config:+ # The three keys the H3 fingerprint checks; weights are never read, so one element each.+ path = tmp_path / filename+ save_file(+ {+ "audio_patch_proj.weight": torch.zeros(1),+ "video_patch_proj.weight": torch.zeros(1),+ "blocks.0.attn.qkv_proj.weight": torch.zeros(1),+ "adaln_t_table": torch.zeros(5, 3),+ },+ str(path),+ )+ on_disk = ModelOnDisk(path)+ return Main_Checkpoint_MiniMaxH3_Config.from_model_on_disk(+ on_disk,+ {+ "hash": "blake3:fake",+ "file_size": path.stat().st_size,+ "name": path.stem,+ "path": str(path),+ "source": str(path),+ "source_type": "path",+ **overrides,+ },+ )+++ "filename, expected",+ [+ ("minimax_h3_fl2va_int8_convrot.safetensors", MiniMaxH3VariantType.FL2VA),+ ("minimax_h3_ref2va_int8_convrot.safetensors", MiniMaxH3VariantType.REF2VA),+ ("minimax_h3_hybrid_fl2va_ref2va_b25-49_int8.safetensors", MiniMaxH3VariantType.REF2VA),+ # #10354: a hybrid whose name never says "ref2va" was classified FL2VA, which withheld the+ # reference input stack it was merged for.+ ("ErosMax_v1.0_hybrid.safetensors", MiniMaxH3VariantType.REF2VA),+ ("Singularity-v1.3-Hybrid-layer25to49.safetensors", MiniMaxH3VariantType.REF2VA),+ ],+)+def test_filename_decides_the_task_variant(tmp_path: Path, filename: str, expected: MiniMaxH3VariantType) -> None:+ assert _probe(tmp_path, filename).variant == expected+++def test_explicit_variant_override_still_wins(tmp_path: Path) -> None:+ """Renamed files stay user-correctable; the name is a heuristic, not a claim."""+ assert _probe(tmp_path, "my-hybrid-merge.safetensors", variant="fl2va").variant == MiniMaxH3VariantType.FL2VA