Skip to content

Commit 1c51f3f

Browse files
authored
Fix get value from qconfig (#3318)
1 parent bb76079 commit 1c51f3f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

intel_extension_for_pytorch/nn/modules/weight_only_quantization.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,15 @@ def from_int4_weight(
287287
lowp_mode = 2
288288
act_quant_mode = 1
289289
cache_weight_for_large_batch = False
290-
if qconfig is not None:
291-
if hasattr(qconfig, "lowp_mode"):
292-
lowp_mode = qconfig.lowp_mode
293-
if hasattr(qconfig, "act_quant_mode"):
294-
act_quant_mode = qconfig.act_quant_mode
295-
if hasattr(qconfig, "cache_weight_for_large_batch"):
290+
if qconfig is not None and hasattr(qconfig, "global_qconfig"):
291+
if hasattr(qconfig.global_qconfig, "lowp_mode"):
292+
lowp_mode = qconfig.global_qconfig.lowp_mode
293+
if hasattr(qconfig.global_qconfig, "act_quant_mode"):
294+
act_quant_mode = qconfig.global_qconfig.act_quant_mode
295+
if hasattr(qconfig.global_qconfig, "cache_weight_for_large_batch"):
296296
cache_weight_for_large_batch = (
297-
qconfig.cache_weight_for_large_batch and lowp_mode == 2
297+
qconfig.global_qconfig.cache_weight_for_large_batch
298+
and lowp_mode in (2, 3)
298299
)
299300

300301
w_dtype = qweight.dtype

0 commit comments

Comments
 (0)