Skip to content

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

[GPU] Keep GatherMatmul conversion with OV_GPU_MOE_DISABLE_FUSION (#38660)

Vladislav Golubev21b9d1d8207b
diff --git a/src/common/transformations/include/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.hpp b/src/common/transformations/include/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.hpp
index 7e262e56386..a8275d13e4a 100644
--- a/src/common/transformations/include/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.hpp
+++ b/src/common/transformations/include/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.hpp
@@ -90,7 +90,11 @@ class TRANSFORMATIONS_API ConvertTiledMoeBlockToGatherMatmuls;
class ov::pass::ConvertTiledMoeBlockTo2GatherMatmuls : public ov::pass::MatcherPass {
public:
OPENVINO_MATCHER_PASS_RTTI("ConvertTiledMoeBlockTo2GatherMatmuls");
- ConvertTiledMoeBlockTo2GatherMatmuls(const std::vector<ov::element::Type>& supported_weights_types = {});
+ ConvertTiledMoeBlockTo2GatherMatmuls(const std::vector<ov::element::Type>& supported_weights_types = {},
+ const std::vector<ov::element::Type>& supported_activation_types = {
+ ov::element::f32,
+ ov::element::f16,
+ ov::element::bf16});
};
// ============================================================================
@@ -150,15 +154,27 @@ public:
class ov::pass::ConvertTiledMoeBlockTo3GatherMatmuls : public ov::pass::MatcherPass {
public:
OPENVINO_MATCHER_PASS_RTTI("ConvertTiledMoeBlockTo3GatherMatmuls");
- ConvertTiledMoeBlockTo3GatherMatmuls(const std::vector<ov::element::Type>& supported_weights_types = {});
+ ConvertTiledMoeBlockTo3GatherMatmuls(const std::vector<ov::element::Type>& supported_weights_types = {},
+ const std::vector<ov::element::Type>& supported_activation_types = {
+ ov::element::f32,
+ ov::element::f16,
+ ov::element::bf16});
};
// CPU uses BGM-producing passes only (stops at BGMs)
+// supported_weights_types: if not empty, only blocks with compressed expert weights of these types are converted.
+// supported_activation_types: only blocks with experts_input of these types are converted.
class ov::pass::ConvertTiledMoeBlockToGatherMatmuls : public ov::pass::GraphRewrite {
public:
OPENVINO_GRAPH_REWRITE_RTTI("ConvertTiledMoeBlockToGatherMatmuls");
- explicit ConvertTiledMoeBlockToGatherMatmuls(const std::vector<ov::element::Type>& supported_weights_types = {}) {
- add_matcher<ov::pass::ConvertTiledMoeBlockTo2GatherMatmuls>(supported_weights_types);
- add_matcher<ov::pass::ConvertTiledMoeBlockTo3GatherMatmuls>(supported_weights_types);
+ explicit ConvertTiledMoeBlockToGatherMatmuls(const std::vector<ov::element::Type>& supported_weights_types = {},
+ const std::vector<ov::element::Type>& supported_activation_types = {
+ ov::element::f32,
+ ov::element::f16,
+ ov::element::bf16}) {
+ add_matcher<ov::pass::ConvertTiledMoeBlockTo2GatherMatmuls>(supported_weights_types,
+ supported_activation_types);
+ add_matcher<ov::pass::ConvertTiledMoeBlockTo3GatherMatmuls>(supported_weights_types,
+ supported_activation_types);
}
};
diff --git a/src/common/transformations/src/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.cpp b/src/common/transformations/src/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.cpp
index c3276ccdd99..3fcaae1369d 100644
--- a/src/common/transformations/src/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.cpp
+++ b/src/common/transformations/src/transformations/common_optimizations/convert_tiled_moe_block_to_gather_matmuls.cpp
@@ -79,10 +79,12 @@ struct MOE2GEMMPatternNodes {
std::shared_ptr<ov::Node> reduce_sum;
};
-MOE2GEMMPatternNodes build_2gemm_pattern(const std::vector<ov::element::Type>& supported_weights_types) {
+MOE2GEMMPatternNodes build_2gemm_pattern(const std::vector<ov::element::Type>& supported_weights_types,
+ const std::vector<ov::element::Type>& supported_activation_types) {
MOE2GEMMPatternNodes p;
- p.experts_input = pattern::wrap_type<v1::Reshape>({pattern::any_input(), pattern::any_input()});
+ p.experts_input = pattern::wrap_type<v1::Reshape>({pattern::any_input(), pattern::any_input()},
+ pattern::type_matches_any(supported_activation_types));
p.tile = pattern::wrap_type<v0::Tile>({p.experts_input, pattern::any_input()}, pattern::consumers_count(1));
p.after_tile_reshape = pattern::wrap_type<v1::Reshape>({p.tile, pattern::any_input()}, pattern::consumers_count(1));
p.gate_up_matmul = pattern::wrap_type<v0::MatMul>(
@@ -154,10 +156,11 @@ struct MOE3GEMMPatternNodes {
std::shared_ptr<ov::Node> reduce_sum;
};
-MOE3GEMMPatternNodes build_3gemm_pattern(const std::vector<ov::element::Type>& supported_weights_types) {
+MOE3GEMMPatternNodes build_3gemm_pattern(const std::vector<ov::element::Type>& supported_weights_types,
+ const std::vector<ov::element::Type>& supported_activation_types) {
MOE3GEMMPatternNodes p;
- p.experts_input = pattern::any_input();
+ p.experts_input = pattern::any_input(pattern::type_matches_any(supported_activation_types));
p.tile = pattern::wrap_type<v0::Tile>({p.experts_input, pattern::any_input()}, pattern::consumers_count(1));
p.after_tile_reshape = pattern::wrap_type<v1::Reshape>({p.tile, pattern::any_input()}, pattern::consumers_count(2));
@@ -215,10 +218,11 @@ using ov::op::internal::GatherMatmul;
// ============================================================================
ConvertTiledMoeBlockTo2GatherMatmuls::ConvertTiledMoeBlockTo2GatherMatmuls(
- const std::vector<ov::element::Type>& supported_weights_types) {
+ const std::vector<ov::element::Type>& supported_weights_types,
+ const std::vector<ov::element::Type>& supported_activation_types) {
MATCHER_SCOPE(ConvertTiledMoeBlockTo2GatherMatmuls);
- auto p = build_2gemm_pattern(supported_weights_types);
+ auto p = build_2gemm_pattern(supported_weights_types, supported_activation_types);
matcher_pass_callback callback = [=](pattern::Matcher& m) {
auto& pm = m.get_pattern_value_map();
@@ -322,10 +326,11 @@ ConvertTiledMoeBlockTo2GatherMatmuls::ConvertTiledMoeBlockTo2GatherMatmuls(
}
ConvertTiledMoeBlockTo3GatherMatmuls::ConvertTiledMoeBlockTo3GatherMatmuls(
- const std::vector<ov::element::Type>& supported_weights_types) {
+ const std::vector<ov::element::Type>& supported_weights_types,
+ const std::vector<ov::element::Type>& supported_activation_types) {
MATCHER_SCOPE(ConvertTiledMoeBlockTo3GatherMatmuls);
- auto p = build_3gemm_pattern(supported_weights_types);
+ auto p = build_3gemm_pattern(supported_weights_types, supported_activation_types);
matcher_pass_callback callback = [=](pattern::Matcher& m) {
auto& pm = m.get_pattern_value_map();
diff --git a/src/common/transformations/tests/common_optimizations/convert_tiled_moe_block_to_gather_matmuls_test.cpp b/src/common/transformations/tests/common_optimizations/convert_tiled_moe_block_to_gather_matmuls_test.cpp
index d10ae94308a..c3b807d224b 100644
--- a/src/common/transformations/tests/common_optimizations/convert_tiled_moe_block_to_gather_matmuls_test.cpp
+++ b/src/common/transformations/tests/common_optimizations/convert_tiled_moe_block_to_gather_matmuls_test.cpp
@@ -1053,4 +1053,60 @@ INSTANTIATE_TEST_SUITE_P(ConvertTiledMoeBlockToGatherMatmulsTest_negative_cases_
::testing::Values(false),
::testing::Values(false)),
ConvertTiledMoeBlockToGatherMatmulsTest::getTestCaseName);
+
+// The test models have f32 activations
+using ConvertTiledMoeBlockToGatherMatmulsActivationTypesParams =
+ std::tuple<MoEType,
+ std::vector<ov::element::Type>, // supported_activation_types
+ bool>; // should_be_applied
+
+class ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest
+ : public TransformationTestsF,
+ public WithParamInterface<ConvertTiledMoeBlockToGatherMatmulsActivationTypesParams> {
+public:
+ static std::string getTestCaseName(
+ const testing::TestParamInfo<ConvertTiledMoeBlockToGatherMatmulsActivationTypesParams>& obj) {
+ const auto& [moe_type, supported_activation_types, should_be_applied] = obj.param;
+ std::ostringstream result;
+ result << "MoEType_" << moe_type << "_SupportedActivationTypes_";
+ for (const auto& type : supported_activation_types) {
+ result << type << "_";
+ }
+ result << "shouldBeApplied_" << (should_be_applied ? "true" : "false");
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ TransformationTestsF::SetUp();
+ const auto& [moe_type, supported_activation_types, should_be_applied] = this->GetParam();
+ const bool is_2gemm = moe_type == MoEType::MoE2GeMM;
+ model = is_2gemm ? initMoE2GeMMSubgraph(false, false, false, true, false, AdditionalConsumersMode::NO)
+ : initMoE3GeMMSubgraph(false, false, false, true, AdditionalConsumersMode::NO);
+ manager.register_pass<ov::pass::ConvertTiledMoeBlockToGatherMatmuls>(std::vector<ov::element::Type>{},
+ supported_activation_types);
+ if (should_be_applied) {
+ model_ref = is_2gemm ? initMoE2GeMMSubgraphRef(false, false, false, true, false)
+ : initMoE3GeMMSubgraphRef(false, false, false, true);
+ }
+ }
+};
+
+TEST_P(ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest, CompareFunctions) {}
+
+INSTANTIATE_TEST_SUITE_P(ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest_positive_cases,
+ ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest,
+ ::testing::Combine(::testing::ValuesIn(moe_types),
+ ::testing::Values(std::vector<ov::element::Type>{ov::element::f16,
+ ov::element::f32}),
+ ::testing::Values(true)),
+ ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest_negative_cases,
+ ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest,
+ ::testing::Combine(::testing::ValuesIn(moe_types),
+ ::testing::Values(std::vector<ov::element::Type>{},
+ std::vector<ov::element::Type>{ov::element::f16}),
+ ::testing::Values(false)),
+ ConvertTiledMoeBlockToGatherMatmulsActivationTypesTest::getTestCaseName);
} // namespace
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.cpp
index 17a3c90c647..120605a7cd0 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.cpp
@@ -37,8 +37,8 @@ namespace ov::intel_gpu {
using namespace ov::pass::pattern;
using namespace ov::pass;
-FuseMoESoftmaxRouter::FuseMoESoftmaxRouter() {
- auto routing_matmul = wrap_type<ov::op::v0::MatMul>();
+FuseMoESoftmaxRouter::FuseMoESoftmaxRouter(const std::vector<ov::element::Type>& supported_activation_types) {
+ auto routing_matmul = wrap_type<ov::op::v0::MatMul>(type_matches_any(supported_activation_types));
auto softmax_m = wrap_type<ov::op::v8::Softmax>({routing_matmul}, consumers_count(1));
auto topk_k_m = wrap_const();
@@ -89,8 +89,8 @@ FuseMoESoftmaxRouter::FuseMoESoftmaxRouter() {
this->register_matcher(matcher, callback);
}
-FuseMoESigmoidRouter::FuseMoESigmoidRouter() {
- auto routing_matmul = wrap_type<ov::op::v0::MatMul>();
+FuseMoESigmoidRouter::FuseMoESigmoidRouter(const std::vector<ov::element::Type>& supported_activation_types) {
+ auto routing_matmul = wrap_type<ov::op::v0::MatMul>(type_matches_any(supported_activation_types));
auto sigmoid_m = wrap_type<ov::op::v0::Sigmoid>({routing_matmul});
auto routing_bias_m = any_input();
@@ -142,9 +142,9 @@ FuseMoESigmoidRouter::FuseMoESigmoidRouter() {
this->register_matcher(matcher, callback);
}
-FuseMoERouter::FuseMoERouter() {
- add_matcher<FuseMoESoftmaxRouter>();
- add_matcher<FuseMoESigmoidRouter>();
+FuseMoERouter::FuseMoERouter(const std::vector<ov::element::Type>& supported_activation_types) {
+ add_matcher<FuseMoESoftmaxRouter>(supported_activation_types);
+ add_matcher<FuseMoESigmoidRouter>(supported_activation_types);
}
} // namespace ov::intel_gpu
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.hpp b/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.hpp
index 744052c89a0..4278abe5661 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.hpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.hpp
@@ -4,6 +4,9 @@
#pragma once
+#include <vector>
+
+#include "openvino/core/type/element_type.hpp"
#include "openvino/pass/graph_rewrite.hpp"
namespace ov::intel_gpu {
@@ -11,20 +14,20 @@ namespace ov::intel_gpu {
class FuseMoESoftmaxRouter : public ov::pass::MatcherPass {
public:
OPENVINO_MATCHER_PASS_RTTI("FuseMoESoftmaxRouter");
- FuseMoESoftmaxRouter();
+ explicit FuseMoESoftmaxRouter(const std::vector<ov::element::Type>& supported_activation_types);
};
class FuseMoESigmoidRouter : public ov::pass::MatcherPass {
public:
OPENVINO_MATCHER_PASS_RTTI("FuseMoESigmoidRouter");
- FuseMoESigmoidRouter();
+ explicit FuseMoESigmoidRouter(const std::vector<ov::element::Type>& supported_activation_types);
};
/// GraphRewrite that applies Mixture of Experts routing subgraph fusion
class FuseMoERouter : public ov::pass::GraphRewrite {
public:
OPENVINO_GRAPH_REWRITE_RTTI("FuseMoERouter");
- FuseMoERouter();
+ explicit FuseMoERouter(const std::vector<ov::element::Type>& supported_activation_types);
};
} // namespace ov::intel_gpu
diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
index 44df7ed18ab..0df64b7cd6a 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
@@ -691,29 +691,37 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
// MOE: TiledMoeBlock -> GatherMatmuls(compressed) -> MoeOp(compressed) -> MoeOpWithRouting(compressed).
// Gated on supports_immad (systolic-only) and oneDNN (required for expert GEMM dispatch).
// Note: even though we are already inside `if (supports_immad)`, oneDNN can still be explicitly disabled by the user.
- if (device_info.supports_immad && config.get_use_onednn() && !config.get_moe_disable_fusion()) {
+ // Also gated on inference precision: GatherMatmul and fused MoE kernels support only f16 activations.
+ const bool f16_activations_possible = infer_precision == ov::element::f16 || infer_precision == ov::element::dynamic;
+ if (device_info.supports_immad && config.get_use_onednn() && f16_activations_possible) {
const std::vector<ov::element::Type> supported_compressed_weights_types{ov::element::u4,
ov::element::i4,
ov::element::i8,
ov::element::u8};
manager.register_pass<ov::pass::ConvertGroupedMatMulToGroupedMatMulCompressed>(
supported_compressed_weights_types);
- manager.register_pass<ov::pass::ConvertTiledMoeBlockToGatherMatmuls>(supported_compressed_weights_types);
- // f32 listed because this pass runs before ConvertPrecision (line ~588);
- // f32 activations are lowered to f16 before reaching the f16-only DPAS kernels.
- manager.register_pass<ov::pass::ConvertGatherMatmulToGatherMatmulCompressed>(
- std::vector<ov::element::Type>{ov::element::f32, ov::element::f16},
- supported_compressed_weights_types);
- manager.register_pass<ov::intel_gpu::FuseMoERouter>();
-
- // MOE3GemmCompressed kernel dispatches expert GEMMs through
- // oneDNN, which requires an in-order OCL queue. If oneDNN is
- // disabled (e.g. via OV_GPU_USE_ONEDNN=0 on an IMMAD GPU), the
- // queue stays out-of-order and the oneDNN stream creation may assert.
- manager.register_pass<ov::pass::MoeOpFusion>();
- manager.register_pass<ov::intel_gpu::FuseMoERouterScale>();
- manager.register_pass<ov::intel_gpu::FuseMOESharedExpert>();
+ // With f16 inference precision, f32 and bf16 activations are also supported: the MoE passes run before ConvertPrecision,
+ // which converts them to f16. With dynamic inference precision, the model activation types are kept as is.
+ std::vector<ov::element::Type> supported_activation_types{ov::element::f16};
+ if (infer_precision == ov::element::f16) {
+ supported_activation_types.insert(supported_activation_types.end(), {ov::element::f32, ov::element::bf16});
+ }
+ manager.register_pass<ov::pass::ConvertTiledMoeBlockToGatherMatmuls>(supported_compressed_weights_types,
+ supported_activation_types);
+ manager.register_pass<ov::pass::ConvertGatherMatmulToGatherMatmulCompressed>(supported_activation_types,
+ supported_compressed_weights_types);
+ manager.register_pass<ov::intel_gpu::FuseMoERouter>(supported_activation_types);
+
+ if (!config.get_moe_disable_fusion()) {
+ // MOE3GemmCompressed kernel dispatches expert GEMMs through
+ // oneDNN, which requires an in-order OCL queue. If oneDNN is
+ // disabled (e.g. via OV_GPU_USE_ONEDNN=0 on an IMMAD GPU), the
+ // queue stays out-of-order and the oneDNN stream creation may assert.
+ manager.register_pass<ov::pass::MoeOpFusion>();
+ manager.register_pass<ov::intel_gpu::FuseMoERouterScale>();
+ manager.register_pass<ov::intel_gpu::FuseMOESharedExpert>();
+ }
}
manager.register_pass<ov::pass::GatedDeltaNetFusion>();
manager.register_pass<ov::pass::InitNodeInfo>();
diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/moe.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/moe.cpp
index bf5be5505bf..b3d623d210f 100644
--- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/moe.cpp
+++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/moe.cpp
@@ -109,7 +109,7 @@ protected:
if (pattern_type == MoePatternType::GEMM3) {
function = ov::test::initMoE3GeMMSubgraph(shape_params,
- ov::element::f32, // data_precision
+ model_precision, // data_precision
wp, // weights_precision
uwd, // use_weight_decompression
dp, // decompression_precision
@@ -127,7 +127,7 @@ protected:
ASSERT_TRUE(pes == false) << "2-GEMM pattern doesn't support per-expert scale";
ASSERT_TRUE(lnm == false) << "2-GEMM pattern doesn't support layernorm multiply";
function = ov::test::initMoE2GeMMSubgraph(shape_params,
- ov::element::f32, // data_precision
+ model_precision, // data_precision
wp, // weights_precision
uwd, // use_weight_decompression
dp, // decompression_precision
@@ -205,6 +205,9 @@ protected:
}
}
+ // Element type of the model activations, can be changed by derived fixtures before SetUp()
+ ov::element::Type model_precision = ov::element::f32;
+
private:
static void set_disable_moe_fusion() {
#ifdef _WIN32
@@ -227,6 +230,64 @@ TEST_P(MoECompressedFusionTest, Inference) {
run();
}
+// GatherMatmul and fused MoE kernels support only f16 activations, so the MoE pipeline must be applied
+// only if the activations are f16 after ConvertPrecision, regardless of OV_GPU_MOE_DISABLE_FUSION.
+// Note: with dynamic inference precision, the model precision is kept.
+class MoECompressedPrecisionTest : public MoECompressedFusionTest {
+protected:
+ MoECompressedPrecisionTest(ov::element::Type model_prc, ov::element::Type infer_prc) : infer_prc(infer_prc) {
+ model_precision = model_prc;
+ }
+
+ void SetUp() override {
+ MoECompressedFusionTest::SetUp();
+ inType = outType = model_precision;
+ configuration[ov::hint::inference_precision.name()] = infer_prc.get_type_name();
+ }
+
+ void validate() override {
+ const auto activations_prc = infer_prc == ov::element::dynamic ? model_precision : infer_prc;
+ if (activations_prc == ov::element::f16) {
+ MoECompressedFusionTest::validate();
+ return;
+ }
+ ov::test::SubgraphBaseTest::validate();
+ for (const auto& type : {"gather_matmul", "moe_3gemm_fused_compressed", "moe_gemm", "moe_router_fused"}) {
+ ov::test::CheckNumberOfNodesWithType(compiledModel, type, 0);
+ }
+ }
+
+private:
+ ov::element::Type infer_prc;
+};
+
+class MoECompressedF32Test : public MoECompressedPrecisionTest {
+public:
+ MoECompressedF32Test() : MoECompressedPrecisionTest(ov::element::f32, ov::element::f32) {}
+};
+
+class MoECompressedDynamicPrecisionF32ModelTest : public MoECompressedPrecisionTest {
+public:
+ MoECompressedDynamicPrecisionF32ModelTest() : MoECompressedPrecisionTest(ov::element::f32, ov::element::dynamic) {}
+};
+
+class MoECompressedDynamicPrecisionF16ModelTest : public MoECompressedPrecisionTest {
+public:
+ MoECompressedDynamicPrecisionF16ModelTest() : MoECompressedPrecisionTest(ov::element::f16, ov::element::dynamic) {}
+};
+
+TEST_P(MoECompressedF32Test, Inference) {
+ run();
+}
+
+TEST_P(MoECompressedDynamicPrecisionF32ModelTest, Inference) {
+ run();
+}
+
+TEST_P(MoECompressedDynamicPrecisionF16ModelTest, Inference) {
+ run();
+}
+
const std::vector<MoERoutingType> routing_types = {MoERoutingType::SOFTMAX, MoERoutingType::SIGMOID_BIAS};
const std::vector<MoeTestShapeParams> moe_params_smoke = {
@@ -357,6 +418,38 @@ INSTANTIATE_TEST_SUITE_P(smoke_MoE2GemmGatherMatmul,
::testing::Values(true)), // use_weight_decompression
MoECompressedFusionTest::getTestCaseName);
+const auto moe_precision_test_params = ::testing::Combine(::testing::Values(moe_params_smoke[1]),
+ ::testing::Values(MoePatternType::GEMM3, MoePatternType::GEMM2),
+ ::testing::Values(MoERoutingType::SOFTMAX),
+ ::testing::Values(ov::element::u4), // weights_precision
+ ::testing::Values(ov::element::f16), // decompression_precision
+ ::testing::Values(ov::element::f16), // scale_precision
+ ::testing::Values(ov::test::utils::DecompressionType::full),
+ ::testing::Values(ov::test::utils::DecompressionType::full),
+ ::testing::Values(true), // reshape_on_decompression
+ ::testing::Values(128),
+ ::testing::Values(size_t{0}), // gate_idx
+ ::testing::Values(true, false), // force_gather_matmul
+ ::testing::Values(MoEActivationType::SWISH),
+ ::testing::Values(false), // use_per_expert_scale
+ ::testing::Values(false), // use_layernorm_multiply
+ ::testing::Values(true)); // use_weight_decompression
+
+INSTANTIATE_TEST_SUITE_P(smoke_MoECompressedF32,
+ MoECompressedF32Test,
+ moe_precision_test_params,
+ MoECompressedF32Test::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_MoECompressedDynamicPrecisionF32Model,
+ MoECompressedDynamicPrecisionF32ModelTest,
+ moe_precision_test_params,
+ MoECompressedDynamicPrecisionF32ModelTest::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_MoECompressedDynamicPrecisionF16Model,
+ MoECompressedDynamicPrecisionF16ModelTest,
+ moe_precision_test_params,
+ MoECompressedDynamicPrecisionF16ModelTest::getTestCaseName);
+
// Gemma-4 style: Gelu activation + SOFTMAX routing with a per-expert scale table (Const[N] → Gather(topk_idx) → Multiply).
INSTANTIATE_TEST_SUITE_P(smoke_MoE3GemmGeluCompressed,
MoECompressedFusionTest,
diff --git a/src/plugins/intel_gpu/tests/unit/transformations/fuse_moe_router_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/fuse_moe_router_test.cpp
index 81108d4d599..5bcb0524377 100644
--- a/src/plugins/intel_gpu/tests/unit/transformations/fuse_moe_router_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/transformations/fuse_moe_router_test.cpp
@@ -114,7 +114,7 @@ TEST_P(FuseMoERouterTest, CompareFunctions) {
auto indices_out = std::make_shared<ov::op::v0::Unsqueeze>(topk_indices, ov::op::v0::Constant::create(element::i32, Shape{1}, {0}));
model = std::make_shared<ov::Model>(ov::OutputVector{weights_out, indices_out}, ov::ParameterVector{hidden_states});
}
- manager.register_pass<FuseMoERouter>();
+ manager.register_pass<FuseMoERouter>(std::vector<ov::element::Type>{data_precision});
{
auto hidden_states = std::make_shared<ov::op::v0::Parameter>(data_precision, Shape{4, 8, 2048});
auto flatten_shape = op::v0::Constant::create(element::i32, Shape{2}, {32, 2048});
@@ -148,6 +148,19 @@ INSTANTIATE_TEST_SUITE_P(smoke,
::testing::Values(8, 10)),
FuseMoERouterTest::get_test_case_name);
+TEST_F(TransformationTestsF, FuseMoERouter_unsupported_activation_type) {
+ auto hidden_states = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{4, 8, 2048});
+ auto flatten_shape = op::v0::Constant::create(element::i32, Shape{2}, {32, 2048});
+ auto hidden_states_reshape = std::make_shared<ov::op::v1::Reshape>(hidden_states, flatten_shape, false);
+ auto routers = op::v0::Constant::create(element::f32, Shape{2048, 128}, {0.2});
+ auto routing_weights = std::make_shared<ov::op::v0::MatMul>(hidden_states_reshape, routers);
+ const auto [routing_out, topk_indices] = build_softmax_routing_for_fuse_test(routing_weights, 8, true);
+ auto weights_out = std::make_shared<ov::op::v0::Unsqueeze>(routing_out, ov::op::v0::Constant::create(element::i32, Shape{1}, {0}));
+ auto indices_out = std::make_shared<ov::op::v0::Unsqueeze>(topk_indices, ov::op::v0::Constant::create(element::i32, Shape{1}, {0}));
+ model = std::make_shared<ov::Model>(ov::OutputVector{weights_out, indices_out}, ov::ParameterVector{hidden_states});
+ manager.register_pass<FuseMoERouter>(std::vector<ov::element::Type>{ov::element::f16});
+}
+
} // namespace intel_gpu
} // namespace test
} // namespace ov