Corrupted video (and audio) outputs
Device: M3 Ultra (256GB) OS: macOS Sequoia 15.7.1
Some combinations of cmd arguments produce corrupted outputs. Not sure which combinations, but it's certainly related to output duration (frame count)
Here's an example frame from the video:
And cmd that generated it:
% ./h3 --model ~/models/MiniMax-H3 -p "<DOES NOT SEEM TO MATTER>" -o outputs/releasenotes11.mp4 --seconds 3 --steps 20
tokenizer 1/1
text encoder 50/50
refine text 1/1
precompute AdaLN 50/50
load transformer core 50/50
denoise 20/20
audio VAE 7/7
video VAE load 36/36
FFmpeg 73/73
h3: wrote outputs/releasenotes11.mp4
same cmd with shorter output duration (--seconds 2) works well. Might be related to https://github.com/antirez/h3.c/issues/15 not sure.
ffmpeg version (if relevant):
ffmpeg version 8.1.2 Copyright (c) 2000-2026 the FFmpeg developers
built with Apple clang version 17.0.0 (clang-1700.6.4.2)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/8.1.2_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libsvtav1 --enable-libopus --enable-libx264 --enable-libmp3lame --enable-libdav1d --enable-libvmaf --enable-libvpx --enable-libx265 --enable-openssl --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 60. 26.102 / 60. 26.102
libavcodec 62. 28.102 / 62. 28.102
libavformat 62. 12.102 / 62. 12.102
libavdevice 62. 3.102 / 62. 3.102
libavfilter 11. 14.102 / 11. 14.102
libswscale 9. 5.102 / 9. 5.102
libswresample 6. 3.102 / 6. 3.102
full video:
https://github.com/user-attachments/assets/4f65377f-b79e-4c97-9856-5e5980864c8e
Seeing the same thing here -
h3 --profile -d "/Volumes/SSD_4TB_01/AI_MODELS/Minimax H3/Minimax H3 BF16" -p "<doesn't matter they all do it>" --render-width 896 --render-height 512 --width 1344 --height 768 --seconds 9 --steps 20 --layers 45 --reuse 2 -o "/Volumes/SSD_4TB_01/AI Images/Videos/tuxkitten5.mp4"
So I was having so many hit and miss runs I built an app to make it easy to create the CLI arguments and track the results.
All of these tests are on a 192GB M2 Ultra running Tahoe 26.4.1
I've had semi decent luck @ 512 x 288 and have got videos to go out to 11 seconds and be fine, and partially fall apart at 13 and totally fall apart at 14 and 15 seconds.
Good at 11 secs.
https://github.com/user-attachments/assets/c9da9ebf-cf66-49ab-933d-900246f3ba8c
H3 -d "/Volumes/SSD_4TB_01/AI_MODELS/Minimax H3/Minimax H3 BF16" -o "/Volumes/SSD_4TB_01/AI Images/Videos/TuxKittenTests10 --width 512 --height 288 --seconds 11 --steps 40 --layers 45 --reuse 2.mp4" --prompt "Scene: A baby black and white tuxedo patterned kitten sleeping on a folded plaid blanket which is on tall wicker basket on a hardwood floor in a living room. Action: the kitten wakes up, turns its head and looks at the camera and blinks, then jumps off the basket and walks to the right. Camera: medium-height lateral tracking shot, 50 mm lens, stable framing. Look: photorealistic fur, warm night time interior lighting. Audio: kitten mews softly while jumping, and begins purring as it walks." --width 512 --height 288 --frames 192 --reuse 2
Not so great at 13 - not following prompt, starting to see flashing lights, weird audio
https://github.com/user-attachments/assets/a8538e7a-fcb8-423a-ae98-38ef48f675a1
H3 -d "/Volumes/SSD_4TB_01/AI_MODELS/Minimax H3/Minimax H3 BF16" -o "/Volumes/SSD_4TB_01/AI Images/Videos/TuxKittenTests10 --width 512 --height 288 --seconds 13 --steps 40 --layers 45 --reuse 2.mp4" --prompt "Scene: A baby black and white tuxedo patterned kitten sleeping on a folded plaid blanket which is on tall wicker basket on a hardwood floor in a living room. Action: the kitten wakes up, turns its head and looks at the camera and blinks, then jumps off the basket and walks to the right. Camera: medium-height lateral tracking shot, 50 mm lens, stable framing. Look: photorealistic fur, warm night time interior lighting. Audio: kitten mews softly while jumping, and begins purring as it walks." --width 512 --height 288 --frames 192 --reuse 2
Total garbage at 15, but hasn't turned into the square mosaic ant races though.
https://github.com/user-attachments/assets/039b5d53-5f00-4242-b7fc-a8605a4679d7
H3 -d "/Volumes/SSD_4TB_01/AI_MODELS/Minimax H3/Minimax H3 BF16" -o "/Volumes/SSD_4TB_01/AI Images/Videos/TuxKittenTests10 --width 512 --height 288 --seconds 15 --steps 40 --layers 45 --reuse 2.mp4" --prompt "Scene: A baby black and white tuxedo patterned kitten sleeping on a folded plaid blanket which is on tall wicker basket on a hardwood floor in a living room. Action: the kitten wakes up, turns its head and looks at the camera and blinks, then jumps off the basket and walks to the right. Camera: medium-height lateral tracking shot, 50 mm lens, stable framing. Look: photorealistic fur, warm night time interior lighting. Audio: kitten mews softly while jumping, and begins purring as it walks." --width 512 --height 288 --frames 192 --reuse 2
Other tests:
4 seconds - 896 x 512 is ok
https://github.com/user-attachments/assets/7b62dcac-890d-4b6e-a49a-d045b6d95202
H3 -d "/Volumes/SSD_4TB_01/AI_MODELS/Minimax H3/Minimax H3 BF16" -o "/Volumes/SSD_4TB_01/AI Images/Videos/TuxKittenTests10 --width 512 --height 288 --seconds 15 --steps 40 --layers 45 --reuse 2.mp4" --prompt "Scene: A baby black and white tuxedo patterned kitten sleeping on a folded plaid blanket which is on tall wicker basket on a hardwood floor in a living room. Action: the kitten wakes up, turns its head and looks at the camera and blinks, then jumps off the basket and walks to the right. Camera: medium-height lateral tracking shot, 50 mm lens, stable framing. Look: photorealistic fur, warm night time interior lighting. Audio: kitten mews softly while jumping, and begins purring as it walks." --width 896 --height 512 --seconds 4 --reuse 2
4 seconds - 1120 x 640 is not
https://github.com/user-attachments/assets/af8e0665-0e9e-479b-9b88-973421bfe3b2
H3 -d "/Volumes/SSD_4TB_01/AI_MODELS/Minimax H3/Minimax H3 BF16" -o "/Volumes/SSD_4TB_01/AI Images/Videos/TuxKittenTests10 --width 512 --height 288 --seconds 15 --steps 40 --layers 45 --reuse 2.mp4" --prompt "Scene: A baby black and white tuxedo patterned kitten sleeping on a folded plaid blanket which is on tall wicker basket on a hardwood floor in a living room. Action: the kitten wakes up, turns its head and looks at the camera and blinks, then jumps off the basket and walks to the right. Camera: medium-height lateral tracking shot, 50 mm lens, stable framing. Look: photorealistic fur, warm night time interior lighting. Audio: kitten mews softly while jumping, and begins purring as it walks." --width 1120 --height 640 --seconds 4 --reuse 2
For comparison, here's a 1344 x 768 15 second clip done in an MLX'd LTX2 on the same machine
https://github.com/user-attachments/assets/54a7ff7e-b703-42ad-828b-65dfa2512c32
It takes way longer to render (couple hours) but "sorta" holds up at both 1344 x 768 and 1920 x 1024, it just tends to fall apart in the middle and ends.
I haven't had time to exhaustively test all the various parameters to get a better notion of what works and what doesn't (I'll be adding an iterator and batch runner to my app as I get time), in order to more exhaustively determine what the issues and limits are.
Root-caused this on a Mac Studio M2 Ultra (128 GB, macOS 26.5.2 / 25F84), where we hit the exact symptom described here: video and audio reduced to noise at large canvases/durations (1344x768, 107 frames, 20 steps -> full-frame colored static), while 512x512 with identical settings is clean.
TL;DR: it is not h3.c's math — MPSGraph's native scaledDotProductAttention silently returns garbage/unwritten output above ~15k sequence rows on M2 Ultra (likely M3 Ultra too, per the reports above). Splitting the SDPA query dimension into blocks of <=2048 rows fixes it end to end.
Isolating the kernel
We linked a standalone test against h3_gpu.o that feeds deterministic random BF16 Q/K/V ([1, seq, 56, 128], non-causal, scale 1/sqrt(128) — exactly the DiT's h3_gpu_sdpa_bf16 configuration) and compares spot rows against a float64 CPU reference:
| sequence | result on M2 Ultra |
|---|---|
| 5,000 / 8,800 / 14,200 | PASS (~1e-5 max error) |
| 15,000 | FAIL — head 55 (last head) ~100% error on every row |
| 15,500 | PASS (non-monotonic) |
| >= 16,000 | FAIL — head 55 garbage on all rows |
| >= ~17,000 (tested up to 36,000) | FAIL — head 55 everywhere plus all 56 heads garbage for rows in the second half |
No NaN/Inf, no Metal or MPSGraph error — output regions are simply wrong or never written (whole-output std collapses from 8.6e-3 at seq 5k to 3.6e-4 at 33k with same-scale inputs). Fully deterministic. This matches the pattern in this thread: fine on M5 Max (#13) and M4 Pro (#51), corruption on M2/M3 Ultra scaling with canvas x frames — 512x512x107f is ~8.9k joint tokens (safe), 1344x768x107f is ~32.9k (destroyed). It also explains why both modalities die together: audio tokens sit in the same joint attention.
Things we ruled out along the way, in case it saves anyone time: RoPE/layout (h3_frame_grid's letterboxed grid is formula-identical to the reference implementations, and 1344x768 at 22 frames — same negative-w RoPE, ~4.9k tokens — renders a clean scene), VAE tiling (512x512 already exercises multi-tile stitching), activation aliasing (H3_DISABLE_DIT_ACTIVATION_ALIAS=1 changes nothing), MPS command buffer reuse (H3_REUSE_MPS_COMMAND=0 changes nothing), int8 paths (M5-gated, inactive on M2), and the model itself (1344x768 is MiniMax-H3's native canvas).
Fix
Non-causal SDPA in h3_gpu_sdpa_graph now slices the query tensor into blocks and concatenates the results inside the same graph — mathematically exact for non-causal attention since each query row's softmax over all keys is independent:
unsigned query_block = h3_gpu_sdpa_query_block(); /* default 2048 */
if (!causal && query_block && sequence > query_block) {
for (uint32_t start = 0; start < sequence; start += query_block) {
uint32_t rows = MIN(query_block, sequence - start);
MPSGraphTensor *q_rows = [graph sliceTensor:qt dimension:2
start:start length:rows name:nil];
[parts addObject:[graph scaledDotProductAttentionWithQueryTensor:q_rows
keyTensor:kt valueTensor:vt scale:scale name:nil]];
}
attention = [graph concatTensors:parts dimension:2 name:nil];
}
Block size matters: 8,192 and 4,096 still corrupt (8,192 fixes the tail-row mode but head 55 still dies per chunk); 2,048 passes every kernel test from 5k to 73k rows (73k = a 10-second 1344x768 job). End to end on the patched engine, the same 1344x768 x 107-frame, 4-step job that previously produced static now renders a correct, detailed scene with clean audio (peak 39.6 GiB). Honest cost note: that denoise pass went from 512 s (broken output) to 3,293 s wall — some of that is work the broken kernel silently skipped, but the chunked encode is genuinely more expensive, so treat the block size as a correctness/speed dial (H3_SDPA_MAX_QUERY_ROWS, 0 restores the single-op path).
One more clue for whoever digs into the Metal side: the failure boundary depends on the dispatch context. A minimal standalone repro (~190 lines, pure MPSGraph, runWithMTLCommandQueue:) only starts failing between 27,000 and 30,000 rows on the same machine, while the engine's encodeToCommandBuffer:-on-MPSCommandBuffer path fails from ~15,000. Both are silent. We are filing the kernel bug with Apple with that repro attached; happy to send the h3.c workaround as a PR if there's interest.
in case it saves anyone time:
It certainly did as I'd just added the entire swatch of --use-slower CLI options to my batch testing app and was about to kick off a queue to iterate through them in, first singly, then in pairs. I didn't really wish to contemplate the length of an exhaustive batch of testing 3 at a time.
happy to send the h3.c workaround as a PR if there's interest.
By all means please do. There are times a 45 minute penalty is acceptable if It yields clean output.
A minimal standalone repro (~190 lines, pure MPSGraph, runWithMTLCommandQueue:) only starts failing between 27,000 and 30,000 rows on the same machine
If I'm reading that correctly we could essentially get almost double the rows without failure and the time penalty of your fix for the issue?
If so that's another approach that may prove viable for many combinations of resolutions/frame count where your fix would need to be called into play even less of the time. what's the path to replicating that on my M2 Ultra?
@uiharu-kazari - I did a similar thing but made your fix a bit more user friendly.
It defaults to 2048, but also adds a command line parameter you can pass "--spda-query-block" which takes an optional parameter. If you call it or call it with 0, it disables the fix, and if you call it with another value it sets the query block to that value.
Added the CLI parameter to the online help as well.
Could push a PR of those changes if others are interested.
I've added support for it in my front end app as well, so it can be saved to presets with optional inclusion on preset recall for testing purpose.
I ran a --width 1344 --height 768 --seconds 10.000 --steps 6 --layers 45 --reuse 1 --seed 42 --ssd-streaming - 466m run time -
h3 profile: H3 DiT Euler denoise wall=27538.551s encode= 1.050s wait=27537.380s root-gpu= 1.901s peak= 10.690GiB h3: BF16 SSD stream 194.517 GiB read in 58.258s (3.339 GiB/s), unhidden wait 0.004s
h3 profile: H3 DiT total wall=27551.624s encode= 1.921s wait=27539.042s root-gpu= 2.210s peak= 10.690GiB alloc= h3 h3 profile: video VAE decoder total wall= 253.397s encode= 31.178s wait= 217.123s root-gpu= 1.777s peak= 9.554GiB alloc= h3:
wrote /Volumes/SSD_4TB_01/AI Images/Videos/Batches/N&S Long Prompt Tests/Consolidated Fixes [s] Timing --width 1344 --height 768 --seconds 10.000 --steps 6 --layers 45 --reuse 1 --seed 42 --ssd-streaming.mp4
real 466m7.731s
user 0m18.226s
sys 1m43.077s
[GUI Note] File renamed with execution time: Consolidated Fixes [s] Timing --width 1344 --height 768 --seconds 10.000 --steps 6 --layers 45 --reuse 1 --seed 42 --ssd-streaming Time 466m7.731s.mp4
It does work, just is a huge hit to render time. I thought the 23Kish wall hit was a one time thing but you get it twice.
https://github.com/user-attachments/assets/de569fec-5756-490a-ba7d-a0911d5b320e
Follow-up with a correction to my earlier comment, plus three new results. Same machine (M2 Ultra, 128 GB, macOS 26.5.2).
Correction: the query-split costs memory, not just time
I wrote that the split "adds no measurable cost since total FLOPs are unchanged" and later that it was a time hit. Both understated it. At high step counts the split can get your process OOM-killed.
A 1344x768 / 107f / --steps 20 --layers 45 --reuse 2 run was killed by jetsam twice, ~30 and ~88 minutes in. The JetsamEvent report shows h3 holding 156 GB of pages on a 128 GB machine. Note the profiler is misleading here — it reported peak= 36.282GiB, because that figure counts DiT tensor storage only and not MPSGraph's intermediates.
Mechanism, as far as I can tell: splitting one attention op into ~17 sub-ops plus a concat multiplies the intermediates MPSGraph allocates per call, and since a whole denoise step is encoded into a single Metal command buffer (h3_gpu_submit waits only at the end), those intermediates stay resident across all 45 layers instead of being released. At --steps 4 it never accumulates enough to notice, which is why my original 4-step validation looked clean.
Reliable recipe: add --ssd-streaming. Keeping weights at ~2 GB instead of ~37 GB offsets the intermediates. That combination completed 1344x768 / 107f / 20 steps in 2 h 16 m with correct output. @LewnWorx — flagging this specifically since you're running 10-second jobs; you may be closer to this ceiling than the "just slow" framing suggested.
An untested idea for a proper fix, for anyone who wants it: re-enable periodic command-buffer splits (H3_DIT_COMMAND_BLOCKS) so intermediates are released mid-forward. I haven't tried it because that path is defaulted off due to the MPSGraph child-buffer race, so it trades a memory bug for a possible correctness bug and needs real validation.
Head-splitting does NOT work (negative result)
Before anyone spends time on it: splitting the heads dimension instead of queries seemed attractive, since each op would read only its own K/V and total bandwidth would match the unsplit call — and the corruption always hits the last head first, which made it look like the right axis. It doesn't hold. Groups of 8 heads pass at 18,432 rows but fail at 33,000; groups of 14 and 28 fail at both. The corruption tracks rows per op, not heads, so reducing query rows is the only lever that works — and the extra K/V traffic is unavoidable.
Two improvements worth having
1. Don't split when you don't need to. The kernel is correct below ~15k rows, so splitting there is pure cost. Gating on a minimum (H3_SDPA_SPLIT_MIN_ROWS, default 12288) restores the original single-op path and full speed for everything smaller — a 512x512 / 107f job goes back to ~68 s per forward pass, identical to pre-patch, while long jobs stay correct.
2. The whole model range is now reachable, correctness-wise. With the split active I verified the kernel against a float64 CPU reference at 5,000 / 12,288 / 14,200 / 15,000 / 18,432 / 27,000 / 28,600 / 33,000 / 49,000 / 73,400 / 109,000 rows — all pass. 109k is 1344x768 at the model's maximum 362 frames, so no supported resolution/duration is blocked by this bug any more. Whether a given combination is practical is now purely a memory-and-time question.
Filed with Apple: FB24605554 (macOS / Incorrect-Unexpected Behavior), with the standalone MPSGraph reproducer attached.
If you're on an M2/M3 Ultra and hitting this, referencing that number in your own Feedback report helps — duplicate reports against the same issue are how these get prioritised internally.
One correction to my earlier data while filing it, since it matters for anyone trying to work around this without the query-split: the failure boundary is not a fixed threshold — it moves between sessions. In one session the standalone repro passed at 20,000 / 24,000 / 27,000 rows and failed at 30,000; two days later, same machine and same binary, 27,000 failed on four consecutive runs. Results are stable within a session but shift across sessions, which points at something resource- or scheduling-dependent rather than a hard size limit.
Practical consequence: you cannot protect yourself by measuring a safe length once and staying under it. Below ~14,000 rows it passes consistently and above ~33,000 it fails consistently, but anything in between is not dependable. The 12,288 gate in my patch has margin against what I have observed, not a guarantee.
Data point: M3 Ultra (96 GB) — Ref2VA noise at 864×480, clean at 512×288; NOT fixed by the SDPA query split (PR #64)
Environment:
- Mac Studio, Apple M3 Ultra, 96 GB unified memory, macOS 27.0, Metal 4
- h3.c main @ 8974cc0, plus PR #64 head (39e9569) — both built with the stock Makefile
- Weights: official MiniMax-H3 snapshot (FL2VA + Ref2VA trees, via the ModelScope mirror of MiniMaxAI/MiniMax-H3, byte-identical layout)
Findings:
- FL2VA prompt-to-video at 864×480, 56 frames, 20 steps (
--steps 20 --reuse 2 --layers 45): clean output. - Same geometry plus a single
--ref-image(Ref2VA path): full-frame colored noise — reproduced at both 4 steps and 20 steps. Every phase (video VAE encoder, Qwen vision, DiT, VAE decoders) completes with no error or warning; only the pixels are garbage. - PR #64 build — with the default split (>12288 rows) AND with forced splitting via
H3_SDPA_SPLIT_MIN_ROWS=0— still noise. So this Ref2VA corruption does not appear to be the long-sequence SDPA issue, or it triggers below the split threshold on this chip. - The identical Ref2VA run at 512×288 (20 steps): renders cleanly — subject identity preserved, prompt followed.
Looks like a second size-dependent corruption in the reference/multimodal path on Ultra-class GPUs: same family as FB24605554, but distinct from the long-query SDPA case. Happy to run diagnostic builds or share sample outputs if useful.