Skip to content

MiniMax H3 / FastH3 transformer on Metal in int8, as a test tool beside the engine (non-lane; proposal, companion to #585) - #586

Closed
drowzeys wants to merge 1 commit into
ashhart:mainfrom
drowzeys:h3-metal-family
Closed

drowzeys wants to merge 1 commit into
ashhart:mainfrom
drowzeys:h3-metal-family

Conversation

@drowzeys

Copy link
Copy Markdown
Contributor

Thank you, Ash, for TensorFold and for the Metal runtime this builds on. This is the Mac half of the work whose CUDA half is #585, kept apart so each pull request is one change. The same plain statement applies here.

Where it sits outside the rules

  • It is the kind of family you declined in h3: MiniMax H3 video and audio generation on MLX (draft proposal, non-lane family) #384. H3 denoises; there is no lane round and no drafted token to verify. Its projections and attention run in int8, which trades precision.
  • No issue came first. If you would rather settle the gate in an issue, close this and I will open one.
  • What changed since h3: MiniMax H3 video and audio generation on MLX (draft proposal, non-lane family) #384: it is Zig over the Metal runtime with no Python or MLX in the forward, and it touches nothing in the lane core or the server.
  • It cannot be exercised from this repository alone. The tool reads a case file (the prompt's rows, the schedule, the tile map), and the exporter that writes one uses the Python 0.6 H3 family, which lives on the fork. The recipe lists the file's tensors. I left the exporter out because it depends on code you have frozen; say if you want it in.

If the answer is still no, that is a fine answer; it will keep living on the fork.

What it is

zig build tf-h3-dit -Dcpu=apple_m1 -Doptimize=ReleaseFast builds a tool that runs every denoising forward of MiniMax H3 / FastH3 for the packed [text | keyframe | audio | video] rows on the M5's tensor units.

  • zig/kernels/metal/h3/h3_products.metal: rows to int8 and the int8 projection forms (plain, group-scaled, SwiGLU).
  • zig/kernels/metal/h3/h3_rows.metal: modulated RMSNorm to int8, head layout with rotary, pooling, tile scores, top-k, the pooled branch, gate mix, the final norm and heads.
  • zig/kernels/metal/h3/h3_attention.metal: tile-routed int8 attention with an online softmax, with half or 8-bit weights.
  • zig/src/families/h3/h3.zig (the forward) and tensors.zig (safetensors mapped for Metal, the checkpoint's shards by name).
  • zig/tests/h3_dit.zig and the tf-h3-dit step in build.zig.
  • docs/recipes/minimax-h3-metal.md: the receipt and the case file's layout.

Receipt

Mac Studio (Apple M5 Ultra, 256 GB, macOS 27.0.1, Zig 0.17.0), checkpoint FastVideo/FastVideo-FastH3-8-Step-V2, 864x480, 124 frames, 8 steps, measured 2026-10-10.

Case Rows A forward First forward against the Python float reference
Text to video about 15,400 5.33 s video cosine 0.9606, relative error 0.280; audio cosine 0.9981, relative error 0.062
From a first frame 16,501 6.15 to 6.44 s not recorded for this case

The video figure is far from the reference, and I do not want that to pass unnoticed: it includes int8 rounding of weights, activations and attention against a float reference with FastVideo's reference routing. Clips made with it have been judged by eye and ear, not by a metric.

This code was split out of the engine on the fork (branch h3-1.0.4) to stand without the Qwen-Image family it used to borrow kernels from. On both cases the final video and audio rows are bit-identical to that engine's.

Checks run on this branch

Check Result
zig fmt --check on the changed Zig files clean
python3 tools/zig/lean_check.py 510 problems on main (4ebf52a), 510 with this change: zero added
zig build tf-h3-dit on an M5 Ultra builds and runs both cases above
zig build test -Dcpu=apple_m1 on that Mac 63 of 129 steps succeed and 583 of 585 tests pass, with 39 steps failing on xcrun: unable to find utility "metal". A clean main (4ebf52a) gives the identical summary on the same machine, so those failures are the machine's toolchain, not this change. I have not run it on a machine where the suite is green.

The Mac build and runs above were done on the commit before the recipe file was added; the code is the same.

Not done, and not claimed

  • No FP64 reference per projection class.
  • One machine (M5 Ultra). Chips without tensor units are refused at load.
  • No exporter in the tree, as said above.

It is used today by keys-TensorFold Studio on Apple silicon.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CPyz4HarJ7ZubrPWPjtSdX

…de the engine

A video model's denoising transformer on the M5 tensor units: no lane round, and int8 projections and tile-routed
int8 attention. zig build tf-h3-dit runs every denoising forward for a case file; the lane core and the server are
untouched. The recipe holds the receipt: 5.33 s a forward at 864x480 on an M5 Ultra, first-forward video cosine
0.9606 against the Python float reference.
@ashhart

ashhart commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Thank you for the Mac half too. The same answer as #585 applies here, so I'll close this one as well. One note from your receipt: the 39 failing steps were xcrun not finding the metal tool, which comes with Xcode's Metal toolchain; with it installed, those steps build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants