GeezerVison is showing github.com — perf(vae): batch spatial padding in Hunyuan causal convolutions by losewayy · Pull Request #2374 · leejet/stable-diffusion.cpp
Conversation
losewayy
commented
Nov 17, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Fold frames and channels into one dimension ([W, H, T * C]) via ggml_ext_cont and ggml_reshape_3d during spatial replicate_pad in Hunyuan's shared CausalConv3d, then restore the 4D shape before convolution. This avoids per-channel CUDA CONCAT kernel launches while keeping temporal padding and carry unchanged.
Related Issue / Discussion
N/A
Additional Information
Tested on RTX 5070 Ti Laptop (sm_120, CUDA 13.4, Vulkan 1.4, Windows Release) against 532d2c1. Standalone CausalConv3d checks (10 edge cases including non-contiguous views and temporal carry, plus 4 larger spatial shapes) are byte-identical on CPU, CUDA, and Vulkan separately. FP16 HunyuanVideo 1.5 VAE runs (512x288, 5 frames; 1 warmup + mean of 2 runs) produce byte-identical latents and decoded pixels on both CUDA and Vulkan.
backend / stage (512x288, 5 frames, FP16) |
baseline |
batched |
diff |
| CUDA encode |
2.835 s |
1.925 s |
-32.1% |
| CUDA decode |
5.499 s |
3.172 s |
-42.3% |
| CUDA combined |
8.334 s |
5.098 s |
-38.8% |
| Vulkan encode |
27.002 s |
26.907 s |
-0.4% |
| Vulkan decode |
43.110 s |
42.993 s |
-0.3% |
| Vulkan combined |
70.112 s |
69.900 s |
-0.3% |
Full video generation and Metal were not tested.
Checklist
Summary by CodeRabbit
- Bug Fixes
- Improved handling of spatial padding during video processing.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 17, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
CausalConv3d::forward now makes its input contiguous and combines frame and channel dimensions before spatial replicate padding. It restores the tensor shape after padding. Temporal padding and convolution behavior remain unchanged.
Changes: Hunyuan VAE spatial padding
| Layer / File(s) |
Summary |
Prepare the tensor for spatial padding src/model/vae/hunyuan_vae.hpp |
CausalConv3d::forward combines the frame and channel dimensions before spatial replicate padding, then restores the four-dimensional shape. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Possibly related PRs
Suggested reviewers: leejet
Merge Risk: Minimal · up to 021d3
-
This change batches spatial padding in the Hunyuan VAE convolutions to speed up CUDA encode and decode. No concrete defect was found, and the author reports identical outputs on the platforms tested. Merge risk is minimal, though Metal was not tested.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: batching spatial padding in the Hunyuan causal convolutions for performance. The raw summary confirms that CausalConv3d::forward now folds frames and channels into one… |
| Description check |
 |
The description follows the template. It has a Summary that explains the change and why it was made. It has a Related Issue / Discussion section marked N/A. It has an Additional Information section wi… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the main change: batching spatial padding in the Hunyuan causal convolutions for performance. The raw summary confirms that CausalConv3d::forward now folds frames and channels into one dimension for spatial replicate padding, then restores the 4D shape. The title follows the conventional commit format and is specific enough for a scan of the history.
Full details: Description check
-
Explanation
The description follows the template. It has a Summary that explains the change and why it was made. It has a Related Issue / Discussion section marked N/A. It has an Additional Information section with detailed test hardware, backends, edge-case coverage, and a timing table. The Checklist is complete and both items are checked. The description does not include an HTML comment placeholder, and the template's comments were removed, which is expected.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
Recent review info
-
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0ae6cb56-f70c-4471-9711-bbca8670a706
Commits
-
Reviewing files that changed from the base of the PR and between 532d2c1 and 021d382.
Files selected for processing: 1
-
src/model/vae/hunyuan_vae.hpp
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Thank you for your contribution.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
filve
pushed a commit
to filve/diffusione-in-tempo-reale
that referenced
this pull request
Nov 24, 2026
…art 1)
The last step towards upstream master comes in three parts. This first
one takes the commits before the Diffusion Graph Language rewrite:
- two unused ggml compat functions removed, so the library links
against a shared libggml 1.0.0 (leejet#2363);
- asym_w4a8_int8 defaults to group size 16, as in ComfyUI (leejet#2388);
- batched spatial padding in the Hunyuan causal convolutions (leejet#2374)
and fewer CUDA launches in the H3 VAE encoder (leejet#2369);
- documentation: Windows ROCm 0xC0000135, Off Grid AI, the server's
browser notification (leejet#2356, leejet#2372, leejet#2318).
The merge is clean; no fork code changes.
Verified with a CPU build: the library, sd-cli and sd-server build, and
all nine unit-test programs pass.
Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|