Skip to content

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

[CPU] Keep fp8 weights uncompressed for FC with activation rank > 3 (#39484)

Bo Liubba7a8ca8591
diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
index 57aa7f54a42..e810075cb4b 100644
--- a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
+++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
@@ -183,6 +183,10 @@ bool FullyConnected::isSupportedCompressedOperation([[maybe_unused]] const std::
op->get_input_element_type(WEIGHT_ZERO_POINTS) != ov::element::dynamic) {
return false;
}
+ // oneDNN brgemm_matmul has no blocked B layouts for ndims > 3, which fp8 weights require.
+ if (op->get_input_partial_shape(DATA).rank().get_length() > 3) {
+ 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) {
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 230d5f7649d..b90e4ff2d99 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
@@ -93,6 +93,12 @@ const std::vector<MatMulDecompressionShapeParams> input_shapes_fp8_grouped = {
{{{}, {{1, 16, 512}}}, {512, 128}, 128UL},
};
+// oneDNN has no blocked fp8 B layout for ndims > 3, so activations of rank > 3 must fall back to folded weights.
+const std::vector<MatMulDecompressionShapeParams> input_shapes_fp8_rank4 = {
+ {{{}, {{1, 8, 16, 256}}}, {256, 64}},
+ {{{-1, -1, -1, 256}, {{1, 8, 16, 256}, {1, 2, 4, 256}}}, {256, 64}},
+};
+
const std::vector<MatMulDecompressionShapeParams> input_shapes_amx = {
{{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {1, 480, 256}},
{{{}, {{1, 4, 32}}}, {32, 256}},
@@ -224,6 +230,21 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_fp8_wd_grouped_not_suppor
::testing::Values(false)),
MatmulWeightsDecompression::getTestCaseName);
+INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_fp8_wd_rank4_not_supported,
+ MatmulWeightsDecompression,
+ ::testing::Combine(::testing::ValuesIn(input_shapes_fp8_rank4),
+ ::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),