-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add matmul int4 for CUDA #17526
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
Add matmul int4 for CUDA #17526
Conversation
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
onnxruntime/python/tools/quantization/matmul_weight_compress_quantizer.py
Fixed
Show fixed
Hide fixed
690f452 to
caa83a0
Compare
| int32_t k = k_block_idx * block_size; | ||
| const BlockwiseQuantBlock<T, block_size, bits>* blob_ptr = src_blob + task_idx; | ||
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); | ||
| } else { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| int32_t k = k_block_idx * block_size; | ||
| const BlockwiseQuantBlock<T, block_size, bits>* blob_ptr = src_blob + task_idx; | ||
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); | ||
| } else { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| int32_t k = k_block_idx * block_size; | ||
| const BlockwiseQuantBlock<T, block_size, bits>* blob_ptr = src_blob + task_idx; | ||
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); | ||
| } else { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| int32_t k = k_block_idx * block_size; | ||
| const BlockwiseQuantBlock<T, block_size, bits>* blob_ptr = src_blob + task_idx; | ||
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); | ||
| } else { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| int32_t k = k_block_idx * block_size; | ||
| const BlockwiseQuantBlock<T, block_size, bits>* blob_ptr = src_blob + task_idx; | ||
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
| if (nullptr != zero_points) { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], zero_points[task_idx], k, K); | ||
| } else { | ||
| blob_ptr->dequant(dst + n * K + k, scale[task_idx], k, K); |
Check warning
Code scanning / PREfast
Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
d026123 to
caa83a0
Compare
43f73ce to
dba6759
Compare
fa73b74 to
a1977f8
Compare
3b59970 to
b73cf79
Compare
onnxruntime/python/tools/kernel_explorer/kernels/dequantize_blockwise_int4.py
Fixed
Show fixed
Hide fixed
f988561 to
64f5aaf
Compare
e8d0497 to
d4e4145
Compare
|
A clean one: #17890 |
Description
Motivation and Context