Skip to content

Commit a5c0d67

Browse files
[HETERO] Support splitting new graph pattern for pipeline parallel and correct the number of submodels (openvinotoolkit#25224)
### Details: - Fix qwen1.5-14b-chat with HETERO pipeline parallelism Add supported to patten: ``` ReadValue->Gather->Concat |------>ShapeOf(fused on other different affinity node) ->.... ``` - Correct the value of HETERO_NUMBER_OF_SUBMODELS by subtracting the number of independent submodels to reduce confusion ### Tickets: - *ticket-id*
1 parent 2a9af43 commit a5c0d67

File tree

5 files changed

+71
-4
lines changed

5 files changed

+71
-4
lines changed

src/inference/src/dev/iplugin.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ std::unordered_set<std::string> ov::get_supported_nodes(
391391
}
392392
}
393393
// For example, A op need to be removed from supported:
394-
// A (fused on B, to be marked as unsupported)
394+
// A (removed nodes, to be marked as unsupported)
395395
// |
396396
// B (unsupported)
397397
//
@@ -400,8 +400,33 @@ std::unordered_set<std::string> ov::get_supported_nodes(
400400
update_supported = false;
401401
for (auto& op : model->get_ordered_ops()) {
402402
const auto& name = op->get_friendly_name();
403-
if (fused_model_op_map.find(name) != fused_model_op_map.end() && supported.count(name)) {
404-
if (!supported.count(fused_model_op_map[name]) &&
403+
if (removed_nodes.count(name) && supported.count(name)) {
404+
if (has_all_consumers_unsupported(supported, op)) {
405+
supported.erase(name);
406+
removed_nodes.erase(name);
407+
update_supported = true;
408+
}
409+
}
410+
}
411+
}
412+
// For example, A op need to be removed from supported:
413+
// A (fused on B, to be marked as unsupported)
414+
// |
415+
// B (unsupported)
416+
//
417+
// A ShapeOf (to be marked as unsupported)
418+
// |
419+
// B (unsupported)
420+
//
421+
update_supported = true;
422+
while (update_supported) {
423+
update_supported = false;
424+
for (auto& op : model->get_ordered_ops()) {
425+
const auto& name = op->get_friendly_name();
426+
bool is_shapeof = ov::is_type<op::util::ShapeOfBase>(op);
427+
if (((fused_model_op_map.find(name) != fused_model_op_map.end()) || is_shapeof) &&
428+
supported.count(name)) {
429+
if ((!supported.count(fused_model_op_map[name]) || is_shapeof) &&
405430
has_all_consumers_unsupported(supported, op)) {
406431
supported.erase(name);
407432
update_supported = true;

src/inference/tests/unit/query_model_test.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,41 @@ const std::vector<ConfigParams> testConfigs2 = {
743743
INSTANTIATE_TEST_SUITE_P(GetSupportedNodesTest, GetSupportedNodesCommonTest, ::testing::ValuesIn(testConfigs));
744744
INSTANTIATE_TEST_SUITE_P(GetSupportedNodesTest, GetSupportedNodesOneConstOp, ::testing::ValuesIn(testConfigs1));
745745
INSTANTIATE_TEST_SUITE_P(GetSupportedNodesTest, GetSupportedNodesStopSplit, ::testing::ValuesIn(testConfigs2));
746+
747+
TEST_F(GetSupportedNodesTest, FilterShapeOf) {
748+
{
749+
auto param = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{1, 1});
750+
param->set_friendly_name("input");
751+
auto weights = ov::op::v0::Constant::create(ov::element::Type_t::f32, {1, 1}, {1});
752+
weights->set_friendly_name("weights");
753+
auto shapeOf = std::make_shared<ov::op::v0::ShapeOf>(weights);
754+
shapeOf->set_friendly_name("shapeof");
755+
auto const1 = ov::op::v0::Constant::create(ov::element::Type_t::i32, {1}, {1});
756+
const1->set_friendly_name("const1");
757+
auto const2 = ov::op::v0::Constant::create(ov::element::Type_t::i64, {}, {0});
758+
const2->set_friendly_name("const2");
759+
auto gather = std::make_shared<ov::op::v8::Gather>(shapeOf, const1, const2);
760+
gather->set_friendly_name("gather");
761+
auto const3 = ov::op::v0::Constant::create(ov::element::Type_t::i64, {1}, {1});
762+
const3->set_friendly_name("const3");
763+
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{const3, gather}, 0);
764+
concat->set_friendly_name("concat");
765+
auto reshape = std::make_shared<ov::op::v1::Reshape>(param, concat, false);
766+
reshape->set_friendly_name("reshape");
767+
auto result = std::make_shared<ov::op::v0::Result>(reshape);
768+
result->set_friendly_name("result");
769+
770+
m_function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param});
771+
}
772+
Run(
773+
[&](std::shared_ptr<ov::Model>& model) {
774+
ov::pass::Manager m;
775+
m.register_pass<ov::pass::InitNodeInfo>();
776+
m.run_passes(model);
777+
},
778+
[&](const std::shared_ptr<ov::Node>& op) {
779+
return true;
780+
},
781+
{"weights"},
782+
0.5f);
783+
}

src/plugins/hetero/src/compiled_model.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ ov::Any ov::hetero::CompiledModel::get_property(const std::string& name) const {
321321
}
322322
return decltype(ov::execution_devices)::value_type{std::move(device_names)};
323323
} else if (ov::hetero::number_of_submodels == name) {
324-
return decltype(ov::hetero::number_of_submodels)::value_type{m_compiled_submodels.size()};
324+
return decltype(ov::hetero::number_of_submodels)::value_type{
325+
(m_compiled_submodels.size() - get_hetero_plugin()->independent_submodel_size)};
325326
}
326327
return m_cfg.get(name);
327328
}

src/plugins/hetero/src/plugin.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ std::pair<ov::SupportedOpsMap, ov::hetero::SubgraphsMappingInfo> ov::hetero::Plu
193193
auto result = std::make_shared<ov::op::v0::Result>(param);
194194
ov::copy_runtime_info(param->shared_from_this(), result);
195195
new_outputs.push_back(result);
196+
independent_submodel_size++;
196197
}
197198
}
198199
model->add_results(new_outputs);

src/plugins/hetero/src/plugin.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ class Plugin : public ov::IPlugin {
6969
bool allow_exception = false) const;
7070

7171
Configuration m_cfg;
72+
73+
mutable size_t independent_submodel_size = 0;
7274
};
7375

7476
} // namespace hetero

0 commit comments

Comments
 (0)