Repository navigation
MiniMax-H3 VAE: fold frames into one GroupNorm only on backends that normalise every dim-3 slice - #111
Conversation
…rm covers one dim-3 slice The batched encoder fallback from #110 folds frames x batch into ggml dim 3 and issues one GROUP_NORM. The pinned ggml SYCL and OpenCL GroupNorm kernels launch num_groups work groups over ne0*ne1*ne2 elements, so every frame after the first is left unwritten (the OpenCL GroupNorm+mul+add fusion also takes its group size from the whole tensor). Fold only on backends whose GroupNorm handles every dim-3 slice (CPU, CUDA, ROCm, MUSA, Metal, Vulkan); elsewhere issue one GROUP_NORM per frame and batch item. The CPU / CUDA / ROCm / Metal / Vulkan graphs are unchanged.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65daec54ce
ℹ️ 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".
| // MiniMax-H3 VAE encoder TemporalGroupNorm: every frame must be its own GroupNorm item on every backend. | ||
| // | ||
| // Build (after `cmake -B build-cpu -DSD_WEBP=OFF -DSD_WEBM=OFF && cmake --build build-cpu`), then run the binary: | ||
| // g++ -std=c++17 -O1 -DGGML_MAX_NAME=160 -DGGML_USE_CPU -DSD_GGML_FUSED_ROPE_ATTN -DSD_GGML_H3_FUSED_OPS \ | ||
| // -DSD_GGML_H3_FUSED_QK_NORM -I src -I include -I ggml/include -I ggml/src -I thirdparty \ | ||
| // scripts/minimax_h3_frame_group_norm_test.cpp build-cpu/libstable-diffusion.a build-cpu/ggml/src/libggml.a \ | ||
| // build-cpu/ggml/src/libggml-cpu.a build-cpu/ggml/src/libggml-base.a -fopenmp -lpthread -ldl \ |
There was a problem hiding this comment.
Keep the regression test local rather than committing it
The newly committed regression test violates CONTRIBUTING.md:21, which explicitly prohibits including test code or test scripts in commits and requires keeping them local while reporting verification results in the PR description. Remove this file from the committed change and retain the verification evidence in the change description instead. Root AGENTS.md explicitly requires following these contribution expectations.
AGENTS.md reference: AGENTS.md:L122-L124
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 43ebb25: the test stays local per CONTRIBUTING; results are in the PR description.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
Summary
Follow-up to #110. The MiniMax-H3 VAE encoder fallback (used wherever the fused CUDA / HIP frame norm is not available) folds
frames x batchinto ggml dim 3 and normalises the whole clip with oneGROUP_NORM. That is only correct on backends whose GroupNorm normalises every dim-3 slice on its own. On the pinned ggml (leejet/ggml d803c238 plus the 55 fork patches) two buildable backends do not:[W, H, C, N]ne03num_groups * ne[3]blocks (stock andgroup-norm-par)num_groups * ne[3]workgroups(ngrp, ne03)threadgroups (since leejet/ggml a70d9e12)-DSD_SYCL=ON)num_groupsworkgroups overne0*ne1*ne2elements-DSD_OPENCL=ON)n_groupsworkgroups overne0*ne1*ne2; the GroupNorm+mul+add fusion usesnelements / groupsas its group sizeReference video is encoded in 17-frame chunks, so any Ref2VA request on a SYCL or OpenCL build hit this.
Change
ggml_ext_group_norm_batches_dim3(backend): true only for the backends verified above (CPU,CUDA,ROCm,MUSA,MTL,Vulkan, by ggml registry name).TemporalGroupNorm::forwardkeeps the MiniMax-H3 VAE: reference padding in one allocation and encoder norm fusion (from upstream #2476) #110 folded graph on those backends and otherwise issues oneGROUP_NORMper frame and per batch item (the pre-MiniMax-H3 VAE: reference padding in one allocation and encoder norm fusion (from upstream #2476) #110 per-frame graph, with batch items split as well so a batch above one is also correct there).The CPU / CUDA / ROCm / Metal / Vulkan graphs are unchanged, and the fused CUDA / HIP frame norm path is untouched.
Testing
A local test (kept out of the PR per CONTRIBUTING) builds the real
TemporalGroupNormgraph against backends named like each ggml registry, checks theGROUP_NORMnode shapes, replays the SYCL / OpenCL single-slice launch on the host, and runs the graph on CPU against an FP64 per-frame oracle. Shapes: 5 frames batch 1, 3 frames batch 2, 1 frame batch 1.GROUP_NORMwithne3 = frames * batch; the replayed single-slice launch leaves 12288 of 15360 elements unwrittenCPU output is byte-identical (FNV-1a of the output bytes) between the pre-#110 parent, master and this branch on every shape, and the per-item graph matches the FP64 oracle to 4.8e-7. CPU and Vulkan builds compile.
Not covered here: no Intel SYCL or OpenCL device was available, so the defect is shown from the kernel launch bounds and the host replay rather than on hardware. A system ggml (
SD_USE_SYSTEM_GGML) older than leejet/ggml a70d9e12 would still mis-handle the folded clip on Metal.Note on #110 timing
The 6.5% L4 request-time figure in #110 came from one base request against two head requests, so it has no base A/A spread behind it. The isolated padding and norm kernel gains were measured separately; the end-to-end number should be read as indicative until a base A/A plus interleaved A/B run is recorded.