Text-to-Video
Diffusers
Safetensors
MiniMax H3
English
video-generation
text-to-audio-video
sdnq
8-bit precision
Instructions to use OzzyGT/MiniMax_H3_sdnq_8bit_pruned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use OzzyGT/MiniMax_H3_sdnq_8bit_pruned with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("OzzyGT/MiniMax_H3_sdnq_8bit_pruned", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Upload 4 files
Browse files- modular_model_index.json +1 -1
- vae/config.json +100 -0
- vae/diffusion_pytorch_model.safetensors +3 -0
- vae/modeling_minimax_h3_vae_fp16.py +47 -0
modular_model_index.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
| 52 |
null,
|
| 53 |
null
|
| 54 |
],
|
| 55 |
-
"pretrained_model_name_or_path": "OzzyGT/
|
| 56 |
"subfolder": "vae",
|
| 57 |
"variant": null,
|
| 58 |
"revision": null
|
|
|
|
| 52 |
null,
|
| 53 |
null
|
| 54 |
],
|
| 55 |
+
"pretrained_model_name_or_path": "OzzyGT/MiniMax_H3_sdnq_8bit_pruned",
|
| 56 |
"subfolder": "vae",
|
| 57 |
"variant": null,
|
| 58 |
"revision": null
|
vae/config.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "MiniMaxH3Fp16DecoderVae",
|
| 3 |
+
"_diffusers_version": "0.36.0.dev0",
|
| 4 |
+
"in_channels": 3,
|
| 5 |
+
"out_channels": 3,
|
| 6 |
+
"latent_channels": 24,
|
| 7 |
+
"block_out_channels": [
|
| 8 |
+
128,
|
| 9 |
+
256,
|
| 10 |
+
256,
|
| 11 |
+
512,
|
| 12 |
+
512,
|
| 13 |
+
1024
|
| 14 |
+
],
|
| 15 |
+
"layers_per_block": 2,
|
| 16 |
+
"spatial_downsample_factors": [
|
| 17 |
+
2,
|
| 18 |
+
2,
|
| 19 |
+
2,
|
| 20 |
+
2,
|
| 21 |
+
1,
|
| 22 |
+
1
|
| 23 |
+
],
|
| 24 |
+
"temporal_downsample_factors": [
|
| 25 |
+
1,
|
| 26 |
+
2,
|
| 27 |
+
2,
|
| 28 |
+
1,
|
| 29 |
+
1,
|
| 30 |
+
1
|
| 31 |
+
],
|
| 32 |
+
"norm_num_groups": 32,
|
| 33 |
+
"norm_eps": 1e-06,
|
| 34 |
+
"spatial_padding_mode": "reflect",
|
| 35 |
+
"decoder_num_layers": 36,
|
| 36 |
+
"decoder_num_attention_heads": 32,
|
| 37 |
+
"decoder_attention_head_dim": 64,
|
| 38 |
+
"decoder_num_register_tokens": 4,
|
| 39 |
+
"decoder_ffn_mult": 4,
|
| 40 |
+
"decoder_rope_theta": 100.0,
|
| 41 |
+
"decoder_rope_dim_ratio": 0.75,
|
| 42 |
+
"decoder_norm_eps": 1e-05,
|
| 43 |
+
"clip_length": 17,
|
| 44 |
+
"token_drop": 3,
|
| 45 |
+
"latents_mean": [
|
| 46 |
+
0.858090341091156,
|
| 47 |
+
-0.9606591463088989,
|
| 48 |
+
1.0661640167236328,
|
| 49 |
+
-0.5090325474739075,
|
| 50 |
+
-0.2727581858634949,
|
| 51 |
+
-1.3675414323806763,
|
| 52 |
+
-0.2553254961967468,
|
| 53 |
+
-0.26907554268836975,
|
| 54 |
+
-0.5376840829849243,
|
| 55 |
+
-0.0464097298681736,
|
| 56 |
+
0.6657370328903198,
|
| 57 |
+
0.19690127670764923,
|
| 58 |
+
-0.5460608005523682,
|
| 59 |
+
-0.4035342037677765,
|
| 60 |
+
-0.23683024942874908,
|
| 61 |
+
0.25928452610969543,
|
| 62 |
+
-0.30133944749832153,
|
| 63 |
+
0.211341992020607,
|
| 64 |
+
-1.1206848621368408,
|
| 65 |
+
0.3581933379173279,
|
| 66 |
+
-0.04225143790245056,
|
| 67 |
+
0.2604829967021942,
|
| 68 |
+
0.22864092886447906,
|
| 69 |
+
0.7056031823158264
|
| 70 |
+
],
|
| 71 |
+
"latents_std": [
|
| 72 |
+
1.2223774194717407,
|
| 73 |
+
1.2767263650894165,
|
| 74 |
+
1.6831774711608887,
|
| 75 |
+
1.7549455165863037,
|
| 76 |
+
1.5636216402053833,
|
| 77 |
+
2.194143533706665,
|
| 78 |
+
0.9653137922286987,
|
| 79 |
+
1.0569885969161987,
|
| 80 |
+
0.841948926448822,
|
| 81 |
+
0.7729952931404114,
|
| 82 |
+
1.8955937623977661,
|
| 83 |
+
0.946841835975647,
|
| 84 |
+
0.7996809482574463,
|
| 85 |
+
0.44988900423049927,
|
| 86 |
+
0.7197399735450745,
|
| 87 |
+
0.6936293244361877,
|
| 88 |
+
2.961095094680786,
|
| 89 |
+
2.7694199085235596,
|
| 90 |
+
3.0496184825897217,
|
| 91 |
+
2.1088054180145264,
|
| 92 |
+
3.276226282119751,
|
| 93 |
+
3.1627357006073,
|
| 94 |
+
2.2816812992095947,
|
| 95 |
+
2.6127843856811523
|
| 96 |
+
],
|
| 97 |
+
"auto_map": {
|
| 98 |
+
"AutoModel": "modeling_minimax_h3_vae_fp16.MiniMaxH3Fp16DecoderVae"
|
| 99 |
+
}
|
| 100 |
+
}
|
vae/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0d4104258a007ff2d30ecc5fb569918171bbc0f5f75488a4646d750c477017ae
|
| 3 |
+
size 5568792128
|
vae/modeling_minimax_h3_vae_fp16.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""MiniMax-H3 video VAE that holds the float16 decoder this checkpoint was saved with.
|
| 2 |
+
|
| 3 |
+
`AutoencoderKLMiniMaxH3` pins every top-level module to float32 through `_keep_in_fp32_modules`,
|
| 4 |
+
so a pipeline-level `dtype=` cannot reach the weights. That is deliberate upstream: the decode
|
| 5 |
+
block runs `vae.decode` inside `torch.autocast(torch.float16)`, and the pin stops a pipeline
|
| 6 |
+
running in bfloat16 from downcasting the decoder to a format with fewer mantissa bits than the
|
| 7 |
+
recipe is built on.
|
| 8 |
+
|
| 9 |
+
The cost is that a checkpoint already storing a float16 decoder gets upcast on load: 5.19 GiB of
|
| 10 |
+
weights become 9.70 GiB, and the autocast then builds a float16 copy of all of them on every pass,
|
| 11 |
+
so decode peaks at 14.90 GiB instead of 6.65 GiB.
|
| 12 |
+
|
| 13 |
+
This class carries the checkpoint's own layout instead of the caller's dtype: the decoder ends up
|
| 14 |
+
float16 with its per-block `scale1` / `scale2` modulation tensors in float32 -- exactly the 511/72
|
| 15 |
+
split stored in the file -- whatever `dtype` the pipeline passes, including bfloat16.
|
| 16 |
+
|
| 17 |
+
It keeps the upstream pin rather than narrowing it, and casts down afterwards, because the route
|
| 18 |
+
matters. Narrowing the pin lets a `dtype=torch.bfloat16` load land the decoder in bfloat16 first,
|
| 19 |
+
and casting that to float16 is a lossy round trip: bfloat16 keeps 8 mantissa bits against
|
| 20 |
+
float16's 10, which measured 1.4e-2 of drift against 2.8e-3 for the real thing. Loading pinned to
|
| 21 |
+
float32 is a lossless widening of the stored float16, so the cast back recovers the original bits.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
import torch
|
| 25 |
+
|
| 26 |
+
from diffusers.models.autoencoders.autoencoder_kl_minimax_h3 import AutoencoderKLMiniMaxH3
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
FP32_DECODER_SUFFIXES = ("scale1", "scale2")
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class MiniMaxH3Fp16DecoderVae(AutoencoderKLMiniMaxH3):
|
| 33 |
+
# Left exactly as upstream: every module widens to float32 at load, losslessly.
|
| 34 |
+
_keep_in_fp32_modules = ["encoder", "decoder", "quant_conv", "post_quant_conv"]
|
| 35 |
+
|
| 36 |
+
def apply_checkpoint_dtypes(self):
|
| 37 |
+
"""Put the decoder back to the float16/float32 split the checkpoint stores."""
|
| 38 |
+
for name, parameter in self.decoder.named_parameters():
|
| 39 |
+
target = torch.float32 if name.endswith(FP32_DECODER_SUFFIXES) else torch.float16
|
| 40 |
+
if parameter.dtype != target and parameter.dtype.is_floating_point:
|
| 41 |
+
parameter.data = parameter.data.to(target)
|
| 42 |
+
return self
|
| 43 |
+
|
| 44 |
+
@classmethod
|
| 45 |
+
def from_pretrained(cls, *args, **kwargs):
|
| 46 |
+
model = super().from_pretrained(*args, **kwargs)
|
| 47 |
+
return model.apply_checkpoint_dtypes()
|