OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] fixed a moe_gemm model caching error (#35381)
Eddy Kim6cf60441f876
diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/bind.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/bind.hppindex 21431163e7b..eea6f4a6bfb 100644--- a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/bind.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/bind.hpp@@ -40,7 +40,11 @@ struct saver_storage {}const save_function& get_save_function(const std::string& type) const {- return map.at(type);+ try {+ return map.at(type);+ } catch (const std::exception& e) {+ OPENVINO_THROW("saver_storage: Failed to get save function for type: ", type, ". Error: ", e.what());+ }}void set_save_function(const value_type& pair) {@@ -70,7 +74,11 @@ struct loader_storage {}const FuncT& get_load_function(const std::string& type) {- return map.at(type);+ try {+ return map.at(type);+ } catch (const std::exception& e) {+ OPENVINO_THROW("loader_storage: Failed to get load function for type: ", type, ". Error: ", e.what());+ }}void set_load_function(const value_type& pair) {diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.cppindex cd1a70b7e00..cbce4a21ede 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.cpp@@ -187,4 +187,5 @@ std::unique_ptr<primitive_impl> MoEGemmImplementationManager::create_impl(const} // namespace onednn} // namespace cldnn+BIND_BINARY_BUFFER_WITH_TYPE(cldnn::moe_gemm)BIND_BINARY_BUFFER_WITH_TYPE(cldnn::onednn::moe_gemm_onednn)diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cppindex d622b86411f..8beacc5f5d4 100644--- a/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/test_cases/moe_gemm_gpu_test.cpp@@ -33,6 +33,7 @@ struct moe_gemm_test_params {int32_t scale_group_size;bool weight_symmetric_quant;bool is_pa;+ bool is_caching_test;};template <typename T>@@ -403,7 +404,7 @@ struct MoEGemmTest : public ::testing::TestWithParam<T> {std::vector<ov::float16> zp_data_f16;std::vector<uint8_t> zp_data;std::vector<cldnn::data_types> quant_types = {data_types::i4, data_types::u4, data_types::i8, data_types::u8};- if (!engine.get_device_info().supports_immad || engine.get_device_info().arch != gpu_arch::xe2)+ if (!engine.get_device_info().supports_immad)return;bool is_weight_compressed = std::any_of(quant_types.begin(), quant_types.end(), [=](const cldnn::data_types& t) -> bool {@@ -413,7 +414,8 @@ struct MoEGemmTest : public ::testing::TestWithParam<T> {auto config = get_test_default_config(engine);config.set_property(ov::intel_gpu::allow_new_shape_infer(true));config.set_property(ov::intel_gpu::optimize_data(true));- network network(engine, topo, config);+ cldnn::network::ptr network = get_network(engine, topo, config, get_test_stream_ptr(), p.is_caching_test);+ OPENVINO_ASSERT(network != nullptr, "Failed to create network");auto get_input_data = [] (size_t M, size_t K, random_generator& rg) {std::vector<ov::float16> input_data(M * K);@@ -470,11 +472,11 @@ struct MoEGemmTest : public ::testing::TestWithParam<T> {auto input_offset_per_expert_mem = engine.allocate_memory(input_offset_per_expert_data_layout);set_values(input_offset_per_expert_mem, input_offset_per_expert_data);- network.set_input_data("input", input_mem);- network.set_input_data("experts_ids", experts_ids_mem);- network.set_input_data("input_offset_per_expert", input_offset_per_expert_mem);- network.set_input_data("input_tokens_lens", input_tokens_lens_mem);- auto outputs = network.execute();+ network->set_input_data("input", input_mem);+ network->set_input_data("experts_ids", experts_ids_mem);+ network->set_input_data("input_offset_per_expert", input_offset_per_expert_mem);+ network->set_input_data("input_tokens_lens", input_tokens_lens_mem);+ auto outputs = network->execute();auto output = outputs.at("moe_gemm").get_memory();cldnn::mem_lock<ov::float16, mem_lock_type::read> output_ptr(output, get_test_stream());@@ -546,7 +548,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::f16, /*weight_dt*/cldnn::data_types::f16, /*scale_dt*/-1, /*scale_group_size*/- false /*weight_symmetric_quant*/+ false, /*weight_symmetric_quant*/+ false, /*is_pa*/+ true /*is_caching_test*/},// f16 / upmoe_gemm_test_params{@@ -562,7 +566,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::f16, /*weight_dt*/cldnn::data_types::f16, /*scale_dt*/-1, /*scale_group_size*/- false /*weight_symmetric_quant*/+ false, /*weight_symmetric_quant*/+ false, /*is_pa*/+ false /*is_caching_test*/},// f16 / downmoe_gemm_test_params{@@ -578,7 +584,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::f16, /*weight_dt*/cldnn::data_types::f16, /*scale_dt*/-1, /*scale_group_size*/- false /*weight_symmetric_quant*/+ false, /*weight_symmetric_quant*/+ false, /*is_pa*/+ true /*is_caching_test*/},// i4 / symmetric/ group size 32 / prefillmoe_gemm_test_params{@@ -595,7 +603,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::f16, /*scale_dt*/32, /*scale_group_size*/true, /*weight_symmetric_quant*/- true, /*is_pa*/+ false, /*is_pa*/+ false, /*is_caching_test*/},// i4 / symmetric/ group size 32 / upmoe_gemm_test_params{@@ -611,7 +620,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::i4, /*weight_dt*/cldnn::data_types::f16, /*scale_dt*/32, /*scale_group_size*/- true /*weight_symmetric_quant*/+ true, /*weight_symmetric_quant*/+ false, /*is_pa*/+ true /*is_caching_test*/},// i4 / symmetric/ group size 32 / downmoe_gemm_test_params{@@ -627,7 +638,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::i4, /*weight_dt*/cldnn::data_types::f16, /*scale_dt*/32, /*scale_group_size*/- true /*weight_symmetric_quant*/+ true, /*weight_symmetric_quant*/+ false, /*is_pa*/+ false /*is_caching_test*/},// u4 / asymmetric/ per_token / prefillmoe_gemm_test_params{@@ -643,7 +656,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::u4, /*weight_dt*/cldnn::data_types::f16, /*scale_dt*/2880, /*scale_group_size*/- false /*weight_symmetric_quant*/+ false, /*weight_symmetric_quant*/+ false, /*is_pa*/+ true /*is_caching_test*/},// u4 / asymmetric/ group size 32 / prefillmoe_gemm_test_params{@@ -659,7 +674,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::u4, /*weight_dt*/cldnn::data_types::f32, /*scale_dt*/32, /*scale_group_size*/- false /*weight_symmetric_quant*/+ false, /*weight_symmetric_quant*/+ false, /*is_pa*/+ false /*is_caching_test*/},// u4 / asymmetric/ group size 32 / upmoe_gemm_test_params{@@ -675,7 +692,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::u4, /*weight_dt*/cldnn::data_types::f32, /*scale_dt*/32, /*scale_group_size*/- false /*weight_symmetric_quant*/+ false, /*weight_symmetric_quant*/+ false, /*is_pa*/+ true /*is_caching_test*/},// u4 / asymmetric/ group size 32 / downmoe_gemm_test_params{@@ -691,5 +710,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_moe_gemm,cldnn::data_types::u4, /*weight_dt*/cldnn::data_types::f32, /*scale_dt*/32, /*scale_group_size*/- false /*weight_symmetric_quant*/+ false, /*weight_symmetric_quant*/+ false, /*is_pa*/+ false /*is_caching_test*/}}));