minimax_h3_video_vae ¶
MiniMax-H3 video VAE for the Apple Silicon MLX runtime.
Faithful MLX port of fastvideo/models/vaes/minimax_h3_video.py (itself parity-validated against the official diffusers implementation):
- Encoder: causal 3D CNN — causal temporal padding, reflect spatial padding, per-frame GroupNorm, residual blocks, spatial/temporal downsampling, then a 1x1x1
quant_convproducing mean/logvar channels. - Decoder: 1x1x1
post_quant_conv, then a 36-layer ViT — per-head Q/K RMSNorm, three-axis rotary embedding (theta 100, rotary width 48 of 64 head dims), register tokens plus a final zero class token, SwiGLU feed-forward, residual scale vectors, FP32 norm accumulation, final LayerNorm, output projection, and channel-major unpatchification (temporal patch 4, spatial patch 16x16) — with the exact clip chunking (clip_length=17,token_drop=3), frame pre-padding, overlap blending, tail trimming, and optional spatial tiling of the released model.
Released weights are FP32; the loader streams shards so peak memory stays bounded, and can optionally store bf16/fp16 after callers have measured the dtype drift against the FP32 acceptance gate.
Production code here never imports PyTorch. Torch parity references live in the tests under tests/local_tests/minimax_h3/.
Classes¶
fastvideo.mlx_runtime.minimax_h3_video_vae.MLXMiniMaxH3VideoVAE ¶
MLXMiniMaxH3VideoVAE(weights: dict[str, Any], config: MiniMaxH3VideoVAEConfigView, *, has_encoder: bool = True)
Encoder + decoder for the released MiniMax-H3 video VAE.
Source code in fastvideo/mlx_runtime/minimax_h3_video_vae.py
Methods:¶
fastvideo.mlx_runtime.minimax_h3_video_vae.MLXMiniMaxH3VideoVAE.decode ¶
decode(z, *, tiled: bool = True, tile_sample_min_height: int = 256, tile_sample_min_width: int = 256, tile_sample_min_overlap_height: int = 64, tile_sample_min_overlap_width: int = 64)
Chunked decode of normalized latents (1, C, T_lat, H', W') -> (1, 3, T, H, W).
Source code in fastvideo/mlx_runtime/minimax_h3_video_vae.py
fastvideo.mlx_runtime.minimax_h3_video_vae.MLXMiniMaxH3VideoVAE.decode_clip_tiled ¶
decode_clip_tiled(z, tile_sample_min_height: int, tile_sample_min_width: int, tile_sample_min_overlap_height: int = 64, tile_sample_min_overlap_width: int = 64)
One clip through the decoder with spatial tiling (memory bounded).
Source code in fastvideo/mlx_runtime/minimax_h3_video_vae.py
fastvideo.mlx_runtime.minimax_h3_video_vae.MLXMiniMaxH3VideoVAE.encode ¶
Normalized pixels (1, 3, T, H, W) -> (mean, logvar) each (1, C, T', H', W').
Pads the clip to clip_length and drops token_drop trailing moment frames exactly like the reference _encode.
Source code in fastvideo/mlx_runtime/minimax_h3_video_vae.py
fastvideo.mlx_runtime.minimax_h3_video_vae.MLXMiniMaxH3VideoVAE.encode_keyframe ¶
Single-frame conditioning encode without chunk padding.
Source code in fastvideo/mlx_runtime/minimax_h3_video_vae.py
fastvideo.mlx_runtime.minimax_h3_video_vae.MLXMiniMaxH3VideoVAE.sample_posterior staticmethod ¶
Reparameterization with an explicit noise array (deterministic parity).
fastvideo.mlx_runtime.minimax_h3_video_vae.MiniMaxH3VideoVAEConfigView dataclass ¶
MiniMaxH3VideoVAEConfigView(in_channels: int = 3, out_channels: int = 3, latent_channels: int = 24, block_out_channels: tuple[int, ...] = (128, 256, 256, 512, 512, 1024), layers_per_block: int = 2, spatial_downsample_factors: tuple[int, ...] = (2, 2, 2, 2, 1, 1), temporal_downsample_factors: tuple[int, ...] = (1, 2, 2, 1, 1, 1), norm_num_groups: int = 32, norm_eps: float = 1e-06, decoder_num_layers: int = 36, decoder_num_attention_heads: int = 32, decoder_attention_head_dim: int = 64, decoder_num_register_tokens: int = 4, decoder_ffn_mult: int = 4, decoder_rope_theta: float = 100.0, decoder_rope_dim_ratio: float = 0.75, decoder_norm_eps: float = 1e-05, clip_length: int = 17, token_drop: int = 3, latents_mean: tuple[float, ...] | None = None, latents_std: tuple[float, ...] | None = None)
Functions:¶
fastvideo.mlx_runtime.minimax_h3_video_vae.mlx_h3_video_vae_from_dir ¶
mlx_h3_video_vae_from_dir(vae_dir: str | Path, *, include_encoder: bool = True, storage_dtype: str = 'fp32', config: MiniMaxH3VideoVAEConfigView | None = None) -> MLXMiniMaxH3VideoVAE
Load the released H3 video VAE, streaming one shard at a time.
storage_dtype="fp32" keeps the released numerics. bf16/fp16 halve residency; measure drift against the FP32 acceptance gate before shipping a reduced-dtype configuration.