def _convert_woq_with_low_precision_checkpoint(
    model,
    qconfig_mapping,
    low_precision_checkpoint,
    quant_config,
    inplace=True,
):
    r"""
    Method to convert fp32 model to WOQ model with checkpoint generated by GPTQ, AWQ and intel/autoround.
    Official FP8 checkpoints of DeepSeek-V3/R1 are also supported.
    Args:
        model: original model
        qconfig_mapping: QConfigMapping object containing observer info, lowp mode, etc.
        low_precision_checkpoint (dict): checkpoint generated by GPTQ/AWQ, etc.
        quant_config (dict): containing info like quantization method ("gptq" or "awq") and group size.
        inplace: do conversion in-place or make a copy of original model
    Return:
        Converted model
    """

    assert isinstance(
        low_precision_checkpoint, dict
    ), "low_precision_checkpoint should be a state_dict"
    quantization_method = quant_config["quant_method"]
    quant_group_size = quant_config.get("group_size", None)
    target_weight_dtype = WoqWeightDtype.INT4

    if quantization_method == "gptq":
        checkpoint_config = _gptq_lowp_checkpoint_config()
        if "desc_act" in quant_config:
            checkpoint_config["desc_act"] = quant_config.get("desc_act", None)
    elif quantization_method == "awq":
        checkpoint_config = _awq_lowp_checkpoint_config()
    elif quantization_method == "fp8":
        checkpoint_config = _fp8_lowp_checkpoint_config()
        target_weight_dtype = WoqWeightDtype.FP8
    elif quantization_method == "rtn":
        checkpoint_config = RTN_LOWP_CHECKPOINT_CONFIG
        bits = quant_config.get("bits", 8)
        target_weight_dtype = WoqWeightDtype.INT8 if bits == 8 else WoqWeightDtype.INT4
    elif quantization_method == "int8":
        checkpoint_config = INT8_LOWP_CHECKPOINT_CONFIG
        bits = quant_config.get("bits", 8)
        target_weight_dtype = WoqWeightDtype.INT8
    else:
        raise AssertionError(
            f"{quantization_method} is not supported, quantization_method choice in [`gptq`, `awq`, `fp8`]."
        )

    state_dict = low_precision_checkpoint
    # Check that keys can be found in the state dict. Bias and g_idx are optional.
    weight_key, scales_key, *_ = _get_keys_from_config(checkpoint_config)
    keys_found = [False] * 2
    for k, _ in state_dict.items():
        if k.endswith("." + weight_key):
            keys_found[0] = True
        if k.endswith("." + scales_key):
            keys_found[1] = True
        if all(keys_found):
            break
    assert all(keys_found), "Error: Format of checkpoint and config do not match"
    q_op_map = {
        torch.nn.Linear: WeightOnlyQuantizedLinear,
    }

    from intel_extension_for_pytorch.nn.utils._weight_prepack import (
        may_import_deepspeed_modules,
    )

    deepspeed_modules = may_import_deepspeed_modules()
    if deepspeed_modules is not None:
        LinearAllreduce, LinearLayer, LmHeadLinearAllreduce, *extra_linear_modules = (
            deepspeed_modules
        )

        q_op_map.update(
            {
                LinearAllreduce: IpexWoqLinearAllreduce,
                LinearLayer: WeightOnlyQuantizedLinear,
            }
        )

        if extra_linear_modules:
            for module in extra_linear_modules:
                if issubclass(module, LinearAllreduce):
                    q_op_map[module] = IpexWoqLinearAllreduce
                elif issubclass(module, LinearLayer):
                    q_op_map[module] = WeightOnlyQuantizedLinear
    linear_modules = tuple(q_op_map.keys())

    def _convert(mod, attr_name):
        # lm_head is not quantized in int4 checkpoint, LmHeadLinearAllReduce is not handled here
        if isinstance(mod, linear_modules):
            mod.qconfig = qconfig_mapping.global_qconfig
            weight, scales, qzeros, bias, group_size, g_idx, w_format = (
                _get_linear_parameters(
                    attr_name, state_dict, checkpoint_config, quant_config
                )
            )
            if quant_group_size is not None:
                group_size = quant_group_size
            if scales is None:
                # lm_head
                if weight is not None and weight.dtype in [
                    torch.float,
                    torch.bfloat16,
                    torch.half,
                ]:
                    mod.weight = torch.nn.Parameter(weight)
                    if hasattr(mod, "bias") and isinstance(
                        mod.bias, torch.nn.Parameter
                    ):
                        mod.bias = torch.nn.Parameter(bias)
                return mod
            mod_new = q_op_map[type(mod)].from_float_and_qweight(
                mod,
                weight,
                target_weight_dtype,
                scales,
                qzeros,
                bias,
                group_size=group_size,
                g_idx=g_idx,
                weight_format=w_format,
            )
            return mod_new
        elif hasattr(mod, "weight") and isinstance(mod.weight, torch.nn.Parameter):
            new_w = state_dict.get(attr_name + ".weight", mod.weight.data)
            mod.weight = torch.nn.Parameter(new_w)
            if hasattr(mod, "bias") and isinstance(mod.bias, torch.nn.Parameter):
                new_b = state_dict.get(attr_name + ".bias", mod.bias.data)
                mod.bias = torch.nn.Parameter(new_b)
            if hasattr(mod, "e_score_correction_bias"):
                new_b = state_dict.get(
                    attr_name + ".e_score_correction_bias",
                    mod.e_score_correction_bias.data,
                )
                mod.e_score_correction_bias = torch.nn.Parameter(new_b)
            return mod

        mod_new = mod

        for name, child in mod.named_children():
            attr = attr_name + "." + name if attr_name != "" else name
            setattr(mod_new, name, _convert(child, attr))
        return mod_new

    if not inplace:
        model_new = copy.deepcopy(model)
    else:
        model_new = model
    return _convert(model_new, "")

    Method to convert fp32 model to WOQ model with checkpoint generated by GPTQ, AWQ and intel/autoround.
    Official FP8 checkpoints of DeepSeek-V3/R1 are also supported.
    Args:
        model: original model
        qconfig_mapping: QConfigMapping object containing observer info, lowp mode, etc.
        low_precision_checkpoint (dict): checkpoint generated by GPTQ/AWQ, etc.
        quant_config (dict): containing info like quantization method ("gptq" or "awq") and group size.
        inplace: do conversion in-place or make a copy of original model
    Return:
        Converted model
    
intel_extension_for_pytorch/utils/weight_only_quantization.py