def load_low_precision_checkpoint(
    pathname: Union[str, os.PathLike],
    rank: int = 0,
    world_size: int = 1,
):
    r"""
    Load low precision checkpoint from a file or a directory containing multiple files.
    Supported file format: .pt, .bin, .pth, .safetensors.
    Args:
        pathname (str or os.PathLike): Path to the checkpoint file or directory containing multiple checkpoint files.
        rank (int, optional): Rank of the current process for Tensor Parallel. Default: 0.
        world_size (int, optional): World size for Tensor Parallel. Default: 1.
    Returns:
        Tuple[Dict[str, torch.Tensor], Dict[str, Any]]: A tuple of low precision checkpoint and quantization config.
        The quantization config contains quantization method, group size and desc_act.
    """
    assert os.path.exists(pathname), f"Checkpoint path does not exist: {pathname}"
    assert os.path.isdir(pathname), f"checkpoint path should be a directory: {pathname}"
    file_types = ["*.pt", "*.pth", "*.bin", "*.safetensors"]
    checkpoint_files = []
    file_type = None
    for pattern in file_types:
        checkpoint_files = list(pathlib.Path(pathname).glob(pattern))
        if checkpoint_files:
            file_type = pattern
            break
    assert checkpoint_files, f"Cannot find checkpoint files in path {pathname}."
    config_file = pathname + "/config.json"
    assert os.path.exists(config_file), f"Cannot find config.json in path: {pathname}."

    load_fn = partial(torch.load, weights_only=True)
    if file_type == "*.safetensors":
        try:
            import safetensors
        except ImportError:
            print("Please install safetensors package to load safetensors checkpoint.")
            exit(1)
        load_fn = safetensors.torch.load_file

    # load config.json and find quantization_config
    model_config = None
    quantization_config = None
    with open(config_file, "r", encoding="utf-8") as file:
        model_config = json.load(file)
    if "quantization_config" in model_config:
        quantization_config = model_config["quantization_config"]
    else:
        for file in ["quant_config.json", "quantize_config.json"]:
            config_file = pathname + "/" + file
            if os.path.exists(config_file):
                with open(config_file, "r", encoding="utf-8") as file:
                    quantization_config = json.load(file)
                break
    assert (
        quantization_config is not None
    ), f"Cannot find quantization config in path: {pathname}."

    # read quantization config
    quant_method = quantization_config.get("quant_method", None)
    group_size = quantization_config.get("group_size", None)
    desc_act = quantization_config.get("desc_act", None)
    backend = quantization_config.get("backend", None)
    bits = quantization_config.get("bits", None)
    weight_block_size = quantization_config.get("weight_block_size", None)
    assert quant_method is not None, "Cannot find quant_method in quantization config."
    if quant_method == "gptq":
        assert desc_act is not None, "group_size should not be None for GPTQ"
        bits = 4 if bits is None else bits
    elif quant_method == "awq":
        desc_act = False
        bits = 4 if bits is None else bits
    elif quant_method == "intel/auto-round":
        if backend is None or "gptq" in backend:
            quant_method = "gptq"
        elif "awq" in backend:
            quant_method = "awq"
        else:
            raise (
                NotImplementedError,
                f"Unsupported backend: {backend} of intel/auto-round",
            )
        desc_act = False
        bits = 4 if bits is None else bits
    elif quant_method == "fp8":
        arch = model_config["architectures"][0]
        assert arch == "DeepseekV3ForCausalLM", (
            "DeepseekV3ForCausalLM is the only supported architecture for fp8 quantization."
            " Found: " + arch
        )
        assert (
            weight_block_size is not None
        ), "weight_block_size should not be None for Deepseek-V3/R1 fp8"
        assert (
            isinstance(weight_block_size, list) and len(weight_block_size) == 2
        ), "weight_block_size should be a list of two integers." " Found: " + str(
            weight_block_size
        )
        group_size = weight_block_size[1]
        desc_act = False
        bits = 8 if bits is None else bits
    elif quant_method == "rtn":
        desc_act = False
        bits = 8 if bits is None else bits
    elif quant_method == "int8":
        desc_act = False
        bits = 8 if bits is None else bits
    else:
        raise (NotImplementedError, f"Unsupported quantization method: {quant_method}")
    quant_config = {
        "quant_method": quant_method,
        "group_size": group_size,
        "desc_act": desc_act,
        "weight_block_size": weight_block_size,
        "bits": bits,
    }

    # load checkpoint files and shard if necessary
    low_precision_checkpoint = {}
    tp_grain_size = group_size if group_size > 0 else 64
    logger.debug(
        f"Loading {len(checkpoint_files)} checkpoint files on rank {rank}/{world_size}"
    )
    for ckpt in checkpoint_files:
        data_f = load_fn(ckpt)
        if quant_method == "fp8":
            _preprocess_deepseek_v3_checkpoint(data_f, quant_config)
        if world_size > 1:
            data_f_shard = shard_low_precision_checkpoint(
                data_f,
                model_config,
                rank,
                world_size,
                quant_method,
                tp_grain_size,
                desc_act,
                bits,
            )
            low_precision_checkpoint.update(data_f_shard)
        else:
            low_precision_checkpoint.update(data_f)
    logger.debug(f"loading checkpoint files done on rank {rank}/{world_size}")

    return low_precision_checkpoint, quant_config

    Load low precision checkpoint from a file or a directory containing multiple files.
    Supported file format: .pt, .bin, .pth, .safetensors.
    Args:
        pathname (str or os.PathLike): Path to the checkpoint file or directory containing multiple checkpoint files.
        rank (int, optional): Rank of the current process for Tensor Parallel. Default: 0.
        world_size (int, optional): World size for Tensor Parallel. Default: 1.
    Returns:
        Tuple[Dict[str, torch.Tensor], Dict[str, Any]]: A tuple of low precision checkpoint and quantization config.
        The quantization config contains quantization method, group size and desc_act.
    
intel_extension_for_pytorch/llm/utils.py