Skip to content

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

[GPU] Disable onednn FC dynamic quantization for 4D FC (#31423)

Andrew Kwangwoong Parke55e5e132c35
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 934b4e31960..76809e166fe 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
@@ -369,11 +369,13 @@ public:
// 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)
+ if (is_dyn_quan_input) {
+ OPENVINO_ASSERT(prim->input_size <= 3, "[GPU] Dynamic quantization for 4D matmul is not implemented");
+ } else {
attr->set_fpmath_mode(dnnl::fpmath_mode::f16, true);
+ }
auto weights_layout = impl_params.get_input_layout(1);
- OPENVINO_ASSERT(prim->input_size <= 3, "not implemented for 4d matmul");
auto shift_size = std::max<size_t>(prim->input_size - 2, 0);
int per_oc = PER_OC << shift_size;
int grouped = GROUPED | (1 << (prim->input_size - 1));
@@ -386,7 +388,7 @@ public:
auto ngroups = scale_layout.get_dim(1);
group_size = ifm / ngroups;
OPENVINO_ASSERT((group_size == 1 || ngroups == 1 || group_size % 32 == 0),
- "group_size should be aligned to 32 if it is not a single scale group or the group_size is not one.");
+ "[GPU] 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 (ngroups == 1) {
diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
index 1ecd08ff5b8..b1e75602f48 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
@@ -1226,6 +1226,13 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
}
}
+ const auto& input_shape = root->get_input_partial_shape(0);
+ const size_t input_rank = input_shape.size();
+ if (input_rank > 3) {
+ GPU_DEBUG_TRACE << root->get_friendly_name() << " dyn_quan is turned off: input rank is not supported" << std::endl;
+ return true;
+ }
+
auto weight_shape = root->get_input_partial_shape(1);
const size_t innermost_size = weight_shape[weight_shape.size() - 1].get_length();
const size_t simd = 16;