Skip to content

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

[CPU] Improve compilation time of fp8 LLM (#29167)

Chen Xu9dde515bf5f5
diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
index 93a08495e79..77424aab90e 100644
--- a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
+++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp
@@ -39,7 +39,7 @@ using namespace ov::element;
namespace ov::intel_cpu::node {
-ov::element::TypeVector FullyConnected::getSupportedCompressedWeightsTypes() {
+ov::element::TypeVector FullyConnected::getSupportedCompressedWeightsTypes(bool apply_fp8) {
using ov::element::Type_t;
bool useMatmulPrim = false;
@@ -49,7 +49,12 @@ ov::element::TypeVector FullyConnected::getSupportedCompressedWeightsTypes() {
return {Type_t::u8, Type_t::i8};
}
#if defined(OPENVINO_ARCH_X86_64)
- return {Type_t::u8, Type_t::i8, Type_t::u4, Type_t::i4, Type_t::nf4, Type_t::f4e2m1};
+ ov::element::TypeVector supportedDataTypes =
+ {Type_t::u8, Type_t::i8, Type_t::u4, Type_t::i4, Type_t::nf4, Type_t::f4e2m1};
+ if (apply_fp8) {
+ supportedDataTypes.insert(supportedDataTypes.end(), {Type_t::f8e4m3, Type_t::f8e5m2});
+ }
+ return supportedDataTypes;
#else
return {};
#endif
diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.h b/src/plugins/intel_cpu/src/nodes/fullyconnected.h
index 46d7c7dc1f0..40391043d0c 100644
--- a/src/plugins/intel_cpu/src/nodes/fullyconnected.h
+++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.h
@@ -72,7 +72,7 @@ public:
size_t OC,
size_t G,
ov::element::Type inferencePrecision) noexcept;
- static ov::element::TypeVector getSupportedCompressedWeightsTypes();
+ static ov::element::TypeVector getSupportedCompressedWeightsTypes(bool apply_fp8 = false);
static ov::element::TypeVector getSupportedCompressedActivationsTypes();
bool isExecutable() const override {
diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
index 316c984dc05..40e0ee1e389 100644
--- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
+++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
@@ -364,7 +364,8 @@ 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();
+ const auto& decompression_precisions =
+ ov::intel_cpu::node::FullyConnected::getSupportedCompressedWeightsTypes(true);
CPU_REGISTER_PASS_COMMON(decompression_handling_manager,
ov::pass::MarkDequantization,
decompression_precisions,
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 656847b37a4..ab1a20e063c 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
@@ -29,6 +29,8 @@ const std::vector<ov::test::ElementType> weights_precisions = {ov::element::u8,
ov::element::i4,
ov::element::nf4};
+const std::vector<ov::test::ElementType> weights_precisions_fp8 = {ov::element::f8e4m3, ov::element::f8e5m2};
+
const std::vector<MatMulDecompressionShapeParams> input_shapes_basic = {
{{{-1, -1, -1}, {{1, 4, 16}, {10, 16, 16}}}, {16, 32}},
{{{}, {{1, 8, 16}}}, {16, 32}, 4ul},
@@ -65,6 +67,22 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic,
::testing::Values(true)),
MatmulWeightsDecompression::getTestCaseName);
+INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic_fp8,
+ MatmulWeightsDecompression,
+ ::testing::Combine(::testing::ValuesIn(input_shapes_basic),
+ ::testing::ValuesIn(weights_precisions_fp8),
+ ::testing::ValuesIn(decompression_precisions),
+ ::testing::Values(ov::element::dynamic),
+ ::testing::Values(true),
+ ::testing::Values(DecompressionType::full),
+ ::testing::Values(DecompressionType::full),
+ // todo: zero points converted to fp32 for reshape == true case
+ ::testing::Values(false),
+ ::testing::ValuesIn(filter_additional_config_basic()),
+ ::testing::ValuesIn(fusing_params),
+ ::testing::Values(false)),
+ MatmulWeightsDecompression::getTestCaseName);
+
INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_amx,
MatmulWeightsDecompression,
::testing::Combine(::testing::ValuesIn(input_shapes_amx),