Skip to content

Commit 4501634

Browse files
merezmanakladievtkrupa-inteloonyshchintelgaoxiong
authored
[GPU] Enable dynamic quantization for MXFP4 & regular FP4 dtypes (#36944)
### Details: - This is a continuation of the fp8 [PR #35283](#35283) that introduced f8e4m3 and f8e5m2 support. - This PR extends the fp8 implementation by adding support for f4e2m1 and its microscaling (mx) variation. - The PR builds upon the existing FP8 utility functions and extends them to handle FP4 types in OpenCL code. - Similar to the fp8 implementation, f4e2m1 is only enabled for dynamic quantization - Dynamic quantize op is extended with OpenCL kernel support for fp4 data types (building upon the existing kernel infrastructure for fp8). - Fully connected op is enabled to accept fp4 & mxfp4 inputs (oneDNN only). - All transformations and optimizations introduced in the mxfp8 PR are compatible with the new fp4 data types - Testing approach follows the same methodology as the mxfp8 implementation ### Tickets: - CVS-172558 --------- Signed-off-by: intelgaoxiong <xiong.gao@intel.com> Signed-off-by: hyunback <hyunback.kim@intel.com> Signed-off-by: Maxim Vafin <maxim.vafin@intel.com> Signed-off-by: Andrii Staikov <andii.staikov@intel.com> Signed-off-by: Raasz, Pawel <pawel.raasz@intel.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com> Signed-off-by: HU Yuan2 <yuan2.hu@intel.com> Signed-off-by: Pawel Raasz <pawel.raasz@intel.com> Signed-off-by: Bogdan Pereanu <bogdan.pereanu@intel.com> Signed-off-by: Min, Byungil <byungil.min@intel.com> Signed-off-by: Andrew Park <andrew.park@intel.com> Signed-off-by: wenzengc <wenzeng.chen@intel.com> Signed-off-by: alexandruenache1111 <alexandru.enache@intel.com> Signed-off-by: Tomasz Jankowski <tomasz1.jankowski@intel.com> Signed-off-by: Sorin Butnariu <sorin.butnariu@intel.com> Signed-off-by: Andrii Staikov <andrii.staikov@intel.com> Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com> Signed-off-by: Chen, Peter <peter.chen@intel.com> Signed-off-by: Min,Byung-il <byungil.min@intel.com> Signed-off-by: yuan.xiong <yuan.xiong@intel.com> Signed-off-by: Stefania Hergane <stefania-persida.hergane@intel.com> Signed-off-by: xiping.yan <xiping.yan@intel.com> Signed-off-by: xipingya <xiping.yan@intel.com> Signed-off-by: Stepan <patrik.stepan@intel.com> Signed-off-by: Vasanth Tovinkere <vasanth.tovinkere@intel.com> Signed-off-by: Xin Wang <xin1.wang@intel.com> Signed-off-by: Alina Kladieva <alina.kladieva@intel.com> Signed-off-by: zhanmyz <yazhan.ma@intel.com> Signed-off-by: Kang, Wenjing <wenjing.kang@intel.com> Signed-off-by: Kirill Suvorov <kirill.suvorov@intel.com> Signed-off-by: Doronin, Maksim <maksim.doronin@intel.com> Signed-off-by: Skrebkov, Artemy <artemy.skrebkov@intel.com> Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com> Signed-off-by: hyunback.kim <hyunback.kim@intel.com> Co-authored-by: Alina Kladieva <alina.kladieva@intel.com> Co-authored-by: Tomasz Krupa <tomasz.krupa@intel.com> Co-authored-by: Olena Onyshchenko <olena.onyshchenko@intel.com> Co-authored-by: intelgaoxiong <xiong.gao@intel.com> Co-authored-by: Michael Frank Hansen <michael.f.hansen@intel.com> Co-authored-by: Tatiana Savina <tatiana.savina@intel.com> Co-authored-by: Sorin Butnariu <sorin.butnariu@intel.com> Co-authored-by: hyunback kim <hyunback.kim@intel.com> Co-authored-by: Arseniy Obolenskiy <arseniy.obolenskiy@intel.com> Co-authored-by: Anastasiya(Asya) Pronina <anastasiya.pronina@intel.com> Co-authored-by: piyush kumar <150425540+Sujanian1304@users.noreply.github.com> Co-authored-by: Maxim Vafin <maxim.vafin@intel.com> Co-authored-by: Mikhail Ryzhov <mikhail.ryzhov@intel.com> Co-authored-by: Andrii Staikov <andrii.staikov@intel.com> Co-authored-by: Vasily Shamporov <vasily.shamporov@intel.com> Co-authored-by: Pawel Raasz <pawel.raasz@intel.com> Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com> Co-authored-by: Jade Cho <jade.cho@intel.com> Co-authored-by: sys-openvino-ci <sys_openvino_ci@intel.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mingyu Kim <mingyu.kim@intel.com> Co-authored-by: Oleg Pipikin <oleg.pipikin@intel.com> Co-authored-by: Chenhu Wang <chenhu.wang@intel.com> Co-authored-by: Ryan Metcalfe <107415876+RyanMetcalfeInt8@users.noreply.github.com> Co-authored-by: Alexey Smirnov <alexey.smirnov@intel.com> Co-authored-by: Ekaterina Shiryaeva <ekaterina.shiriaeva@intel.com> Co-authored-by: Sungeun Kim <sungeun.kim@intel.com> Co-authored-by: Przemyslaw Wysocki <przemyslaw.wysocki@intel.com> Co-authored-by: Yuan Hu <yuan2.hu@intel.com> Co-authored-by: zaixing.wang <zaixing.wang@intel.com> Co-authored-by: Alicja Miloszewska <alicja.miloszewska@intel.com> Co-authored-by: Bo Liu <bo4.liu@intel.com> Co-authored-by: Bogdan Pereanu <bogdan.pereanu@intel.com> Co-authored-by: Andrei Kashchikhin <andrey.kashchikhin@intel.com> Co-authored-by: Mircea-Aurelian Dan <mircea-aurelian.dan@intel.com> Co-authored-by: Min, Byungil <byungil.min@intel.com> Co-authored-by: Ashutosh Singh <ashutosh.singh@intel.com> Co-authored-by: Andrew Kwangwoong Park <andrew.park@intel.com> Co-authored-by: Siddhant Shekhar <shekharsiddhant93@gmail.com> Co-authored-by: Pavel Durandin <pavel.durandin@intel.com> Co-authored-by: Dmitry Matveev <dmitry.matveev@intel.com> Co-authored-by: Roman Lyamin <Roman.Lyamin@intel.com> Co-authored-by: Eddy Kim <eddy.kim@intel.com> Co-authored-by: Katarzyna Mitrus <katarzyna.mitrus@intel.com> Co-authored-by: Wenzeng Chen <wenzeng.chen@intel.com> Co-authored-by: Taylor Yeonbok Lee <taylor.lee@intel.com> Co-authored-by: Andrey Babushkin <andrey.babushkin@intel.com> Co-authored-by: Alexandru Enache <alexandru.enache@intel.com> Co-authored-by: Vigh Sebastian <sebastian-robert.vigh@intel.com> Co-authored-by: Denis Orlov <denis.orlov@intel.com> Co-authored-by: Tomasz Jankowski <tomasz1.jankowski@intel.com> Co-authored-by: Evgeny Kotov <evgeny.kotov@intel.com> Co-authored-by: Daria Mityagina <daria.mityagina@intel.com> Co-authored-by: ashwins990 <ashwin.sekhar@fujitsu.com> Co-authored-by: Aleksandr Voron <aleksandr.voron@intel.com> Co-authored-by: Michal Miotk <michal.miotk@intel.com> Co-authored-by: liang <liang.gao@intel.com> Co-authored-by: Lei Chen <lei5.chen@intel.com> Co-authored-by: Maksim Doronin <maksim.doronin@intel.com> Co-authored-by: Surya Siddharth Pemmaraju <surya.siddharth.pemmaraju@intel.com> Co-authored-by: David Nam <david.nam@intel.com> Co-authored-by: Paul Youngsoo Ahn <paul.y.ahn@intel.com> Co-authored-by: Kamil Wieloch <113444477+kwieloch-intel@users.noreply.github.com> Co-authored-by: Wanglei Shen <wanglei.shen@intel.com> Co-authored-by: Dan Liu <dan1.liu@intel.com> Co-authored-by: Stefania Hergane <stefania-persida.hergane@intel.com> Co-authored-by: Szymon Gutaj <szymon.gutaj@intel.com> Co-authored-by: Razvan Apetroaie <razvan-mihai.apetroaie@intel.com> Co-authored-by: Wilson Seok <wilson.seok@intel.com> Co-authored-by: Nikolay Proshunin <nikolay.proshunin@intel.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: whitneyfoster <whitney.foster@intel.com> Co-authored-by: Nikolay Shchegolev <nikolay.shchegolev@intel.com> Co-authored-by: Chon Ming Lee <chon.ming.lee@intel.com> Co-authored-by: Susanta Bhattacharjee <susanta.bhattacharjee@intel.com> Co-authored-by: Mateusz Mikolajczyk <mateusz.mikolajczyk@intel.com> Co-authored-by: Chen Peter <peter.chen@intel.com> Co-authored-by: Maksim Kutakov <maksim.kutakov@intel.com> Co-authored-by: river.li <river.li@intel.com> Co-authored-by: ceciliapeng2011 <cecilia.peng@intel.com> Co-authored-by: Luo Cheng <cheng.luo@intel.com> Co-authored-by: Li, Tingqian <tingqian.li@intel.com> Co-authored-by: rnwang04 <ruonan1.wang@intel.com> Co-authored-by: Zhai, Xuejun <xuejun.zhai@intel.com> Co-authored-by: Luwei Zhou <luwei.zhou@intel.com> Co-authored-by: Wang Wangwang <wangwang.wang@intel.com> Co-authored-by: Nesterov Alexander <alexander.nesterov@intel.com> Co-authored-by: bopeng1234 <bo.peng@intel.com> Co-authored-by: Gracjan Koscinski <gracjan.koscinski@intel.com> Co-authored-by: Piotr Krzemiński <piotr.krzeminski@intel.com> Co-authored-by: liang <gxgaoliang@126.com> Co-authored-by: Egor Duplenskii <egor.duplensky@gmail.com> Co-authored-by: Sofya Balandina <sofya.balandina@intel.com> Co-authored-by: Xiuchuan Zhai <xiuchuan.zhai@intel.com> Co-authored-by: Alan Zhai <zhaixiuchuan@hotmail.com> Co-authored-by: Patrik Stepan <patrik.stepan@intel.com> Co-authored-by: Andrey Churkin <andrey.churkin@intel.com> Co-authored-by: Ethan Yang <ethan.yang@intel.com> Co-authored-by: Alexey Moskalev <alexey.moskalev@intel.com> Co-authored-by: Xiong Yuan <yuan.xiong@intel.com> Co-authored-by: Klimenko, Mikhail <mikhail.klimenko@intel.com> Co-authored-by: Vladislav Golubev <vladislav.golubev@intel.com> Co-authored-by: Sun Xiaoxia <xiaoxia.sun@intel.com> Co-authored-by: Xiping Yan <xiping.yan@intel.com> Co-authored-by: Wiktor Kobiela <wiktor.kobiela@intel.com> Co-authored-by: jszczepa <jaroslaw.szczepanski@intel.com> Co-authored-by: Damian Kurek <damian.kurek@intel.com> Co-authored-by: Arseniy Obolenskiy <gooddoog@student.su> Co-authored-by: Tikhonov Ivan <ivan.tikhonov@intel.com> Co-authored-by: Andrei Tamas <andrei-stefan.tamas@intel.com> Co-authored-by: Sergey Shumihin <sergey.shumihin@intel.com> Co-authored-by: tovinkere <vasanth.tovinkere@gmail.com> Co-authored-by: Xin Wang <xin1.wang@intel.com> Co-authored-by: Yaru Du <yaru.du@intel.com> Co-authored-by: Dvoretckii, Mikhail <mikhail.dvoretckii@intel.com> Co-authored-by: czekun <chen.zekun@intel.com> Co-authored-by: Nikita Kudriavtsev <nikita.kudriavtsev@intel.com> Co-authored-by: Weiguo Meng <weiguo.meng@intel.com> Co-authored-by: Egor Tyuvaev <egor.tyuvaev@intel.com> Co-authored-by: Daria Ilina <daria.ilina@intel.com> Co-authored-by: Simon Ewing <simon.ewing@intel.com> Co-authored-by: Pengqiang Li <pengqiang.li@intel.com> Co-authored-by: Alexander Kalistratov <alexander.kalistratov@intel.com> Co-authored-by: Arun Thakur <nk9599341@gmail.com> Co-authored-by: Hannah mnq <hannah.mushtaque@gmail.com> Co-authored-by: Artyom Anokhov <artyom.anokhov@intel.com> Co-authored-by: Yury Gaydaychuk <yury.gaydaychuk@intel.com> Co-authored-by: Jozef Wludzik <jozef.wludzik@intel.com> Co-authored-by: Qiujiao Wu <qiujiao.wu@intel.com> Co-authored-by: Yash Vijay <yash_vijay@outlook.com> Co-authored-by: tovinkere <vasanth.tovinkere@intel.com> Co-authored-by: Wang, Yang <yang4.wang@intel.com> Co-authored-by: Alexander Dokuchaev <alexander.dokuchaev@intel.com> Co-authored-by: Maksim Proshin <maksim.proshin@intel.com> Co-authored-by: Nazanin Beheshti <nazanin.beheshti@intel.com> Co-authored-by: Eugene Smirnov <eugene.smirnov@intel.com> Co-authored-by: Vladimir Zlobin <vladimir.zlobin@intel.com> Co-authored-by: abhijain1204fujitsu <139222713+abhijain1204fujitsu@users.noreply.github.com> Co-authored-by: Mang Guo <mang.guo@intel.com> Co-authored-by: Dylan Neve <dylan.neve@intel.com> Co-authored-by: Yazhan Ma <yazhan.ma@intel.com> Co-authored-by: fcmiron <catalin.miron@intel.com> Co-authored-by: Wenjing Kang <wenjing.kang@intel.com> Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> Co-authored-by: Kirill Suvorov <kirill.suvorov@intel.com> Co-authored-by: Mateusz Tabaka <mateusz.tabaka@intel.com> Co-authored-by: shiyi <shiyi.zou@intel.com> Co-authored-by: Golubev, Andrey <andrey.golubev@intel.com> Co-authored-by: Shagun Gupta <137595846+MissLostCodes@users.noreply.github.com> Co-authored-by: Jaskaran Singh Nagi <jaskaran.singh.nagi@intel.com> Co-authored-by: barnasm1 <michal.barnas@intel.com> Co-authored-by: Prithviraj-R <prithviraj.r@intel.com> Co-authored-by: Artemy Skrebkov <artemy.skrebkov@intel.com> Co-authored-by: mfhansen <mfhansen@users.noreply.github.com> Co-authored-by: Jakub Kasprzak <jakub.kasprzak@intel.com> Co-authored-by: Koryun Khachatryan <koryun.khachatryan@intel.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Chen Xu <chen.xu@intel.com> Co-authored-by: Chirla Darius <darius.chirla@intel.com> Co-authored-by: Valentina Kats <valentina.kats@intel.com> Co-authored-by: Omar Ali <110394937+om4rrr@users.noreply.github.com> Co-authored-by: Aleksandra Głowacka <aleksandra.glowacka@intel.com> Co-authored-by: Zhang Yi <yi3.zhang@intel.com>
1 parent 5d13a5c commit 4501634

32 files changed

Lines changed: 734 additions & 33 deletions

src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace low_precision {
2828
namespace precision_set {
2929
LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_int8_support();
3030
LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_fp8_support();
31+
LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_fp8_fp4_support();
3132
LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_int8_int16_int32_support();
3233
} // namespace precision_set
3334

@@ -59,7 +60,7 @@ class LP_TRANSFORMATIONS_API DataPrecision {
5960
element::i8, element::u8,
6061
element::i16, element::u16,
6162
element::i32, element::u32,
62-
element::f8e4m3, element::f8e5m2,
63+
element::f8e4m3, element::f8e5m2, element::f4e2m1,
6364
};
6465
return lowPrecision.find(precision) != lowPrecision.end();
6566
}

src/common/low_precision_transformations/src/layer_transformation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ const std::vector<element::Type>& precision_set::get_fp8_support() {
3636
return fp8_support;
3737
}
3838

39+
const std::vector<element::Type>& precision_set::get_fp8_fp4_support() {
40+
static const std::vector<element::Type> low_bit_float_support = {
41+
ov::element::f8e4m3, ov::element::f8e5m2, ov::element::f4e2m1,
42+
};
43+
return low_bit_float_support;
44+
}
45+
3946
const std::vector<element::Type>& precision_set::get_int8_int16_int32_support() {
4047
static const std::vector<element::Type> int8_int16_int32_support = {
4148
ov::element::u8, ov::element::i8,

src/common/transformations/src/transformations/fp16_compression/mark_decompression_convert_constant_folding.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ MarkCompressedFloatConstants::MarkCompressedFloatConstants() {
143143
return false;
144144
if (const_node->get_output_element_type(0) != element::f16 &&
145145
const_node->get_output_element_type(0) != element::bf16 &&
146+
const_node->get_output_element_type(0) != element::f4e2m1 &&
146147
const_node->get_output_element_type(0) != element::f8e4m3 &&
147148
const_node->get_output_element_type(0) != element::f8e5m2 &&
148149
const_node->get_output_element_type(0) != element::f8e8m0)

src/plugins/intel_gpu/src/graph/debug_helper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ void log_memory_to_file(memory::ptr mem, layout data_layout, stream& stream, std
284284
dump<ov::float8_e5m2>(actual_mem, stream, file_stream, dump_raw);
285285
else if (mem_dt == cldnn::data_types::f8e4m3)
286286
dump<ov::float8_e4m3>(actual_mem, stream, file_stream, dump_raw);
287+
else if (mem_dt == cldnn::data_types::f4e2m1)
288+
dump<ov::float4_e2m1>(actual_mem, stream, file_stream, dump_raw);
287289
else if (mem_dt == cldnn::data_types::f8e8m0)
288290
dump<ov::float8_e8m0>(actual_mem, stream, file_stream, dump_raw);
289291
else if (mem_dt == cldnn::data_types::boolean)

src/plugins/intel_gpu/src/graph/impls/ocl/dynamic_quantize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct dynamic_quantize_impl : typed_primitive_impl_ocl<dynamic_quantize> {
5555
params.combine_scales_and_zp = desc->attrs.output_storage_type != ov::op::internal::DynamicQuantize::OutputStorageType::Planar;
5656
params.generate_precomputed_reduction = desc->attrs.precomputed_reduction;
5757

58+
validate_f4e2m1_packed_output(impl_param.get_output_layout(0), "dynamic_quantize");
59+
5860
return params;
5961
}
6062

@@ -75,6 +77,7 @@ attach_dynamic_quantize_impl::attach_dynamic_quantize_impl() {
7577
data_types::f16,
7678
data_types::i8,
7779
data_types::u8,
80+
data_types::f4e2m1,
7881
data_types::f8e4m3,
7982
data_types::f8e5m2,
8083
data_types::f8e8m0,

src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ kernel_selector::data_type to_data_type(data_types dt) {
268268
return kernel_selector::data_type::F32;
269269
case cldnn::data_types::bf16:
270270
return kernel_selector::data_type::BF16;
271+
case cldnn::data_types::f4e2m1:
272+
return kernel_selector::data_type::F4E2M1;
271273
case cldnn::data_types::f8e4m3:
272274
return kernel_selector::data_type::F8E4M3;
273275
case cldnn::data_types::f8e5m2:
@@ -305,6 +307,8 @@ data_types from_data_type(kernel_selector::data_type dt) {
305307
return cldnn::data_types::f16;
306308
case kernel_selector::data_type::F32:
307309
return cldnn::data_types::f32;
310+
case kernel_selector::data_type::F4E2M1:
311+
return cldnn::data_types::f4e2m1;
308312
case kernel_selector::data_type::F8E4M3:
309313
return cldnn::data_types::f8e4m3;
310314
case kernel_selector::data_type::F8E5M2:
@@ -336,6 +340,8 @@ kernel_selector::weights_type to_weights_type(data_types dt) {
336340
return kernel_selector::weights_type::INT32;
337341
case cldnn::data_types::bf16:
338342
return kernel_selector::weights_type::BF16;
343+
case cldnn::data_types::f4e2m1:
344+
return kernel_selector::weights_type::F4E2M1;
339345
case cldnn::data_types::f8e4m3:
340346
return kernel_selector::weights_type::F8E4M3;
341347
case cldnn::data_types::f8e5m2:
@@ -365,6 +371,8 @@ data_types from_weights_type(kernel_selector::weights_type dt) {
365371
return data_types::f32;
366372
case kernel_selector::weights_type::INT32:
367373
return data_types::i32;
374+
case kernel_selector::weights_type::F4E2M1:
375+
return data_types::f4e2m1;
368376
case kernel_selector::weights_type::F8E4M3:
369377
return data_types::f8e4m3;
370378
case kernel_selector::weights_type::F8E5M2:

src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333
namespace cldnn {
3434
namespace ocl {
3535

36+
inline void validate_f4e2m1_packed_output(const layout& output_layout, const char* primitive_name) {
37+
if (output_layout.data_type != ov::element::f4e2m1 || output_layout.is_dynamic()) {
38+
return;
39+
}
40+
41+
OPENVINO_ASSERT(output_layout.get_linear_size() % 8 == 0,
42+
"[GPU] ", primitive_name, ": f4e2m1 output size must be a multiple of 8 elements "
43+
"(32-bit atomic write granularity), but got: ",
44+
output_layout.get_linear_size());
45+
}
46+
3647
/*
3748
Base class for all GPU implementation of specified primitive type.
3849
For example, all gpu convolution implementations should derive from typed_primitive_impl_ocl<convolution>.

src/plugins/intel_gpu/src/graph/impls/ocl/reorder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ struct reorder_impl : typed_primitive_impl_ocl<reorder> {
112112
params.winograd = impl_param.input_layouts[0].format.is_winograd() || output_layout.format.is_winograd();
113113
params.truncate = impl_param.typed_desc<reorder>()->truncate;
114114

115+
validate_f4e2m1_packed_output(output_layout, "reorder");
116+
115117
return params;
116118
}
117119

@@ -122,6 +124,7 @@ struct reorder_impl : typed_primitive_impl_ocl<reorder> {
122124
}
123125

124126
update_shapes(*_kernel_data.params, impl_param);
127+
validate_f4e2m1_packed_output(impl_param.get_output_layout(), "reorder");
125128
(_kernel_data.update_dispatch_data_func)(*_kernel_data.params, _kernel_data);
126129
}
127130

src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/jitter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,18 @@ JitConstants make_type_jit_constants(const std::string& name, const ov::element:
320320
type_size = "4";
321321
is_fp = true;
322322
break;
323+
case ov::element::f4e2m1:
324+
type = "fp4e2m1_t";
325+
max_val = "(fp4e2m1_t){as_uchar((uchar)0x7)}"; // 6.0
326+
min_val = "(fp4e2m1_t){as_uchar((uchar)0xF)}"; // -6.0
327+
val_one = "(fp4e2m1_t){as_uchar((uchar)0x2)}";
328+
val_zero = "(fp4e2m1_t){as_uchar((uchar)0x0)}";
329+
to_type = "_convert_fp4e2m1_t(v)";
330+
to_type_sat = "_convert_fp4e2m1_t_sat(v)";
331+
as_type = "as_fp4e2m1_t(v)";
332+
type_size = "0.5f";
333+
is_fp = true;
334+
break;
323335
case ov::element::f8e4m3:
324336
type = "fp8e4m3_t";
325337
max_val = "(fp8e4m3_t){as_char((char)0x7E)}"; // 448.0

src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct fully_connected_onednn : typed_primitive_onednn_impl<fully_connected> {
7171
}
7272

7373
const auto input_dt = instance.get_input_layout(0).data_type;
74-
const bool is_dyn_quan_input = cldnn::one_of(input_dt, {data_types::i8, data_types::u8, data_types::f8e4m3, data_types::f8e5m2});
74+
const bool is_dyn_quan_input = cldnn::one_of(input_dt, {data_types::i8, data_types::u8, data_types::f4e2m1, data_types::f8e4m3, data_types::f8e5m2});
7575

7676
if (is_dyn_quan_input && prim->activation_scale.is_valid()) {
7777
const auto activation_scale_idx = idx++;
@@ -312,7 +312,7 @@ struct fully_connected_onednn : typed_primitive_onednn_impl<fully_connected> {
312312
}
313313

314314
const auto input_dt = impl_params->get_input_layout(0).data_type;
315-
const bool is_dyn_quan_input = cldnn::one_of(input_dt, {data_types::i8, data_types::u8, data_types::f8e4m3, data_types::f8e5m2});
315+
const bool is_dyn_quan_input = cldnn::one_of(input_dt, {data_types::i8, data_types::u8, data_types::f4e2m1, data_types::f8e4m3, data_types::f8e5m2});
316316
if (is_dyn_quan_input && dynamic_quantized_activation) {
317317
auto src_scale_idx = ++idx;
318318
auto partial_shape = impl_params->get_input_layout(0).get_partial_shape();
@@ -360,7 +360,7 @@ struct fully_connected_onednn : typed_primitive_onednn_impl<fully_connected> {
360360

361361
if (prim->compressed_weights) {
362362
const auto input_dt = impl_params.get_input_layout(0).data_type;
363-
const bool is_dyn_quan_input = cldnn::one_of(input_dt, {data_types::i8, data_types::u8, data_types::f8e4m3, data_types::f8e5m2});
363+
const bool is_dyn_quan_input = cldnn::one_of(input_dt, {data_types::i8, data_types::u8, data_types::f4e2m1, data_types::f8e4m3, data_types::f8e5m2});
364364
if (is_dyn_quan_input) {
365365
OPENVINO_ASSERT(prim->input_size <= 3, "[GPU] Dynamic quantization for 4D matmul is not implemented");
366366
} else {

0 commit comments

Comments
 (0)