Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

MiniMax-H3 ncnn Vulkan

:exclamation: :exclamation: :exclamation: More features and optimizations in progress

CI download

ncnn implementation of MiniMax-H3 for video and stereo audio generation from text, keyframes or multimodal references.

h3-ncnn-vulkan uses ncnn project as the universal neural network inference framework.

Features

  • BF16 text encoder and DiT, FP32 vision and VAEs
  • Vulkan GPU acceleration
  • Portable standalone executable
  • No CUDA, PyTorch, Python or FFmpeg dependency for inference
  • Automatic weight streaming and tiled video VAE inference
  • Text, first and last frames, or multimodal references
  • Dynamic resolution and frame count
  • Stereo audio generation
  • Intermediate keyframes for longer videos
  • LoRA adapters, portable modulation banks and optional rough modes
  • Lossy WebM and lossless Matroska output

minimax-h3 text-to-video 832x480, 124 frames, 14GiB RAM budget

dit transformer 2nd step(s/it) less is betterRX9060XTRTX3060
stable-diffusion.cpp (vulkan) 2026112783.81375.59
h3-ncnn-vulkan 2026120151.15101.46

minimax-h3 FL2VA 832x480, 56 frames, 14GiB RAM budget

dit transformer step(s/it) less is betterRX9060XT
stable-diffusion.cpp (vulkan) 2026112746.19
h3-ncnn-vulkan 20261201 rough-mode 025.50
h3-ncnn-vulkan 20261201 rough-mode 123.54
h3-ncnn-vulkan 20261201 rough-mode 222.53
h3-ncnn-vulkan 20261201 rough-mode 319.43

Download

Download the Linux x86-64 (glibc 2.28 or newer), macOS universal (Apple silicon and Intel), or Windows x86-64 ZIP from GitHub Releases. For a local build, see Build from Source.

The release workflow builds all three packages from source and collects them in a draft release. Release workflow

prepare model files

Place the downloaded models/ directory next to h3-ncnn-vulkan (h3-ncnn-vulkan.exe on Windows). Run the examples from the package root. To use the command as written, add the package root to your PATH in the current shell:

  • Linux and macOS: export PATH="$PWD:$PATH"
  • Windows (PowerShell): $env:Path = "$PWD;$env:Path"

The default model path is models/h3. Set -m to use a different model directory.

h3-ncnn-vulkan
models/
    h3/
        LICENSE
        NOTICE
        processor/
        text_encoder/
        vae/
        audio_vae/
        transformer/

Download the files for text-to-video-and-audio (T2VA) from the package root. The default 50-point schedule uses the prepared BF16 modulation bank. This set takes about 128 GB. h3 model folder(huggingface) or h3 model folder(modelscope)

hf download nihui-szyl/h3-ncnn --local-dir models \
    --include 'h3/LICENSE' \
    --include 'h3/NOTICE' \
    --include 'h3/processor/*' \
    --include 'h3/text_encoder/*' \
    --include 'h3/vae/decoder.ncnn.*' \
    --include 'h3/audio_vae/decoder.ncnn.*' \
    --include 'h3/transformer/fl2va/transformer-core.ncnn.*' \
    --include 'h3/transformer/fl2va/fixed-build/modulations.ncnn.*' \
    --include 'h3/transformer/fl2va/fixed-modulations-bf16-steps50-none.bin'

Keep the fixed-build files. The runtime uses them to validate the prepared bank and to compute modulations for other schedules. The first generation example uses this download.

Additional model files for FL2VA, Ref2VA and LoRA

For FL2VA with one or two image keyframes, add the vision encoder, spatial VAE encoder and video bank. This adds about 2.9 GB to the T2VA download.

hf download nihui-szyl/h3-ncnn --local-dir models \
    --include 'h3/vision/*' \
    --include 'h3/vae/encoder_spatial.ncnn.*' \
    --include 'h3/transformer/fl2va/fixed-modulations-bf16-steps50-video.bin'

For the Ref2VA example with an image and audio, add the Ref2VA core, producer and matching bank alongside the encoders. This adds about 70 GB to the T2VA download.

hf download nihui-szyl/h3-ncnn --local-dir models \
    --include 'h3/vision/*' \
    --include 'h3/vae/encoder_spatial.ncnn.*' \
    --include 'h3/audio_vae/encoder.ncnn.*' \
    --include 'h3/transformer/ref2va/transformer-core.ncnn.*' \
    --include 'h3/transformer/ref2va/fixed-build/modulations.ncnn.*' \
    --include 'h3/transformer/ref2va/fixed-modulations-bf16-steps50-both.bin'

Use the bank that matches your references as described under Modulation cache. An audio reference needs audio_vae/encoder.ncnn.*. A video reference needs vae/encoder_temporal.ncnn.*.

pi-H3 also needs the shared transformer/pi-h3.safetensors. The optional two- and four-forward banks in transformer/fl2va/ cover text-only and keyframe inputs. The LoRA adapters themselves are available from their publishers. LoRA

The complete model folder takes about 206 GB.

hf download nihui-szyl/h3-ncnn --local-dir models --include 'h3/*'

About MiniMax-H3

MiniMax-H3 generates video and audio together. This implementation supports text to video and audio (T2VA), first and last frames to video and audio (FL2VA), and image, video or audio references (Ref2VA).

T2VA and FL2VA share the DiT in transformer/fl2va/. Ref2VA uses transformer/ref2va/.

Usages

requirements

  • A Vulkan-capable GPU and driver.
  • Disk space for the model files used by the selected workflow.
  • Additional disk space for streamed weights. Set H3_WEIGHT_TMPDIR to a disk-backed directory with tens of GiB free when paging.
  • RAM and VRAM for the requested resolution, frame count, prompt and references.

The table gives estimated planning budgets with disk weight streaming, rounded up to the next multiple of 128 MiB.

Output resolutionFramesDurationRAM budget (MiB)VRAM budget (MiB)
640 × 352562.33 s14081408
640 × 3521245.17 s14082304
640 × 35224310.13 s14083712
832 × 480562.33 s14082048
832 × 4801245.17 s14083584
832 × 48024310.13 s14085760
1024 × 10241245.17 s16647424
1280 × 736562.33 s16643584
1280 × 7361245.17 s16646784
1280 × 73624310.13 s166412416
1920 × 1088562.33 s30726784
1920 × 10881245.17 s320013952
1920 × 108824310.13 s320026496
640 × 352489 (joined)20.38 s15363072
1280 × 736489 (joined)20.38 s17929984

The estimates use the prompt in the memory example below, 24 fps, the default 50 scheduler points, a portable BF16 modulation bank, rough mode 0 and WebM output. Single-segment rows use T2VA. Joined rows use FL2VA with four image keyframes and segments of 158, 158 and 175 frames.

The DiT fuses the gate and up projections in each feed-forward block. The planner selects how many token rows to process at once and which paged weights to keep between tiles. AdaLN processes up to 1024 token rows at a time. Attention processes up to 1024 query rows at a time. Each row attends to all keys and values. For long sequences, packed heads are unpacked in groups of up to eight. On devices using the standard attention kernel, the tile size adapts to the key sequence length to keep the score buffer within a 128 MiB target.

The planner uses the ncnn graph, tensor sizes and allocation lifetimes on the selected Vulkan device, including DiT tiles, video VAE tiles and the modulation producer when a bank needs baking. The OS and Vulkan driver need additional capacity. With the bundled ncnn revision, mapped weight pages can stay resident during disk paging, so process RAM can exceed the planning budget.

Example Command

Text to video and audio

h3-ncnn-vulkan -p "A red ceramic teapot slowly rotates on a pale oak table in daylight." \
    -s 384,256 -f 56 -o teapot.webm

First and last frames to video and audio

h3-ncnn-vulkan -t fl2va -i first.png -i last.png \
    -p "The red ceramic teapot slowly turns cobalt blue." \
    -s 384,256 -f 124 -o keyframes.webm

Generate a longer video with intermediate keyframes

h3-ncnn-vulkan -t fl2va -i A.png -i B.png -i C.png -i D.png \
    -f 73 -f 90 -f 107 \
    -p "The teapot turns to the left." \
    -p "The teapot continues turning as it moves closer." \
    -p "The teapot completes the turn in close-up." -o joined.webm

Pass one frame count per pair of adjacent keyframes. Use one shared prompt or one prompt per segment. The writer counts each shared boundary once, so this example produces 268 frames. All segments share one canvas and optional audio reference. Each model is loaded once per stage, and adjacent segments reuse their shared keyframe encodings.

Multimodal references

h3-ncnn-vulkan -t ref2va -i teapot.png --reference-audio tone.wav \
    -p "Using <Picture 1> as the reference, show the teapot rotating slowly. Use <Audio 1> as the sound reference." \
    --reference-short-edge 512 -s 384,256 -f 124 -o reference.webm

Set size, frame count, scheduler steps, seed and GPU

h3-ncnn-vulkan -s 640,352 -f 124 -l 50 -r 2026 -g 0 \
    -p "A red ceramic teapot rotates on a table." -o teapot.webm

Estimate memory with explicit budgets, in MiB

h3-ncnn-vulkan --estimate-memory --ram-budget 16384 --vram-budget 32768 \
    -p "A red ceramic teapot rotates on a table." -s 1280,736 -f 124 -o teapot.webm

Generate with the same parameters

h3-ncnn-vulkan --ram-budget 16384 --vram-budget 32768 \
    -p "A red ceramic teapot rotates on a table." -s 1280,736 -f 124 -o teapot.webm

A budget of 0 uses the available capacity automatically. Larger budgets keep more weights resident and improve throughput. The estimate reports the selected stage peaks and the overall requirements with disk paging or resident weights. For joined FL2VA, it includes intermediate results held across segments.

Optional rough K/V reuse

h3-ncnn-vulkan -t fl2va -i first.png --rough-mode 2 \
    -p "The red ceramic teapot slowly turns cobalt blue." \
    -s 384,256 -f 124 -o rough.webm

Rough modes reuse K/V and can change movement and sound. Active rows attend to the full K/V sequence. --kv-cache-mib caps the cache for the clip at 6144 MiB by default.

ModeCached K/V rowsRefresh forwards
0NoneEvery forward
1Text1, 3, 5, …
2Text and references1, 3, 5, …
3Text and referencesFirst forward only

LoRA

Load an adapter with --lora. Repeat the option to combine adapters and give --lora-scale values in the same order. Unspecified strengths default to 1. Merged adapters combine updates in FP32 during loading. Pika Flex Turbo evaluates its low-rank projections in Vulkan.

h3-ncnn-vulkan -t fl2va -i teapot.png -i teapot.png \
    -p "A smooth full orbit around the stationary teapot." \
    -s 640,352 -f 73 -l 29 \
    --lora minimax_h3_flf2v_lora_v1.safetensors -o orbit.webm

Combine Orbit with pi-H3 in the same run. pi-H3 sets the sampling schedule.

h3-ncnn-vulkan -t fl2va -i subject.png -i subject.png \
    -p "A smooth 360 degree camera orbit around the stationary subject." \
    -s 384,384 -f 124 -l 3 \
    --lora minimax_h3_flf2v_lora_v1.safetensors \
    --lora pi_h3_2step_adapter/diffusion_pytorch_model.safetensors -o orbit-pi.webm
Supported adapters and sampling presets

Use pi-H3 for a text-only generation

h3-ncnn-vulkan -p "A red ceramic teapot with steam rising in daylight." \
    -s 384,256 -f 73 \
    --lora pi_h3_4step_adapter/diffusion_pytorch_model.safetensors -o pi-h3.webm
AdapterWorkflowSampling
360 OrbitFL2VASet -l 29 for 28 DiT forwards. Use the same reference for both keyframes.
Character Swap V1 / V1.5, Fight Flow V1 / V2Ref2VAH3 schedule. For Character Swap, pass the source clip with --reference-video and the new character with -i.
Sentinel7 Extreme RealismFL2VAH3 schedule. Includes audio input and output projections.
Larry H3 TurboT2VA / FL2VADual-clock Euler. V4 defaults to 6 DiT forwards. Earlier 4-step weights default to 4.
Pika H3 Flex TurboMatch the FL2VA or Ref2VA filenameSimple Euler with the file's 2, 4 or 8 forward preset. FL2VA uses video shift 6.
pi-H3 2-step / 4-step VAE adaptersT2VA / FL2VA fixed buildpi-H3 Euler with 2 or 4 DiT forwards and strength 1.

Keep the original Pika filename and pi-H3 folder name to select their presets automatically. The pi-H3 VAE adapters use the existing video VAE. The DWD checkpoints require a separate pixel refiner.

Adapter and sampler references are available from the publishers. Orbit, Character Swap, Fight Flow, Larry Turbo, Pika Flex Turbo, pi-H3, Extreme Realism

Modulation cache

The model download includes portable BF16 modulation banks for the default -l 50. Filenames end in none, video, audio or both, according to the input references. The optional pi-H3 banks in transformer/fl2va/ cover text-only generation and FL2VA with one or both keyframes, at -l 3 and -l 5.

Matching banks can be copied between machines. The loader checks model fingerprints, sampling preset and reference modalities. Requests without a matching bank use the modulation producer and cache the result under fixed-build/banks/.

Precompute a bank for another schedule

Use --bake-modulations to precompute a portable bank for a base H3 schedule or supported pi-H3 preset. Specify the workflow and reference type.

h3-ncnn-vulkan -t fl2va -l 17 --bake-modulations video
h3-ncnn-vulkan -t ref2va -l 17 --bake-modulations both
h3-ncnn-vulkan -t fl2va --lora pi_h3_2step_adapter/diffusion_pytorch_model.safetensors --bake-modulations video

Full Usages

Usage: h3-ncnn-vulkan [options]

  -h                 show this help
  -p TEXT            prompt (one for the video or one per FL2VA segment)
  -o PATH            lossy .webm or lossless .mkv (default: output.webm)
  -i PATH            FL2VA keyframe or Ref2VA image reference (repeat in order)
  -s WIDTH,HEIGHT    output dimensions, multiples of 32
  -f N               frames at 24 fps, rounded up (repeat per FL2VA segment)
  -l N               scheduler points, including zero (default: 50 or adapter preset)
  -r N               sampling seed (default: 42)
  -m DIR             ncnn model directory (default: models/h3)
  -g N               Vulkan device index (default: automatic)
  -t TYPE            t2va, fl2va, ref2va (default: t2va)

  --last-image PATH                 optional final FL2VA keyframe
  --reference-video PATH            WebM/MKV video reference, including its audio stream
  --reference-audio PATH            WAV or WebM/MKV audio reference for fl2va or ref2va
  --reference-short-edge N          ref2va image short edge (default: 2048)
  --reference-video-short-edge N    ref2va video short edge (default: 768)
  --lora PATH                       H3 LoRA .safetensors file (repeat to combine)
  --lora-scale VALUE                adapter strengths in --lora order (default: 1)
  --bake-modulations TYPE           build a bank only: none, video, audio, both
  --rough-mode 0|1|2|3              exact, alternate text, alternate full, freeze full (default: 0)
  --kv-cache-mib N                  Vulkan K/V cache ceiling (default: 6144)
  --ram-budget MiB                  process RAM budget (0=auto, default)
  --vram-budget MiB                 Vulkan memory budget (0=auto, default)
  --estimate-memory                 calculate the memory plan without running inference
  • Use -s WIDTH,HEIGHT to set the output dimensions. Each side is a multiple of 32 from 32 to 4096 pixels. The default is 124 frames at 24 fps. The VAE rounds the frame count up to 17 * n + 5, with supported output lengths of 22 to 345 frames per segment.
  • -l counts scheduler points including the final zero. The default 50 points run 49 DiT forwards, and 17 points run 16.
  • FL2VA accepts either keyframe or both. It also accepts one experimental --reference-audio with or without keyframes. Refer to it as <Audio 1> in the prompt. Speaker similarity can vary.
  • Ref2VA accepts up to 9 images, 3 videos and 3 audio files. Pass references in prompt order. Number <Picture i>, <Video i> and <Audio i> independently from 1. Audio embedded in a reference video receives its own audio label.
  • Images can be PNG, JPEG or WebP. Reference videos can be WebM or MKV with VP8/VP9 and optional Opus or PCM. Audio references can be mono/stereo PCM WAV or Opus/PCM tracks in WebM or MKV.
  • The output filename extension selects the encoding.
ExtensionVideoStereo audio
.webmVP9 4:2:0Opus, 48 kHz
.mkvLossless VP9 RGB 4:4:4FP32 PCM, 32 kHz

Build from Source

  1. Initialize the submodules in the source checkout.
git submodule update --init --recursive --depth 1
  1. Build and install with CMake.
cmake -S src -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel 8
cmake --install build --prefix "$PWD/build/package"

The standard CMake install puts the executable in build/package/bin/. The release ZIPs instead put it at the package root.

The build requires a C/C++ compiler, CMake, Git, Ninja, Make, NASM, diffutils, Perl and Vulkan development headers. CMake builds ncnn and the static media libraries from the pinned submodules under src/. RTTI and C++ exceptions are disabled by default (NCNN_DISABLE_RTTI=ON, NCNN_DISABLE_EXCEPTION=ON).

On Windows, use MSYS2 UCRT64 with GCC, CMake, Ninja, Make, NASM, diffutils and Perl for the bundled build. On macOS, pass -DVulkan_LIBRARY=/path/to/libMoltenVK.a to link MoltenVK.

Use -DUSE_SYSTEM_NCNN=ON for an installed ncnn with Vulkan and batch support. Select system image libraries with USE_SYSTEM_JPEG, USE_SYSTEM_PNG, USE_SYSTEM_WEBP or USE_SYSTEM_ZLIB. System PNG uses system zlib. For prebuilt static codecs, set H3_MEDIA_PREFIX to the installation prefix.

Sample Videos

The examples below use this project's Vulkan pipeline, the base MiniMax H3 model, and the 50-point BF16 modulation banks. Each video runs at 24 fps and includes its generated stereo audio. Expand a command to see the full prompt, output size and seed.

Copy the videos directory to the package root to run the examples with reference inputs.

Text to video and audio

Tram Arrives in the Rain · 1280 × 736 · 192 frames · 8 s

expand for full prompt and command
h3-ncnn-vulkan \
    -s 1280,736 -f 192 -l 50 -r 42 --rough-mode 0 \
    -p "integrated_multimodal_description: [Shot 1] A cinematic night street in light rain, viewed from beside a quiet tram stop at pavement height. A cream-and-teal vintage tram enters slowly from the left, its warm windows reflected in the puddles. It rings one clear bell as it passes the foreground streetlamp and eases toward the stop. [Shot 2] At 00:04.000 the camera cuts to a close-up of the near wheel and its reflection. The wheel rolls steadily for a moment, then comes to a complete stop as the brakes hiss. Droplets continue falling into the puddle as the camera holds.
overall_soundscape: Steady light rain and a low rail rumble. One distinct bell as the tram passes the streetlamp, then a brief brake hiss timed to the wheel stopping. The rumble fades and the rain remains.
non_diegetic_music: None." -o rain-tram.webm

https://github.com/user-attachments/assets/a9362e39-453b-45b9-8243-6b884a483cb4

First and last frames to video and audio

A Little Victory · 768 × 768 · 124 frames · 5.17 s

expand for full prompt and command
h3-ncnn-vulkan \
    -t fl2va \
    -i videos/first.png -i videos/last.png \
    -s 768,768 -f 124 -l 50 -r 42 --rough-mode 0 \
    -p "integrated_multimodal_description: [Shot 1] One unbroken full-body shot of the same silver-haired, cat-eared chibi mascot between the supplied first and last frames. Keep her white-and-charcoal pixel-trim jacket, dark boots, cat-shaped hair clip, and gray tail consistent. The locked camera faces her against a clean, warm-white background throughout. She begins with both hands relaxed. She brightens, raises her right hand beside her cheek, and makes a clear V sign with two fingers while the others curl. In a bright, cheerful voice she says <d>[Chinese] 好耶!</d> once at about 00:02.500, with her mouth moving to the two syllables. She gives a small wink and holds the final pose, with a gentle tail sway. Match the supplied final frame by the end.
overall_soundscape: A quiet room, a faint sleeve rustle as her hand rises, and one clear, close voice. No other voices.
non_diegetic_music: None." -o little-victory.webm
First frame
First frame
Last frame
Last frame
➡️

https://github.com/user-attachments/assets/f9229f79-cd16-47dd-88cd-cf80d8246b92

Multimodal references to video and audio

Felt Robot Plays the Xylophone · 1280 × 736 · 158 frames · 6.58 s

expand for full prompt and command

Use the Ref2VA model files and add the temporal video encoder (h3/vae/encoder_temporal.ncnn.*).

h3-ncnn-vulkan \
    -t ref2va -i videos/robot.jpg \
    --reference-video videos/mallet-motion.webm \
    --reference-audio videos/wooden-notes.wav \
    --reference-short-edge 768 --reference-video-short-edge 416 \
    -s 1280,736 -f 158 -l 50 -r 42 --rough-mode 0 \
    -p "subject_definitions: <Picture 1> is the appearance reference for the small hand-sewn orange felt robot. <Video 1> is the motion reference for the three separate mallet strikes, moving left to right. <Audio 1> is the reference for the sound and ascending pitches of the three wooden notes.
summary: A little orange felt robot plays three notes on a miniature wooden xylophone, then looks up with a pleased smile.
retention_analysis: Preserve the orange felt head and body, dark oval eyes, cream chest panel, short felt limbs, and single round-tipped antenna from <Picture 1>. Transfer the mallet motion from <Video 1> to one of the robot's hands. Match the three pitches and short wooden decay in <Audio 1>.
detailed_description: [Shot 1] A single locked medium close-up at tabletop height. The robot and all three wooden bars are visible the whole time. Soft sunlight falls across the pale craft table. The robot holds one small felt-tipped mallet and looks down at the xylophone. It lifts the mallet, taps the left bar at about 00:01.500, lifts it again and taps the middle bar at 00:03.000, then taps the right bar at 00:04.500. Each note starts when the mallet visibly touches its bar and the mallet rebounds right away. It lowers the mallet and looks up at the camera, quietly pleased. The eyes, face and limbs retain their handmade felt textures.
overall_soundscape: Three distinct dry xylophone notes, low then middle then high. Let each short note decay fully. Faint room tone under the notes. No speech.
non_diegetic_music: None." -o felt-xylophone.webm
Picture 1 · robot appearance
Picture 1 · robot appearance
Video 1 · mallet motion
Video 1 · mallet motion
Audio 1 · wooden notes
➡️

https://github.com/user-attachments/assets/5950956e-59ef-42be-b67b-ae1ac27bd604

Original MiniMax-H3 Project

Other Open-Source Code Used

The standalone package includes third-party license notices.

License

Source code is licensed under Apache-2.0. Project license

The checkpoint and converted weights are subject to the terms for access, use and redistribution in the MiniMax H3 Community License. Model license

关于 About

ncnn implementation of MiniMax-H3 for video and stereo audio generation from text, keyframes or multimodal references
amdappleh3intellinuxmacosminimax-h3ncnnnvidiavulkanwindows

语言 Languages

C++96.8%
CMake3.0%
C0.3%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
16
Total Commits
峰值: 16次/周
Less
More

核心贡献者 Contributors