
MiniMax H3: Generate Video With Native Audio in Python
Summary
Run the open-weight MiniMax H3 model to make 768p clips with in-sync stereo audio using Diffusers.
MiniMax open-sourced H3, a 33B-parameter omni-modal model that generates video and its soundtrack in the same denoising loop. There is no separate vocoder and no bolt-on audio pass: the picture and the stereo audio come out of one transformer call. On Hugging Face the weights have already crossed tens of thousands of downloads a month, spawned dozens of Spaces, and landed a first-class Diffusers pipeline. That combination, open weights plus a documented Python API, is why it is worth learning this week rather than waiting.
This guide is hands-on. You will load the model through Diffusers, generate a clip with synchronized audio from a plain text prompt, fit the 123GB of weights onto a single or consumer GPU with quantization and offloading, condition on keyframes, and feed in references (a subject image, a motion clip, a voice) to steer both the picture and the sound. Every code block is taken from the official model card and the Diffusers pipeline reference, and the constraints are the ones the pipeline actually enforces.
A word on scope. The full MiniMax product generates up to 2K resolution through a three-stage hosted system (H3-Context-IR, H3-Base, H3-Regenerate-2K). The open weights are H3-Base, which produces 768p video with audio locally. The 2K regeneration stage and the Context-IR prompt-expansion service are API-only. This tutorial covers what you can run yourself: local 768p generation with native audio.
Prerequisites
- An NVIDIA GPU. Full bfloat16 wants an 80GB card; with int8 quantization and offloading you can run it on 24-32GB, and down to 12-16GB with a small canvas. Apple Silicon and CPU are not practical for a 33B video model.
- Python 3.10+ and a recent PyTorch build with CUDA.
- Comfort with Hugging Face
diffusers. H3 uses the newer Modular Diffusers API, not the classicDiffusionPipeline. - About 75GB of free disk (and, for offloaded runs, ~75GB of host RAM) for the checkpoint.
- Acceptance of the MiniMax H3 Community License. Users in the USA, EU, UK, and South Korea complete an application form on the MiniMax platform.
Why H3 is different: one packed sequence, two schedulers
Most open video models generate silent frames and leave you to add sound. H3 denoises a single packed sequence that holds the text conditioning, any conditioning media, and both the video and the audio latents at once. Because audio and video are produced jointly, lip movement, footsteps, and music land in time with the picture without a separate alignment step.
Two details fall out of this design and shape the whole API. First, the pipeline carries two schedulers: one for the video latents (shift 12.0) and one for the audio latents (shift 3.0), both stepped inside the same transformer call. Second, the released checkpoints are guidance-distilled. Guidance is baked into the weights, so there is no guider, no negative_prompt, and no guidance_scale. Every denoising step runs exactly one forward pass. If you come from Stable Diffusion habits, drop the negative prompt reflex here; it does nothing.
H3 ships three workflows against one repository: t2va (text to video plus audio), fl2va (start and/or end keyframe), and ref2va (an ordered mix of image, video, and audio references). The first two share the transformer/ partition; ref2va uses transformer_ref/. Everything else, the VAEs, the Qwen3-VL conditioner, tokenizer, and schedulers, is shared and stored once.
Step 1 - Install and load the modular pipeline
Install Diffusers from source (H3's pipeline lives on main at time of writing), plus Transformers and Accelerate:
pip install -U git+https://github.com/huggingface/diffusers transformers accelerate
# For reference-conditioned (ref2va) media decoding you also need PyAV:
pip install av
Load a single workflow. Passing workflow= prunes the pipeline to that task, so it only declares and fetches that task's components. A t2va pipeline never touches the transformer_ref/ partition:
import torch
from diffusers import ModularPipeline
pipe = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-H3", workflow="t2va")
pipe.load_components(dtype=torch.bfloat16)
Before you make a request, print pipe.doc. Pruned to one workflow it lists exactly that task's inputs with their defaults, the components it expects, and the outputs it returns. It is the fastest way to see what a call needs:
print(pipe.doc) # inputs, defaults, components, and outputs for t2va
If you want every workflow available on one pipeline, leave workflow= out. Be aware that a plain load_components() with no workflow pulls both 61.7GB transformer partitions.
Step 2 - Generate a clip with synced audio (text-to-video)
H3 runs at a fixed 24 fps and generates between 5 and 15 seconds. You request a frame count, not a duration, and num_frames is snapped up to the next value the video VAE can decode, the sequence 17 * n + 5. So 124 frames (17x7+5) is valid and gives roughly 5.2 seconds. The video and audio come back as separate outputs, and muxing them into one file is left to you, which encode_video handles:
import torch
from diffusers import ComponentsManager, ModularPipeline
from diffusers.utils.export_utils import encode_video
# The 61.7GB transformer and 62.1GB conditioner do not both fit on one card, so register
# them in a manager that moves each on and off the accelerator as the blocks reach it.
manager = ComponentsManager()
manager.enable_auto_cpu_offload(device="cuda")
pipe = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-H3", components_manager=manager)
pipe.load_components(workflow="t2va", dtype=torch.bfloat16)
prompt = "A red fox trotting through a snowy pine forest, snow crunching underfoot"
results = pipe(
prompt=prompt,
num_frames=124, # 17*7 + 5 -> ~5.2s at 24fps
generator=torch.Generator().manual_seed(42),
output=["videos", "audio", "sampling_rate"], # return only these
)
encode_video(
results["videos"][0],
fps=24,
output_path="fox.mp4",
audio=results["audio"][0],
audio_sample_rate=results["sampling_rate"],
)
Expected output. results["videos"][0] is a list of PIL frames (124 of them). results["audio"][0] is a tensor of shape (1, 2, num_samples), stereo at 32 kHz, and results["sampling_rate"] is that 32000. After muxing you get fox.mp4: about 5.2 seconds of 768p footage with the crunch of snow riding on top. Because the same generator seed draws the conditioning, video, and audio noise in a fixed order, rerunning with seed 42 returns the identical clip and soundtrack.
Step 3 - Fit it on your GPU
The transformer is 61.7GB in bfloat16 and the Qwen3-VL conditioner another 62.1GB, so how you load depends on your hardware. The single biggest speed lever on every setup is canvas size: height and width only need to be multiples of 32, and 960x544 runs about 2.3x faster per step than the trained 1344x768.
On one 80GB card, register the components and let the manager stream them on and off:
import torch
from diffusers import ComponentsManager, ModularPipeline
manager = ComponentsManager()
pipe = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-H3", components_manager=manager)
pipe.load_components(workflow="t2va", dtype=torch.bfloat16)
manager.enable_auto_cpu_offload(device="cuda", memory_reserve_margin="12GB")
pipe.transformer.set_attention_backend("_flash_3_hub") # Hopper: ~3x faster, kernels from the Hub
On a consumer 24-32GB card, quantize the two large components to int8 as they load and stream the transformer's blocks from CPU RAM. This uses supported loaders only, straight from the bfloat16 checkpoint:
import torch
from diffusers import MiniMaxH3Transformer3DModel, ModularPipeline, TorchAoConfig
from diffusers.hooks import apply_group_offloading
from transformers import Qwen3VLForConditionalGeneration
from transformers import TorchAoConfig as TransformersTorchAoConfig
from torchao.quantization import Int8WeightOnlyConfig
pipe = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-H3")
pipe.update_components(
transformer=MiniMaxH3Transformer3DModel.from_pretrained(
"MiniMaxAI/MiniMax-H3", subfolder="transformer", dtype=torch.bfloat16,
quantization_config=TorchAoConfig(Int8WeightOnlyConfig(version=2)),
low_cpu_mem_usage=False,
),
text_encoder=Qwen3VLForConditionalGeneration.from_pretrained(
"MiniMaxAI/MiniMax-H3", subfolder="text_encoder", dtype=torch.bfloat16,
quantization_config=TransformersTorchAoConfig(Int8WeightOnlyConfig(version=2)),
),
)
pipe.load_components(workflow="t2va", dtype=torch.bfloat16)
# int8 v2 tensors are pinnable (streamed offload needs that); freezing removes the one
# autograd path quantized tensors cannot serve.
pipe.transformer.requires_grad_(False)
pipe.text_encoder.requires_grad_(False)
offload = dict(onload_device=torch.device("cuda"), offload_device=torch.device("cpu"), use_stream=True)
pipe.transformer.enable_group_offload(offload_type="block_level", num_blocks_per_group=1, **offload)
apply_group_offloading(pipe.text_encoder.model, offload_type="leaf_level", **offload)
pipe.vae.to("cuda")
pipe.audio_vae.to("cuda")
On 12-16GB the same recipe works with the video VAE group-offloaded too and a small canvas like 960x544. Expect the weights to live in host RAM, around 75GB at int8. With two cards, nothing has to be offloaded: split the pipeline and put each half on its own device.
| Hardware | Strategy | Notes |
|---|---|---|
| 2x 80GB | Full bf16, split across devices | Nothing evicted once resident |
| 1x 80GB | ComponentsManager auto CPU offload | Add flash-attn on Hopper for ~3x |
| 24-32GB | int8 + block-level group offload | ~75GB host RAM; small canvas helps |
| 12-16GB | int8 + offload video VAE too, 960x544 | Slowest, but it runs |
Step 4 - Start or end on a keyframe (fl2va)
The fl2va workflow conditions on a first frame (image), a last frame (last_image), or both. The first keyframe is stretched onto the target canvas, and the canvas defaults to that keyframe's aspect ratio. Pass a last_image on its own to generate up to a frame:
import torch
from diffusers import ComponentsManager, ModularPipeline
from diffusers.utils import load_image
from diffusers.utils.export_utils import encode_video
manager = ComponentsManager()
manager.enable_auto_cpu_offload(device="cuda")
pipe = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-H3", components_manager=manager)
pipe.load_components(workflow="fl2va", dtype=torch.bfloat16)
prompt = "A red fox trotting through a snowy pine forest, snow crunching underfoot"
image = load_image(
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
)
outputs = ["videos", "audio", "sampling_rate"]
results = pipe(prompt=prompt, image=image, num_frames=124,
generator=torch.Generator().manual_seed(42), output=outputs)
encode_video(results["videos"][0], fps=24, output_path="keyframe.mp4",
audio=results["audio"][0], audio_sample_rate=results["sampling_rate"])
Step 5 - Omni-references: subject, motion, and voice (ref2va)
The ref2va workflow is where H3 stands out. You pass an ordered list of references: up to 9 images, 3 videos, and 3 audio clips, 12 in total. The order is semantic; it labels the references in the prompt presentation (<Picture 1>, <Video 1>, <Audio 1>) and advances the shared audio/video clock, so reordering the same references is a different request.
There is one reference class per modality. Build each with its from_file classmethod, which decodes a path or URL and, crucially, carries the media's real rates along. Do not decode videos with load_video: it drops the frame rate, and a reference conditioned at the wrong speed fails silently. An audio reference can never appear on its own; it has to be paired with at least one image or video:
import torch
from diffusers import ComponentsManager, ModularPipeline
from diffusers.modular_pipelines.minimax_h3 import (
MiniMaxH3AudioReference, MiniMaxH3ImageReference, MiniMaxH3VideoReference,
)
from diffusers.utils.export_utils import encode_video
manager = ComponentsManager()
manager.enable_auto_cpu_offload(device="cuda")
pipe = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-H3", workflow="ref2va", components_manager=manager)
pipe.load_components(dtype=torch.bfloat16)
subject = MiniMaxH3ImageReference.from_file("subject.png") # who is on screen
motion = MiniMaxH3VideoReference.from_file("dance.mp4") # how they move (brings its fps)
voice = MiniMaxH3AudioReference.from_file("voice.wav") # the timbre to speak in
results = pipe(
prompt="The character from <Picture 1> dances to the rhythm of <Video 1>, "
"speaking in the voice of <Audio 1>: 'Follow the wind, live free.'",
references=[subject, motion, voice],
num_frames=124,
output=["videos", "audio", "sampling_rate"],
)
encode_video(results["videos"][0], fps=24, output_path="ref2va.mp4",
audio=results["audio"][0], audio_sample_rate=results["sampling_rate"])
num_frames is required for ref2va. To make a clip exactly as long as a reference soundtrack, compute it as round(samples / sample_rate * 24); it is snapped up to the next 17 * n + 5, and the result must still land between 5 and 15 seconds.
Worked example: keep a character consistent across two shots
Because all workflows share one pipeline, a t2va generation can feed straight back in as a ref2va reference. The generated media is already at H3's native rates (24 fps frames, audio at the VAE's sample rate), so the in-memory constructor needs no rate arguments and nothing is re-encoded through a lossy container. This is the clean way to carry a subject from one shot to the next:
import torch
from diffusers import ComponentsManager, ModularPipeline
from diffusers.modular_pipelines.minimax_h3 import MiniMaxH3VideoReference
manager = ComponentsManager()
manager.enable_auto_cpu_offload(device="cuda")
# No workflow= means both partitions load once, so the ref2va call needs no reload.
pipe = ModularPipeline.from_pretrained("MiniMaxAI/MiniMax-H3", components_manager=manager)
pipe.load_components(dtype=torch.bfloat16)
# Shot 1: text to video + audio
shot1 = pipe(
prompt="An astronaut hiking through the mountains, humming a tune",
num_frames=124, output=["videos", "audio", "sampling_rate"],
)
# Feed shot 1 back in as a reference to keep the same astronaut and tune
reference = MiniMaxH3VideoReference(
frames=shot1["videos"][0],
audio=shot1["audio"][0],
sample_rate=shot1["sampling_rate"],
)
shot2 = pipe(
prompt="The same astronaut now walks along a beach at sunset, humming the same tune",
references=[reference],
num_frames=124, output=["videos", "audio", "sampling_rate"],
)
A prompting tip that pays off: H3's own pipeline expands prompts into a structured form with three parts, a shot-by-shot integrated_multimodal_description, an overall_soundscape, and a line of non_diegetic_music. You do not need the hosted expander to benefit from the pattern. Writing your prompt as (1) what the camera sees per shot, (2) the diegetic sound, and (3) the score gives the joint model the separate handles it was trained on, and audio quality improves noticeably.
Common pitfalls and gotchas
- Frame count is quantized.
num_framesis snapped up to the next17 * n + 5. Ask for 100 and you do not get 100. Valid counts are 5, 22, 39, 56, 73, 90, 107, 124, ... keep the resulting duration between 5 and 15 seconds at 24 fps. - Do not use
load_videofor references. It drops the frame rate, and H3 resamples references onto its 24 fps clock. A reference whose real rate was lost is conditioned at the wrong speed and nothing raises. Use each class'sfrom_file, which preserves rates via PyAV. - No negative prompt, no guidance scale. The checkpoints are guidance-distilled. There is no guider, no
negative_prompt, and noguidance_scale. Passing them does nothing; steer with the positive prompt instead. - Audio references cannot be the only input. A
MiniMaxH3AudioReferencemust be paired with at least one image or video reference, or the request is invalid. - Reference order is meaningful. The list order labels references as <Picture 1>, <Video 1>, and so on, and sets their place on the rotary clock. Reordering the same media is a different generation.
- Dimensions must be multiples of 32.
heightandwidthboth have to be multiples of 32. Smaller canvases are dramatically faster; 960x544 is a good speed/quality tradeoff versus the trained 1344x768. - Loading without a workflow pulls both transformers. A plain
load_components()with noworkflow=fetches both 61.7GB partitions (about 123GB of transformer). If you only need text-to-video, passworkflow="t2va". - 2K is not in the open weights. The open release is H3-Base at 768p. The 2K H3-Regenerate stage and the Context-IR prompt service are hosted API only, so plan for 768p locally and upscale separately if you need more.
- Muxing is your job. Video and audio return as separate outputs. Combine them yourself, for example with
encode_video(...), or you will save silent frames.
Quick reference
| Item | Value |
|---|---|
| Model | MiniMaxAI/MiniMax-H3 (33B, open weights, BF16) |
| API | Diffusers ModularPipeline (Modular Diffusers) |
| Workflows | t2va (text), fl2va (keyframes), ref2va (references) |
| Output | videos (PIL frames) + audio (1,2,N) + sampling_rate |
| Frame rate / duration | 24 fps, 5-15 s |
| Valid num_frames | 17 * n + 5 (5, 22, 39, ..., 124, ...) |
| Resolution | 768px short edge default; H, W multiples of 32 |
| Audio | 32 kHz stereo, generated jointly |
| Guidance | Distilled: no negative_prompt / guidance_scale |
| Muxing helper | diffusers.utils.export_utils.encode_video |
| License | MiniMax H3 Community License (region form for US/EU/UK/KR) |
Next steps
- Try
pipe.docfor each workflow to see the exact inputs, then swap the fox prompt for your own three-part (shot / soundscape / score) prompt. - For serving rather than notebooks, deploy H3-Base with SGLang or vLLM (both have official recipes) and call it over HTTP.
- Explore the community's turbo LoRAs and few-step distillations on Hugging Face to cut inference steps, and quantized checkpoints to shrink the memory footprint.
- If you need 2K, pair a local 768p H3-Base generation with MiniMax's hosted Regenerate-2K API using the same original context.
MiniMax H3 is a rare thing: a frontier-scale generative model with genuinely open weights and a clean Python API, where the audio is not an afterthought. Start with a 5-second t2va clip on a small canvas, get the muxing right, then layer in keyframes and references. Sources: MiniMax H3 model card, Diffusers MiniMax-H3 pipeline docs, MiniMax open-source announcement.
Comments
Be the first to comment
Found this useful?
Get new AI guides for builders by email. Free.
Join 3,605 newsletter subscribers.