Skip to content

Commit 549dcf8

Browse files
lixcliMangodadada
authored andcommitted
[Inference] Fix weight_only_int4 bug (PaddlePaddle#9073)
1 parent 6969b80 commit 549dcf8

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

llm/utils/argument.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,6 @@ class QuantArgument:
299299
do_ptq: bool = field(default=False, metadata={"help": "Whether to use PTQ"})
300300
ptq_step: int = field(default=32, metadata={"help": "Step for PTQ"})
301301

302-
weight_quant_method: str = field(
303-
default="abs_max_channel_wise",
304-
metadata={"help": "Weight quantization method, choosen from ['abs_max_channel_wise', 'groupwise']"},
305-
)
306-
307302
# Pre-quant method Shift related parameters
308303
shift: bool = field(default=False, metadata={"help": "Whether to use Shift"})
309304
shift_all_linears: bool = field(default=False, metadata={"help": "Whether to shift all linears"})

llm/utils/quant.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
WEIGHT_OBSERVER = dict(
7171
abs_max_channel_wise=AbsMaxChannelWiseWeightObserver,
72-
group_wise=GroupWiseWeightObserver,
72+
groupwise=GroupWiseWeightObserver,
7373
)
7474

7575
CACHEKV_OBSERVER = dict(
@@ -259,12 +259,12 @@ def prepare_qconfig(args):
259259
activation = act_observer(quant_bits=a_quant_bit)
260260
weight = weight_observer(quant_bits=w_quant_bit)
261261

262-
elif quant_type in ["wint4", "w4a16", "weight_only_int8"]:
262+
elif quant_type in ["wint4", "w4a16", "weight_only_int4"]:
263263
activation = None
264-
weight = GroupWiseWeightObserver(quant_bits=4, group_size=args.group_size) # TODO
264+
weight = weight_observer(quant_bits=4)
265+
265266
elif quant_type in ["wint8", "w8a16", "weight_only_int8"]:
266267
activation = None
267-
268268
if "w" in args.use_fp8:
269269
weight = weight_observer(quant_bits=(4, 3))
270270
else:

0 commit comments

Comments
 (0)