Skip to content

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

[NPUW] Fix multiple MatMul matching issue in NPUW LM head cutting (#32475)

Guoliang Shica968e4d115a
diff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp b/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp
index 56275297465..1f98e0eea5f 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp
@@ -881,6 +881,14 @@ public:
auto matched_matmul = std::static_pointer_cast<ov::op::v0::MatMul>(matched_node_matmul);
auto matched_result = std::static_pointer_cast<ov::op::v0::Result>(matched_node_result);
+ // Some LLMs add intermediate hidden state outputs that can interfere with LM head detection.
+ // Skip Result nodes that were manually added (marked with "manually_added_output" in RT_INFO).
+ // For example, Eagle-3 target/draft models add "last_hidden_state" output which should be skipped.
+ const auto& rt_info = matched_result->get_rt_info();
+ if (rt_info.count("manually_added_output")) {
+ return false;
+ }
+
// Cut point:
auto matmul_first_source = matched_matmul->input(0).get_source_output();