-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add QKV fusion to the Hunyuan Video transformer #10407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience, QKV fusion does not really help much with eiter time or memory requirements, even with quantization. In fact, there is even slow downs at times depending on the quantization technique applied.
Not sure if it would be beneficial adding but since we do support it for some other things, it makes sense to do so in the interest of consistency. Will ask @yiyixuxu to make the final call
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
@Ednaordinary thanks for the PR! |
that's fair enough! I'll revisit to see if it shows an improvement when/if bnb or torchao gain concatenation support (or another quant system with support for those is added) |
(reopening/making a new pr if something changes) |
What does this PR do?
This adds QKV fusion to Hunyuan Video. At the moment, this gives minimal/no improvement:
The biggest improvement is expected in combination with torchao, though that currently errors out due to torchao tensors not having the ability to be concatenated:
BitsAndBytes also errors out (relevant but somewhat dated discussion):
There's a slight hack in HunyuanVideoIndividualTokenRefinerBlock, since attention with qkv fusion seems to become
tuple(tensor, None)
instead of just a tensorReproducible script
Comparison
QKV fusion:
output_qkv.mp4
No fusion:
output.mp4
Results are different but comparable.
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@a-r-r-o-w @DN6