File size: 4,952 Bytes
fb6b9a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
946b77d
fb6b9a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226b7bf
fb6b9a8
 
9f66d08
fb6b9a8
9f66d08
 
fb6b9a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""MiniMax-H3 family: H3 (video+audio), H3-Image (image, fine-tuned from H3), H3-Image-PE (text).

Facts these rules rely on (checked 2026-11-17 against the official repos):
- H3 and H3-Image share one DiT shape (hidden 5376, 50 blocks); tensor shapes alone cannot
  separate them. Full weights can: H3 has an audio branch (audio_patch_proj, final_layer.audio_out
  in the original/ComfyUI layout; audio_proj_in/out in diffusers), H3-Image has none and adds
  PDD heads (pdd_proj_out.* in diffusers, pdd_steps in ComfyUI metadata).
- blocks.10.attn.out_proj.weight differs clearly between H3 and H3-Image, and is identical
  between H3 and its ComfyUI repack, so a few hundred values tell repack / finetune / member.
- LoRAs only touch the shared blocks; their lineage comes from training metadata
  (minimax_h3_fl2va / ref2va / text_to_video vs minimax_h3_image), the card, sample media
  and the creation date.
- H3-Image-PE is a Qwen3.8-27B text model; Qwen3-VL-32B is H3's own text encoder.
"""
import re

from ..family import Family, Member

IMAGE_TEXT = re.compile(r"h3[-_ ]?image|h3image|minimax[-_ ]h3[-_ ]image", re.I)
PE_TEXT = re.compile(r"h3[-_ ]?image[-_ ]?pe\b|prompt[-_ ]?(enhanc|expan)|提示词扩写|\bPE\b")
VIDEO_TEXT = re.compile(r"text[-_ ]to[-_ ]video|image[-_ ]to[-_ ]video|\bt2v\b|\bi2v\b|\br2v\b|fl2va|ref2va|"
                        r"\bvideos?\b|frames?\b|fps\b|视频", re.I)


def full_dit_without_audio(ev, ctx):
    """A complete H3-shaped DiT with no audio branch and no PDD heads -> H3-Image layout."""
    m = ctx["markers"]
    if ctx["is_dit"] and not ctx["is_lora"] and ctx["sig"].get("block_tensors", 0) >= 200 \
            and not re.search(r"audio", m) and not re.search(r"pdd", m) \
            and re.search(r"video_out|proj_out|video_patch_proj", m):
        return [("H3-Image", "完整 DiT 权重但没有音频分支,符合 H3-Image")]
    return []


FAMILY = Family(
    key="h3",
    title="MiniMax-H3 家族",
    members=[
        Member("H3", "MiniMaxAI/MiniMax-H3", "video", None),
        Member("H3-Image", "MiniMaxAI/MiniMax-H3-Image", "image", IMAGE_TEXT),
        Member("H3-Image-PE", "MiniMaxAI/MiniMax-H3-Image-PE", "text", PE_TEXT, tracked=False),
    ],
    default_member="H3",
    name_queries=["h3", "hailuo"],
    fulltext_queries=['"MiniMax-H3"', '"MiniMax H3"', '"minimax_h3"', '"H3-Image"', '"MiniMaxH3"'],
    tag_filters=["minimax-h3"],
    family_text=re.compile(r"minimax[-_ ]?h3|mm[-_ ]?h3|hailuo", re.I),
    name_hint=re.compile(r"minimax|mm-?h3|hailuo|h3[-_ ]?image|(^|[^a-z0-9])h3([^a-z0-9]|$)", re.I),
    sig_dims={5376, 21504, 96768},
    sig_names=re.compile(r"(^|[._])(blocks|transformer_blocks|double_blocks|refiner_blocks)[._]\d+[._]"
                         r"(attn|ff|mlp|adaln|self_attn|cross_attn)"),
    marker_rules=[
        (re.compile(r"audio_patch_proj|audio_proj_in|audio_proj_out|audio_out\b|final_layer\.audio"), "H3",
         "完整权重里有音频分支(audio_patch_proj / audio_out),只有 H3 有", True),
        (re.compile(r"pdd_proj_out|pdd_head"), "H3-Image", "权重里有 PDD 头,只有 H3-Image 有", False),
    ],
    meta_rules=[
        (re.compile(r"pdd_steps"), "H3-Image", "文件头里有 PDD 配置,只有 H3-Image 有"),
        (re.compile(r"h3[-_]?image|minimax_h3_image|minimaxh3image"), "H3-Image", "文件头的训练信息写明底模是 H3-Image"),
        (re.compile(r"fl2va|ref2va|text_to_video|image_to_video|minimax[-_]h3"), "H3", "文件头的训练信息写明底模是 H3"),
    ],
    index_rules=[("MiniMaxH3Image", "H3-Image"), ("MiniMaxH3", "H3")],
    extra_structural=full_dit_without_audio,
    probe_names=["blocks.10.attn.out_proj.weight", "transformer_blocks.10.attn.to_out.0.weight"],
    probe_sources=[
        ("H3", "MiniMaxAI/MiniMax-H3", "FL2VA/transformer"),
        ("H3", "MiniMaxAI/MiniMax-H3", "Ref2VA/transformer"),
        ("H3", "MiniMaxAI/MiniMax-H3", "transformer"),
        ("H3", "MiniMaxAI/MiniMax-H3", "transformer_ref"),
        ("H3-Image", "MiniMaxAI/MiniMax-H3-Image", "transformer"),
        ("H3-Image", "MiniMaxAI/MiniMax-H3-Image", "transformer_diffusers"),
    ],
    card_rules=[
        (IMAGE_TEXT, "H3-Image", 4, "模型卡提到 H3-Image", False),
        (VIDEO_TEXT, "H3", 2, "模型卡讲的是视频生成", True),
    ],
    native_quant={"H3-Image-PE": re.compile(r"nvfp4|fp4|modelopt", re.I)},   # the official PE ships as NVFP4
    nsfw_author_exempt={"RunningHubAI", "Abiray"},
    text_member="H3-Image-PE",
    text_member_hint=PE_TEXT,
    text_member_name=re.compile(r"h3[-_ ]?image[-_ ]?pe|image[-_]pe\b", re.I),
    text_component=re.compile(r"qwen3[-_.]?vl|text[-_ ]?encoder|conditioner", re.I),
    component_names=re.compile(r"(^|[^a-z])(vae|tae|taeh3|text[-_ ]?encoders?|conditioner|qwen3[-_.]?vl|"
                               r"upscal\w*|latent[-_ ]upscal\w*|audio[-_]vae|clip|tokenizer|embeddings?|decoder)([^a-z]|$)", re.I),
)