Skip to content
EN

MiniMax-H3 Deployment and Usage

This guide serves MiniMax-H3 on Ascend NPUs with xLLM and generates video with audio through /v1/video/generation. BF16 inference is validated with four NPUs using TP2/SP2 and eight NPUs using TP2/SP4. The fl2va pipeline performs text-to-video-and-audio (T2VA) when no image conditions are supplied.

Prepare the xLLM Ascend NPU development environment, then build from the xLLM repository root:

Terminal window
git submodule update --init --recursive
python setup.py build --device npu

Before starting the service, load the Ascend environment and dependency library paths. Install FFmpeg with both ffmpeg and ffprobe on PATH. If etcd is enabled, also provide the Go toolchain required by third_party/Mooncake/mooncake-common/etcd/go.mod.

Use the root Diffusers component layout from MiniMaxAI/MiniMax-H3. The _class_name in model_index.json must be MiniMaxH3ModularPipeline; keep all component directories declared in that index. With the Hugging Face hf CLI available, download the components to your checkpoint directory:

Terminal window
export MODEL_PATH=/path/to/MiniMax-H3
hf download MiniMaxAI/MiniMax-H3 \
--revision 42ed227ee7df40d41602854ae760620d6eb651fe \
--local-dir "$MODEL_PATH" \
--include model_index.json --include 'transformer/*' \
--include 'transformer_ref/*' --include 'vae/*' --include 'audio_vae/*' \
--include 'scheduler/*' --include 'audio_scheduler/*' --include 'processor/*' \
--include 'text_encoder/*' --include 'tokenizer/*'

The H3 pipeline requires conditioning generated by the model’s matching text encoder. Supplying input.prompt alone does not run text encoding in this service. xLLM does not provide a text-encoder preprocessing command for H3; the request below starts from existing encoder output, not raw text alone. Obtain the features and token tags from the matching H3 encoder, then save a PyTorch dictionary as conditioning.pt with the following fields. The prompt, features, and tags must come from the same encoding operation:

FieldType and shapeDescription
promptStringPrompt used to produce the conditioning
prompt_embedBF16 Tensor, [1, L, 5120]H3 text features
prompt_token_tagsINT64 Tensor, [L]Encoder token tags with values 0 or 1

Send the embedding with shape [L, 5120] in the HTTP request; the server adds the batch dimension. Put the token tags in the tensor’s parameters.prompt_token_tags.int64_tensor_param. Random tensors, embeddings from another model, or mismatched tags are not valid substitutes.

Start on four available NPUs. Set XLLM_BINARY to the built xLLM executable:

Terminal window
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export MODEL_PATH=/path/to/MiniMax-H3
export XLLM_BINARY=/path/to/xllm
export OMP_NUM_THREADS=8
export HCCL_BUFFSIZE=256
python -m xllm.launch_server serve --binary-path="$XLLM_BINARY" \
--nnodes=4 --backend=dit --model="$MODEL_PATH" --model_id=minimax-h3 \
--tp_size=2 --sp_size=2 --cfg_size=1 --vae_size=4 \
--text_encoder_tp_size=1 --dit_h3_task_type=fl2va --dit_cache_policy=None \
--dit_laser_attention_enabled=false --dit_sparse_attention_enabled=false \
--master_node_addr=127.0.0.1:19885 --host=127.0.0.1 --port=8000 \
--max_body_size=2147483648 --logtostderr=true

For eight NPUs, set ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 and change the following arguments:

Layout--nnodes--tp_size--sp_size--vae_size
Four NPUs4224
Eight NPUs8248

--vae_size sets the VAE process group size independently of TP/SP and does not contribute to the TP * SP * CFG * DP product. It must be positive and divide --nnodes. The layouts above distribute spatial video tiles across all NPUs for decoding, then gather and stitch the results. This setting does not parallelize audio VAE decoding. The VAE remains in FP32. Each participating NPU loads the complete video VAE weights and holds the gathered tiles; allow device memory for these weights and decode intermediates before enabling this configuration.

Set --vae_size=1 for local VAE decoding without changing TP/SP. When spatial tiling is unnecessary or there are fewer tiles than VAE ranks, each participating rank uses local decoding, so increasing --vae_size does not provide tile parallelism for those inputs.

--max_body_size allows for internal transfer of generated tensors; do not size it based on the compressed MP4. The standard checkpoint has 56 attention heads, 96 video patch channels, and 32 audio channels. Parallel layouts must satisfy heads % (TP * SP) == 0, video_patch_dim % TP == 0, and audio_in_channels % TP == 0.

To enable Laser on Ascend NPUs, change the service argument above to --dit_laser_attention_enabled=true. The default is false. Keep the same checkpoint, text conditioning, request fields and parallel layout described in this recipe; enabling Laser does not run the text encoder.

For the Python pipeline, use the four-NPU TP2/SP2/VAE4 layout with --model_impl=python --dit_laser_attention_enabled=true --dit_cache_policy=None. The worker loads Laser Attention from the matching xllm-kernel package.

Build xLLM together with its matching xllm_ops submodule. Rebuild the native operator in a fresh build directory when updating it so generated kernel caches are not reused. Use the Ascend environment described above.

H3 selects Laser for self-attention with at least 2,048 live tokens and a head dimension no greater than 128. Short sequences use the existing dense attention operator. H3 excludes sequence-parallel padding from attention; Laser handles its own sequence and head-dimension alignment. No additional input padding or input-range scaling is required from the user.

This option provides dense, non-causal attention. It does not add support for external attention masks, dropout or grouped-query attention. The model and request limitations below still apply.

Run this request from the directory containing conditioning.pt. The client needs PyTorch to read the conditioning; HTTP and Base64 handling use the Python standard library.

Terminal window
python - <<'PY'
import base64
import json
import urllib.request
from pathlib import Path
import torch
conditioning = torch.load("conditioning.pt", map_location="cpu", weights_only=True)
embedding = conditioning["prompt_embed"].squeeze(0).float().contiguous()
payload = {
"model": "minimax-h3",
"input": {
"prompt": conditioning["prompt"],
"prompt_embed": {
"name": "prompt_embed",
"datatype": "FP32",
"shape": list(embedding.shape),
"contents": {"fp32_contents": embedding.flatten().tolist()},
"parameters": {"prompt_token_tags": {"int64_tensor_param": conditioning["prompt_token_tags"].tolist()}},
},
},
"parameters": {
"size": "1344*768",
"num_inference_steps": 50,
"seed": 42,
"num_frames": 124,
"fps": 24,
"sampling_rate": 32000,
"flow_shift": 12.0,
"guidance_scale": 1.0,
"num_videos_per_prompt": 1,
"output_type": "base64",
},
}
request = urllib.request.Request(
"http://127.0.0.1:8000/v1/video/generation",
data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=3600) as response:
result = json.load(response)
video = result["output"]["results"][0]["video"]["base64"]
Path("output.mp4").write_bytes(base64.b64decode(video, validate=True))
PY

output.mp4 contains video and 32 kHz stereo audio. Inspect its media metadata:

Terminal window
ffprobe -v error -show_entries \
stream=codec_type,width,height,nb_frames,r_frame_rate,sample_rate,channels \
-of json output.mp4

The current service supports batch one and num_videos_per_prompt=1. Resolution and frame count are aligned to model requirements; the resulting duration must be between 5 and 15 seconds. The request above produces 1344×768 video with 124 frames at 24 FPS. Other tasks, checkpoint formats, dtypes, and parallel layouts require separate validation.

H3 uses dense inference by default. To enable approximate TaylorSeer caching, explicitly set --dit_cache_policy=TaylorSeer (or "dit_cache_policy": "TaylorSeer" in the JSON configuration). For a 50-step request, replace the cache arguments in the service command with:

Terminal window
--dit_cache_policy=TaylorSeer \
--dit_cache_warmup_steps=45 \
--dit_cache_skip_interval_steps=2 \
--dit_cache_n_derivatives=1

The interval must be greater than zero; 1 computes every denoising step. Warmup steps and derivative order must be nonnegative. Cache history is local to each request and each SP shard. The cache approximates the packed video/audio/text transformer block output; timestep-dependent output normalization, media projection, scheduler updates, and VAE decoding still execute normally. Caching changes the numerical result and requires workload-specific quality validation. Set --dit_cache_policy=None for dense inference.

To use FBCache instead of TaylorSeer or dense inference, replace the cache arguments in the service command with the following. These settings are for a 50-step request; keep the same conditioning and HTTP request format:

Terminal window
--dit_cache_policy=FBCache \
--dit_cache_warmup_steps=45 \
--dit_cache_residual_diff_threshold=0.09

Warmup steps and the residual threshold must be nonnegative. Setting the threshold to 0 disables reuse; setting warmup to at least the request’s denoising step count also keeps every step fully computed. Approximate reuse changes numerical results, so choose settings using video and audio quality checks for your workload.

FBCache cannot be combined with rolling weight loading. For TP=1, explicitly set --enable_rolling_load=false; all resident weights and inference workspace must then fit on one device. Disabling rolling does not guarantee that TP=1 fits. Use the multi-device layouts above when memory is insufficient. H3 supports only None, TaylorSeer, and FBCache; FBCacheTaylorSeer is unsupported.

With --model_impl=python, four NPUs with TP2/SP2/VAE4 or eight NPUs with TP2/SP4/VAE8 support optional Cache-DiT 1.5.1. The dependency is installed when building the A2/A3 Docker images; its version is controlled by the CACHE_DIT_VERSION build argument.

Keep --enable_graph=false --enable_rolling_load=false --dit_cache_policy=None. Cache-DiT is approximate: skipped middle blocks use cached residuals or Taylor forecasts. Video/audio output quality must be evaluated separately from latency. ACLGraph, Ref2VA and other DiT models are outside this integration.

Add --enable_cache_dit=true --cache_dit_config=/path/to/cache_dit.json to the Python service command. The JSON file contains any of the following fields; this example aligns with the explicit H3 comparison recipe:

{
"Fn_compute_blocks": 2,
"Bn_compute_blocks": 1,
"max_warmup_steps": 4,
"residual_diff_threshold": 0.4,
"max_continuous_cached_steps": 4,
"enable_taylorseer": true,
"taylorseer_order": 2
}

Without a file, defaults are Fn=1, Bn=0, warmup=4, threshold=0.24, continuous limit=3, TaylorSeer=false and order=1. Each request may set parameters.enable_cache_dit and partially override parameters.cache_dit_params with these same seven keys. Explicit false disables caching even when the service enables it; 0 and -1 are preserved. A continuous limit of 0 disables cache hits, and -1 removes this limit. Unknown fields are rejected. Cache-DiT 1.5.1 requires Fn >= 1 and Bn >= 0 when enabled; their sum must not exceed the number of Transformer blocks.

Each request starts with empty residuals, derivatives and step counters. The actual scheduler layouts determine the cache step count, including joint video/audio timesteps. Cache statistics in each rank’s log report the effective configuration, computed/cached steps, residual differences and actual block calls. TP/SP decisions use the existing xLLM C++ process groups.

Server and workers must use the same build; this integration uses packed input schema 14.

Report issue