Skip to content

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

[CPU] Enable FP8 weights decompression via oneDNN MatMul (#38061)

Bo Liufd0dbeff5cd1
diff --git a/src/common/transformations/src/transformations/op_conversions/convert_fc_to_compressed.cpp b/src/common/transformations/src/transformations/op_conversions/convert_fc_to_compressed.cpp
index 584a748b6b1..b92f87ba9c4 100644
--- a/src/common/transformations/src/transformations/op_conversions/convert_fc_to_compressed.cpp
+++ b/src/common/transformations/src/transformations/op_conversions/convert_fc_to_compressed.cpp
@@ -23,6 +23,7 @@
#include "ov_ops/fully_connected.hpp"
#include "ov_ops/fully_connected_compressed.hpp"
#include "transformations/pattern_blocks/compressed_weights_block.hpp"
+#include "transformations/rt_info/disable_precision_conversion.hpp"
#include "transformations/utils/utils.hpp"
namespace v0 = ov::op::v0;
@@ -210,6 +211,13 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyCon
const size_t IC = *(weights_shape.rbegin());
const size_t OC = *(weights_shape.rbegin() + 1);
const size_t G = grouped ? (has_transpose ? *(scale_shape.rbegin() + 2) : *(scale_shape.rbegin() + 1)) : 1;
+ // The flags are not copyable and are needed by supports_config
+ if (ov::is_conversion_disabled(fc, element::f16)) {
+ ov::disable_conversion(new_fc, element::f16);
+ }
+ if (ov::is_conversion_disabled(fc, element::f32, element::bf16)) {
+ ov::disable_conversion(new_fc, element::f32, element::bf16);
+ }
if (supports_config && !supports_config(new_fc, IC, OC, G))
return false;
diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_matmul_primitive.cpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_matmul_primitive.cpp
index 4c093c8349c..bd275fcca4f 100644
--- a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_matmul_primitive.cpp
+++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_matmul_primitive.cpp
@@ -44,6 +44,9 @@
#if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
# include <cpu/x64/cpu_isa_traits.hpp>
#endif
+#if defined(OPENVINO_ARCH_X86_64)
+# include "utils/precision_support.h"
+#endif
namespace ov::intel_cpu {
@@ -514,6 +517,13 @@ bool DnnlMatMulPrimitive::useWeightsDecompressionImpl(const ov::element::Type in
}
#endif
+#if defined(OPENVINO_ARCH_X86_64)
+ // bf16/f16 x fp8: copy-B upconverts the weights to xf16, then a plain xf16 GEMM runs.
+ if (any_of(weightsType, f8e4m3, f8e5m2)) {
+ return hasFp8WeightsDecompressionSupport(inputType);
+ }
+#endif
+
return (any_of(inputType, f32, bf16, f16) && any_of(weightsType, u8, i8, u4, i4));
}
@@ -543,18 +553,31 @@ DnnlShapeAgnosticDataPtr DnnlMatMulPrimitive::createShapeAgnosticData(const MatM
createPrimitiveAttrs(attrs, memory, context, useWeightsDecompression, attrs.weightsNonTransposed);
if (srcDesc->getShape().isDynamic() || weiDesc->getShape().isDynamic()) {
- const auto& srcShape = srcDesc->getShape();
- const auto& weiShape = weiDesc->getShape();
- auto [inDymmyDims, weiDymmyDims] =
- makeDummyInputDims(srcShape, weiShape, dstDesc->getShape(), attrs.transposeA, attrs.transposeB);
- const auto& outDymmyDims = makeDummyOutputDims(inDymmyDims,
- weiDymmyDims,
- attrs.transposeA,
- attrs.transposeB,
- dstDesc->getShape().getRank());
- srcDesc = std::make_shared<DnnlBlockedMemoryDesc>(srcDesc->getPrecision(), Shape(inDymmyDims));
- weiDesc = std::make_shared<DnnlBlockedMemoryDesc>(weiDesc->getPrecision(), Shape(weiDymmyDims));
- dstDesc = std::make_shared<DnnlBlockedMemoryDesc>(dstDesc->getPrecision(), Shape(outDymmyDims));
+ if (attrs.fcSemantic && srcDesc->getShape().getRank() != weiDesc->getShape().getRank()) {
+ // FC semantic: rank-2 static weights with possibly higher-rank dynamic src/dst, so
+ // only src/dst get dummy dims; K == IC and N == OC are taken from the [OC, IC] weights.
+ const auto& weiDims = weiDesc->getShape().getStaticDims();
+ auto srcDummyDims = MemoryDescUtils::makeDummyShape(srcDesc->getShape()).getStaticDims();
+ srcDummyDims.back() = weiDims[weiDims.size() - 1];
+ auto dstDummyDims = srcDummyDims;
+ dstDummyDims.back() = weiDims[weiDims.size() - 2];
+
+ srcDesc = std::make_shared<DnnlBlockedMemoryDesc>(srcDesc->getPrecision(), Shape(srcDummyDims));
+ dstDesc = std::make_shared<DnnlBlockedMemoryDesc>(dstDesc->getPrecision(), Shape(dstDummyDims));
+ } else {
+ const auto& srcShape = srcDesc->getShape();
+ const auto& weiShape = weiDesc->getShape();
+ auto [inDymmyDims, weiDymmyDims] =
+ makeDummyInputDims(srcShape, weiShape, dstDesc->getShape(), attrs.transposeA, attrs.transposeB);
+ const auto& outDymmyDims = makeDummyOutputDims(inDymmyDims,
+ weiDymmyDims,
+ attrs.transposeA,
+ attrs.transposeB,
+ dstDesc->getShape().getRank());
+ srcDesc = std::make_shared<DnnlBlockedMemoryDesc>(srcDesc->getPrecision(), Shape(inDymmyDims));
+ weiDesc = std::make_shared<DnnlBlockedMemoryDesc>(weiDesc->getPrecision(), Shape(weiDymmyDims));
+ dstDesc = std::make_shared<DnnlBlockedMemoryDesc>(dstDesc->getPrecision(), Shape(outDymmyDims));
+ }
}
const dnnl::memory::desc srcDnnlDesc = MemoryDescUtils::convertToDnnlMemoryDesc(srcDesc)->getDnnlDesc();
diff --git a/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp
index 2ce2c13f73f..ec5b3381525 100644
--- a/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp
+++ b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp
@@ -32,6 +32,7 @@
#include "utils/arch_macros.h"
#include "utils/debug_capabilities.h"
#include "utils/general_utils.h"
+#include "utils/precision_support.h"
#if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
# include <common/memory_desc_wrapper.hpp>
@@ -158,6 +159,11 @@ static const TypeMapping dnnlMatMulTypeMapping {
{{_u8 | _i8, _i8, _any, _any}, {bypass(), bypass(), just<f32>(), just<f32>()}},
// compresses int weights
{{_f32 | _bf16 | _f16, _u8 | _i8, _any, _any}, {bypass(), bypass(), use<0>(), use<0>()}},
+ // fp8 weights are decompressed inside the matmul kernel
+ {{_bf16, _f8e4m3 | _f8e5m2, _any, _any}, {bypass(), bypass(), use<0>(), use<0>()},
+ []() { return hasFp8WeightsDecompressionSupport(ov::element::bf16); }},
+ {{_f16, _f8e4m3 | _f8e5m2, _any, _any}, {bypass(), bypass(), use<0>(), use<0>()},
+ []() { return hasFp8WeightsDecompressionSupport(ov::element::f16); }},
// @todo should we fallback to FPXX instead of _f32?
{{_any, _any, _any, _any}, {just<f32>(), just<f32>(), just<f32>(), just<f32>()}},
// @todo explicitly cover configuration limitations for oneDNN on ARM
@@ -165,7 +171,11 @@ static const TypeMapping dnnlMatMulTypeMapping {
// clang-format on
[[maybe_unused]] static inline bool noWeightsDecompression(const FCConfig& config) {
- return !DnnlFCPrimitive::useWeightsDecompressionImpl(srcType(config), weiType(config), config.attrs.modelType);
+ // fp8 weights are decompressed by dnnl::matmul rather than by the dnnl FC primitive
+ const bool fp8Decompression = any_of(weiType(config), f8e4m3, f8e5m2) &&
+ DnnlMatMulPrimitive::useWeightsDecompressionImpl(srcType(config), weiType(config));
+ return !fp8Decompression &&
+ !DnnlFCPrimitive::useWeightsDecompressionImpl(srcType(config), weiType(config), config.attrs.modelType);
}
[[maybe_unused]] static inline bool noSparseDecompression(const FCConfig& config) {
@@ -185,6 +195,10 @@ static const TypeMapping dnnlMatMulTypeMapping {
if (any_of(srcType(config), i32) && any_of(weiType(config), i32)) {
return true;
}
+ // bf16/f16 activations with fp8 weights decompression
+ if (any_of(weiType(config), f8e4m3, f8e5m2)) {
+ return DnnlMatMulPrimitive::useWeightsDecompressionImpl(srcType(config), weiType(config));
+ }
// support integer type quantization matmul
return any_of(srcType(config), u8, i8) && any_of(weiType(config), u8, i8);
}
@@ -415,6 +429,11 @@ const std::vector<ExecutorImplementation<FCAttrs>>& getImplementations() {
})
VERIFY(dnnlMatMulSupportedPrecision(config), UNSUPPORTED_SRC_WEI_PRECISIONS);
VERIFY(noSparseDecompression(config), UNSUPPORTED_SPARSE_WEIGHTS);
+ // fp8 decompression uses rank-2 [OC, IC] weights
+ if (any_of(weiType(config), f8e4m3, f8e5m2)) {
+ VERIFY(weiRank(config) == 2U, UNSUPPORTED_WEI_RANK);
+ return true;
+ }
VERIFY(weiRank(config) == 3U, UNSUPPORTED_WEI_RANK);
VERIFY(weiDims(config)[0] > 1, UNSUPPORTED_WEI_RANK);
return true;
diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
index 8887a65ec2f..d71a19384f4 100644
--- a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
+++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
@@ -51,6 +51,10 @@
#include "transformations/utils/utils.hpp"
#include "utils/debug_capabilities.h"
#include "utils/general_utils.h"
+#if defined(OPENVINO_ARCH_X86_64)
+# include "transformations/rt_info/disable_precision_conversion.hpp"
+# include "utils/precision_support.h"
+#endif
#if defined(OV_CPU_WITH_KLEIDIAI)
# include "openvino/core/shape.hpp"
# include "utils/arm_isa_support.h"
@@ -61,7 +65,7 @@ using namespace ov::element;
namespace ov::intel_cpu::node {
-ov::element::TypeVector FullyConnected::getSupportedCompressedWeightsTypes([[maybe_unused]] bool apply_fp8) {
+ov::element::TypeVector FullyConnected::getSupportedCompressedWeightsTypes() {
using ov::element::Type_t;
bool useMatmulPrim = false;
@@ -71,12 +75,15 @@ ov::element::TypeVector FullyConnected::getSupportedCompressedWeightsTypes([[may
return {Type_t::u8, Type_t::i8};
}
#if defined(OPENVINO_ARCH_X86_64)
- ov::element::TypeVector supportedDataTypes =
- {Type_t::u8, Type_t::i8, Type_t::u4, Type_t::i4, Type_t::nf4, Type_t::f4e2m1, Type_t::u2};
- if (apply_fp8) {
- supportedDataTypes.insert(supportedDataTypes.end(), {Type_t::f8e4m3, Type_t::f8e5m2});
- }
- return supportedDataTypes;
+ return {Type_t::u8,
+ Type_t::i8,
+ Type_t::u4,
+ Type_t::i4,
+ Type_t::nf4,
+ Type_t::f4e2m1,
+ Type_t::u2,
+ Type_t::f8e4m3,
+ Type_t::f8e5m2};
#elif defined(OV_CPU_WITH_KLEIDIAI)
// Symmetric weight-only compression uses i4. Asymmetric groupwise
// compression exported by Optimum uses u4 weights plus u4 zero-points.
@@ -96,14 +103,8 @@ ov::element::TypeVector FullyConnected::getSupportedCompressedActivationsTypes()
return {Type_t::f32, Type_t::f16};
}
#if defined(OPENVINO_ARCH_X86_64)
- // BF16 compressed-activations path is intended for SIMD (avx512_vnni)
- // dynamic-quant kernels. On AMX-capable HW, AMX BF16 TMUL outperforms
- // VNNI int8 on prefill, so keep f32 here and let the existing AMX BF16
- // path handle bf16 inference precision.
- if (ov::with_cpu_x86_avx512_core_amx()) {
- return {Type_t::f32};
- }
- return {Type_t::f32, Type_t::bf16};
+ // f16 is accepted only for fp8 weights, see isSupportedCompressedOperation()
+ return {Type_t::f32, Type_t::bf16, Type_t::f16};
#elif defined(OV_CPU_WITH_KLEIDIAI)
return {Type_t::f32};
#else
@@ -158,6 +159,46 @@ bool FullyConnected::isSupportedCompressedOperation([[maybe_unused]] const std::
return false;
}
+ const auto weightsPrecision = op->get_input_element_type(WEIGHTS);
+ if (any_of(weightsPrecision, ov::element::f8e4m3, ov::element::f8e5m2)) {
+ // No f32 x fp8 kernel, so the constant is folded unless the activations end up bf16/f16.
+ // f32 counts as bf16 under the bf16 hint (enforced later) unless the node is excluded from it.
+ auto activationPrecision = op->get_input_element_type(DATA);
+ if (activationPrecision == ov::element::f32 && config.inferencePrecision == ov::element::bf16 &&
+ !ov::is_conversion_disabled(op, ov::element::f16) &&
+ !ov::is_conversion_disabled(op, ov::element::f32, ov::element::bf16)) {
+ activationPrecision = ov::element::bf16;
+ }
+ if (!hasFp8WeightsDecompressionSupport(activationPrecision)) {
+ return false;
+ }
+ // Grouped scales over IC are rejected by oneDNN for fp8 weights
+ // (brgemm_matmul_utils.cpp, per-K weight scales check).
+ if (G != 1) {
+ return false;
+ }
+ // The fp8 dequantization scheme is scale-only.
+ if (op->get_input_size() > WEIGHT_ZERO_POINTS &&
+ op->get_input_element_type(WEIGHT_ZERO_POINTS) != ov::element::dynamic) {
+ return false;
+ }
+ // Weights must be a real 2D [OC, IC] constant, not broadcast by the scale multiply.
+ const auto& weightsShape = op->get_input_shape(WEIGHTS);
+ if (weightsShape.size() != 2 || weightsShape[0] != OC || weightsShape[1] != IC) {
+ return false;
+ }
+ // Same shape limits as the other weights decompression paths.
+ return IC >= 4 && OC != 1;
+ }
+
+ bool useMatmulPrim = false;
+ CPU_DEBUG_CAP_ENABLE(useMatmulPrim = getEnvBool("OV_CPU_ENABLE_DNNL_MAMTUL_FOR_FC");)
+ // At the moment there is no implementation supporting integer weights decompression with f16 input
+ // (subject to change once we completely switch to dnnl::matmul).
+ if (!useMatmulPrim && op->get_input_element_type(DATA) == ov::element::f16) {
+ return false;
+ }
+
if (ov::with_cpu_x86_avx512_core_amx() && config.inferencePrecision == ov::element::bf16) {
// OneDNN AMX IP implementation has limited shapes support due to performance considerations. As a
// current solution conditions below are copied from OneDNN to make sure correct IP impl will be
diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.h b/src/plugins/intel_cpu/src/nodes/fullyconnected.h
index 9b1d9802a38..547615eeb8e 100644
--- a/src/plugins/intel_cpu/src/nodes/fullyconnected.h
+++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.h
@@ -77,7 +77,7 @@ public:
size_t OC,
size_t G,
const Config& config) noexcept;
- static ov::element::TypeVector getSupportedCompressedWeightsTypes(bool apply_fp8 = false);
+ static ov::element::TypeVector getSupportedCompressedWeightsTypes();
static ov::element::TypeVector getSupportedCompressedActivationsTypes();
bool isExecutable() const override {
diff --git a/src/plugins/intel_cpu/src/nodes/gathermatmul.cpp b/src/plugins/intel_cpu/src/nodes/gathermatmul.cpp
index 301797be4eb..5fbabe0a665 100644
--- a/src/plugins/intel_cpu/src/nodes/gathermatmul.cpp
+++ b/src/plugins/intel_cpu/src/nodes/gathermatmul.cpp
@@ -166,7 +166,7 @@ bool GatherMatmul::isSupportedCompressedOperation([[maybe_unused]] const std::sh
#endif
}
-ov::element::TypeVector GatherMatmul::getSupportedCompressedWeightsTypes([[maybe_unused]] bool apply_fp8) {
+ov::element::TypeVector GatherMatmul::getSupportedCompressedWeightsTypes() {
using ov::element::Type_t;
#ifdef OPENVINO_ARCH_X86_64
return {Type_t::u8, Type_t::i8, Type_t::u4, Type_t::i4};
diff --git a/src/plugins/intel_cpu/src/nodes/gathermatmul.h b/src/plugins/intel_cpu/src/nodes/gathermatmul.h
index 1513ee600b0..abd769bd095 100644
--- a/src/plugins/intel_cpu/src/nodes/gathermatmul.h
+++ b/src/plugins/intel_cpu/src/nodes/gathermatmul.h
@@ -43,7 +43,7 @@ public:
size_t OC,
size_t G,
const Config& config) noexcept;
- static ov::element::TypeVector getSupportedCompressedWeightsTypes(bool apply_fp8 = false);
+ static ov::element::TypeVector getSupportedCompressedWeightsTypes();
static ov::element::TypeVector getSupportedCompressedActivationsTypes();
private:
diff --git a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp
index f17553e506b..483afbdf08a 100644
--- a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp
+++ b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp
@@ -23,6 +23,7 @@ impl_desc_type parse_impl_name(std::string impl_desc_name) {
REPLACE_WORD(brg_conv, brgconv);
REPLACE_WORD(brdgmm, brgconv);
REPLACE_WORD(avx10_1_512, avx512);
+ REPLACE_WORD(avx10_2, avx512);
REPLACE_WORD(brg_matmul, brgemm);
REPLACE_WORD(simple, ref);
diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
index bdb786f8905..2b7a56d025c 100644
--- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
+++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
@@ -478,8 +478,7 @@ void Transformations::PreLpt(const std::vector<ov::element::Type>& defaultPrecis
// We need to fuse Transpose to MatMul to have a simpler callback for the next transformation
CPU_REGISTER_PASS_X64(decompression_handling_manager, ov::pass::TransposeMatMul);
CPU_REGISTER_PASS_ARM(decompression_handling_manager, ov::pass::TransposeMatMul);
- const auto& decompression_precisions =
- ov::intel_cpu::node::FullyConnected::getSupportedCompressedWeightsTypes(true);
+ const auto& decompression_precisions = ov::intel_cpu::node::FullyConnected::getSupportedCompressedWeightsTypes();
CPU_REGISTER_PASS_COMMON(decompression_handling_manager,
ov::pass::MarkDequantization,
decompression_precisions,
diff --git a/src/plugins/intel_cpu/src/utils/precision_support.cpp b/src/plugins/intel_cpu/src/utils/precision_support.cpp
index b55b94ea85c..5efca59dc10 100644
--- a/src/plugins/intel_cpu/src/utils/precision_support.cpp
+++ b/src/plugins/intel_cpu/src/utils/precision_support.cpp
@@ -46,6 +46,24 @@ bool hasHardwareSupport(const ov::element::Type& precision) {
}
}
+bool hasFp8WeightsDecompressionSupport([[maybe_unused]] ov::element::Type activationPrecision) {
+#if defined(OPENVINO_ARCH_X86_64)
+ using namespace dnnl::impl::cpu::x64;
+ switch (activationPrecision) {
+ case ov::element::f16:
+ // no native f16 compute on Sapphire Rapids, so it is excluded
+ return mayiuse(avx512_core_amx_fp16) || mayiuse(avx10_2);
+ case ov::element::bf16:
+ return mayiuse(avx512_core_amx) || mayiuse(avx10_2);
+ default:
+ // oneDNN has no f32 x fp8 configuration (including ACCURACY mode's dynamic)
+ return false;
+ }
+#else
+ return false;
+#endif
+}
+
ov::element::Type defaultFloatPrecision() {
if (hasHardwareSupport(ov::element::f16)) {
return ov::element::f16;
diff --git a/src/plugins/intel_cpu/src/utils/precision_support.h b/src/plugins/intel_cpu/src/utils/precision_support.h
index 7ba32e6bf79..ecbb88ad9f5 100644
--- a/src/plugins/intel_cpu/src/utils/precision_support.h
+++ b/src/plugins/intel_cpu/src/utils/precision_support.h
@@ -11,4 +11,14 @@ namespace ov::intel_cpu {
bool hasHardwareSupport(const ov::element::Type& precision);
ov::element::Type defaultFloatPrecision();
+/**
+ * @brief Whether fp8 (f8e4m3 / f8e5m2) weights may be kept compressed down to the
+ * oneDNN primitive and decompressed inside the kernel, for the given
+ * activation precision. Mirrors oneDNN's own ISA gate for the brgemm_matmul
+ * `is_bf16_fp8` / `is_f16_fp8` configurations. `ov::element::dynamic` is a
+ * real, valid input here (ACCURACY execution mode), not a wildcard - it
+ * correctly resolves to false, same as f32.
+ */
+bool hasFp8WeightsDecompressionSupport(ov::element::Type activationPrecision);
+
} // namespace ov::intel_cpu
diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/matmul_weights_decompression.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/matmul_weights_decompression.cpp
index 596303c5ba4..4462f12359b 100644
--- a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/matmul_weights_decompression.cpp
+++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/matmul_weights_decompression.cpp
@@ -142,6 +142,17 @@ void MatmulWeightsDecompression::check_results() {
type = fc->get_rt_info().at(ov::exec_model_info::LAYER_TYPE).as<std::string>();
EXPECT_EQ(type, "FullyConnected");
+#if defined(OPENVINO_ARCH_X86_64)
+ if (use_matmul_decompression_impl &&
+ (compressed_weights_precision == ov::element::f8e4m3 || compressed_weights_precision == ov::element::f8e5m2)) {
+ // fp8 weights stay compressed only with the oneDNN brgemm matmul kernel;
+ // this also guards impl name parsing of the ISA.
+ const auto implType = fc->get_rt_info().at(ov::exec_model_info::IMPL_TYPE).as<std::string>();
+ EXPECT_NE(implType.find("brgemm"), std::string::npos) << "unexpected impl type: " << implType;
+ EXPECT_NE(implType.find("avx512"), std::string::npos) << "unexpected impl type: " << implType;
+ }
+#endif
+
const auto& expected_weights_precision =
use_matmul_decompression_impl ? compressed_weights_precision : fc->get_input_element_type(0);
EXPECT_EQ(fc->get_input_element_type(1), expected_weights_precision);
diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/matmul_weights_decompression.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/matmul_weights_decompression.cpp
index 0f870a141ee..e56582ce7a6 100644
--- a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/matmul_weights_decompression.cpp
+++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/matmul_weights_decompression.cpp
@@ -5,6 +5,7 @@
#include "custom/subgraph_tests/src/classes/matmul_weights_decompression.hpp"
#include "common_test_utils/subgraph_builders/weights_decompression_builders.hpp"
+#include "utils/precision_support.h"
using namespace CPUTestUtils;
@@ -18,6 +19,24 @@ std::vector<ov::AnyMap> filter_additional_config_basic() {
std::vector<ov::AnyMap> additional_config = {{ov::hint::dynamic_quantization_group_size(0)}};
return additional_config;
}
+const ov::AnyMap fp8_accuracy_mode_config = {ov::hint::dynamic_quantization_group_size(0),
+ ov::hint::execution_mode(ov::hint::ExecutionMode::ACCURACY)};
+
+// fp8 weights decompression needs a bf16/f16 inference precision; each one is gated
+// independently since e.g. Sapphire Rapids supports bf16 but not f16.
+std::vector<ov::AnyMap> get_additional_config_fp8_wd() {
+ std::vector<ov::AnyMap> additional_config = {};
+ if (ov::intel_cpu::hasFp8WeightsDecompressionSupport(ov::element::bf16)) {
+ additional_config.push_back(
+ {{ov::hint::dynamic_quantization_group_size(0), ov::hint::inference_precision(ov::element::bf16)}});
+ }
+ if (ov::intel_cpu::hasFp8WeightsDecompressionSupport(ov::element::f16)) {
+ additional_config.push_back(
+ {{ov::hint::dynamic_quantization_group_size(0), ov::hint::inference_precision(ov::element::f16)}});
+ }
+ return additional_config;
+}
+
std::vector<ov::AnyMap> filter_additional_config_amx() {
std::vector<ov::AnyMap> additional_config = {};
if (ov::with_cpu_x86_avx512_core_amx())
@@ -52,6 +71,28 @@ const std::vector<MatMulDecompressionShapeParams> input_shapes_basic_u2 = {
{{{}, {{1, 4, 48}}}, {48, 256}},
{{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {1, 480, 256}},
};
+// Cover blocked-B layouts (N = 64/48/32/16), N/K tails, M == 1, dynamic M and LLM-sized shapes.
+const std::vector<MatMulDecompressionShapeParams> input_shapes_fp8_wd = {
+ {{{}, {{1, 16, 256}}}, {256, 64}},
+ {{{}, {{1, 16, 256}}}, {256, 48}},
+ {{{}, {{1, 16, 256}}}, {256, 32}},
+ {{{}, {{1, 16, 256}}}, {256, 16}},
+ {{{}, {{1, 16, 260}}}, {260, 77}},
+ {{{}, {{1, 11, 154}}}, {154, 77}},
+ {{{}, {{1, 8, 18}}}, {18, 32}},
+ {{{}, {{1, 8, 6}}}, {6, 32}},
+ {{{}, {{1, 1, 480}}}, {480, 256}},
+ {{{-1, -1, 480}, {{1, 17, 480}, {1, 1, 480}}}, {480, 256}},
+ {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {480, 256}},
+ {{{}, {{1, 128, 512}}}, {512, 1024}},
+};
+
+// Grouped scales are rejected by oneDNN for fp8 weights, so these must fall back to folded weights.
+const std::vector<MatMulDecompressionShapeParams> input_shapes_fp8_grouped = {
+ {{{}, {{1, 8, 256}}}, {256, 64}, 64UL},
+ {{{}, {{1, 16, 512}}}, {512, 128}, 128UL},
+};
+
const std::vector<MatMulDecompressionShapeParams> input_shapes_amx = {
{{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {1, 480, 256}},
{{{}, {{1, 4, 32}}}, {32, 256}},
@@ -99,6 +140,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic_u2,
::testing::Values(true)),
MatmulWeightsDecompression::getTestCaseName);
+// f32 inference precision: fp8 weights must be folded on every platform.
INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic_fp8,
MatmulWeightsDecompression,
::testing::Combine(::testing::ValuesIn(input_shapes_basic),
@@ -115,6 +157,55 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic_fp8,
::testing::Values(false)),
MatmulWeightsDecompression::getTestCaseName);
+// fp8 weights decompression engaged: bf16/f16 activations, scale-only dequantization.
+INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_fp8_wd,
+ MatmulWeightsDecompression,
+ ::testing::Combine(::testing::ValuesIn(input_shapes_fp8_wd),
+ ::testing::ValuesIn(weights_precisions_fp8),
+ ::testing::ValuesIn(decompression_precisions),
+ ::testing::Values(ov::element::dynamic),
+ ::testing::Values(true),
+ ::testing::Values(DecompressionType::full),
+ ::testing::Values(DecompressionType::empty),
+ ::testing::Values(false),
+ ::testing::ValuesIn(get_additional_config_fp8_wd()),
+ ::testing::ValuesIn(fusing_params),
+ ::testing::Values(true)),
+ MatmulWeightsDecompression::getTestCaseName);
+
+// ACCURACY mode without an inference_precision hint must fold fp8 weights on every platform.
+INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_fp8_wd_accuracy_mode_not_supported,
+ MatmulWeightsDecompression,
+ ::testing::Combine(::testing::ValuesIn(input_shapes_fp8_wd),
+ ::testing::ValuesIn(weights_precisions_fp8),
+ ::testing::ValuesIn(decompression_precisions),
+ ::testing::Values(ov::element::dynamic),
+ ::testing::Values(true),
+ ::testing::Values(DecompressionType::full),
+ ::testing::Values(DecompressionType::empty),
+ ::testing::Values(false),
+ ::testing::Values(fp8_accuracy_mode_config),
+ ::testing::ValuesIn(fusing_params),
+ ::testing::Values(false)),
+ MatmulWeightsDecompression::getTestCaseName);
+
+// Grouped (per-IC-group) fp8 scales are not applied by the fp8 copy-B kernel, so
+// these must fall back to folded weights as well.
+INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_fp8_wd_grouped_not_supported,
+ MatmulWeightsDecompression,
+ ::testing::Combine(::testing::ValuesIn(input_shapes_fp8_grouped),
+ ::testing::ValuesIn(weights_precisions_fp8),
+ ::testing::ValuesIn(decompression_precisions),
+ ::testing::Values(ov::element::dynamic),
+ ::testing::Values(true),
+ ::testing::Values(DecompressionType::full),
+ ::testing::Values(DecompressionType::empty),
+ ::testing::Values(false),
+ ::testing::ValuesIn(get_additional_config_fp8_wd()),
+ ::testing::ValuesIn(fusing_params),
+ ::testing::Values(false)),
+ MatmulWeightsDecompression::getTestCaseName);
+
INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_amx,
MatmulWeightsDecompression,
::testing::Combine(::testing::ValuesIn(input_shapes_amx),
diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn
index a2b68ecbe3d..885d61d768b 160000
--- a/src/plugins/intel_cpu/thirdparty/onednn
+++ b/src/plugins/intel_cpu/thirdparty/onednn
@@ -1 +1 @@
-Subproject commit a2b68ecbe3dbce66701937a34482e34ba681acac
+Subproject commit 885d61d768b7ddb950c3604ba6a44d8f3d2133b2