# h3.c

> A dependency-light C and Metal inference engine that runs the MiniMax H3 multimodal model natively on Apple Silicon, turning a text prompt into video and audio

- Category: Models & Inference / Local Runtimes
- Language: C
- Licence: MIT
- Repository: https://github.com/antirez/h3.c
- Canonical page: https://ai-tldr.dev/tools/h3-c/
- Updated: 2026-08-09

## In short

h3.c (the repository calls the program h3-metal) is a native inference engine for the MiniMax H3 multimodal model on Apple Silicon, written in C with Metal compute kernels. It sits in the Local Runtimes category of the Models & Inference tools and is open-source, written in C and licensed MIT.

## Overview

h3.c (the repository calls the program h3-metal) is a native inference engine for the MiniMax H3 multimodal model on Apple Silicon, written in C with Metal compute kernels. You point it at a local Hugging Face snapshot of the model weights and it generates video and audio from a text prompt on your own machine — no Python stack, no server, one `./h3` binary plus FFmpeg and FFprobe on your PATH.

The project is built as a sequence of working vertical slices: host and model metadata first, then portable Metal block parity, prompt encoding, prompt-to-video/audio, and first/last-frame conditioning. Prompt-to-video/audio, first/last-frame conditioning and ordered Ref2VA image/video/audio references all work end to end, with ongoing work on H3-specific Metal performance and memory optimisation on M3 Max and M5 Max hardware.

Its most distinctive feature is how hard it pushes on the memory/quality/speed trade-off. Flags let you run a subset of the transformer blocks (`--layers`), reuse denoiser velocities instead of computing every pass (`--reuse`), or stream weights from SSD (`--ssd-streaming`), which the README measured as dropping tracked DiT tensor storage from about 36.5 GiB to 2.0 GiB at 512-square resolution on an M5 Max, using the original BF16 checkpoint with no quantization. Without `-p` the same binary opens an interactive session that keeps prompt conditioning, the prepared DiT and the video decoder resident between generations.

## What it does

- Native C plus Metal implementation for Apple Silicon — one binary, no Python runtime
- Prompt-to-video and prompt-to-audio generation, with first-frame and last-frame conditioning anchors
- Ordered Ref2VA references: attach images that the model sees as <Picture 1>, <Picture 2> and refer to by number in the prompt
- Interactive session mode that caches prompt conditioning and decoders so re-rolling a seed skips reloading
- Explicit quality/speed controls — --steps, --reuse and --layers — plus --ssd-streaming for low-memory runs of the unquantized BF16 checkpoint
- In-terminal previews of the evolving frame via the Kitty/Ghostty and iTerm2/WezTerm/Konsole graphics protocols

## Getting started

The examples assume the Hugging Face snapshot of MiniMax H3 is in ./MiniMax-H3 and that FFmpeg and FFprobe are on your PATH.

1. Build and inspect the model

   Compile the binary, then run --info: it checks the model layout and prints the selected Metal device without mapping all the weights or generating media. ./h3 --help prints the full CLI reference.

```bash
make -j8
mkdir -p outputs
./h3 --info -d ./MiniMax-H3
```

2. Generate a first video

   The README's balanced preset generates 22 frames at 24 fps (about 0.92 seconds), running 45 of the 50 transformer blocks and extrapolating half the denoiser transitions.

```bash
./h3 --profile \
  -d ./MiniMax-H3 \
  -p "A red fox walks through fresh snow in a pine forest. Medium tracking shot, natural winter light, realistic fur, soft footsteps and wind." \
  --width 512 --height 512 \
  --frames 22 --steps 20 \
  --layers 45 --reuse 2 \
  --show \
  -o outputs/fox-fast.mp4
```

3. Run interactively

   Omitting -p starts an interactive session. Type a prompt to generate a numbered video; !status, !seed random, !seconds 2, !show, !save output.mp4 and !cache are the common commands, and !help lists them all.

```bash
./h3 -d ./MiniMax-H3 --width 512 --height 512 --steps 6
```

4. Anchor the first and last frames

   First/last-frame conditioning persists across a session; use !first clear or !last clear to remove an anchor. For a general conditioning image use !ref-image instead — the two modes cannot be mixed.

```text
h3> !first opening.png
h3> !last ending.png
h3> The camera moves slowly around the subject.
```

5. Run with a small memory footprint

   --ssd-streaming keeps two DiT blocks in memory and reads the next from SSD while the GPU works. It is an explicit memory/speed trade-off, is not the default, and cannot be combined with --use-int8-row-fc2.

```bash
./h3 --profile \
  -d ./MiniMax-H3 \
  -p "A red fox walks through fresh snow in a pine forest." \
  --width 512 --height 512 --frames 22 --steps 20 \
  --layers 50 --reuse 1 --ssd-streaming \
  -o outputs/fox-ssd.mp4
```

## When to use it

- Generate video and audio from a prompt entirely on a Mac, with the weights and the output staying on your machine
- Iterate on a shot cheaply — four-pass drafts first, then restore layers and denoising passes as the composition settles
- Fit a large multimodal checkpoint onto a machine with limited unified memory by streaming DiT blocks from SSD instead of quantizing
- Read a compact C implementation to understand how a diffusion-transformer video model is actually executed

## Version history

- 2026-08-09: antirez published h3.c, an MIT-licensed C engine that runs the MiniMax H3 multimodal model natively on Apple Silicon and generates video and audio from a prompt using Metal.
