PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
support `transformers.Conv1D` packing (#118)
Kaihui-intel02a6660ead32
diff --git a/auto_round/export/export_to_itrex/export.py b/auto_round/export/export_to_itrex/export.pyindex 5c854822d..54b1dcd83 100644--- a/auto_round/export/export_to_itrex/export.py+++ b/auto_round/export/export_to_itrex/export.py@@ -19,6 +19,7 @@ from os.path import isdir, isfile, joinfrom typing import Dict, List, Optional, Unionimport torch+import transformersfrom safetensors.torch import save_file as safe_savefrom auto_round.export.register import register_format@@ -198,12 +199,19 @@ def pack_model(else:scale = scale.to(dtype=convert_dtype)zp = zp.to(dtype=torch.int32)-+ if isinstance(m, transformers.modeling_utils.Conv1D):+ fp_weight = fp_weight.t_().contiguous()int_weight = quant_weight_w_scale(fp_weight, scale, zp, group_size, fp_weight.device)+ if isinstance(m, torch.nn.Linear):+ in_features = m.in_features+ out_features = m.out_features+ elif isinstance(m, transformers.modeling_utils.Conv1D):+ in_features = m.weight.shape[0]+ out_features = m.weight.shape[1]int_weight = int_weight.type(torch.int32)new_module = WeightOnlyLinear(- m.in_features,- m.out_features,+ in_features,+ out_features,num_bits,group_size,dtype=dtype,