def unpack_int4(weight, scale, zp):
    """
    Test function to verify quantize int4 is correct.
    Will not be used in model inference.
    """
    weight = weight.transpose(1, 0)
    scale = scale.transpose(1, 0)
    zp = zp.transpose(1, 0)
    h1, h2 = weight.shape
    group_size = h2 * 8 // scale.shape[1]
    group_num = scale.shape[1]
    fp_weight = torch.zeros(h1, h2 * 8).half().to(weight.device)
    fp_zero_point = torch.zeros(h1, group_num).to(weight.device)
    for pack in range(0, h2):
        for i in range(8):
            fp_weight[:, pack * 8 + i] = (weight[:, pack] >> (i * 4)) & 0xF
    for pack in range(0, h1 // 8):
        for i in range(8):
            fp_zero_point[pack * 8 + i, :] = (zp[pack, :] >> (i * 4)) & 0xF
    for g in range(group_num):
        fp_weight[:, g * group_size:(g + 1) * group_size] = (fp_weight[:, g * group_size:(g + 1) * group_size] - \
                                                             fp_zero_point[:, g].unsqueeze(1)) * scale[:, g].unsqueeze(1)
    return fp_weight.transpose(1, 0)

    Test function to verify quantize int4 is correct.
    Will not be used in model inference.
    
slora/common/basemodel/triton_kernel/dequantize_gemm_int4.py