Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Fix onednn FC grouped scale for 8bit compressed weight matmul (#30941)

Min, Byungilfeb16c6df10d
diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.cpp
index 6a9876ed575..97a09d109b6 100644
--- a/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.cpp
@@ -286,7 +286,6 @@ public:
const kernel_impl_params* impl_params = reinterpret_cast<kernel_impl_params*>(ib.getKernelImplParams());
auto prim = impl_params->typed_desc<fully_connected>();
auto weights_layout = impl_params->get_input_layout(1);
- bool is_four_bit_weight = weights_layout.data_type == data_types::u4 || weights_layout.data_type == data_types::i4;
auto shift_size = std::max<size_t>(prim->input_size - 2, 0);
auto& arg = impl_params->get_program().get_node(impl_params->desc->id).as<fully_connected>();
int idx = !arg.bias_term() ? 1 : 2;
@@ -300,9 +299,10 @@ public:
auto decompression_scale_idx = ++idx;
auto scale_layout = arg.get_dependency(decompression_scale_idx).get_output_layout();
+ auto ngroups = scale_layout.get_dim(1);
if (scale_layout.count() == 1) {
_attrs->set_scales(DNNL_ARG_WEIGHTS, COMMON, dnnl::memory::dims{}, _ds_data_type);
- } else if (!is_four_bit_weight) {
+ } else if (ngroups == 1) {
_attrs->set_scales(DNNL_ARG_WEIGHTS, per_oc, dnnl::memory::dims{}, _ds_data_type);
} else {
_attrs->set_scales(DNNL_ARG_WEIGHTS, grouped, {_ds_group_size, 1}, _ds_data_type);
@@ -362,19 +362,16 @@ public:
int group_size = 0;
dnnl::memory::data_type ds_data_type = dnnl::memory::data_type::undef;
dnnl::memory::data_type dzp_data_type = dnnl::memory::data_type::undef;
- bool is_four_bit_weight = false;
int idx = !arg.bias_term() ? 1 : 2;
// There may be a performance difference between InnerProduct and MatMul primitives in oneDNN,
// so use MatMul only for weights compression and IP for all other cases.
if (prim->compressed_weights) {
bool is_dyn_quan_input = impl_params.get_input_layout(0).data_type == data_types::i8 || impl_params.get_input_layout(0).data_type == data_types::u8;
-
if (!is_dyn_quan_input)
attr->set_fpmath_mode(dnnl::fpmath_mode::f16, true);
auto weights_layout = impl_params.get_input_layout(1);
- is_four_bit_weight = weights_layout.data_type == data_types::u4 || weights_layout.data_type == data_types::i4;
auto shift_size = std::max<size_t>(prim->input_size - 2, 0);
int per_oc = PER_OC << shift_size;
int grouped = GROUPED << shift_size;
@@ -390,8 +387,7 @@ public:
"group_size should be aligned to 32 if it is not a single scale group or the group_size is not one.");
if (scale_layout.count() == 1) {
attr->set_scales(DNNL_ARG_WEIGHTS, COMMON, dnnl::memory::dims{}, ds_data_type);
- } else if (!is_four_bit_weight) {
- // 8-bit quantized weight
+ } else if (ngroups == 1) {
attr->set_scales(DNNL_ARG_WEIGHTS, per_oc, dnnl::memory::dims{}, ds_data_type);
} else {
// OneDNN does not support scalar zero-point for s4 and u8 type. Need to broadcast it.
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp
index b57a0294a78..20414a989c2 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp
@@ -1418,8 +1418,14 @@ TEST(fully_connected_gpu, fully_connected_gpu_fb_io_block_fp16) {
}
}
+
class fully_connected_gpu_tests: public ::testing::Test {
public:
+ enum class TestMode { Static, Dynamic };
+ enum class WzpMode { Symmetric, AsymmetricScalar, AsymmetricNonScalar };
+ enum class WeightMode { Bit8, Bit4 };
+ enum class TargetDevice { SkipDgpu, RunOnDgpu};
+
void test_compressed_scale_zp_bias(bool is_caching_test) {
auto& engine = get_test_engine();
@@ -1590,7 +1596,7 @@ public:
count++;
OPENVINO_ASSERT(abs_diff < 256);
}
- std::cout << "---> count: " << count << ", max_diff:" << max_diff << ", avg_diff: " << (avg/count) << std::endl;
+ GPU_DEBUG_LOG << "---> count: " << count << ", max_diff:" << max_diff << ", avg_diff: " << (avg/count) << std::endl;
}
void test_compressed_int4_scale(bool is_caching_test, bool is_dynamic, long int batch_num, long int scales_group_size = 128, bool is_wei_dyn = false) {
@@ -3732,54 +3738,63 @@ void test_compressed_int4_scale_dynamic_batch_gemv(bool is_caching_test,
ASSERT_EQ(3.0f, output_ptr[3]);
}
- void test_compressed_int4_scale_dyn_quan_weight_i4(bool is_dynamic, int batch = 1, int ifm = 512, int ofm = 2048,
- size_t quantize_group_size = 32, int scales_group_size = 128,
- bool is_wzp_test = false, bool is_wzp_scalar = false) {
+ void test_comp_weight_scale_zp(bool is_dynamic, int batch = 1, int ifm = 1024, int ofm = 1024,
+ size_t quantize_group_size = 32, int scales_group_size = 32, int wzp_group_size = 32,
+ WzpMode wzp_mode = WzpMode::Symmetric, WeightMode weight_mode = WeightMode::Bit8,
+ TargetDevice dgpu = TargetDevice::RunOnDgpu) {
tests::random_generator rg(GET_SUITE_NAME);
auto& engine = get_test_engine();
- if (engine.get_device_info().dev_type == device_type::discrete_gpu)
+ if (dgpu == TargetDevice::SkipDgpu && engine.get_device_info().dev_type == device_type::discrete_gpu)
GTEST_SKIP();
long int batch_num = batch;
long int ifm_num = ifm;
long int ofm_num = ofm;
- long int wzp_num = is_wzp_scalar ? 1 : ofm_num;
+ long int scale_num = ifm_num / scales_group_size;
+ long int wzp_num = (wzp_mode == WzpMode::AsymmetricNonScalar) ? ofm_num : 1;
+ long int wzp_ifm_num = (wzp_mode == WzpMode::AsymmetricNonScalar) ? (ifm_num / wzp_group_size) : 1;
+ auto weight_type = (weight_mode == WeightMode::Bit4) ? data_types::i4 : data_types::u8;
auto input_ps = ov::PartialShape{ batch_num, 1, ifm_num };
auto input_mem = engine.allocate_memory({ input_ps, data_types::f16, format::bfyx });
- auto weights_mem = engine.allocate_memory({ {ofm_num, ifm_num}, data_types::i4, format::bfyx });
- auto scale_mem = engine.allocate_memory({ {ofm_num, ifm_num / scales_group_size}, data_types::f16, format::fbyx });
- auto dcomp_zp_mem = engine.allocate_memory({ {wzp_num, 1}, data_types::u8, format::bfyx });
-
+ auto weights_mem = engine.allocate_memory({ {ofm_num, ifm_num}, weight_type, format::bfyx });
+ auto scale_mem = engine.allocate_memory({ {ofm_num, scale_num}, data_types::f16, format::fbyx });
+ auto dcomp_zp_mem = engine.allocate_memory({ {wzp_num, wzp_ifm_num}, data_types::u8, format::fbyx });
auto input_data = rg.generate_random_1d<ov::float16>(batch_num * ifm_num, -2.f, 2.f);
set_values(input_mem, input_data);
- auto weigths_data = rg.generate_random_1d<uint8_t>(ofm_num * ifm_num / 2, 0, 4);
- set_values(weights_mem, weigths_data);
+ if (weight_mode == WeightMode::Bit4) {
+ auto weigths_data = rg.generate_random_1d<uint8_t>(ofm_num * ifm_num / 2, 0, 4);
+ set_values(weights_mem, weigths_data);
+ } else {
+ auto weigths_data = rg.generate_random_1d<uint8_t>(ofm_num * ifm_num, 0, 4);
+ set_values(weights_mem, weigths_data);
+ }
- auto scale_data = rg.generate_random_1d<ov::float16>(ofm_num * ifm_num / scales_group_size, -2.f, 2.f);
+ auto scale_data = rg.generate_random_1d<ov::float16>(ofm_num * scale_num, -2.f, 2.f);
set_values(scale_mem, scale_data);
- if (is_wzp_test) {
- auto zp_data = rg.generate_random_1d<uint8_t>(wzp_num, 0, 2);
+ bool need_wzp_test = (wzp_mode != WzpMode::Symmetric);
+ if (need_wzp_test) {
+ auto zp_data = rg.generate_random_1d<uint8_t>(wzp_num * wzp_ifm_num, 0, 4);
set_values(dcomp_zp_mem, zp_data);
}
auto in_layout = is_dynamic ? layout{ ov::PartialShape{ -1, -1, -1 }, data_types::f16, format::bfyx }
: layout{ input_ps, data_types::f16, format::bfyx };
- auto dcomp_zp_name = is_wzp_test ? "wzp" : "";
+ auto dcomp_zp_name = need_wzp_test ? "wzp" : "";
auto fc_prim = fully_connected("fc_prim", input_info("input"), "weights", "", "scale", dcomp_zp_name, data_types::f16, 3, 2);
- if (is_wzp_test) {
+ if (need_wzp_test) {
fc_prim.compressed_weights = true;
- fc_prim.decompression_zero_point = is_wzp_test ? input_info("wzp") : input_info();
+ fc_prim.decompression_zero_point = need_wzp_test ? input_info("wzp") : input_info();
}
- // Implemented dynamic quantize kernel
+ // Implemented reference kernel
auto get_ref_results = [&]() {
topology topo;
topo.add(input_layout("input", in_layout));
@@ -3792,7 +3807,7 @@ void test_compressed_int4_scale_dynamic_batch_gemv(bool is_caching_test,
config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
ov::intel_gpu::ImplementationDesc fc_impl_desc = { format::bfyx, "fully_connected_gpu_bfyx_ref", impl_types::ocl };
config.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"fc_prim", fc_impl_desc} }));
- config.set_user_property(ov::hint::dynamic_quantization_group_size(0));
+ config.set_user_property(ov::hint::dynamic_quantization_group_size(quantize_group_size));
network network(engine, topo, config);
network.set_input_data("input", input_mem);
@@ -3815,7 +3830,7 @@ void test_compressed_int4_scale_dynamic_batch_gemv(bool is_caching_test,
fc_prim
);
- auto config = get_test_default_config(engine);
+ ExecutionConfig config = get_test_default_config(engine);
config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
config.set_property(ov::intel_gpu::optimize_data(true));
config.set_user_property(ov::hint::dynamic_quantization_group_size(quantize_group_size));
@@ -3852,141 +3867,10 @@ void test_compressed_int4_scale_dynamic_batch_gemv(bool is_caching_test,
max_diff = abs_diff;
avg += abs_diff;
count++;
- OPENVINO_ASSERT(abs_diff < 6);
- }
- GPU_DEBUG_LOG << "---> count: " << count << ", max_diff:" << max_diff << ", avg_diff: " << (avg/count) << std::endl;
- OPENVINO_ASSERT((avg/count) < 0.5);
- }
-
- void test_compressed_int8_scale_dyn_quan_weight_u8(bool is_dynamic, int batch = 1, int ifm = 512, int ofm = 2048,
- size_t quantize_group_size = 32, int scales_group_size = 128,
- bool is_wzp_test = false, bool is_wzp_scalar = false, int wzp_size = 1) {
- tests::random_generator rg(GET_SUITE_NAME);
- auto& engine = get_test_engine();
-
- if (engine.get_device_info().dev_type == device_type::discrete_gpu)
- GTEST_SKIP();
-
- long int batch_num = batch;
- long int ifm_num = ifm;
- long int ofm_num = ofm;
- long int wzp_num = is_wzp_scalar ? 1 : ofm_num;
-
- auto input_ps = ov::PartialShape{ batch_num, 1, ifm_num };
- auto input_mem = engine.allocate_memory({ input_ps, data_types::f16, format::bfyx });
-
- auto weights_mem = engine.allocate_memory({ {ofm_num, ifm_num}, data_types::u8, format::bfyx });
- auto scale_mem = engine.allocate_memory({ {ofm_num, ifm_num / scales_group_size}, data_types::f16, format::fbyx });
- auto dcomp_zp_mem = engine.allocate_memory({ {wzp_num, wzp_size}, data_types::u8, format::bfyx });
-
-
- auto input_data = rg.generate_random_1d<ov::float16>(batch_num * ifm_num, -2.f, 2.f);
- set_values(input_mem, input_data);
-
- auto weigths_data = rg.generate_random_1d<uint8_t>(ofm_num * ifm_num, 0, 4);
- set_values(weights_mem, weigths_data);
-
- auto scale_data = rg.generate_random_1d<ov::float16>(ofm_num * ifm_num / scales_group_size, -2.f, 2.f);
- set_values(scale_mem, scale_data);
-
- if (is_wzp_test) {
- auto zp_data = rg.generate_random_1d<uint8_t>(wzp_num, 0, 2);
- set_values(dcomp_zp_mem, zp_data);
- }
-
- auto in_layout = is_dynamic ? layout{ ov::PartialShape{ -1, -1, -1 }, data_types::f16, format::bfyx }
- : layout{ input_ps, data_types::f16, format::bfyx };
-
- auto dcomp_zp_name = is_wzp_test ? "wzp" : "";
- auto fc_prim = fully_connected("fc_prim", input_info("input"), "weights", "", "scale", dcomp_zp_name, data_types::f16, 3, 2);
-
- if (is_wzp_test) {
- fc_prim.compressed_weights = true;
- fc_prim.decompression_zero_point = is_wzp_test ? input_info("wzp") : input_info();
- }
-
- // Implemented dynamic quantize kernel
- auto get_ref_results = [&]() {
- topology topo;
- topo.add(input_layout("input", in_layout));
- topo.add(data("weights", weights_mem));
- topo.add(data("scale", scale_mem));
- topo.add(data("wzp", dcomp_zp_mem));
- topo.add(fc_prim);
-
- auto config = get_test_default_config(engine);
- config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
- ov::intel_gpu::ImplementationDesc fc_impl_desc = { format::bfyx, "fully_connected_gpu_bf_tiled", impl_types::ocl };
- config.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"fc_prim", fc_impl_desc} }));
- config.set_user_property(ov::hint::dynamic_quantization_group_size(0));
-
- network network(engine, topo, config);
- network.set_input_data("input", input_mem);
-
- auto outputs = network.execute();
- OPENVINO_ASSERT(outputs.size() == 1);
- OPENVINO_ASSERT(outputs.begin()->first == "fc_prim");
-
- auto output_layout = outputs.begin()->second.get_layout();
- auto output_mem = outputs.begin()->second.get_memory();
-
- return engine.reinterpret_buffer(*output_mem, output_layout);
- };
-
- topology topology(
- input_layout("input", in_layout),
- data("weights", weights_mem),
- data("scale", scale_mem),
- data("wzp", dcomp_zp_mem),
- fc_prim
- );
-
- auto config = get_test_default_config(engine);
- config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
- config.set_property(ov::intel_gpu::optimize_data(true));
- config.set_user_property(ov::hint::dynamic_quantization_group_size(quantize_group_size));
-
- network::ptr network = get_network(engine, topology, config, get_test_stream_ptr(), false);
-
- if (is_dynamic && !engine.get_device_info().supports_immad) {
- auto inst = network->get_primitive("fc_prim");
- auto impl = inst->get_impl();
- ASSERT_TRUE(impl != NULL);
- // For UINT8 weight, SLM kernel (no dyn-quan) would not be selected
- auto kernel_num = (is_dynamic) ? 3 : 1;
- kernel_num = (quantize_group_size < 32) ? 1 : kernel_num;
- ASSERT_EQ(impl->get_kernels().size(), size_t(kernel_num));
- }
-
- network->set_input_data("input", input_mem);
-
- auto outputs = network->execute();
- ASSERT_EQ(outputs.size(), size_t(1));
- ASSERT_EQ(outputs.begin()->first, "fc_prim");
-
- auto output_mem = outputs.begin()->second.get_memory();
- const int batch_alignment = 64;
- if ((batch > batch_alignment) && (batch % batch_alignment != 0)) {
- ASSERT_EQ(output_mem->get_layout().batch(), align_to(batch, batch_alignment));
- }
- cldnn::mem_lock<ov::float16> output_ptr (output_mem, get_test_stream());
-
- auto ref_output_mem = get_ref_results();
- cldnn::mem_lock<ov::float16> output_ptr_ref (ref_output_mem, get_test_stream());
-
- size_t count = 0;
- float max_diff = 0.f;
- float avg = 0.f;
- for (size_t i = 0; i < output_ptr_ref.size(); ++i) {
- auto abs_diff = std::abs((float)output_ptr_ref[i] - (float)output_ptr[i]);
- if (max_diff < abs_diff)
- max_diff = abs_diff;
- avg += abs_diff;
- count++;
- OPENVINO_ASSERT(abs_diff < 8);
+ OPENVINO_ASSERT(abs_diff < 10);
}
GPU_DEBUG_LOG << "---> count: " << count << ", max_diff:" << max_diff << ", avg_diff: " << (avg/count) << std::endl;
- OPENVINO_ASSERT((avg/count) < 0.8);
+ OPENVINO_ASSERT((avg/count) < 1);
}
};
@@ -5030,60 +4914,56 @@ TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dyn_quan_dynamic_f_input
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_batch_1) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 1, 2048, 3072);
+ this->test_comp_weight_scale_zp(true, 1, 2048, 3072, 32, 128, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 359, 1536, 2560);
+ this->test_comp_weight_scale_zp(true, 359, 1536, 2560, 32, 128, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case_12_groupsize) {
// Expect no dynamic-quantized FC
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 269, 512, 1024, 12);
+ this->test_comp_weight_scale_zp(true, 269, 512, 1024, 12, 128, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case_34_groupsize) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 359, 1536, 2560, 34);
+ this->test_comp_weight_scale_zp(true, 359, 1536, 2560, 34, 128, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case_64_groupsize) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 359, 1536, 2560, 64);
+ this->test_comp_weight_scale_zp(true, 359, 1536, 2560, 64, 128, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case_148_groupsize) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 359, 1536, 2560, 148);
+ this->test_comp_weight_scale_zp(true, 359, 1536, 2560, 148, 128, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case_128_groupsize) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 359, 1536, 2560, 128);
+ this->test_comp_weight_scale_zp(true, 359, 1536, 2560, 128, 128, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case_128_groupsize_32_scale) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 359, 1536, 2560, 128, 32);
+ this->test_comp_weight_scale_zp(true, 359, 1536, 2560, 128, 32, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_edge_case_128_groupsize_64_scale) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 359, 1536, 2560, 128, 64);
+ this->test_comp_weight_scale_zp(true, 359, 1536, 2560, 128, 64, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_no_wzp) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 320, 1024, 1024, 32, 32, false);
+ this->test_comp_weight_scale_zp(true, 320, 1024, 1024, 32, 32, 1, WzpMode::Symmetric, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_wzp) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 320, 1024, 1024, 32, 32, true);
+ this->test_comp_weight_scale_zp(true, 320, 1024, 1024, 32, 32, 1024, WzpMode::AsymmetricNonScalar, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_wzp_scalar) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 320, 1024, 1024, 32, 32, true);
+ this->test_comp_weight_scale_zp(true, 320, 1024, 1024, 32, 32, 1, WzpMode::AsymmetricScalar, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_wzp_128) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 320, 1024, 1024, 128, 128, true);
-}
-
-TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_wzp_static) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(false, 320, 1024, 1024, 32, 32, true);
+ this->test_comp_weight_scale_zp(true, 320, 1024, 1024, 128, 128, 128, WzpMode::AsymmetricNonScalar, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
// Test gemv for INT4 weight compression
@@ -5193,48 +5073,48 @@ TEST_F(fully_connected_gpu_tests, gemv_compressed_int4_dynamic_batch) {
// Test weight zp for INT8 ASYM
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_wzp_128_large_input_1025) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 1025, 3584, 4608, 128, 128, true);
+ this->test_comp_weight_scale_zp(true, 1025, 1792, 4608, 128, 128, 1, WzpMode::AsymmetricScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_wzp_128_large) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 320, 4096, 4096, 128, 128, true);
+ this->test_comp_weight_scale_zp(true, 160, 2048, 2048, 128, 128, 2048, WzpMode::AsymmetricNonScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_wzp_32_ifm_1024) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 320, 1024, 1024, 32, 32, true);
+ this->test_comp_weight_scale_zp(true, 160, 1024, 1024, 32, 32, 1024, WzpMode::AsymmetricNonScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_wzp_32_ifm_2048) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 320, 2048, 2048, 32, 32, true);
+ this->test_comp_weight_scale_zp(true, 160, 2048, 2048, 32, 32, 1, WzpMode::AsymmetricScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_wzp_32_ifm_4096) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 320, 4096, 4096, 32, 32, true);
+ this->test_comp_weight_scale_zp(true, 320, 2048, 2048, 32, 32, 1, WzpMode::AsymmetricScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_wzp_128_small) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 16, 1024, 1024, 128, 128, true);
+ this->test_comp_weight_scale_zp(true, 16, 1024, 1024, 128, 128, 1024, WzpMode::AsymmetricNonScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_wzp_128_single) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 1, 1024, 1024, 128, 128, true);
+ this->test_comp_weight_scale_zp(true, 1, 1024, 1024, 128, 128, 1, WzpMode::AsymmetricScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
// Test per-token dyn-quan
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_test_fake_per_token) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 600, 1024, 2048, -1, 32, true);
+ this->test_comp_weight_scale_zp(true, 600, 1024, 2048, -1, 32, 1024, WzpMode::AsymmetricNonScalar, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int4_scale_dynamic_quantize_test_per_token) {
- this->test_compressed_int4_scale_dyn_quan_weight_i4(true, 600, 1024, 2048, -1, 1024, true);
+ this->test_comp_weight_scale_zp(true, 600, 1024, 2048, -1, 1024, 1024, WzpMode::AsymmetricNonScalar, WeightMode::Bit4, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_test_per_token_small_scale) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 600, 1024, 2048, -1, 32, true);
+ this->test_comp_weight_scale_zp(true, 600, 1024, 2048, -1, 32, 1, WzpMode::AsymmetricScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_int8_scale_dynamic_quantize_test_per_token_full_scale) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(true, 600, 1024, 2048, -1, 1024, true);
+ this->test_comp_weight_scale_zp(true, 600, 1024, 2048, -1, 1024, 1, WzpMode::AsymmetricScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
TEST_F(fully_connected_gpu_tests, compressed_scale_bias) {
@@ -5347,9 +5227,34 @@ TEST_F(fully_connected_gpu_tests, dynamic_multi_inference_multiple_shapes_cached
}
TEST_F(fully_connected_gpu_tests, compressed_int8_dynamic_quantize_grouped_wzp_test) {
- this->test_compressed_int8_scale_dyn_quan_weight_u8(false, 320, 1024, 1024, 32, 32, true, false, 32);
+ this->test_comp_weight_scale_zp(false, 160, 1024, 1024, 32, 32, 32, WzpMode::AsymmetricNonScalar, WeightMode::Bit8, TargetDevice::SkipDgpu);
}
+TEST_F(fully_connected_gpu_tests, onednn_acc_test_compressed_weight_int8_group_scale_zp) {
+ this->test_comp_weight_scale_zp(false, 64, 256, 2048, 0, 32, 32, WzpMode::AsymmetricNonScalar, WeightMode::Bit8);
+}
+
+TEST_F(fully_connected_gpu_tests, onednn_acc_test_compressed_weight_int8_per_oc_scale_zp) {
+ this->test_comp_weight_scale_zp(false, 64, 256, 2048, 0, 256, 256, WzpMode::AsymmetricNonScalar, WeightMode::Bit8);
+}
+
+TEST_F(fully_connected_gpu_tests, onednn_acc_test_compressed_weight_int8_group_scale_scalar_zp) {
+ this->test_comp_weight_scale_zp(false, 64, 256, 2048, 0, 32, 32, WzpMode::Symmetric, WeightMode::Bit8);
+}
+
+TEST_F(fully_connected_gpu_tests, onednn_acc_test_compressed_weight_int4_group_scale_zp) {
+ this->test_comp_weight_scale_zp(false, 64, 256, 2048, 0, 32, 32, WzpMode::AsymmetricNonScalar, WeightMode::Bit4);
+}
+
+TEST_F(fully_connected_gpu_tests, onednn_acc_test_compressed_weight_int4_per_oc_scale_zp) {
+ this->test_comp_weight_scale_zp(false, 64, 256, 2048, 0, 256, 256, WzpMode::AsymmetricNonScalar, WeightMode::Bit4);
+}
+
+TEST_F(fully_connected_gpu_tests, onednn_acc_test_compressed_weight_int4_group_scale_scalar_zp) {
+ this->test_comp_weight_scale_zp(false, 64, 256, 2048, 0, 32, 32, WzpMode::Symmetric, WeightMode::Bit4);
+}
+
+
using fully_connected_dynamic_test_params = std::tuple<
std::vector<ov::Dimension::value_type>, // batch_sizes
ov::Dimension::value_type, // input_f