Repository navigation
Use biased u8*i8 dot products in the small-M 4-bit MatMul kernel. - #1106
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
Unpack 4-bit weights as unsigned-biased uint8_t (Q4_0 [0, 15], bias 8; MxFp4 2*E2M1+12 in [0, 24], bias 12), precompute kBias * sum(q_a_block), and subtract in int32_t inside TransposeReduce4 before float scaling (bit-exact). Since q_a is in [-127, 127], paired int16_t sums stay <= 12192 < 32767, enabling non-saturating pmaddubsw + pmaddwd (x86 SSSE3..AVX3) and 1x vpdpbusd (AVX3_DL+), with BitCast i8*i8 elsewhere. Zen 3 bench_matmul (M=1..16): 1.19x-1.28x (AVX2), 1.27x-1.70x (SSE4). PiperOrigin-RevId: 1031331410
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.
Use biased u8*i8 dot products in the small-M 4-bit MatMul kernel.
Unpack 4-bit weights as unsigned-biased uint8_t (Q4_0 [0, 15], bias 8; MxFp4
2E2M1+12 in [0, 24], bias 12), precompute kBias * sum(q_a_block), and subtract
in int32_t inside TransposeReduce4 before float scaling (bit-exact). Since q_a
is in [-127, 127], paired int16_t sums stay <= 12192 < 32767, enabling
non-saturating pmaddubsw + pmaddwd (x86 SSSE3..AVX3) and 1x vpdpbusd (AVX3_DL+),
with BitCast i8i8 elsewhere. Zen 3 bench_matmul (M=1..16): 1.19x-1.28x (AVX2),
1.27x-1.70x (SSE4).