Skip to content

Conversation

@rkfg
Copy link

@rkfg rkfg commented Apr 18, 2025

One of the powerful features of Hunyuan Video is its ability to create nice videos at very low resolution. For example, Wan really struggles with it and mostly makes garbage at low res. So we should exploit it and allow user to choose a lower resolution to speed up inference tremendously.

For example, I went from 4.3s/it (640p) to 1.7s/it (320p) to 1.08 s/it (240p) on my 3090 Ti with TeaCache enabled. That's x2.5-x4 speed increase compared to the original 640p! I just added more buckets (320p and 240p) and a selector. The default is still 640p. Also the chosen bucket is printed to the console now.

@morganavr
Copy link

Why did not you add these "mirrored" resolutions for 240p bucket? You added mirrored res (where width and height are inversed) for 320p bucket.

Missing resolutions:

(336, 224),
(304, 256),
(272, 288),
(240, 320),
(208, 352),
(176, 384),

@rkfg
Copy link
Author

rkfg commented Apr 18, 2025

They're not exactly mirrored. I used 32px steps (from the middle resolution, up and down) and these just didn't match. I tried some other sizes and there was an error like RuntimeError: The size of tensor a (2658) must match the size of tensor b (2628) at non-singleton dimension 1. I'm not sure what exactly causes it but most probably an invalid size.

@brandon929
Copy link

I added similar support on a fork I created to support MPS: https://github.com/brandon929/FramePack/blob/9a5f8291df4550831b4f0fa8c694c44f7252d1ec/diffusers_helper/bucket_tools.py#L19C1-L35C23.

My approach was to make the 640 bucket the source of truth for aspect-ratios, and to just scale things to the desired resolution. This prevents having to build tables for all the resolutions you wish to support.

@rkfg
Copy link
Author

rkfg commented Apr 19, 2025

Yeah, this is more flexible. If you want to submit a PR with your solution I'll close mine.

@brandon929
Copy link

I merged my changes with yours, and added the following PR: #158

@rkfg rkfg closed this Apr 20, 2025
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.

3 participants