Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions gptqmodel/utils/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ def create_quant_layer(QuantLinear, bits, desc_act, dynamic, group_size, module,
recurse_setattr(module, name, new_layer.to(ori_layer_device))
return QuantLinear

# public/stable api exposed to transformer/optimum
def hf_convert_gptq_v1_to_v2_format(
model,
bits: int,
qlinear_kernel: nn.Module,
):
quantize_config = QuantizeConfig(bits=bits)
return convert_gptq_v1_to_v2_format(model, quantize_config, qlinear_kernel)


def convert_gptq_v1_to_v2_format(
model,
Expand Down Expand Up @@ -225,6 +234,16 @@ def convert_gptq_v1_to_v2_format(
return model


# public/stable api exposed to transformer/optimum
def hf_convert_gptq_v2_to_v1_format(
model,
bits: int,
qlinear_kernel: nn.Module,
):
quantize_config = QuantizeConfig(bits=bits)
return convert_gptq_v2_to_v1_format(model, quantize_config, qlinear_kernel)


def convert_gptq_v2_to_v1_format(
model,
quantize_config: QuantizeConfig,
Expand Down Expand Up @@ -416,6 +435,12 @@ def simple_dispatch_model(model, device_map):
return model


# public/stable api exposed to transformer/optimum
def hf_gptqmodel_post_init(model, use_act_order: bool, quantize_config: QuantizeConfig = None,
max_input_length: Optional[int] = None):
return gptqmodel_post_init(model, use_act_order, quantize_config, max_input_length)


def gptqmodel_post_init(model, use_act_order: bool, quantize_config: QuantizeConfig = None,
max_input_length: Optional[int] = None):
"""
Expand Down