Skip to content

MiniMax-H3 VAE: reference padding in one allocation and encoder norm fusion (from upstream #2476) - #110

Merged
danielhanchen merged 3 commits into
masterfrom
r17-h3-vae-2476
Dec 2, 2026
Merged

danielhanchen merged 3 commits into
masterfrom
r17-h3-vae-2476

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Ports two pieces of leejet/stable-diffusion.cpp leejet#2476 (MIT) to the fork's MiniMax-H3 video VAE.

Changes

  1. Last-frame padding allocates the padded clip once and copies each plane, instead of one full-clip concat per padded frame. A Ref2VA reference video always pads 12 frames (normalized length = 5 mod 17).
  2. Encoder: CausalConv3d does its spatial reflection, the downsample end padding and the causal zero frames in one padding op, and TemporalGroupNorm runs GroupNorm + affine + SiLU as one frame-norm op on CUDA / HIP (vae_frame_norm_hip.cu built with -fno-fast-math, as upstream). Backends without the ops (CPU, Metal, Vulkan) build one batched GroupNorm over all frames instead of a slice, norm and concat per frame.

The fork's decoder already has its own fused QKV / RoPE path, so the upstream decoder changes are not part of this PR. The upstream Vulkan shaders and leejet#2479 (upload / compute overlap, which needs leejet#2470's weight transfer files) are not included. ggml is untouched; all fork ggml patches still apply.

Results

  • Padding microbench, 124 -> 136 frames at 864x480, 1 thread, ABBA x2: 4.78 s -> 0.36 s, peak 1885 -> 1242 MiB, output identical.
  • CPU VAE encode of a 20-frame reference (padded to 34): latents byte-identical before and after both commits.
  • L4 (CUDA sm_89), MiniMax-H3 Ref2VA 864x480, 124-frame reference video, 8 steps, plain decode, unsloth/MiniMax-H3-GGUF ref2va Q4_K:
build request (s) decode (s) output md5
master 848.3 48.5 2da16326
+ padding 846.2, 847.4 48.5, 51.5 2da16326
+ encoder fusion 790.3, 794.0 48.5, 51.5 2da16326

The encoder fusion cuts the request by 6.5% and the output video is byte-identical to master.

  • Linux RADV (gfx1151, Vulkan): the padding before the VAE goes from 2.3 s to 0.6 s.

Not covered

  • Metal and ROCm were not run. Metal and Vulkan take the batched GroupNorm fallback.
  • Windows Vulkan (AMD) result is still pending.
  • On Linux RADV every render, master included, hits ErrorDeviceLost in DiT sampling at this size, so Vulkan request time and quality were not measured end to end.

…of one full-clip concat per padded frame (from upstream leejet#2476)
…+ affine + SiLU on CUDA / HIP, one batched GroupNorm elsewhere (from upstream leejet#2476)
@danielhanchen danielhanchen self-assigned this Dec 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T04:14:42.395494Z 239d142 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 239d1425c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 367b615 into master Dec 2, 2026
7 checks passed
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.

1 participant