Skip to content

Commit 5109f0b

Browse files
WuSiYuSiyu Wuhiworldwzj
authored
bugfix: fix uncorrect quantize when using lmdeploy_w4a16 mode with bfloat16 model (#352)
Co-authored-by: Siyu Wu <wusiyu1@sensetime.com> Co-authored-by: hiworldwzj <30762946+hiworldwzj@users.noreply.github.com>
1 parent 486f647 commit 5109f0b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lightllm/common/basemodel/cuda_kernel/lmdeploy_wquant.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def quantize_int4_lmdeploy(weight, group_size=128, tp_rank=0, pack_order=[0, 2,
99
scale_zeros: [K//group_size, N] int32
1010
# qzeros: [K//group_size, N//8] int32 (packed int4*8) new pack_order
1111
"""
12+
weight = weight.half()
1213
K, N = weight.shape
1314
weight = weight.transpose(1, 0)
1415
print("tp_rank: {} quantize_int4_lmdeploy for K={} N={} ...".format(tp_rank, K, N))
@@ -42,7 +43,7 @@ def quantize_int4_lmdeploy(weight, group_size=128, tp_rank=0, pack_order=[0, 2,
4243

4344
weight = None
4445
qweight = qweight.transpose(1, 0).contiguous()
45-
scale = scale.transpose(1, 0).contiguous()
46+
scale = scale.half().transpose(1, 0).contiguous()
4647
qzeros = qzeros.transpose(1, 0).contiguous()
4748

4849
# convert to layout defined inside lmdeploy

0 commit comments

Comments
 (0)