Repository navigation
MiniMax-H3 VAE: reference padding in one allocation and encoder norm fusion (from upstream #2476) - #110
Merged
Conversation
…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)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
added a commit
to unslothai/unsloth
that referenced
this pull request
Dec 2, 2026
…GroupNorm fallback fix) (#20791) ## Summary Moves the Studio sd.cpp prebuilt pin from `master-982-0518b34-uf22ff38` to `master-982-0518b34-u0c69df2` (unslothai/stable-diffusion.cpp at `0c69df28`). The new build adds three fork changes: - unslothai/stable-diffusion.cpp#110 (from upstream #2476): the MiniMax-H3 video VAE pads the last frames into one allocation instead of one full-clip concat per padded frame. In the encoder, CausalConv3d does its reflection, downsample end padding and causal zero frames in one padding op. On CUDA / HIP, TemporalGroupNorm runs GroupNorm + affine + SiLU as one frame-norm op. CPU, Metal and Vulkan build one batched GroupNorm over all frames instead of a slice, norm and concat per frame. - unslothai/stable-diffusion.cpp#111: SYCL and OpenCL keep the per-frame GroupNorm fallback. The CPU, CUDA, Vulkan and Metal graphs are the same as in #110. - unslothai/stable-diffusion.cpp#112: CI only. The Windows CUDA 13 toolkit install no longer fails when it cleans up an extracted redist folder that is not yet empty. That failure is why the `c4b0713` build published without its three Windows CUDA 13 bundles, so this build is the one to pin. `0c69df28` is three commits ahead of `f22ff38d31`. The source changes are in `src/model/vae/minimax_h3_vae.hpp`, `src/core/ggml_extensions.*`, `src/core/ggml_extend.*` and two new CUDA files (`vae_frame_norm.cu`, `vae_pad.cu`); #112 only touches `.github/workflows/unsloth-sd-prebuilt.yml`. ggml and the fork's ggml patch list are unchanged. ## Changes - `install_sd_cpp_prebuilt.py`: `DEFAULT_TAG` and `PINNED_RELEASE_ASSETS` move to the new tag, with all 22 assets and their sha256. The digests come from the release's `sd-prebuilt-sha256.json`. The two JSON files were hashed after download. All 22 match the digests the GitHub releases API reports. - `sd_cpp_args.py`: the new tag joins `METAL_IMPLICIT_GEMM_CONV_TAGS` and `VULKAN_PAGEABLE_OFFLOAD_TAGS`. `0c69df28` descends from `f22ff38d31`, so it still carries #103 (implicit GEMM Metal CONV_2D) and #106 (Vulkan offload in pageable RAM). - Tests that name the pin move with it: `test_diffusion_more_families.py`, `test_sd_cpp_args.py` (new row; `uf22ff38` stays as the previous pin), `test_sd_cpp_cuda_cpu_torch.py`, `test_sd_cpp_vulkan_cpu_torch.py`, `test_sd_cpp_metal_vae_conv_default.py`, `test_sd_cpp_metal_vae_conv_direct.py`, `test_sd_cpp_metal_vae_conv_status_argv.py` and `test_h3_native_pageable_offload.py`. The last one now also checks that `u9213d05` and `ub6ed0ee` stay pageable. ## Tests Release check: the release is published (not a draft, not a prerelease) with the same 22 asset names as `uf22ff38`. Apart from the tag, source commit, timestamp and hashes, `sd-prebuilt-manifest.json` is the same as the old one, including the asset and CUDA coverage rows. Linux x86_64 CPU, `uf22ff38` vs `uc4b0713` (the build of #110 + #111; `u0c69df2` adds only the CI change of #112), using the release zips: FLUX.2 klein 4B Q4_K_M (4 steps) and Z-Image-Turbo Q4_K_M (8 steps), 256x256, seed 42, `--rng cpu`, Studio's `--flash-attn off,diffusion=on,te=auto`, 8 threads, A B B A, each render in a fresh process. For each model all four PNGs are byte-identical. Each log reports its own tag and commit. MiniMax-H3 on CUDA, from the fork PR #110 run on an L4 (sm_89): Ref2VA at 864x480, 124-frame reference video, 8 steps, plain decode, unsloth/MiniMax-H3-GGUF ref2va Q4_K. | build | request (s) | decode (s) | output md5 | | --- | --- | --- | --- | | before #110 | 848.3 | 48.5 | 2da16326 | | #110 | 790.3, 794.0 | 48.5, 51.5 | 2da16326 | The request is 6.5% faster and the output video is byte-identical. The fork PR also reports the padding step at 124 -> 136 frames, 864x480, going from 4.78 s to 0.36 s with peak memory 1885 -> 1242 MiB, and CPU VAE encode latents byte-identical before and after. Unit tests: the sd.cpp, installer and H3 suites (136 files) give 4639 passed on this branch and 4638 on main. The extra case is the new previous-pin row. The same 57 failed and 64 errored test IDs show up on both sides; they are mostly in the H3 image suites, fail the same way on main, and do not touch the pin. `test_sd_cpp_pinned_prebuilt.py` and `test_sd_cpp_install_ratelimit.py` pass on this branch. With the pin on the incomplete `uc4b0713` release (19 assets), `test_sd_cpp_pinned_prebuilt.py` fails 9 tests (the Windows CUDA 13 routing cases and `test_the_shipped_asset_list_carries_every_cuda_family_bundle`), so the suite catches a release that is missing bundles. ## Not covered - The CPU renders used the `uc4b0713` zips, not `u0c69df2`. The only change between them is the CI workflow. - The L4 numbers come from the fork PR's build, not from this release's CUDA bundle. No new GPU render was made for this pin. - No Metal, Vulkan, ROCm or Windows render was run for this pin. Metal and Vulkan take the batched GroupNorm path. In the fork PR, Linux RADV only measured the padding step (2.3 s to 0.6 s), because every render at that size, master included, hit `ErrorDeviceLost` in DiT sampling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports two pieces of leejet/stable-diffusion.cpp leejet#2476 (MIT) to the fork's MiniMax-H3 video VAE.
Changes
vae_frame_norm_hip.cubuilt 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
The encoder fusion cuts the request by 6.5% and the output video is byte-identical to master.
Not covered
ErrorDeviceLostin DiT sampling at this size, so Vulkan request time and quality were not measured end to end.