-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[WIP]gml-hexagon: Q4_0 mm opt #17907
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
chraac
wants to merge
28
commits into
ggml-org:master
Choose a base branch
from
chraac:dev-mulmat-opt
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.
+133
−59
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
407b408
fix test failure
chraac 4ddb8a4
fix: correct scaling calculations in rope_cache_init
chraac cfca78b
wip
chraac e9a02fd
wip
chraac e324bb0
fix: optimize element copying in rope_hex_f32 using memcpy
chraac 0121291
fix: optimize loop boundaries in rope_hex_f32 for better performance
chraac 010039a
rename
chraac a6ef41f
wip
chraac 0376146
Merge branch 'master' into dev-fix-rope
chraac 8abecfa
Merge tag 'b7207' into dev-fix-rope
chraac b567413
feat: add profiling macros for performance measurement in operations
chraac 7c8f101
refactor: replace manual timing with profiling macros in matmul opera…
chraac 3a70465
Merge branch 'master' into dev-fix-rope
chraac 3b0cef4
Revert "refactor: replace manual timing with profiling macros in matm…
chraac 121e656
Revert "feat: add profiling macros for performance measurement in ope…
chraac 401fd3e
refactor: optimize vector operations in vec_dot_q4x4x2_q8x4x2_rx2 fun…
chraac cf491f2
wip
chraac 3a01d82
feat: enhance vec_dot_q4x4x2_q8x4x2_rx2 function with optimized data …
chraac 87ad8b2
Merge branch 'master' into dev-mulmat-opt
chraac 421d031
feat: add hvx_vec_load_d_and_mpy function for optimized data loading …
chraac bd43860
wip
chraac b197464
feat: add hvx_vec_load_d_and_mpy_r2x2 function for optimized vector l…
chraac 309d782
feat: optimize vec_dot functions with improved data handling and loading
chraac dbe9309
wip
chraac 00d5fb3
feat: add build information and update vector loading functions for o…
chraac b54ff18
revert rope changes
chraac f757245
Merge tag 'b7345' into dev-mulmat-opt
chraac 09c4899
fix: revert HVX_Vector back to HVX_UVector
chraac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Optimized the scale multiplication step. The previous implementation only processed 32x
f16elements (half the vector width). This change enables 64xf16multiplication to fully utilize the HVX vector capacity.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.
I'm getting garbled output for all models.
Also, ultimately we end up with the INT32 accumulator for each block (32 elements).
In order to multiply it with the FP16 scale we need to convert both (accumulator and scale) into FP32 (QF32). This means that we still need to do the same number of multiplies and use the same number of HVX registers either way.
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.
Reverted scale loading to handle unaligned scales, as alignment cannot be ensured for all tensor shapes.
Thought this resolves the garbled output issues. Tested on:
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.
Regarding the scales utilization: The original source uses 2
Q6_Wqf32_vmpy_VhfVhfinstructions for 2 rows but ignores the upper half. This PR aims to fully utilize the results of both multiplications.As for the accumulator width: For
Q4_0, an INT32 accumulator is likely excessive. Sincesrc0(4-bit) *src1(8-bit) fits in 12 bits, accumulating 32 elements only requires 17 bits total. A 32-bit accumulator is far larger than what is strictly required.