linoyts HF Staff commited on
Commit
f66e612
·
verified ·
1 Parent(s): 88f4fae

MiniMax-H3 + LightVAE lite decoder (modular diffusers)

Browse files
README.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: diffusers
3
+ license: apache-2.0
4
+ base_model:
5
+ - MiniMaxAI/MiniMax-H3
6
+ - lightx2v/LightVAE
7
+ pipeline_tag: image-to-video
8
+ tags:
9
+ - minimax-h3
10
+ - video
11
+ - modular-diffusers
12
+ - lightvae
13
+ ---
14
+
15
+ # MiniMax-H3 + LightVAE (modular diffusers)
16
+
17
+ A ready-to-load **modular diffusers** repo for [MiniMax-H3](https://huggingface.co/MiniMaxAI/MiniMax-H3) in which the
18
+ video VAE **decoder** is replaced by [lightx2v/LightVAE](https://huggingface.co/lightx2v/LightVAE)'s block-pruned Lite
19
+ decoder (ViT decoder pruned from 36 to 12 transformer blocks). LightVAE preserves H3's latent interface
20
+ (24-channel latents, same spatial/temporal compression, same `latents_mean/std`), so the transformer, the audio VAE,
21
+ and the scheduler are untouched and the decoder is a drop-in replacement.
22
+
23
+ Only the `vae` component points here; every other component (`transformer`, `text_encoder`, `audio_vae`, ...) is
24
+ loaded from the H3 base and pruned repos through this repo's `modular_model_index.json`. The included VAE also keeps
25
+ the **stock H3 encoder** (encode is cheap and leaves the latent interface untouched); only the heavy decode path is
26
+ swapped.
27
+
28
+ ## Contents
29
+
30
+ ```
31
+ modular_model_index.json # vae -> this repo/vae ; everything else -> MiniMax-H3 / MiniMax-H3-Pruned
32
+ vae/ # AutoencoderKLMiniMaxH3, decoder_num_layers=12 (stock encoder + LightVAE Lite decoder)
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ Requires `diffusers` with the MiniMax-H3 integration.
38
+
39
+ ```python
40
+ import torch
41
+ from huggingface_hub import hf_hub_download
42
+ from diffusers import ComponentsManager
43
+ from diffusers.modular_pipelines.minimax_h3 import MiniMaxH3Blocks
44
+ from diffusers.modular_pipelines.minimax_h3.references import MiniMaxH3VideoReference
45
+
46
+ # ref2va workflow: loads only the reference transformer partition (not both)
47
+ blocks = MiniMaxH3Blocks(workflow="ref2va")
48
+ pipe = blocks.init_pipeline(
49
+ "diffusers-modular/MiniMax-H3-LightVAE",
50
+ components_manager=ComponentsManager(),
51
+ collection="h3",
52
+ )
53
+ pipe.load_components(dtype=torch.bfloat16, trust_remote_code=True)
54
+
55
+ # both autoencoders stay fp32 on the native attention backend
56
+ pipe.vae.set_attention_backend("native")
57
+ pipe.audio_vae.set_attention_backend("native")
58
+
59
+ # optional: lightx2v 4-step Ref2V Turbo LoRA (on the transformer; independent of the VAE)
60
+ pipe.load_lora_weights(
61
+ hf_hub_download("lightx2v/Minimax-h3-Turbo", "minimax_h3_ref2v_turbo_4step_v0.1_bf16.safetensors"),
62
+ adapter_name="turbo",
63
+ )
64
+ pipe.set_adapters(["turbo"], [1.0])
65
+
66
+ state = pipe(
67
+ prompt="a red fox walking through snow, cinematic",
68
+ references=[MiniMaxH3VideoReference.from_file("reference.mp4")],
69
+ height=448,
70
+ width=768,
71
+ num_frames=124, # must be 17*n + 5
72
+ num_inference_steps=4, # 4 with the Turbo LoRA; ~20 without
73
+ generator=torch.Generator("cpu").manual_seed(0),
74
+ )
75
+
76
+ frames = state.get("videos")[0] # list of PIL frames
77
+ audio = state.get("audio") # waveform (or None)
78
+ sampling_rate = state.get("sampling_rate")
79
+ ```
80
+
81
+ Swapping back to the stock decoder is just pointing `vae` at `MiniMaxAI/MiniMax-H3` / `vae` in the index.
82
+
83
+ ## How it was built
84
+
85
+ `vae/` is an `AutoencoderKLMiniMaxH3` instantiated with `decoder_num_layers=12`, loaded with:
86
+ - `encoder.*` + `quant_conv.*` from `MiniMaxAI/MiniMax-H3/vae` (stock H3 encoder),
87
+ - `decoder.*` + `post_quant_conv.*` from `lightx2v/LightVAE/lightvae-lite-h3-decoder.safetensors`.
88
+
89
+ `latents_mean/std` are bit-identical between the stock VAE config and the LightVAE decoder checkpoint, confirming the
90
+ shared latent interface. State dict loads strict (0 missing, 0 unexpected).
91
+
92
+ ## Roadmap
93
+
94
+ - **Lite encoder.** LightVAE also ships a Lite *encoder* (`lightvae-lite-h3-encoder.safetensors`, non-uniform resnet
95
+ depth `[1,1,1,1,1,2]`). Loading it needs `AutoencoderKLMiniMaxH3` to accept a per-level `layers_per_block`; tracked
96
+ as a follow-up.
97
+ - **int8 decoder.** `lightvae-lite-h3-decoder-int8-convrot.safetensors` for a cheaper decode once its kernel path is wired.
98
+
99
+ ## Credits
100
+
101
+ LightVAE by [lightx2v](https://huggingface.co/lightx2v/LightVAE). MiniMax-H3 by [MiniMaxAI](https://huggingface.co/MiniMaxAI/MiniMax-H3).
modular_model_index.json ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "MiniMaxH3ModularPipeline",
3
+ "_diffusers_version": "0.40.0.dev0",
4
+ "_blocks_class_name": "MiniMaxH3Blocks",
5
+ "text_encoder": [
6
+ "transformers",
7
+ "Qwen3VLForConditionalGeneration",
8
+ {
9
+ "type_hint": [
10
+ "transformers",
11
+ "Qwen3VLForConditionalGeneration"
12
+ ],
13
+ "pretrained_model_name_or_path": "multimodalart/MiniMax-H3-Pruned",
14
+ "subfolder": "text_encoder",
15
+ "variant": null,
16
+ "revision": null
17
+ }
18
+ ],
19
+ "tokenizer": [
20
+ "transformers",
21
+ "Qwen2TokenizerFast",
22
+ {
23
+ "type_hint": [
24
+ "transformers",
25
+ "Qwen2TokenizerFast"
26
+ ],
27
+ "pretrained_model_name_or_path": "MiniMaxAI/MiniMax-H3",
28
+ "subfolder": "tokenizer",
29
+ "variant": null,
30
+ "revision": null
31
+ }
32
+ ],
33
+ "processor": [
34
+ "transformers",
35
+ "Qwen3VLProcessor",
36
+ {
37
+ "type_hint": [
38
+ "transformers",
39
+ "Qwen3VLProcessor"
40
+ ],
41
+ "pretrained_model_name_or_path": "MiniMaxAI/MiniMax-H3",
42
+ "subfolder": "processor",
43
+ "variant": null,
44
+ "revision": null
45
+ }
46
+ ],
47
+ "vae": [
48
+ "diffusers",
49
+ "AutoencoderKLMiniMaxH3",
50
+ {
51
+ "type_hint": [
52
+ "diffusers",
53
+ "AutoencoderKLMiniMaxH3"
54
+ ],
55
+ "pretrained_model_name_or_path": "diffusers-modular/MiniMax-H3-LightVAE",
56
+ "subfolder": "vae",
57
+ "variant": null,
58
+ "revision": null
59
+ }
60
+ ],
61
+ "audio_vae": [
62
+ "diffusers",
63
+ "AutoencoderKLMiniMaxH3Audio",
64
+ {
65
+ "type_hint": [
66
+ "diffusers",
67
+ "AutoencoderKLMiniMaxH3Audio"
68
+ ],
69
+ "pretrained_model_name_or_path": "MiniMaxAI/MiniMax-H3",
70
+ "subfolder": "audio_vae",
71
+ "variant": null,
72
+ "revision": null
73
+ }
74
+ ],
75
+ "transformer": [
76
+ "diffusers",
77
+ "AutoModel",
78
+ {
79
+ "type_hint": [
80
+ "diffusers",
81
+ "AutoModel"
82
+ ],
83
+ "pretrained_model_name_or_path": "multimodalart/MiniMax-H3-Pruned",
84
+ "subfolder": "transformer",
85
+ "variant": null,
86
+ "revision": null
87
+ }
88
+ ],
89
+ "transformer_ref": [
90
+ "diffusers",
91
+ "AutoModel",
92
+ {
93
+ "type_hint": [
94
+ "diffusers",
95
+ "AutoModel"
96
+ ],
97
+ "pretrained_model_name_or_path": "multimodalart/MiniMax-H3-Pruned",
98
+ "subfolder": "transformer_ref",
99
+ "variant": null,
100
+ "revision": null
101
+ }
102
+ ],
103
+ "scheduler": [
104
+ "diffusers",
105
+ "MiniMaxH3Scheduler",
106
+ {
107
+ "type_hint": [
108
+ "diffusers",
109
+ "MiniMaxH3Scheduler"
110
+ ],
111
+ "pretrained_model_name_or_path": "MiniMaxAI/MiniMax-H3",
112
+ "subfolder": "scheduler",
113
+ "variant": null,
114
+ "revision": null
115
+ }
116
+ ],
117
+ "audio_scheduler": [
118
+ "diffusers",
119
+ "MiniMaxH3Scheduler",
120
+ {
121
+ "type_hint": [
122
+ "diffusers",
123
+ "MiniMaxH3Scheduler"
124
+ ],
125
+ "pretrained_model_name_or_path": "MiniMaxAI/MiniMax-H3",
126
+ "subfolder": "audio_scheduler",
127
+ "variant": null,
128
+ "revision": null
129
+ }
130
+ ]
131
+ }
vae/config.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "AutoencoderKLMiniMaxH3",
3
+ "_diffusers_version": "0.40.0.dev0",
4
+ "block_out_channels": [
5
+ 128,
6
+ 256,
7
+ 256,
8
+ 512,
9
+ 512,
10
+ 1024
11
+ ],
12
+ "clip_length": 17,
13
+ "decoder_attention_head_dim": 64,
14
+ "decoder_ffn_mult": 4,
15
+ "decoder_norm_eps": 1e-05,
16
+ "decoder_num_attention_heads": 32,
17
+ "decoder_num_layers": 12,
18
+ "decoder_num_register_tokens": 4,
19
+ "decoder_rope_dim_ratio": 0.75,
20
+ "decoder_rope_theta": 100.0,
21
+ "in_channels": 3,
22
+ "latent_channels": 24,
23
+ "latents_mean": [
24
+ 0.858090341091156,
25
+ -0.9606591463088989,
26
+ 1.0661640167236328,
27
+ -0.5090325474739075,
28
+ -0.2727581858634949,
29
+ -1.3675414323806763,
30
+ -0.2553254961967468,
31
+ -0.26907554268836975,
32
+ -0.5376840829849243,
33
+ -0.0464097298681736,
34
+ 0.6657370328903198,
35
+ 0.19690127670764923,
36
+ -0.5460608005523682,
37
+ -0.4035342037677765,
38
+ -0.23683024942874908,
39
+ 0.25928452610969543,
40
+ -0.30133944749832153,
41
+ 0.211341992020607,
42
+ -1.1206848621368408,
43
+ 0.3581933379173279,
44
+ -0.04225143790245056,
45
+ 0.2604829967021942,
46
+ 0.22864092886447906,
47
+ 0.7056031823158264
48
+ ],
49
+ "latents_std": [
50
+ 1.2223774194717407,
51
+ 1.2767263650894165,
52
+ 1.6831774711608887,
53
+ 1.7549455165863037,
54
+ 1.5636216402053833,
55
+ 2.194143533706665,
56
+ 0.9653137922286987,
57
+ 1.0569885969161987,
58
+ 0.841948926448822,
59
+ 0.7729952931404114,
60
+ 1.8955937623977661,
61
+ 0.946841835975647,
62
+ 0.7996809482574463,
63
+ 0.44988900423049927,
64
+ 0.7197399735450745,
65
+ 0.6936293244361877,
66
+ 2.961095094680786,
67
+ 2.7694199085235596,
68
+ 3.0496184825897217,
69
+ 2.1088054180145264,
70
+ 3.276226282119751,
71
+ 3.1627357006073,
72
+ 2.2816812992095947,
73
+ 2.6127843856811523
74
+ ],
75
+ "layers_per_block": 2,
76
+ "norm_eps": 1e-06,
77
+ "norm_num_groups": 32,
78
+ "out_channels": 3,
79
+ "spatial_downsample_factors": [
80
+ 2,
81
+ 2,
82
+ 2,
83
+ 2,
84
+ 1,
85
+ 1
86
+ ],
87
+ "spatial_padding_mode": "reflect",
88
+ "temporal_downsample_factors": [
89
+ 1,
90
+ 2,
91
+ 2,
92
+ 1,
93
+ 1,
94
+ 1
95
+ ],
96
+ "token_drop": 3
97
+ }
vae/diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1c69d47b24b0d5f8bbfba28bb04e93b4c16a3db1c4928e8b94dd7c4bfa3bf1d
3
+ size 3969719952