-
Notifications
You must be signed in to change notification settings - Fork 14.1k
ggml-blas: refactor BLAS backend #18027
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
Draft
taronaeo
wants to merge
15
commits into
ggml-org:master
Choose a base branch
from
taronaeo:feat/blas_mmid
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+1,117
−223
Conversation
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
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
only for mul_mat and mul_mat_id ops Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Signed-off-by: Aaron Teo <[email protected]>
Collaborator
Author
|
Made the PR ready for review by accident - pressed the wrong button. |
Signed-off-by: Aaron Teo <[email protected]>
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.
I saw this comment and felt a bit sad since we use the BLAS backend a lot: #14909 (comment)
Currently, the BLAS backend dequantizes the weight tensors on the fly, which runs on every matrix multiplication operation. This is not ideal, and more performance gains can be attained by pre-dequantizing the weight tensors and running the matrix multiplication calculation on the dequantized buffers.
We currently see a 53.56% performance improvement for Prompt Processing, and 107.79% for Token Generation.
Next up in the roadmap will be to probably introduce the following:
But this PR focuses more on improving the performance first.
Changes
test-backend-ops.cppnow sets weight tensors toGGML_BACKEND_BUFFER_USAGE_WEIGHTSinstead ofGGML_BACKEND_BUFFER_USAGE_ANYwhich is used to detect when to dequantize a tensor.Performance Benchmark
$ build/bin/llama-bench -m ~/Library/Caches/llama.cpp/LiquidAI_LFM2-8B-A1B-GGUF_LFM2-8B-A1B-Q4_K_M.gguf -r 1 -t 8This PR
build: 717531b (7364)
Upstream
build: 254098a (7399)
AI Declaration: AI has been used to modify the
test-backend-ops.cppcode to set weight tensors usage toGGML_BACKEND_BUFFER_USAGE_WEIGHTSbecause I couldn't figure it out without it crashing. Modifications to the BLAS backend were written by a human.