[GPU] Enable dynamic quantization for MXFP4 & regular FP4 dtypes#36944
Open
merezman wants to merge 172 commits into
Open
[GPU] Enable dynamic quantization for MXFP4 & regular FP4 dtypes#36944merezman wants to merge 172 commits into
merezman wants to merge 172 commits into
Conversation
Bump product version 2025.4.0
…4_rebase Resolved conflicts and adapted FP4 implementation to FP8 updates: GPU Kernels: - Updated reorder_data.cl with FP4 packing/unpacking logic (2 elements per byte) - Added FP4 INPUT unpacking using byte-level operations - Added FP4 OUTPUT packing with atomic operations - Merged IS_LOW_BIT_FP to include all FP4 and FP8 variants (F8E8M0 added) - Updated f8_utils.cl include path from batch_headers to root Dynamic Quantize: - Updated dynamic_quantize_gpu_opt.cl and dynamic_quantize_gpu_ref.cl - Merged FP8 updates while preserving FP4 support - Kept DynamicQuantize reuse optimization in dynamic_quantize_fully_connected.cpp - Used float instead of half for scale calculations (more precise) Code Organization: - Removed MOE-related files (deleted in target branch) - Accepted target branch updates for paged_attention implementations - Updated submodules (onednn, onednn_gpu) - Merged workflow and build configuration updates
…RG_HINT_MAX_GROUP_SIZE)
- Restore f4e2m1 data type in oneDNN FullyConnected: * Add f4e2m1 to is_dyn_quan_input checks (3 places) * Add f4e2m1 to fp_compressed_case (input/weights/output check) * Remove bf16 from compressed_case output types (match original) - Restore FP4 unit tests in dynamic_quantize_gpu_test.cpp: * dynamic_quantization_mxf4e2m1 test (MXFP4 with f8e8m0 scale) * dynamic_quantization_f4e2m1 test (standard FP4) - Restore FP4 functional tests in matmul_weights_decompression.cpp: * Add f4e2m1 to smoke_MatMulCompressedWeights_dyn_quan_mxfp8 test * Add f4e2m1 to smoke_MatMulCompressedWeights_dyn_quan_fp8 test These FP4 changes were lost during merge when target branch introduced new FP8 support that replaced/restructured some of the original FP4 tests.
merezman
marked this pull request as ready for review
July 17, 2026 12:28
tkrupa-intel
self-requested a review
July 17, 2026 12:33
Contributor
There was a problem hiding this comment.
Pull request overview
Enables FP4 (f4e2m1) and MXFP4 (f4e2m1 + f8e8m0 scales) dynamic-quantization support in the Intel GPU plugin, extending the existing FP8 dynamic-quantization path across kernel selector plumbing, OpenCL kernels, oneDNN FC acceptance, and test coverage.
Changes:
- Add FP4/MXFP4 data type support to dynamic_quantize and reorder kernels (kernel selector + OpenCL implementations).
- Extend plugin graph/runtime and oneDNN FC paths to recognize and handle FP4 compressed/dynamic-quantized inputs.
- Add/extend unit + functional tests for FP4 and MXFP4 scenarios.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/plugins/intel_gpu/tests/unit/transformations/convert_fc_to_compressed_test.cpp | Adds FC→FCCompressed transformation tests for FP4 and MXFP4 weights/scales. |
| src/plugins/intel_gpu/tests/unit/test_cases/dynamic_quantize_gpu_test.cpp | Adds unit tests for dynamic quantization outputting FP4 and MXFP4. |
| src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp | Extends matmul decompression functional coverage to FP4/MXFP4 and adjusts thresholds. |
| src/plugins/intel_gpu/src/plugin/transformations/compressed_weights_pattern.hpp | Updates compressed-weights pattern to include FP4 and f8e8m0 types. |
| src/plugins/intel_gpu/src/plugin/common_utils.cpp | Marks f4e2m1 as supported element type in plugin utility checks. |
| src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel.cpp | Enables reorder kernel key support and JIT flags for FP4 input/output. |
| src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_base.cpp | Adjusts reorder calc type selection to handle FP4. |
| src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_ref.cpp | Enables FP4 output type and updates validation/JIT flags. |
| src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt.cpp | Enables FP4 output type and updates JIT flags for optimized kernel. |
| src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.h | Adds FP4 datatype bit to ParamsKey. |
| src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.cpp | Implements enabling FP4 in input/output type keys. |
| src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp | Adds FP4 to datatype string conversion. |
| src/plugins/intel_gpu/src/kernel_selector/jitter.cpp | Adds FP4 type JIT constants and weights-type mapping. |
| src/plugins/intel_gpu/src/kernel_selector/common_types.h | Adds FP4 to Datatype and WeightsType enums. |
| src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data.cl | Implements FP4 unpack/pack logic in reorder kernel. |
| src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/f4_utils.cl | New FP4 conversion/packing utilities for OpenCL kernels. |
| src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/batch_headers/common.cl | Adds FP4 _as_* prefix support for common JIT macros. |
| src/plugins/intel_gpu/src/kernel_selector/cl_kernels/dynamic_quantize_gpu_ref.cl | Extends reference dynamic quantize kernel to FP4 output packing. |
| src/plugins/intel_gpu/src/kernel_selector/cl_kernels/dynamic_quantize_gpu_opt.cl | Extends optimized dynamic quantize kernel to FP4 output packing. |
| src/plugins/intel_gpu/src/graph/primitive_inst.cpp | Allows FP4 as a supported dynamic_quantize output type during shape updates. |
| src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp | Maps FP4 to oneDNN datatype and adjusts offset handling for 4-bit types. |
| src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp | Extends FC oneDNN impl eligibility to FP4 compressed cases. |
| src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.cpp | Treats FP4 inputs as dynamic-quantized inputs for FC handling. |
| src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp | Adds FP4 mappings between clDNN and kernel_selector types. |
| src/plugins/intel_gpu/src/graph/impls/ocl/dynamic_quantize.cpp | Adds FP4 to supported output types list for OCL dynamic_quantize impl. |
| src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/jitter.cpp | Adds FP4 type JIT constants for OCL v2 jitter path. |
| src/plugins/intel_gpu/src/graph/debug_helper.cpp | Adds FP4 dumping support in debug helper. |
| src/common/transformations/src/transformations/fp16_compression/mark_decompression_convert_constant_folding.cpp | Extends compressed-float constant marking to FP4. |
| src/common/low_precision_transformations/src/layer_transformation.cpp | Renames FP8 support accessor and adds FP4 to the supported low-bit float set. |
| src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp | Updates low-precision API declarations for low-bit float support (FP8+FP4). |
Comment on lines
27
to
32
| namespace low_precision { | ||
| namespace precision_set { | ||
| LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_int8_support(); | ||
| LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_fp8_support(); | ||
| LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_low_bit_float_support(); | ||
| LP_TRANSFORMATIONS_API const std::vector<element::Type>& get_int8_int16_int32_support(); | ||
| } // namespace precision_set |
Comment on lines
+856
to
+859
| auto scale_convert = std::make_shared<ov::op::v0::Convert>(scale_const, ov::element::f16); | ||
| auto scale = std::make_shared<ov::op::v1::Multiply>(weights_convert, scale_convert); | ||
| auto no_bias = std::make_shared<ov::intel_gpu::op::Placeholder>(); | ||
| auto fc = std::make_shared<ov::intel_gpu::op::FullyConnected>(input1, scale, no_bias); |
Comment on lines
+866
to
+869
| auto weights_const = ov::op::v0::Constant::create(ov::element::f4e2m1, ov::Shape{ 32, 16 }, { 1 }); | ||
| auto scale_const = ov::op::v0::Constant::create(ov::element::f8e8m0, ov::Shape{ 32, 1 }, { 1 }); | ||
| auto no_bias = std::make_shared<ov::intel_gpu::op::Placeholder>(); | ||
| auto fc_compressed = std::make_shared<ov::intel_gpu::op::FullyConnectedCompressed>(input1, weights_const, no_bias, scale_const); |
Comment on lines
284
to
290
| dump<ov::float8_e5m2>(actual_mem, stream, file_stream, dump_raw); | ||
| else if (mem_dt == cldnn::data_types::f8e4m3) | ||
| dump<ov::float8_e4m3>(actual_mem, stream, file_stream, dump_raw); | ||
| else if (mem_dt == cldnn::data_types::f4e2m1) | ||
| dump<ov::float4_e2m1>(actual_mem, stream, file_stream, dump_raw); | ||
| else if (mem_dt == cldnn::data_types::f8e8m0) | ||
| dump<ov::float8_e8m0>(actual_mem, stream, file_stream, dump_raw); |
Comment on lines
+204
to
210
| if((activations_precision == ov::element::f4e2m1 || weights_precision == ov::element::f4e2m1) && scale_precision_to_use== ov::element::f8e8m0) { | ||
| rel_threshold = threshold_f16; | ||
| } else if (activations_precision == ov::element::f16) { | ||
| abs_threshold = threshold_f16; | ||
| } else { | ||
| abs_threshold = 1e-4f; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details:
Tickets: