Conversation
nifleisch
reviewed
Apr 29, 2025
2850640 to
aa361d1
Compare
sharpenb
reviewed
May 12, 2025
sharpenb
reviewed
May 12, 2025
sharpenb
reviewed
May 12, 2025
sharpenb
reviewed
May 12, 2025
sharpenb
requested changes
May 12, 2025
Member
sharpenb
left a comment
There was a problem hiding this comment.
Thanks for the PR! I left some comments :)
nifleisch
requested changes
May 13, 2025
Collaborator
nifleisch
left a comment
There was a problem hiding this comment.
Still awesome PR! I only have one small remark about the ModelContext.
nifleisch
approved these changes
May 14, 2025
9e5f43b to
fc95279
Compare
sharpenb
requested changes
May 14, 2025
Member
sharpenb
left a comment
There was a problem hiding this comment.
Looks very good. It can be merged after renaming and fixing the safe_memory_cleanup :)
Member
sharpenb
reviewed
May 16, 2025
Member
sharpenb
left a comment
There was a problem hiding this comment.
I only had a last comment :)
cbffcc4 to
0c7d7a7
Compare
… removed from cuda device after smashing
0c7d7a7 to
6f5a331
Compare
sharpenb
approved these changes
May 16, 2025
Member
sharpenb
left a comment
There was a problem hiding this comment.
Super cool, let's merge it :)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR introduces a new family of algorithm:$n$ matrices together (eg $W_{large}=[W_{small}, \dots, W_{small}]$ ) and perform a single $W_{large} \cdot x$ product instead of $n$ smaller $W _{small} \cdot x$ products.
FUSERFACTORIZER !The general idea behind matrix fusing is to concatenate
There is no memory gains. And, in general, there is no latency gains.
However, when combined with quantization, matrix fusing can enable speedups (see huggingface/diffusers#9185)
The main changes in the code are:
FUSERFACTORIZERin the newfusingfactorizingfolder;fuserfactorizer for qkv matrices fordiffusersmodels;diffuserspackage that are compatible with fusing (ie have some FusedAttention processors);Related Issue
Fixes #(issue number)
Type of Change
How Has This Been Tested?
I have added a unit test for the new qkv fuser on sdv1.4.
Checklist
Additional Notes