You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(vae): batch spatial padding in Hunyuan causal convolutions - #2374
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.
If this PR adds or changes model support, I have added or updated its usage guide and relevant model index/README entries following the model documentation requirements.
Summary by CodeRabbit
Bug Fixes
Improved handling of spatial padding during video processing.
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.
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)
Create a new PR
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.
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.
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
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.
Summary
Fold frames and channels into one dimension (
[W, H, T * C]) viaggml_ext_contandggml_reshape_3dduring spatialreplicate_padin Hunyuan's sharedCausalConv3d, then restore the 4D shape before convolution. This avoids per-channel CUDACONCATkernel 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. StandaloneCausalConv3dchecks (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.512x288, 5 frames, FP16)Full video generation and Metal were not tested.
Checklist
Summary by CodeRabbit