-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Metal: PP speedup #3084
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
Metal: PP speedup #3084
Conversation
Although, to me it looks like one should simply fuse scale + diagnonal infinity + soft_max on the KQtensor.
It does work for PP, but somehow it fails for TG. Need to look more into it.
This time more carefully
M2 Ultra results:
Updated the table after rebasing to |
I think this is because I did not rebase on latest master before opening the PR. In the meantime you merged #2995 into master, which brings significant improvement in TG for |
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.
Yup, I've updated the table after rebasing - all good now
Let me take a more detailed look and will merge this later today
Speedup is achieved via
soft_max
,diag_mask_inf
,scale
,silu
,gelu
f16 x f32
matrix multiplications that can not be done via the usual matrix multiplication kernel because the tensors are not contiguous. This mostly affects theK x Q
matrix multiplication, the importance of which grows with increasing context / batch size.Q5_K
andQ6_K
.The table gives results on a 30-core M2 Max. TG performance is mostly unaffected, but there are some very minor gains here and there. For PP the lion share of the speedup comes from the new
f16 x f32
matrix multiplication kernel, which somehow does not benefit as much the Falcon model, so this is something left to look Into.