Skip to content

MiniMax H3 on Metal: the released MiniMax-H3 weights, and re-voicing a finished clip - #960

Closed
drowzeys wants to merge 4 commits into
ashhart:mainfrom
drowzeys:upstream/h3-revoice
Closed

drowzeys wants to merge 4 commits into
ashhart:mainfrom
drowzeys:upstream/h3-revoice

Conversation

@drowzeys

Copy link
Copy Markdown
Contributor

Stacked on upstream/h3-steps (#959) (then upstream/h3-firstframe and upstream/h3-metal, #949). Review those first.

The released MiniMax-H3 transformer now runs on TensorFold's Metal runtime, and it can re-voice a finished clip. A few-step FastH3 clip gets its picture fast, but the distilled audio is its weaker half. Re-voicing keeps that picture and runs the audio again, from noise, on the released full model's weights:

  • every row but the generated audio stays at the keyframe level;
  • the audio goes down the released model's own 30-step schedule.

This change adds three things to the Zig family:

  • a loader for the released checkpoint's layout;
  • the dense attention it was trained with;
  • the held-picture schedule.

The same loader serves the Ref2VA model in the next pull request.

On the Mac Studio (M5 Ultra), re-voicing the 864x480, 124-frame fox clip from #949, 15,435 rows, 30 audio steps:

  • The end-to-end result matches the MLX reference.
    • After all 30 steps, the audio latents agree with the Python sampler's revoice at cosine 0.99946 (relative error 0.033).
    • Decoded, the two soundtracks correlate at 0.9983 sample for sample and 0.9982 by log spectrogram.
    • Loudness is 0.0412 RMS here against 0.0422.
  • Parity on real steps.
    • Step 16 of 30: audio velocity cosine 0.99993 (relative error 0.012), video 0.99965.
    • Step 1: audio 0.99979, video 0.99965.
  • Speed is on par with MLX: 15.0 s a step here (median of 30) against 14.3 s for MLX's bf16 forward with its dense fused attention, on the same Mac. Attention is 6.2 s of the 15 s; a dense-attention kernel is the next speed lever.
  • No new kernels.
    • h3_heads gains a row stride, so it reads each head's fused [q, k, v] rows in place.
    • h3_swiglu gains a gate-first flag.
    • Both forms are in the kernel contract.
    • Lean check: 0 added.

What it adds

  • The released layout in h3.zig and block.zig:
    • model-* shard names;
    • blocks.N.*;
    • one product for every head's fused [q, k, v];
    • the SwiGLU stored [gate; value];
    • no routing gates, so attention is dense: every 64-row tile attends every tile, with the same bf16 attention kernel;
    • the embedder and AdaLN names in modulation.zig.
  • schedule.zig:
    • the released model's grid: torch's float32 linspace(1, 0, N + 1), shifted in float32, repeats dropped;
    • a plan that holds every row but the generated audio at 0.999.
    • Host tests compare against the Python schedule for 9 and 31 points.
  • The tool:
    • revoice=N: the video rows never move;
    • once: run only the first step, for parity.
    • It finds the released checkpoint by its tensor names.
  • The case exporter for a re-voice run is h3_revoice_case.py on the fork's exporter branch (h3-case-tools). It needs the Python 0.6 family on the fork and is not part of this change.
  • The 2x decoder and the audio level handling are decoder and post-processing work in the fork's Python tools, and stay there. The Zig family is the transformer.

Receipts

Same Mac, macOS 27.0.1, Zig 0.17.0.

Check Video velocity Audio velocity
Step 1, the case's tables cosine 0.99965, rel. error 0.026 cosine 0.99979, rel. error 0.021
Step 1, tables made here (revoice=30) cosine 0.99945, rel. error 0.033 cosine 0.99972, rel. error 0.024
Step 16, the case's tables cosine 0.99965, rel. error 0.027 cosine 0.99993, rel. error 0.012
Step 16, tables made here cosine 0.99945, rel. error 0.033 cosine 0.99990, rel. error 0.015
Step 16, the two native runs against each other cosine 0.99951, rel. error 0.031 cosine 0.99996, rel. error 0.010
End to end, 30 steps Result
Final audio latents against the reference's cosine 0.99946, rel. error 0.033
Decoded audio: waveform correlation, log spectrogram correlation 0.9983, 0.9982
Decoded audio RMS: native, reference 0.0412, 0.0422
A step: native median, reference 15.0 s, 14.3 s

The tables made here use a float64 time embedder. The reference's comes from MLX's GPU float32 matmul, which on the M5 is less exact (see #949's stack, upstream/h3-steps (#959)). At this checkpoint 61% of the table values are bit-identical, and the rest are within a bf16 step.

zig-out/bin/tf-h3-dit <MiniMax-H3>/FL2VA/transformer 13 rv-at0/case.safetensors out revoice=30
zig-out/bin/tf-h3-dit <MiniMax-H3>/FL2VA/transformer 13 rv-at15/case.safetensors out revoice=30,from=15,once

Kernel contract and host suite: they ran on the top of this stack (upstream/h3-ref2va), whose tree contains this change; see that body.

Next steps

  • A dense-attention kernel for the released model, where tiles are not routed: today it pays the routed kernel's per-tile online softmax.
  • The keys-and-values cache over the held rows (the Python sampler's default re-voice form), which lets a step run the audio rows alone.

Licenses

The code is Apache-2.0. MiniMax H3 weights are under the MiniMax H3 Community License. No weights are included.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PfjmufXm4L7qsVNFyRw9ZK

@ashhart

ashhart commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Thank you, @drowzeys, we will carry the released-weight and revoice work with your credit into the gated H3 reference/audio path; the landing order and remaining checks are in our reply on #961.

Posted by Ash's AI Assistant Synthena

@ashhart ashhart mentioned this pull request Oct 17, 2026
…de the engine

A video and audio model's denoising transformer on the M5 tensor units, in the checkpoint's precision: bf16
weights read in place, products on the prefill kernels' tfp::gemm_nax (MLX's GEMM, fp32 sums), FastH3's
tile-routed attention in bf16 with fp32 scores and an online softmax. zig build tf-h3-dit runs every denoising
forward for a case file. The lane core, the server and the other families are untouched.

Thirteen kernels are registered with the kernel contract and pass gates 1-4; their launches and the two GEMM
entry points are in registry.zig. The recipe holds the receipt.
A case exported with a first frame holds the keyframe's rows between the text and the audio. They enter like video
rows on every pass at the keyframe noise level and are never stepped. Text to video is bit-identical to before.
…aLN tables made here

The rungs, shifts and per-row timestep plan come from the checkpoint's contract (or N rungs spread from its first);
the timestep embedder runs on the host and each block's AdaLN projection on the GPU (h3_modulation, registered with
the kernel contract), so a case no longer fixes the step count.
…a finished picture

Loads the released checkpoint's layout (model-* shards, each head's fused [q, k, v] rows, [gate; value] SwiGLU rows,
dense attention without routing gates, its embedder and AdaLN names). revoice=N holds every row but the generated
audio at the keyframe level and takes the audio down the released model's grid, as the Python sampler's revoice does.
h3_heads takes a row-head stride and h3_swiglu a gate-first flag; both are covered by the kernel contract.
@drowzeys
drowzeys force-pushed the upstream/h3-revoice branch from 6b93d8d to ad04d82 Compare October 17, 2026 01:30
ashhart added a commit that referenced this pull request Oct 18, 2026
… beneath it

The H3 and FastH3 transformer on Metal as a test tool beside the release's, clips that start from an image, any step
count with its schedule and AdaLN tables, the released MiniMax-H3 weights with re-voicing of a finished clip, and
Ref2VA's reference pictures, videos and audio. Against this branch: build.zig runs the H3 schedule's host tests
beside the XPU admission tests.
@ashhart

ashhart commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thank you, @drowzeys, for H3/FastH3 on Metal. The selected work from #960 is included through #961 (013b75368) in 1.1.0, within one family and the bf16 tf-h3-dit test tool. Geometry/media checks and transactional schedule replacement accompany the integration. Full scope and numerical, resource and reference-media results are on #961: Apple M5 Ultra H3 kernels passed 15/15 with controls; full FastH3/H3 checkpoint/media-tool cells remain unrun.

Posted by Ash's AI Assistant Synthena

@ashhart

ashhart commented Oct 19, 2026

Copy link
Copy Markdown
Owner

The bf16 H3 Metal component shipped in 1.1.0 as 013b75368; thanks @drowzeys. We're closing it as landed.

Posted by Ash's AI Assistant Synthena

@ashhart ashhart closed this Oct 19, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…hart#950, ashhart#959 and ashhart#960 beneath it

The H3 and FastH3 transformer on Metal as a test tool beside the release's, clips that start from an image, any step
count with its schedule and AdaLN tables, the released MiniMax-H3 weights with re-voicing of a finished clip, and
Ref2VA's reference pictures, videos and audio. Against this branch: build.zig runs the H3 schedule's host tests
beside the XPU admission tests.
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