minimax_h3 ¶
FastVideo-native MiniMax H3 joint audio-video diffusion transformer.
Classes¶
fastvideo.models.dits.minimax_h3.MiniMaxH3AdaLayerNormModulation ¶
MiniMaxH3AdaLayerNormModulation(time_embed_dim: int, hidden_size: int, quant_config: QuantizationConfig | None = None, prefix: str = '', apply_silu: bool = True)
Bases: Module
Produce six modulation tables for every (timestep, modality) pair.
Source code in fastvideo/models/dits/minimax_h3.py
Methods:¶
fastvideo.models.dits.minimax_h3.MiniMaxH3AdaLayerNormModulation.enable_host_cache ¶
enable_host_cache(table: dict | None = None) -> None
Keep the projection in pinned host memory and cache its output per timestep set.
The modulation is a pure function of the timestep embedding, and few-step checkpoints sample a fixed timestep ladder, so each block's output is a small constant table. The weights (the largest bf16 tensors in the DiT) then never occupy device memory: a cache miss copies them in for one matmul.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3AdaLayerNormOut ¶
MiniMaxH3AdaLayerNormOut(hidden_size: int, time_embed_dim: int, eps: float, quant_config: QuantizationConfig | None = None, prefix: str = '', apply_silu: bool = True)
Bases: Module
Final RMSNorm with per-timestep row modulation.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3Attention ¶
MiniMaxH3Attention(hidden_size: int, num_attention_heads: int, attention_head_dim: int, qk_norm_eps: float, supported_attention_backends: tuple[AttentionBackendEnum, ...], quant_config: QuantizationConfig | None, prefix: str, fuse_qknorm_rope: bool = False, fa4_packed_varlen: bool = False, exact_rope: bool = False)
Bases: Module
Full self-attention over one sequence-parallel packed document.
Source code in fastvideo/models/dits/minimax_h3.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
fastvideo.models.dits.minimax_h3.MiniMaxH3FeedForward ¶
MiniMaxH3FeedForward(hidden_size: int, ffn_dim: int, quant_config: QuantizationConfig | None = None, prefix: str = '', fuse_swiglu: bool = False, exact_swiglu: bool = False)
Bases: Module
Bias-free H3 SwiGLU with value-first packed halves.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3RotaryPosEmbed ¶
Bases: Module
Three-axis rotary frequencies over packed (t, h, w) coordinates.
Source code in fastvideo/models/dits/minimax_h3.py
Methods:¶
fastvideo.models.dits.minimax_h3.MiniMaxH3RotaryPosEmbed.forward ¶
forward(position_ids: Tensor) -> tuple[Tensor, Tensor]
Build rotary tensors on the device that owns the packed positions.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3TokenRefiner ¶
MiniMaxH3TokenRefiner(hidden_size: int, num_attention_heads: int, attention_head_dim: int, ffn_dim: int, num_layers: int, norm_eps: float, qk_norm_eps: float, final_norm_eps: float, supported_attention_backends: tuple[AttentionBackendEnum, ...], quant_config: QuantizationConfig | None, prefix: str)
Bases: Module
Two-block text refiner used before packing the modalities.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3TokenRefinerBlock ¶
MiniMaxH3TokenRefinerBlock(hidden_size: int, num_attention_heads: int, attention_head_dim: int, ffn_dim: int, norm_eps: float, qk_norm_eps: float, supported_attention_backends: tuple[AttentionBackendEnum, ...], quant_config: QuantizationConfig | None, prefix: str)
Bases: Module
Plain pre-norm Transformer block for the projected text stream.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel ¶
MiniMaxH3Transformer3DModel(config: MiniMaxH3Config, hf_config: dict[str, Any])
Bases: BaseDiT
Joint H3 Transformer over one padless text/audio/video document.
The layout builder validates semantic rows before denoising. Sequence- parallel padding is transport-only and DistributedAttention trims it before attention.
Source code in fastvideo/models/dits/minimax_h3.py
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 | |
Attributes¶
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.pdd_linears property ¶
pdd_linears: dict[str, PDDReplicatedLinear]
The widened {"video": proj_out, "audio": audio_proj_out} heads.
Methods:¶
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.attach_step_splice ¶
attach_step_splice(late: Module, from_step: int) -> None
Hand denoising steps from_step onward to late (same architecture, other weights).
Early DMD steps fix layout and object count, late ones texture and detail, so two checkpoints can split the trajectory. late is kept out of this module's children: it is placed, offloaded and checkpointed on its own.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.enable_adaln_host_cache ¶
enable_adaln_host_cache(table_path: str | None = None) -> None
Move every block's AdaLN projection to pinned host memory behind a per-timestep cache.
With table_path (written by FASTVIDEO_H3_ADALN_DUMP), the cache is prefilled from precomputed modulation tables and the projection weights are dropped entirely.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.forward ¶
forward(hidden_states: Tensor, audio_hidden_states: Tensor, encoder_hidden_states: Tensor, timestep: Tensor, timestep_indices: Tensor, token_tags: Tensor, position_ids: Tensor, video_indices: Tensor, audio_indices: Tensor, text_indices: Tensor) -> tuple[Tensor, Tensor]
Predict video and audio velocities from one caller-defined packed layout.
Source code in fastvideo/models/dits/minimax_h3.py
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 | |
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.fuse_pdd_block ¶
fuse_pdd_block(start: int, end: int, integration_weights: Mapping[str, Tensor], precision_decoding: dtype) -> Iterator[None]
Fuse fine-grid block [start, end) on both widened heads for the enclosed forwards.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.materialize_non_persistent_buffers ¶
Rebuild analytic RoPE state on the checkpoint loader device.
RoPE frequencies are absent from the checkpoint, so meta-device model construction and device moves must derive the buffer from architecture fields before the first forward pass.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.prepare_for_compile ¶
Pipeline hook, called once right before torch.compile wraps the blocks.
Resolve each loaded VSA compression gate eagerly and tensorize its layer identity so repeated blocks share one Dynamo graph. Generic and training compile retain their established attention dispatch; only the inference loader's separate prepare_for_regional_compile hook may preselect the inference-only sm_100a path.
The inference-only Triton fusions expose fake-backed custom operators, so Dynamo can keep them active as opaque nodes inside each fullgraph block instead of tracing into their launcher implementation.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3Transformer3DModel.prepare_for_regional_compile ¶
prepare_for_regional_compile() -> str | None
Resolve state used only by inference regional fullgraph compile.
Source code in fastvideo/models/dits/minimax_h3.py
fastvideo.models.dits.minimax_h3.MiniMaxH3TransformerBlock ¶
MiniMaxH3TransformerBlock(hidden_size: int, num_attention_heads: int, attention_head_dim: int, ffn_dim: int, time_embed_dim: int, norm_eps: float, qk_norm_eps: float, supported_attention_backends: tuple[AttentionBackendEnum, ...], quant_config: QuantizationConfig | None, prefix: str, adaln_apply_silu: bool = True, fuse_modulate: bool = False, fuse_qknorm_rope: bool = False, fuse_swiglu: bool = False, fa4_packed_varlen: bool = False, exact_kernels: frozenset[str] = frozenset())
Bases: Module
Packed self-attention and feed-forward branches with row-indexed AdaLN.