-
Notifications
You must be signed in to change notification settings - Fork 3k
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
(WIP) bitnet and t-mac #23540
base: main
Are you sure you want to change the base?
(WIP) bitnet and t-mac #23540
Conversation
Signed-off-by: Liqun Fu <[email protected]>
Can you add description/context ? |
Signed-off-by: Liqun Fu <[email protected]>
@@ -402,7 +402,8 @@ | |||
struct BlockwiseQuantizer { | |||
// To support other qbits, need to add bit packing code for | |||
// storing to dst and zero points | |||
static_assert(qbits == 4, "Only 4b block quantization is supported!"); | |||
static_assert(qbits == 4 || qbits == 2, "Only 4b block quantization is supported!"); | |||
//static_assert(qbits != 2 || Columnwise, "Only support Columnwise in qbits == 2 case."); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Signed-off-by: Liqun Fu <[email protected]>
switch (ComputeType) { | ||
case SQNBIT_CompInt8: { | ||
// workspace buffer is used for block quantization of A to int8 | ||
const size_t BlockCountK = MlasDivRoundup(K, BlkLen); | ||
// QuantData + Scale | ||
const size_t PerGemmWorkspaceSize = M * BlockCountK * Q8BlkSize(BlkLen); | ||
return PerGemmWorkspaceSize; | ||
} | ||
default: { | ||
return 0; | ||
} | ||
} |
Check notice
Code scanning / CodeQL
No trivial switch statements Note
Signed-off-by: Liqun Fu <[email protected]>
Signed-off-by: Liqun Fu <[email protected]>
Signed-off-by: Liqun Fu <[email protected]>
} | ||
const uint8_t vi1 = weights[j * q_rows + i / 2] >> 4; | ||
const float v1 = (static_cast<float>(vi1) - zp1) * scale1; | ||
dst[j * rows + (i + 1)] = static_cast<ElementT>(v1); | ||
} | ||
} |
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.
maybe separate the template specializations for qnbits so the code would be cleaner?
|
||
template <typename Tin, bool signed_quant> | ||
struct BlockwiseQDQQuantizer<Tin, 4, signed_quant> { | ||
struct BlockwiseQDQQuantizer { |
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.
would it be better to separate the specializations for different qbits?
} | ||
|
||
size_t | ||
SQ2BitGemmKernel_CompInt8_avx2( |
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.
@@ -113,6 +120,7 @@ struct MLAS_QNBIT_GEMM_DISPATCH { | |||
|
|||
Q4BitGemmPackQuantBData_Fn* SQ4BitGemmPackQuantBData = nullptr; | |||
Q4BitGemmPackQuantBData_Fn* HQ4BitGemmPackQuantBData = nullptr; | |||
Q4BitGemmPackQuantBData_Fn* SQ2BitGemmPackQuantBData = nullptr; |
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.
Preparation for 2bit T-MAC and ternary bit BitNet implementation.