Faster AVX2 matrix multiplications for lgacy quants #405
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.
It seems some people still use the
ggmllegacy qunatsQ4_0, Q4_1, Q5_0andQ5_1, so here is a PR that improves matrix multiplication performance for these quants on AVX2. The gains forQ4_1, Q5_0andQ5_1, which do not have tiniBLAS implementation are very significant, but evenQ4_0is faster than tinyBLAS (see table below).I have gone for a templated implementation. This costs 2-3% in performance but reduces the code by at least a factor of 2.
The implementation requires at least a C++14 compiler because I have used
autofor the return type of two functions. Is this a problem?Prompt processing speed for a 512-token prompt (PP-512) for a 7B LLaMA model
The PR can also help with token generation (TG) speed. On my system TG is fully memory bound for more than 4-8 threads (depending on quantization type). So, to have a better illustration of the performance differences, here are the TG-128 results with just 2 threads on a Ryzen-7950X for a 7B LLaMA model: