Skip to content

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

NPUW: Introduce a dedicated GQA handling path (#36065)

Dmitry Matveevd400af4e0d09
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw_option_defs.inc b/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw_option_defs.inc
index c45743dcb6c..1d91c9fbd6a 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw_option_defs.inc
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw_option_defs.inc
@@ -44,6 +44,8 @@ INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_FALLBACK_EXEC, bool, true, ov::intel_npu::npuw, f
INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_ACC_CHECK, bool, false, ov::intel_npu::npuw::accuracy, check, "NPUW_ACC_CHECK", ROOT, HIDDEN, UNCACHED, ALL)
INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_ACC_THRESH, double, 0.01, ov::intel_npu::npuw::accuracy, threshold, "NPUW_ACC_THRESH", ROOT, HIDDEN, UNCACHED, ALL)
INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_ACC_DEVICE, std::string, "", ov::intel_npu::npuw::accuracy, reference_device, "NPUW_ACC_DEVICE", ROOT, HIDDEN, UNCACHED, ALL)
+INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_GQA, bool, false, ov::intel_npu::npuw::gqa, enabled, "NPUW_GQA", ROOT, EXPOSED, CACHED, ALL)
+INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_UNQDQ, bool, false, ov::intel_npu::npuw, unqdq, "NPUW_UNQDQ", ROOT, EXPOSED, CACHED, ALL)
INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_DUMP_FULL, bool, false, ov::intel_npu::npuw::dump, full, "NPUW_DUMP_FULL", ROOT, HIDDEN, UNCACHED, DEV)
INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_DUMP_SUBS, std::string, "", ov::intel_npu::npuw::dump, subgraphs, "NPUW_DUMP_SUBS", ROOT, HIDDEN, UNCACHED, DEV)
INTEL_NPU_NPUW_SIMPLE_OPT(NPUW_DUMP_SUBS_DIR, std::string, "", ov::intel_npu::npuw::dump, subgraphs_dir, "NPUW_DUMP_SUBS_DIR", ROOT, HIDDEN, UNCACHED, DEV)
diff --git a/src/plugins/intel_npu/src/plugin/npuw/attn/attn_subgraph.cpp b/src/plugins/intel_npu/src/plugin/npuw/attn/attn_subgraph.cpp
index a533a111c5c..699b455c5cb 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/attn/attn_subgraph.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/attn/attn_subgraph.cpp
@@ -1145,8 +1145,8 @@ std::vector<ov::npuw::v1::subgraphs::ScopedPatternRegistration> register_pattern
registrations.emplace_back(registry.on<ov::npuw::patterns::attn::SDPA>().scoped());
registrations.emplace_back(registry.on<ov::npuw::patterns::attn::SDPADecomposed>().scoped());
- // Behavior registration: fires for any function tagged "attn" (i.e. from either SDPA
- // or SDPADecomposed pattern). The at_partition callback checks whether dynamic
+ // Behavior registration: fires for any function tagged "attn" (i.e. from any SDPA-family
+ // isolation pattern). The at_partition callback checks whether dynamic
// attention was detected (f._attention set by Partitioner::attention()) and, if so,
// stashes the compile-time descriptor in the pipeline context for later stages.
ov::npuw::v1::subgraphs::PatternRegistration attn_behavior;
diff --git a/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp
index 99ebd4abbb0..5b9c821e5c7 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp
@@ -11,6 +11,7 @@
#include "accuracy/comparator.hpp"
#include "attn/attn_subgraph.hpp"
+#include "gqa_compiled_model.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "just_sync_infer_request.hpp"
#include "logging.hpp"
@@ -294,6 +295,7 @@ std::shared_ptr<ov::npuw::ICompiledModel> ov::npuw::ICompiledModel::create(
LOG_INFO("Choosing which NPUW CompiledModel to create");
LOG_BLOCK();
std::shared_ptr<ov::npuw::ICompiledModel> compiled_model;
+ auto use_gqa_key = ov::intel_npu::npuw::gqa::enabled.name();
auto use_llm_key = ov::intel_npu::npuw::llm::enabled.name();
auto use_kokoro_key = ov::intel_npu::npuw::kokoro::enabled.name();
@@ -303,7 +305,10 @@ std::shared_ptr<ov::npuw::ICompiledModel> ov::npuw::ICompiledModel::create(
auto config = properties;
config.erase(ov::cache_dir.name());
- if (properties.count(use_llm_key) && properties.at(use_llm_key).as<bool>() == true) {
+ if (properties.count(use_gqa_key) && properties.at(use_gqa_key).as<bool>() == true) {
+ LOG_INFO("ov::npuw::GQACompiledModel will be created.");
+ compiled_model = std::make_shared<ov::npuw::GQACompiledModel>(model, plugin, config);
+ } else if (properties.count(use_llm_key) && properties.at(use_llm_key).as<bool>() == true) {
LOG_INFO("ov::npuw::LLMCompiledModel will be created.");
compiled_model = std::make_shared<ov::npuw::LLMCompiledModel>(model, plugin, config);
} else if (properties.count(use_kokoro_key) && properties.at(use_kokoro_key).as<bool>() == true) {
diff --git a/src/plugins/intel_npu/src/plugin/npuw/gqa_compiled_model.cpp b/src/plugins/intel_npu/src/plugin/npuw/gqa_compiled_model.cpp
new file mode 100644
index 00000000000..babe2fbd457
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/gqa_compiled_model.cpp
@@ -0,0 +1,319 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "gqa_compiled_model.hpp"
+
+#include <algorithm>
+#include <cctype>
+#include <utility>
+
+#include "intel_npu/config/npuw.hpp"
+#include "logging.hpp"
+#include "npuw_transformations/collapse_unqdq.hpp"
+#include "npuw_transformations/conv_to_matmul.hpp"
+#include "npuw_transformations/drop_zp_subtract.hpp"
+#include "npuw_transformations/untangle_dq_scale.hpp"
+#include "openvino/core/version.hpp"
+#include "openvino/runtime/properties.hpp"
+#include "serialization.hpp"
+
+namespace {
+
+void merge_config_with(ov::AnyMap& lhs, const ov::AnyMap& rhs) {
+ for (const auto& [key, value] : rhs) {
+ if (auto it = lhs.find(key); it != lhs.end()) {
+ it->second = value;
+ } else {
+ lhs.emplace(key, value);
+ }
+ }
+}
+
+ov::AnyMap with_gqa_defaults(const std::shared_ptr<ov::Model>& model, const ov::AnyMap& properties) {
+ enum class GQAModelStage {
+ UNKNOWN,
+ PREFILL,
+ GENERATE,
+ };
+
+ const auto detect_gqa_model_stage = [&]() {
+ const auto to_lower = [](std::string value) {
+ std::transform(value.begin(), value.end(), value.begin(), [](unsigned char ch) {
+ return static_cast<char>(std::tolower(ch));
+ });
+ return value;
+ };
+
+ const auto is_cache_parameter_name = [&](const std::string& name) {
+ const auto lower_name = to_lower(name);
+ return lower_name.find("past") != std::string::npos || lower_name.find("present") != std::string::npos ||
+ lower_name.find("cache") != std::string::npos;
+ };
+
+ bool saw_generate_input = false;
+ bool saw_prefill_input = false;
+
+ for (const auto& parameter : model->get_parameters()) {
+ if (is_cache_parameter_name(parameter->get_friendly_name())) {
+ continue;
+ }
+
+ const auto element_type = parameter->get_element_type();
+ if (!element_type.is_real()) {
+ continue;
+ }
+
+ const auto& partial_shape = parameter->get_partial_shape();
+ if (partial_shape.rank().is_dynamic() || partial_shape.rank().get_length() != 3) {
+ continue;
+ }
+
+ const auto& token_dim = partial_shape[1];
+ if (token_dim.is_dynamic()) {
+ continue;
+ }
+
+ const auto token_count = token_dim.get_length();
+ if (token_count == 1) {
+ saw_generate_input = true;
+ } else if (token_count > 1) {
+ saw_prefill_input = true;
+ }
+
+ if (saw_generate_input && saw_prefill_input) {
+ return GQAModelStage::UNKNOWN;
+ }
+ }
+
+ if (saw_generate_input) {
+ return GQAModelStage::GENERATE;
+ }
+ if (saw_prefill_input) {
+ return GQAModelStage::PREFILL;
+ }
+ return GQAModelStage::UNKNOWN;
+ };
+
+ ov::AnyMap config = {
+ {"NPUW_ONLINE_PIPELINE", "REP"},
+ {std::string(::intel_npu::NPUW_DEVICES::key()), "NPU"},
+ {std::string(::intel_npu::NPUW_FOLD::key()), "YES"},
+ {ov::cache_mode.name(), ov::CacheMode::OPTIMIZE_SPEED},
+ {std::string(::intel_npu::NPUW_UNQDQ::key()), "YES"},
+ };
+
+ if (detect_gqa_model_stage() != GQAModelStage::GENERATE) {
+ merge_config_with(config,
+ {{"NPUW_ONLINE_ISOLATE", "ATTN"},
+ {"NPUW_FOLD_ONLY", "attn"},
+ {"NPUW_ATTN", "STATIC"},
+ {"NPUW_ONLINE_KEEP_BLOCK_SIZE", "9"}});
+ } else {
+ merge_config_with(config,
+ {{std::string(::intel_npu::NPUW_FUNCALL_ASYNC::key()), "YES"},
+ {std::string(::intel_npu::NPUW_UNFOLD_IREQS::key()), "YES"}});
+ LOG_INFO("Detected generate-style GQA model; skipping ATTN isolation defaults");
+ }
+ merge_config_with(config, properties);
+ return config;
+}
+
+} // namespace
+
+ov::npuw::GQACompiledModel::PreparedState ov::npuw::GQACompiledModel::prepare(const std::shared_ptr<ov::Model>& model,
+ const ov::AnyMap& properties) {
+ auto prepared_properties = with_gqa_defaults(model, properties);
+ // Untangle shared scale constants so every DequantizeLinear Multiply
+ // gets its own copy. Some exporters reuse a single scale node across
+ // multiple layers; NPUW's FOLD pass requires per-instance scalars.
+ ov::npuw::UntangleDQScale untangle_dq_scale;
+ untangle_dq_scale.run_on_model(model);
+ // Drop all-zero zero-point Subtract nodes so ConvToMatMul sees a clean
+ // Convert(Parameter) → Multiply(scale) weight chain.
+ ov::npuw::DropZPSubtract drop_zp_subtract;
+ drop_zp_subtract.run_on_model(model);
+ // Rewrite 1x1 Convolutions with compressed (Parameter-sourced) weights as
+ // MatMul + scale Multiply, keeping the Parameter shapes intact.
+ ov::npuw::ConvToMatMul conv_to_matmul;
+ conv_to_matmul.run_on_model(model);
+ // Collapse FakeQuantize-based QDQ chains when requested.
+ if (prepared_properties.at(std::string(::intel_npu::NPUW_UNQDQ::key())).as<bool>()) {
+ ov::npuw::CollapseUNQDQ collapse_unqdq;
+ collapse_unqdq.run_on_model(model);
+ }
+ return {model, std::move(prepared_properties)};
+}
+
+std::shared_ptr<ov::npuw::ICompiledModel> ov::npuw::GQACompiledModel::make_compiled_model(
+ const std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap& properties) {
+ return std::make_shared<ov::npuw::CompiledModel>(model, plugin, properties);
+}
+
+ov::npuw::GQACompiledModel::GQACompiledModel(const std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap& properties,
+ CompiledModelFactory factory)
+ : GQACompiledModel(prepare(model, properties), plugin, std::move(factory)) {}
+
+ov::npuw::GQACompiledModel::GQACompiledModel(PreparedState prepared,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ CompiledModelFactory factory)
+ : ov::npuw::ICompiledModel(prepared.model, plugin),
+ m_compiled_model(factory(prepared.model, plugin, prepared.properties)) {
+ OPENVINO_ASSERT(m_compiled_model != nullptr, "GQACompiledModel requires a valid inner compiled model");
+}
+
+void ov::npuw::GQACompiledModel::export_model(std::ostream& stream) const {
+ using namespace ov::npuw::s11n;
+ write(stream, NPUW_SERIALIZATION_INDICATOR);
+ write(stream, NPUW_GQA_COMPILED_MODEL_INDICATOR);
+ write(stream, OPENVINO_VERSION_MAJOR);
+ write(stream, OPENVINO_VERSION_MINOR);
+ write(stream, OPENVINO_VERSION_PATCH);
+ write(stream, std::string(NPUW_SERIALIZATION_VERSION));
+ m_compiled_model->export_model(stream);
+}
+
+std::shared_ptr<ov::npuw::ICompiledModel> ov::npuw::GQACompiledModel::import_model(
+ std::istream& stream,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap& properties) {
+ LOG_INFO("Deserializing GQACompiledModel...");
+ LOG_BLOCK();
+
+ using namespace ov::npuw::s11n;
+
+ ov::npuw::s11n::IndicatorType serialization_indicator;
+ read(stream, serialization_indicator);
+ NPUW_ASSERT(serialization_indicator == NPUW_SERIALIZATION_INDICATOR);
+
+ ov::npuw::s11n::IndicatorType gqa_indicator;
+ read(stream, gqa_indicator);
+ NPUW_ASSERT(gqa_indicator == NPUW_GQA_COMPILED_MODEL_INDICATOR);
+
+ int vmajor, vminor, vpatch;
+ std::string s11n_version;
+ read(stream, vmajor);
+ read(stream, vminor);
+ read(stream, vpatch);
+ read(stream, s11n_version);
+
+ if (vmajor != OPENVINO_VERSION_MAJOR || vminor != OPENVINO_VERSION_MINOR || vpatch != OPENVINO_VERSION_PATCH ||
+ s11n_version != std::string(NPUW_SERIALIZATION_VERSION)) {
+ OPENVINO_THROW("GQA blob was serialized with a different OV version (",
+ vmajor,
+ '.',
+ vminor,
+ '.',
+ vpatch,
+ " / NPUW s11n ",
+ s11n_version,
+ "); current is ",
+ OPENVINO_VERSION_MAJOR,
+ '.',
+ OPENVINO_VERSION_MINOR,
+ '.',
+ OPENVINO_VERSION_PATCH,
+ " / NPUW s11n ",
+ NPUW_SERIALIZATION_VERSION);
+ }
+
+ // The rest of the stream is the inner CompiledModel ORC blob.
+ // After import it is fully self-contained; no outer GQA wrapper is needed
+ // because the partitioning is already baked in and port mappings are consistent.
+ return ov::npuw::CompiledModel::import_model(stream, plugin, properties);
+}
+
+std::shared_ptr<const ov::Model> ov::npuw::GQACompiledModel::get_runtime_model() const {
+ return m_compiled_model->get_runtime_model();
+}
+
+void ov::npuw::GQACompiledModel::set_property(const ov::AnyMap& properties) {
+ m_compiled_model->set_property(properties);
+}
+
+ov::Any ov::npuw::GQACompiledModel::get_property(const std::string& name) const {
+ return m_compiled_model->get_property(name);
+}
+
+std::shared_ptr<ov::ISyncInferRequest> ov::npuw::GQACompiledModel::create_sync_infer_request() const {
+ auto self = std::static_pointer_cast<const GQACompiledModel>(shared_from_this());
+ return std::make_shared<ov::npuw::GQAInferRequest>(std::move(self));
+}
+
+ov::npuw::GQAInferRequest::GQAInferRequest(std::shared_ptr<const GQACompiledModel> compiled_model)
+ : ov::ISyncInferRequest(compiled_model),
+ m_compiled_model(std::move(compiled_model)) {}
+
+void ov::npuw::GQAInferRequest::ensure_inner_request_locked() const {
+ if (m_inner_request == nullptr) {
+ m_inner_request = m_compiled_model->m_compiled_model->create_infer_request();
+ OPENVINO_ASSERT(m_inner_request != nullptr, "GQA infer request requires a valid inner request");
+ }
+}
+
+const ov::Output<const ov::Node>& ov::npuw::GQAInferRequest::map_port_locked(
+ const ov::Output<const ov::Node>& port) const {
+ ensure_inner_request_locked();
+
+ const auto& outer_inputs = m_compiled_model->inputs();
+ const auto& inner_inputs = m_inner_request->get_compiled_model()->inputs();
+ for (size_t i = 0; i < outer_inputs.size(); ++i) {
+ if (outer_inputs[i] == port) {
+ OPENVINO_ASSERT(i < inner_inputs.size(), "Input port index is out of range in inner infer request");
+ return inner_inputs[i];
+ }
+ }
+
+ const auto& outer_outputs = m_compiled_model->outputs();
+ const auto& inner_outputs = m_inner_request->get_compiled_model()->outputs();
+ for (size_t i = 0; i < outer_outputs.size(); ++i) {
+ if (outer_outputs[i] == port) {
+ OPENVINO_ASSERT(i < inner_outputs.size(), "Output port index is out of range in inner infer request");
+ return inner_outputs[i];
+ }
+ }
+
+ OPENVINO_THROW("Unknown GQA infer request port: ", port.get_any_name());
+}
+
+void ov::npuw::GQAInferRequest::infer() {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ ensure_inner_request_locked();
+ m_inner_request->infer();
+}
+
+ov::SoPtr<ov::ITensor> ov::npuw::GQAInferRequest::get_tensor(const ov::Output<const ov::Node>& port) const {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ ensure_inner_request_locked();
+ return m_inner_request->get_tensor(map_port_locked(port));
+}
+
+void ov::npuw::GQAInferRequest::set_tensor(const ov::Output<const ov::Node>& port,
+ const ov::SoPtr<ov::ITensor>& tensor) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ ensure_inner_request_locked();
+ m_inner_request->set_tensor(map_port_locked(port), tensor);
+}
+
+void ov::npuw::GQAInferRequest::check_tensors() const {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ // Trigger lazy inner request initialization; the JustInferRequest constructor
+ // allocates all sub-tensors during construction, so nothing more is needed here.
+ ensure_inner_request_locked();
+}
+
+std::vector<ov::SoPtr<ov::IVariableState>> ov::npuw::GQAInferRequest::query_state() const {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ ensure_inner_request_locked();
+ return m_inner_request->query_state();
+}
+
+std::vector<ov::ProfilingInfo> ov::npuw::GQAInferRequest::get_profiling_info() const {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ ensure_inner_request_locked();
+ return m_inner_request->get_profiling_info();
+}
diff --git a/src/plugins/intel_npu/src/plugin/npuw/gqa_compiled_model.hpp b/src/plugins/intel_npu/src/plugin/npuw/gqa_compiled_model.hpp
new file mode 100644
index 00000000000..61e277b27d6
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/gqa_compiled_model.hpp
@@ -0,0 +1,85 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <functional>
+#include <memory>
+#include <mutex>
+
+#include "npuw/compiled_model.hpp"
+
+namespace ov::npuw {
+
+class GQACompiledModel;
+
+class GQAInferRequest final : public ov::ISyncInferRequest {
+public:
+ explicit GQAInferRequest(std::shared_ptr<const GQACompiledModel> compiled_model);
+
+ void infer() override;
+
+ ov::SoPtr<ov::ITensor> get_tensor(const ov::Output<const ov::Node>& port) const override;
+ void set_tensor(const ov::Output<const ov::Node>& port, const ov::SoPtr<ov::ITensor>& tensor) override;
+ void check_tensors() const override;
+
+ std::vector<ov::SoPtr<ov::IVariableState>> query_state() const override;
+ std::vector<ov::ProfilingInfo> get_profiling_info() const override;
+
+private:
+ void ensure_inner_request_locked() const;
+ const ov::Output<const ov::Node>& map_port_locked(const ov::Output<const ov::Node>& port) const;
+
+ std::shared_ptr<const GQACompiledModel> m_compiled_model;
+ mutable std::mutex m_mutex;
+ mutable std::shared_ptr<ov::IAsyncInferRequest> m_inner_request;
+};
+
+class GQACompiledModel final : public ov::npuw::ICompiledModel {
+public:
+ using CompiledModelFactory =
+ std::function<std::shared_ptr<ov::npuw::ICompiledModel>(const std::shared_ptr<ov::Model>&,
+ const std::shared_ptr<const ov::IPlugin>&,
+ const ov::AnyMap&)>;
+
+ static std::shared_ptr<ov::npuw::ICompiledModel> make_compiled_model(
+ const std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap& properties);
+
+ GQACompiledModel(const std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap& properties,
+ CompiledModelFactory factory = make_compiled_model);
+
+ static std::shared_ptr<ov::npuw::ICompiledModel> import_model(std::istream& stream,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap& properties);
+
+ void export_model(std::ostream& stream) const override;
+ std::shared_ptr<const ov::Model> get_runtime_model() const override;
+
+ void set_property(const ov::AnyMap& properties) override;
+ ov::Any get_property(const std::string& name) const override;
+
+private:
+ struct PreparedState {
+ std::shared_ptr<ov::Model> model;
+ ov::AnyMap properties;
+ };
+
+ static PreparedState prepare(const std::shared_ptr<ov::Model>& model, const ov::AnyMap& properties);
+
+ GQACompiledModel(PreparedState prepared,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ CompiledModelFactory factory);
+
+ std::shared_ptr<ov::ISyncInferRequest> create_sync_infer_request() const override;
+
+ friend class GQAInferRequest;
+
+ std::shared_ptr<ov::npuw::ICompiledModel> m_compiled_model;
+};
+
+} // namespace ov::npuw
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/collapse_unqdq.cpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/collapse_unqdq.cpp
new file mode 100644
index 00000000000..43d0381cd8f
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/collapse_unqdq.cpp
@@ -0,0 +1,77 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "collapse_unqdq.hpp"
+
+#include <memory>
+#include <string>
+
+#include "openvino/core/graph_util.hpp"
+#include "openvino/op/convert.hpp"
+#include "openvino/op/fake_quantize.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/subtract.hpp"
+#include "openvino/pass/matcher_pass.hpp"
+#include "openvino/pass/pattern/op/optional.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace opp = ov::pass::pattern;
+
+namespace {
+
+ov::Output<ov::Node> preserve_output_type(const ov::Output<ov::Node>& replacement,
+ const ov::element::Type& expected_type,
+ const std::string& friendly_name) {
+ if (replacement.get_element_type() == expected_type) {
+ return replacement;
+ }
+
+ auto convert = std::make_shared<ov::op::v0::Convert>(replacement, expected_type);
+ convert->set_friendly_name(friendly_name);
+ return convert;
+}
+
+} // namespace
+
+class CollapseUNQDQChain final : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ov::npuw::CollapseUNQDQChain");
+
+ CollapseUNQDQChain() {
+ // Pattern:
+ // FakeQuantize(input, ...)
+ // → Convert (quantize, e.g. to u16)
+ // → Convert (dequantize, back to f32)
+ // → Subtract (zero-point)
+ // → Multiply (scale) ← anchor
+ auto input = opp::any_input();
+ auto fake_q = opp::wrap_type<ov::op::v0::FakeQuantize>(
+ {input, opp::any_input(), opp::any_input(), opp::any_input(), opp::any_input()});
+ auto cvt_q = opp::wrap_type<ov::op::v0::Convert>({fake_q});
+ auto cvt_dq = opp::wrap_type<ov::op::v0::Convert>({cvt_q});
+ auto subtract = opp::wrap_type<ov::op::v1::Subtract>({cvt_dq, opp::any_input()});
+ auto multiply = opp::wrap_type<ov::op::v1::Multiply>({subtract, opp::any_input()});
+
+ // Note: use [=] so pattern nodes stay alive inside the callback.
+ ov::matcher_pass_callback callback = [=](opp::Matcher& m) {
+ auto& node_to_output = m.get_pattern_value_map();
+
+ const auto matched_multiply = ov::as_type_ptr<ov::op::v1::Multiply>(m.get_match_root());
+ const auto matched_input = node_to_output.at(input);
+
+ ov::Output<ov::Node> replacement = matched_input;
+ replacement = preserve_output_type(replacement,
+ matched_multiply->get_output_element_type(0),
+ matched_multiply->get_friendly_name());
+ ov::replace_node(matched_multiply, ov::OutputVector{replacement});
+ return true;
+ };
+
+ register_matcher(std::make_shared<opp::Matcher>(multiply, "CollapseUNQDQChain"), callback);
+ }
+};
+
+ov::npuw::CollapseUNQDQ::CollapseUNQDQ() {
+ add_matcher<CollapseUNQDQChain>();
+}
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/collapse_unqdq.hpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/collapse_unqdq.hpp
new file mode 100644
index 00000000000..ed0d0544047
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/collapse_unqdq.hpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/pass/graph_rewrite.hpp"
+
+namespace ov::npuw {
+
+class CollapseUNQDQ : public ov::pass::GraphRewrite {
+public:
+ OPENVINO_GRAPH_REWRITE_RTTI("ov::npuw::CollapseUNQDQ");
+ CollapseUNQDQ();
+};
+
+} // namespace ov::npuw
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/conv_to_matmul.cpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/conv_to_matmul.cpp
new file mode 100644
index 00000000000..aece851393f
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/conv_to_matmul.cpp
@@ -0,0 +1,276 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "conv_to_matmul.hpp"
+
+#include <algorithm>
+#include <cstdint>
+#include <functional>
+#include <memory>
+#include <numeric>
+#include <string>
+#include <vector>
+
+#include "openvino/core/graph_util.hpp"
+#include "openvino/core/validation_util.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/convert.hpp"
+#include "openvino/op/convolution.hpp"
+#include "openvino/op/matmul.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/pass/matcher_pass.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace opp = ov::pass::pattern;
+
+namespace {
+
+ov::Output<ov::Node> preserve_output_type(const ov::Output<ov::Node>& replacement,
+ const ov::element::Type& expected_type,
+ const std::string& friendly_name) {
+ if (replacement.get_element_type() == expected_type) {
+ return replacement;
+ }
+
+ auto convert = std::make_shared<ov::op::v0::Convert>(replacement, expected_type);
+ convert->set_friendly_name(friendly_name);
+ return convert;
+}
+
+bool is_pointwise_kernel_shape(const ov::Shape& shape) {
+ return shape.size() == 4 && shape[2] == 1 && shape[3] == 1;
+}
+
+bool is_matmul_side_shape(const ov::Shape& shape) {
+ return shape.size() == 4 && shape[1] == 1;
+}
+
+bool is_conv_activation_shape(const ov::Shape& shape) {
+ return shape.size() == 4 && shape[2] == 1;
+}
+
+std::size_t element_count(const ov::Shape& shape) {
+ return std::accumulate(shape.begin(), shape.end(), std::size_t{1}, std::multiplies<std::size_t>{});
+}
+
+std::shared_ptr<ov::op::v0::Constant> make_i32_shape_constant(const std::vector<int32_t>& dims) {
+ return ov::op::v0::Constant::create(ov::element::i32, ov::Shape{dims.size()}, dims);
+}
+
+bool has_permutation(const ov::Output<ov::Node>& output, const std::vector<int64_t>& expected) {
+ const auto constant = ov::util::get_constant_from_source(output);
+ if (constant == nullptr) {
+ return false;
+ }
+
+ return constant->cast_vector<int64_t>() == expected;
+}
+
+ov::Output<ov::Node> peel_passthrough_nodes(ov::Output<ov::Node> output) {
+ while (true) {
+ if (const auto convert = ov::as_type_ptr<ov::op::v0::Convert>(output.get_node_shared_ptr())) {
+ output = convert->input_value(0);
+ continue;
+ }
+ if (const auto reshape = ov::as_type_ptr<ov::op::v1::Reshape>(output.get_node_shared_ptr())) {
+ output = reshape->input_value(0);
+ continue;
+ }
+ return output;
+ }
+}
+
+// Returns true if `output` is a chain of one or more Convert nodes whose final
+// input is a Parameter. Such a chain is the compressed-weight pattern:
+// Parameter (i4/i8/…) → Convert → [Convert …] → Multiply(scale) → Conv
+// We require at least one Convert so we never reshape raw quantised data.
+bool is_convert_param_chain(const ov::Output<ov::Node>& output) {
+ auto cur = output;
+ while (true) {
+ const auto convert = ov::as_type_ptr<ov::op::v0::Convert>(cur.get_node_shared_ptr());
+ if (convert == nullptr) {
+ return false;
+ }
+ if (ov::is_type<ov::op::v0::Parameter>(convert->input_value(0).get_node_shared_ptr())) {
+ return true;
+ }
+ cur = convert->input_value(0);
+ }
+}
+
+bool rewrite_conv_to_matmul(const std::shared_ptr<ov::op::v1::Convolution>& convolution) {
+ const auto transpose_in = ov::as_type_ptr<ov::op::v1::Transpose>(convolution->input_value(0).get_node_shared_ptr());
+ const auto weight_multiply =
+ ov::as_type_ptr<ov::op::v1::Multiply>(convolution->input_value(1).get_node_shared_ptr());
+ if (weight_multiply == nullptr) {
+ return false;
+ }
+
+ ov::Output<ov::Node> matmul_input;
+ if (transpose_in != nullptr) {
+ if (!has_permutation(transpose_in->input_value(1), {0, 3, 1, 2})) {
+ return false;
+ }
+ matmul_input = transpose_in->input_value(0);
+ } else {
+ const auto& conv_input_shape = convolution->input_value(0).get_shape();
+ if (!is_conv_activation_shape(conv_input_shape)) {
+ return false;
+ }
+ matmul_input = std::make_shared<ov::op::v1::Transpose>(
+ convolution->input_value(0),
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, std::vector<int32_t>{0, 2, 3, 1}));
+ }
+
+ if (!is_matmul_side_shape(matmul_input.get_shape())) {
+ return false;
+ }
+
+ // weight_convert_output: output of the outermost Convert in the
+ // Convert(…Convert(Parameter)…) chain — already a float tensor with shape
+ // [OC, IC, 1, 1]. We add a Reshape *after* this node so that the
+ // Parameter shape [OC, IC, 1, 1] is preserved in the graph.
+ ov::Output<ov::Node> weight_convert_output;
+ ov::Output<ov::Node> scale_source;
+
+ const auto match_branch = [&](const ov::Output<ov::Node>& weight_branch,
+ const ov::Output<ov::Node>& scale_branch) -> bool {
+ // Weight must be a chain of Converts whose root is a Parameter.
+ // Any intermediate Subtract (zero-point) node will cause the chain
+ // check to fail and the match to be skipped.
+ if (!is_convert_param_chain(weight_branch)) {
+ return false;
+ }
+
+ const auto peeled_scale_source = peel_passthrough_nodes(scale_branch);
+ const auto scale_base_node = peeled_scale_source.get_node_shared_ptr();
+ if (!ov::is_type<ov::op::v0::Parameter>(scale_base_node) &&
+ !ov::is_type<ov::op::v0::Constant>(scale_base_node)) {
+ return false;
+ }
+
+ const auto& conv_weight_shape = weight_branch.get_shape();
+ if (!is_pointwise_kernel_shape(conv_weight_shape) ||
+ element_count(peeled_scale_source.get_shape()) != conv_weight_shape[0]) {
+ return false;
+ }
+
+ weight_convert_output = weight_branch;
+ scale_source = peeled_scale_source;
+ return true;
+ };
+
+ if (!match_branch(weight_multiply->input_value(0), weight_multiply->input_value(1)) &&
+ !match_branch(weight_multiply->input_value(1), weight_multiply->input_value(0))) {
+ return false;
+ }
+
+ const auto& conv_weight_shape = weight_convert_output.get_shape(); // [OC, IC, 1, 1]
+
+ if (convolution->get_strides() != ov::Strides{1, 1} || convolution->get_dilations() != ov::Strides{1, 1} ||
+ convolution->get_pads_begin() != ov::CoordinateDiff{0, 0} ||
+ convolution->get_pads_end() != ov::CoordinateDiff{0, 0}) {
+ return false;
+ }
+
+ // Reshape the float weight tensor from [OC, IC, 1, 1] to [OC, IC].
+ // The Reshape is inserted *after* the Convert chain so the Parameter node
+ // retains its original shape and the runtime can bind tensors as-is.
+ auto weight_reshape =
+ std::make_shared<ov::op::v1::Reshape>(weight_convert_output,
+ make_i32_shape_constant({static_cast<int32_t>(conv_weight_shape[0]),
+ static_cast<int32_t>(conv_weight_shape[1])}),
+ false);
+
+ auto matmul = std::make_shared<ov::op::v0::MatMul>(matmul_input, weight_reshape, false, true);
+
+ auto scale_reshape = std::make_shared<ov::op::v1::Reshape>(
+ scale_source,
+ make_i32_shape_constant({1, 1, 1, static_cast<int32_t>(conv_weight_shape[0])}),
+ false);
+ ov::Output<ov::Node> scaled_coeff = scale_reshape;
+ if (scale_reshape->get_output_element_type(0) != matmul->get_output_element_type(0)) {
+ scaled_coeff = std::make_shared<ov::op::v0::Convert>(scale_reshape, matmul->get_output_element_type(0));
+ }
+ auto scaled_output = std::make_shared<ov::op::v1::Multiply>(matmul, scaled_coeff);
+
+ const auto consumers = convolution->output(0).get_target_inputs();
+ if (consumers.size() == 1) {
+ const auto consumer = *consumers.begin();
+ if (const auto transpose_out =
+ ov::as_type_ptr<ov::op::v1::Transpose>(consumer.get_node()->shared_from_this())) {
+ if (has_permutation(transpose_out->input_value(1), {0, 2, 3, 1}) &&
+ is_matmul_side_shape(transpose_out->output(0).get_shape())) {
+ ov::Output<ov::Node> replacement = preserve_output_type(scaled_output->output(0),
+ transpose_out->get_output_element_type(0),
+ transpose_out->get_friendly_name());
+ replacement.get_node_shared_ptr()->set_friendly_name(transpose_out->get_friendly_name());
+ ov::replace_node(transpose_out, ov::OutputVector{replacement});
+ return true;
+ }
+ }
+ }
+
+ auto transpose_back = std::make_shared<ov::op::v1::Transpose>(
+ scaled_output,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, std::vector<int32_t>{0, 3, 1, 2}));
+ ov::Output<ov::Node> replacement = preserve_output_type(transpose_back->output(0),
+ convolution->get_output_element_type(0),
+ convolution->get_friendly_name());
+ replacement.get_node_shared_ptr()->set_friendly_name(convolution->get_friendly_name());
+ ov::replace_node(convolution, ov::OutputVector{replacement});
+ return true;
+}
+
+} // namespace
+
+class ConvToMatMulMatcher final : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ov::npuw::ConvToMatMulMatcher");
+
+ ConvToMatMulMatcher() {
+ auto convolution_with_output_transpose_pattern = opp::wrap_type<ov::op::v1::Convolution>();
+ auto output_transpose_pattern =
+ opp::wrap_type<ov::op::v1::Transpose>({convolution_with_output_transpose_pattern, opp::any_input()});
+
+ ov::matcher_pass_callback output_transpose_callback = [](opp::Matcher& matcher) {
+ const auto output_transpose = ov::as_type_ptr<ov::op::v1::Transpose>(matcher.get_match_root());
+ if (output_transpose == nullptr) {
+ return false;
+ }
+
+ const auto convolution =
+ ov::as_type_ptr<ov::op::v1::Convolution>(output_transpose->input_value(0).get_node_shared_ptr());
+ if (convolution == nullptr) {
+ return false;
+ }
+
+ return rewrite_conv_to_matmul(convolution);
+ };
+
+ register_matcher(std::make_shared<opp::Matcher>(output_transpose_pattern, "ConvToMatMulOutputTransposeMatcher"),
+ output_transpose_callback);
+
+ auto convolution_pattern = opp::wrap_type<ov::op::v1::Convolution>();
+
+ ov::matcher_pass_callback convolution_callback = [](opp::Matcher& matcher) {
+ const auto convolution = ov::as_type_ptr<ov::op::v1::Convolution>(matcher.get_match_root());
+ if (convolution == nullptr) {
+ return false;
+ }
+
+ return rewrite_conv_to_matmul(convolution);
+ };
+
+ register_matcher(std::make_shared<opp::Matcher>(convolution_pattern, "ConvToMatMulMatcher"),
+ convolution_callback);
+ }
+};
+
+ov::npuw::ConvToMatMul::ConvToMatMul() {
+ add_matcher<ConvToMatMulMatcher>();
+}
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/conv_to_matmul.hpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/conv_to_matmul.hpp
new file mode 100644
index 00000000000..49bf418e405
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/conv_to_matmul.hpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/pass/graph_rewrite.hpp"
+
+namespace ov::npuw {
+
+class ConvToMatMul : public ov::pass::GraphRewrite {
+public:
+ OPENVINO_GRAPH_REWRITE_RTTI("ov::npuw::ConvToMatMul");
+ ConvToMatMul();
+};
+
+} // namespace ov::npuw
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/drop_zp_subtract.cpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/drop_zp_subtract.cpp
new file mode 100644
index 00000000000..5b5d9d55ab4
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/drop_zp_subtract.cpp
@@ -0,0 +1,62 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "drop_zp_subtract.hpp"
+
+#include <algorithm>
+#include <memory>
+
+#include "openvino/core/graph_util.hpp"
+#include "openvino/core/validation_util.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/subtract.hpp"
+#include "openvino/pass/matcher_pass.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace opp = ov::pass::pattern;
+
+namespace {
+
+bool is_all_zero_constant(const ov::Output<ov::Node>& output) {
+ const auto constant = ov::util::get_constant_from_source(output);
+ if (constant == nullptr) {
+ return false;
+ }
+
+ const auto values = constant->cast_vector<double>();
+ return std::all_of(values.begin(), values.end(), [](double value) {
+ return value == 0.0;
+ });
+}
+
+} // namespace
+
+class DropZeroPointSubtractMatcher final : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ov::npuw::DropZeroPointSubtractMatcher");
+
+ DropZeroPointSubtractMatcher() {
+ auto subtract_pattern = opp::wrap_type<ov::op::v1::Subtract>();
+
+ ov::matcher_pass_callback callback = [](opp::Matcher& matcher) {
+ const auto subtract = ov::as_type_ptr<ov::op::v1::Subtract>(matcher.get_match_root());
+ if (subtract == nullptr) {
+ return false;
+ }
+
+ if (!is_all_zero_constant(subtract->input_value(1))) {
+ return false;
+ }
+
+ ov::replace_node(subtract, ov::OutputVector{subtract->input_value(0)});
+ return true;
+ };
+
+ register_matcher(std::make_shared<opp::Matcher>(subtract_pattern, "DropZeroPointSubtractMatcher"), callback);
+ }
+};
+
+ov::npuw::DropZPSubtract::DropZPSubtract() {
+ add_matcher<DropZeroPointSubtractMatcher>();
+}
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/drop_zp_subtract.hpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/drop_zp_subtract.hpp
new file mode 100644
index 00000000000..b6e56f0985a
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/drop_zp_subtract.hpp
@@ -0,0 +1,20 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/pass/graph_rewrite.hpp"
+
+namespace ov::npuw {
+
+// Removes Subtract(x, zeros) nodes where the subtracted constant is all-zero.
+// This simplifies the dequantization chain (zero-point elimination) before
+// further transformations such as ConvToMatMul.
+class DropZPSubtract : public ov::pass::GraphRewrite {
+public:
+ OPENVINO_GRAPH_REWRITE_RTTI("ov::npuw::DropZPSubtract");
+ DropZPSubtract();
+};
+
+} // namespace ov::npuw
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/untangle_dq_scale.cpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/untangle_dq_scale.cpp
new file mode 100644
index 00000000000..be27fd0b380
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/untangle_dq_scale.cpp
@@ -0,0 +1,65 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "untangle_dq_scale.hpp"
+
+#include <numeric>
+
+#include "openvino/op/constant.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/util/op_types.hpp"
+
+// Finds every Constant node that:
+// - is a tiny scalar (0-D or 1-element) of a floating-point type, and
+// - is consumed by more than one Multiply node,
+// and gives each Multiply its own private copy. This ensures that NPUW's FOLD
+// pass sees one independent scalar bank entry per repeating-block instance.
+//
+// Implementation is a plain graph walk (like patterns::opt::untangleConst) to
+// avoid any MatcherPass/GraphRewrite ordering subtleties.
+
+bool ov::npuw::UntangleDQScale::run_on_model(const std::shared_ptr<ov::Model>& model) {
+ bool changed = false;
+
+ // Snapshot the ops — we may add new Constants during the loop.
+ const auto ops = model->get_ordered_ops();
+
+ for (const auto& node : ops) {
+ if (!ov::op::util::is_constant(node)) {
+ continue;
+ }
+
+ const auto& shape = node->output(0).get_shape();
+ const std::size_t total =
+ std::accumulate(shape.begin(), shape.end(), std::size_t{1}, std::multiplies<std::size_t>{});
+ if (total > 1) {
+ continue; // not a scalar — skip
+ }
+
+ const auto& etype = node->output(0).get_element_type();
+ if (!etype.is_real()) {
+ continue; // only float scalars belong in the DQ scale bank
+ }
+
+ // Collect readers so we can iterate without invalidating the set.
+ const auto readers_set = node->output(0).get_target_inputs();
+ if (readers_set.size() <= 1) {
+ continue;
+ }
+
+ // Clone the constant for every reader except the first, giving each
+ // clone a name derived from the reader so get_unique_name() keeps them apart.
+ auto it = readers_set.begin();
+ ++it; // skip first reader – it keeps the original constant
+ auto const_node = std::static_pointer_cast<ov::op::v0::Constant>(node);
+ for (; it != readers_set.end(); ++it) {
+ auto cloned = std::make_shared<ov::op::v0::Constant>(*const_node);
+ cloned->set_friendly_name(it->get_node()->get_friendly_name() + "/untangled_scale");
+ it->replace_source_output(cloned->output(0));
+ changed = true;
+ }
+ }
+
+ return changed;
+}
diff --git a/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/untangle_dq_scale.hpp b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/untangle_dq_scale.hpp
new file mode 100644
index 00000000000..6a2900e9486
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/untangle_dq_scale.hpp
@@ -0,0 +1,22 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/pass/pass.hpp"
+
+namespace ov::npuw {
+
+// Ensures every shared tiny floating-point Constant (typically a DequantizeLinear
+// scale) consumed by more than one op gets its own private copy. Some model
+// exporters reuse a single scale node across several layers; this shared ownership
+// prevents NPUW's FOLD pass from building a complete per-instance scalar bank,
+// causing partitioning to fail.
+class UntangleDQScale : public ov::pass::ModelPass {
+public:
+ OPENVINO_MODEL_PASS_RTTI("ov::npuw::UntangleDQScale");
+ bool run_on_model(const std::shared_ptr<ov::Model>& model) override;
+};
+
+} // namespace ov::npuw
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp
index 459050b89a3..0d0a82bd400 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp
@@ -8,6 +8,7 @@
#include "../../util.hpp"
#include "../patterns/avoid.hpp"
#include "../patterns/compute.hpp"
+#include "../patterns/gqa.hpp"
#include "../patterns/moe.hpp"
#include "../patterns/sdpa.hpp"
#include "group.hpp"
@@ -768,6 +769,7 @@ void Snapshot::earlyRegroup() {
HNDL_FAKE(FakeQuantize);
HNDL_ATTN(SDPA);
HNDL_ATTN(SDPADecomposed);
+ HNDL_ATTN(GQA);
#undef HNDL_MOE
#undef HNDL_ATTN
#undef HNDL_FAKE
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/utils/utils.hpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/utils/utils.hpp
index 9f27e94f261..ded331e266e 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/utils/utils.hpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/online/utils/utils.hpp
@@ -92,19 +92,20 @@ std::vector<Isolate> getIsolates(const std::string& isolates_unparsed);
std::vector<std::string> getNoFolds(const ::intel_npu::Config& cfg);
std::vector<std::string> getNoFolds(const std::string& nofolds_unparsed);
-static const std::map<std::string, std::string> ISOL_PRESETS = {{"COMPUTE",
- "P:DQMatMulGQu4/compute,P:DQMatMulCWu4/compute,"
- "P:DQMatMulGQi4/compute,P:DQMatMulCWi4/compute,"
- "P:DQMatMulConv/compute,"
- "P:VocabMatMul/compute,"
- "P:RMSNorm/compute,P:RMSNorm2/compute,"
- "P:RMSNorm3/compute,P:RMSNorm4/compute,"
- "P:VariadicSplit/compute"},
- {"FAKE", "P:FakeConvert/fake,P:FakeQuantize/fake"},
- {"ATTN", "P:SDPA/attn,P:SDPADecomposed/attn"},
- {"MOE",
- "P:GPTOSSExpert/expert,P:GPTOSSRouter/router,"
- "P:Qwen3Expert/expert,P:Qwen3Router/router"}};
+static const std::map<std::string, std::string> ISOL_PRESETS = {
+ {"COMPUTE",
+ "P:DQMatMulGQu4/compute,P:DQMatMulCWu4/compute,"
+ "P:DQMatMulGQi4/compute,P:DQMatMulCWi4/compute,"
+ "P:DQMatMulConv/compute,"
+ "P:VocabMatMul/compute,"
+ "P:RMSNorm/compute,P:RMSNorm2/compute,"
+ "P:RMSNorm3/compute,P:RMSNorm4/compute,"
+ "P:VariadicSplit/compute"},
+ {"FAKE", "P:FakeConvert/fake,P:FakeQuantize/fake"},
+ {"ATTN", "P:SDPA/attn,P:SDPADecomposed/attn,P:GQA/attn"},
+ {"MOE",
+ "P:GPTOSSExpert/expert,P:GPTOSSRouter/router,"
+ "P:Qwen3Expert/expert,P:Qwen3Router/router"}};
} // namespace util
} // namespace online
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/gqa.cpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/gqa.cpp
new file mode 100644
index 00000000000..2c70b344f1f
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/gqa.cpp
@@ -0,0 +1,108 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "gqa.hpp"
+
+#include "../../logging.hpp"
+#include "../online/group.hpp" // online::Group
+#include "../online/snapshot.hpp" // online::Snapshot
+#include "openvino/op/broadcast.hpp"
+#include "openvino/op/group_query_attention.hpp"
+#include "openvino/op/shape_of.hpp"
+#include "openvino/op/slice.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov {
+namespace npuw {
+namespace patterns {
+namespace attn {
+
+namespace opp = ov::pass::pattern;
+
+GQA::GQA(const std::shared_ptr<ov::npuw::online::Snapshot>& snapshot, const std::string& isol_tag) {
+ // Match any GroupQueryAttention node regardless of input count (7 base + optional rotary inputs)
+ auto gqa = opp::wrap_type<ov::op::internal::GroupQueryAttention>();
+
+ auto node_to_gptr = snapshot->getNodeToGroupMap();
+
+ auto callback = [=](ov::pass::pattern::Matcher& m) {
+ auto& node_to_output = m.get_pattern_value_map();
+ auto matched_gqa = node_to_output.at(gqa).get_node_shared_ptr();
+
+ LOG_DEBUG("GQA pattern matched: " << matched_gqa->get_friendly_name());
+
+ auto isolate = [&](const std::shared_ptr<ov::Node>& node) {
+ auto it = node_to_gptr->find(node);
+ if (it != node_to_gptr->end()) {
+ it->second->isolate(isol_tag);
+ }
+ };
+
+ // Isolate a Slice node and its Broadcast+ShapeOf step-param harness (input[3]).
+ auto isolate_slice_with_harness = [&](const std::shared_ptr<ov::Node>& slice) {
+ isolate(slice);
+ if (slice->get_input_size() > 3) {
+ auto bcast = slice->input(3).get_source_output().get_node_shared_ptr();
+ if (ov::is_type<ov::op::v3::Broadcast>(bcast)) {
+ isolate(bcast);
+ // ShapeOf feeds input[1] of Broadcast
+ if (bcast->get_input_size() > 1) {
+ auto shapeof = bcast->input(1).get_source_output().get_node_shared_ptr();
+ if (ov::is_type<ov::op::v3::ShapeOf>(shapeof)) {
+ isolate(shapeof);
+ }
+ }
+ }
+ }
+ };
+
+ // Isolate the GQA node itself
+ isolate(matched_gqa);
+
+ // input[4] (past_value) may pass through a Transpose before entering GQA.
+ // Pull that Transpose into the same isolated block.
+ if (matched_gqa->get_input_size() > 4) {
+ auto src4 = matched_gqa->input(4).get_source_output().get_node_shared_ptr();
+ if (ov::is_type<ov::op::v1::Transpose>(src4)) {
+ isolate(src4);
+ }
+ }
+
+ // output[1] (present_key): Slice -> Result (with Broadcast+ShapeOf harness).
+ if (matched_gqa->get_output_size() > 1) {
+ for (auto& target : matched_gqa->output(1).get_target_inputs()) {
+ auto slice = target.get_node()->shared_from_this();
+ if (ov::is_type<ov::op::v8::Slice>(slice)) {
+ isolate_slice_with_harness(slice);
+ }
+ }
+ }
+
+ // output[2] (present_value): Slice -> Transpose -> Result (with Broadcast+ShapeOf harness).
+ if (matched_gqa->get_output_size() > 2) {
+ for (auto& target : matched_gqa->output(2).get_target_inputs()) {
+ auto slice = target.get_node()->shared_from_this();
+ if (ov::is_type<ov::op::v8::Slice>(slice)) {
+ isolate_slice_with_harness(slice);
+ for (auto& t2 : slice->output(0).get_target_inputs()) {
+ auto trans = t2.get_node()->shared_from_this();
+ if (ov::is_type<ov::op::v1::Transpose>(trans)) {
+ isolate(trans);
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ };
+
+ register_matcher(std::make_shared<opp::Matcher>(gqa, "TagGQA"), std::move(callback));
+}
+
+} // namespace attn
+} // namespace patterns
+} // namespace npuw
+} // namespace ov
diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/gqa.hpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/gqa.hpp
new file mode 100644
index 00000000000..85e52e2f2b5
--- /dev/null
+++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/gqa.hpp
@@ -0,0 +1,35 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/pass/matcher_pass.hpp"
+
+namespace ov {
+namespace npuw {
+namespace online {
+class Snapshot;
+} // namespace online
+namespace patterns {
+namespace attn {
+
+class GQA : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("npuw::patterns::attn::GQA");
+ static constexpr const char* pattern_name() {
+ return "GQA";
+ }
+ static constexpr const char* isolation_tag() {
+ return "attn";
+ }
+ static constexpr const char* group_name() {
+ return "attn";
+ }
+ GQA(const std::shared_ptr<ov::npuw::online::Snapshot>& snapshot, const std::string& isol_tag);
+};
+
+} // namespace attn
+} // namespace patterns
+} // namespace npuw
+} // namespace ov
diff --git a/src/plugins/intel_npu/src/plugin/npuw/serialization.hpp b/src/plugins/intel_npu/src/plugin/npuw/serialization.hpp
index d5072db6406..03ad029242f 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/serialization.hpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/serialization.hpp
@@ -44,7 +44,11 @@ const constexpr ov::npuw::s11n::IndicatorType NPUW_COMPILED_MODEL_INDICATOR =
const constexpr ov::npuw::s11n::IndicatorType NPUW_LLM_COMPILED_MODEL_INDICATOR =
{char{0x4c}, char{0x4c}, char{0x4d}, char{0x43}, char{0x4d}, char{0x4f}};
-const constexpr char* NPUW_SERIALIZATION_VERSION = "0.25";
+// GQA = 0x47,0x51,0x41 + CMO = 0x43,0x4d,0x4f
+const constexpr ov::npuw::s11n::IndicatorType NPUW_GQA_COMPILED_MODEL_INDICATOR =
+ {char{0x47}, char{0x51}, char{0x41}, char{0x43}, char{0x4d}, char{0x4f}};
+
+const constexpr char* NPUW_SERIALIZATION_VERSION = "0.26";
// Forward declaration
namespace intel_npu {
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 286dff6c645..35638fc48a3 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -20,6 +20,7 @@
#include "intel_npu/utils/utils.hpp"
#include "metrics.hpp"
#include "npuw/compiled_model.hpp"
+#include "npuw/gqa_compiled_model.hpp"
#include "npuw/llm_compiled_model.hpp"
#include "npuw/orc/schema_npuw.hpp"
#include "npuw/serialization.hpp"
@@ -164,7 +165,9 @@ std::shared_ptr<ov::ICompiledModel> import_model_npuw(std::istream& stream,
stream.clear();
stream.seekg(stream_start_pos);
- if (compiled_model_indicator == NPUW_LLM_COMPILED_MODEL_INDICATOR) {
+ if (compiled_model_indicator == NPUW_GQA_COMPILED_MODEL_INDICATOR) {
+ return ov::npuw::GQACompiledModel::import_model(stream, pluginSO, properties);
+ } else if (compiled_model_indicator == NPUW_LLM_COMPILED_MODEL_INDICATOR) {
// Properties are required for ov::weights_path
return ov::npuw::LLMCompiledModel::import_model(stream, pluginSO, properties);
} else if (compiled_model_indicator == NPUW_COMPILED_MODEL_INDICATOR) {
diff --git a/src/plugins/intel_npu/tests/unit/CMakeLists.txt b/src/plugins/intel_npu/tests/unit/CMakeLists.txt
index 8b1d3c64702..9cd19fc286f 100644
--- a/src/plugins/intel_npu/tests/unit/CMakeLists.txt
+++ b/src/plugins/intel_npu/tests/unit/CMakeLists.txt
@@ -44,6 +44,7 @@ ov_add_test_target(
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/metadata.cpp
# npuw core
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp
+ ${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/gqa_compiled_model.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model_utils.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.cpp
@@ -93,8 +94,12 @@ ov_add_test_target(
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/attn/attn_subgraph.cpp
# npuw_transformations
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/add_position_ids_param.cpp
+ ${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/collapse_unqdq.cpp
+ ${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/conv_to_matmul.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/convert_kvcache_to_precision.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/decompose_gqa.cpp
+ ${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/drop_zp_subtract.cpp
+ ${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/untangle_dq_scale.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/lora_stateful_to_stateless.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/optimize_value_tensors.cpp
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/npuw_transformations/patch_sliding_window_mask.cpp
@@ -137,6 +142,7 @@ install(TARGETS ${TARGET_NAME}
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/npu/executor_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/llm_compiled_model_graph_options_test.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/npuw/gqa_compiled_model_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/stored_tokens_state_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/lincache_utils_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/partitioning_options_test.cpp
@@ -149,6 +155,8 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/npuw/subgraph_behavior_infer_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/preserve_const_matmul_pattern_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/pipeline_passes/add_position_ids_param_test.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/npuw/pipeline_passes/collapse_unqdq_test.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/npuw/pipeline_passes/conv_to_matmul_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/pipeline_passes/patch_sliding_mask_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/pipeline_passes/remove_empty_kv_inputs_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/pipeline_passes/stateful_to_stateless_test.cpp
diff --git a/src/plugins/intel_npu/tests/unit/npuw/gqa_compiled_model_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/gqa_compiled_model_test.cpp
new file mode 100644
index 00000000000..79b2e700aeb
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/gqa_compiled_model_test.cpp
@@ -0,0 +1,429 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <algorithm>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "gqa_compiled_model.hpp"
+#include "llm_test_helpers.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/convolution.hpp"
+#include "openvino/op/convert.hpp"
+#include "openvino/op/fake_quantize.hpp"
+#include "openvino/op/group_query_attention.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/matmul.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/subtract.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/op/unsqueeze.hpp"
+#include "openvino/runtime/properties.hpp"
+
+namespace {
+
+using ov::test::npuw::MockSubCompiledModel;
+using ov::test::npuw::NullPlugin;
+using ov::test::npuw::build_llm_test_model;
+
+template <class Op>
+std::size_t count_ops(const std::shared_ptr<ov::Model>& model) {
+ const auto ops = model->get_ops();
+ return std::count_if(ops.begin(), ops.end(), [](const auto& op) {
+ return ov::is_type<Op>(op);
+ });
+}
+
+std::shared_ptr<ov::Model> build_group_query_attention_model() {
+ auto query = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 4, 1, 16});
+ auto key = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 2, 1, 16});
+ auto value = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 2, 1, 16});
+ auto past_key = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 2, 8, 16});
+ auto past_value = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 2, 8, 16});
+ auto seqlens_k = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, ov::Shape{1});
+ auto total_sequence_length = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, ov::Shape{1});
+
+ auto gqa = std::make_shared<ov::op::internal::GroupQueryAttention>(
+ ov::OutputVector{query, key, value, past_key, past_value, seqlens_k, total_sequence_length},
+ 4,
+ 2,
+ 0.0f,
+ false,
+ false);
+
+ ov::ResultVector results = {std::make_shared<ov::op::v0::Result>(gqa->output(0)),
+ std::make_shared<ov::op::v0::Result>(gqa->output(1)),
+ std::make_shared<ov::op::v0::Result>(gqa->output(2))};
+ ov::ParameterVector params = {query, key, value, past_key, past_value, seqlens_k, total_sequence_length};
+ return std::make_shared<ov::Model>(results, params, "gqa_model");
+}
+
+std::shared_ptr<ov::Model> build_unqdq_model(const ov::element::Type& input_type = ov::element::f32) {
+ auto input = std::make_shared<ov::op::v0::Parameter>(input_type, ov::Shape{1, 4});
+ auto input_low = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {-1.0f});
+ auto input_high = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {1.0f});
+ auto output_low = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {0.0f});
+ auto output_high = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {255.0f});
+ auto fake_quantize =
+ std::make_shared<ov::op::v0::FakeQuantize>(input, input_low, input_high, output_low, output_high, 256);
+ auto quantized_convert = std::make_shared<ov::op::v0::Convert>(fake_quantize, ov::element::u16);
+ auto dequantized_convert = std::make_shared<ov::op::v0::Convert>(quantized_convert, ov::element::f32);
+ auto zero_point = std::make_shared<ov::op::v0::Convert>(
+ ov::op::v0::Constant::create(ov::element::u16, ov::Shape{}, {128}),
+ ov::element::f32);
+ auto subtract = std::make_shared<ov::op::v1::Subtract>(dequantized_convert, zero_point);
+ auto scale = std::make_shared<ov::op::v0::Convert>(
+ ov::op::v0::Constant::create(ov::element::f16, ov::Shape{}, {0.1f}),
+ ov::element::f32);
+ auto multiply = std::make_shared<ov::op::v1::Multiply>(subtract, scale);
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(multiply)},
+ ov::ParameterVector{input},
+ "gqa_unqdq_model");
+}
+
+std::shared_ptr<ov::Model> build_hidden_states_model(std::size_t tokens) {
+ auto input_hidden_states =
+ std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, tokens, 16});
+ input_hidden_states->set_friendly_name("input_hidden_states");
+ return std::make_shared<ov::Model>(
+ ov::ResultVector{std::make_shared<ov::op::v0::Result>(input_hidden_states)},
+ ov::ParameterVector{input_hidden_states},
+ "gqa_hidden_states_model");
+}
+
+std::shared_ptr<ov::Model> build_conv_to_matmul_model() {
+ auto activation = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 1, 8, 3});
+ auto weights = std::make_shared<ov::op::v0::Parameter>(ov::element::i8, ov::Shape{4, 3, 1, 1});
+ auto scale = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{4, 1, 1, 1});
+
+ auto transpose_in = std::make_shared<ov::op::v1::Transpose>(
+ activation,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, std::vector<int32_t>{0, 3, 1, 2}));
+ auto scaled_weights = std::make_shared<ov::op::v1::Multiply>(
+ std::make_shared<ov::op::v0::Convert>(weights, ov::element::f32),
+ std::make_shared<ov::op::v0::Convert>(scale, ov::element::f32));
+ auto convolution = std::make_shared<ov::op::v1::Convolution>(transpose_in,
+ scaled_weights,
+ ov::Strides{1, 1},
+ ov::CoordinateDiff{0, 0},
+ ov::CoordinateDiff{0, 0},
+ ov::Strides{1, 1});
+ auto transpose_out = std::make_shared<ov::op::v1::Transpose>(
+ convolution,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, std::vector<int32_t>{0, 2, 3, 1}));
+
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(transpose_out)},
+ ov::ParameterVector{activation, weights, scale},
+ "gqa_conv_to_matmul_model");
+}
+
+std::shared_ptr<ov::Model> build_dumped_gqa_conv_model() {
+ auto activation = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 512, 5120});
+ auto weights = std::make_shared<ov::op::v0::Parameter>(ov::element::i4, ov::Shape{5120, 5120, 1, 1});
+ auto scale = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{5120});
+
+ auto converted_activation = std::make_shared<ov::op::v0::Convert>(activation, ov::element::f32);
+ auto unsqueezed_activation = std::make_shared<ov::op::v0::Unsqueeze>(
+ converted_activation,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {1}));
+ auto transposed_activation = std::make_shared<ov::op::v1::Transpose>(
+ unsqueezed_activation,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 3, 1, 2}));
+ auto scaled_weights = std::make_shared<ov::op::v1::Multiply>(
+ std::make_shared<ov::op::v0::Convert>(weights, ov::element::f32),
+ std::make_shared<ov::op::v1::Reshape>(
+ scale,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {5120, 1, 1, 1}),
+ true));
+ auto convolution = std::make_shared<ov::op::v1::Convolution>(transposed_activation,
+ scaled_weights,
+ ov::Strides{1, 1},
+ ov::CoordinateDiff{0, 0},
+ ov::CoordinateDiff{0, 0},
+ ov::Strides{1, 1});
+ auto transpose_out = std::make_shared<ov::op::v1::Transpose>(
+ convolution,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 2, 3, 1}));
+
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(transpose_out)},
+ ov::ParameterVector{activation, weights, scale},
+ "dumped_gqa_conv_model");
+}
+
+std::shared_ptr<ov::Model> build_conv_to_matmul_and_unqdq_model() {
+ const auto conv_model = build_conv_to_matmul_model();
+ const auto unqdq_model = build_unqdq_model(ov::element::f16);
+
+ ov::ResultVector results;
+ for (const auto& result : conv_model->get_results()) {
+ results.push_back(std::make_shared<ov::op::v0::Result>(result->input_value(0)));
+ }
+ for (const auto& result : unqdq_model->get_results()) {
+ results.push_back(std::make_shared<ov::op::v0::Result>(result->input_value(0)));
+ }
+
+ ov::ParameterVector parameters = conv_model->get_parameters();
+ const auto unqdq_parameters = unqdq_model->get_parameters();
+ parameters.insert(parameters.end(), unqdq_parameters.begin(), unqdq_parameters.end());
+
+ return std::make_shared<ov::Model>(results, parameters, "gqa_conv_to_matmul_and_unqdq_model");
+}
+
+struct CompileCall {
+ ov::AnyMap props;
+ std::shared_ptr<ov::Model> model;
+};
+
+class RecordingFactory {
+public:
+ ov::npuw::GQACompiledModel::CompiledModelFactory make_factory() {
+ return [this](const std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap& props) -> std::shared_ptr<ov::npuw::ICompiledModel> {
+ m_calls.push_back({props, model});
+ return std::make_shared<MockSubCompiledModel>(model, plugin, props);
+ };
+ }
+
+ const CompileCall& only_call() const {
+ OPENVINO_ASSERT(m_calls.size() == 1u, "Expected a single compile call");
+ return m_calls.front();
+ }
+
+private:
+ std::vector<CompileCall> m_calls;
+};
+
+class PropertyForwardingMockCompiledModel final : public ov::npuw::ICompiledModel {
+public:
+ PropertyForwardingMockCompiledModel(const std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<const ov::IPlugin>& plugin)
+ : ov::npuw::ICompiledModel(model, plugin) {}
+
+ void export_model(std::ostream&) const override {}
+ std::shared_ptr<const ov::Model> get_runtime_model() const override {
+ return {};
+ }
+ void set_property(const ov::AnyMap& properties) override {
+ last_set_properties = properties;
+ }
+ ov::Any get_property(const std::string& name) const override {
+ if (name == "NPUW_FOLD") {
+ return true;
+ }
+ return {};
+ }
+
+private:
+ std::shared_ptr<ov::ISyncInferRequest> create_sync_infer_request() const override {
+ return {};
+ }
+
+public:
+ ov::AnyMap last_set_properties;
+};
+
+
+class GQACompiledModelTest : public ::testing::Test {
+protected:
+ void SetUp() override {
+ m_plugin = std::make_shared<NullPlugin>();
+ }
+
+ static ov::AnyMap base_props() {
+ return {{"NPUW_GQA", "YES"}};
+ }
+
+ static void merge_props(ov::AnyMap& dst, const ov::AnyMap& src) {
+ for (const auto& [key, value] : src) {
+ dst[key] = value;
+ }
+ }
+
+ std::unique_ptr<ov::npuw::GQACompiledModel> create_compiled_model(const std::shared_ptr<ov::Model>& model,
+ const ov::AnyMap& extra_props,
+ RecordingFactory& recorder) const {
+ auto props = base_props();
+ merge_props(props, extra_props);
+ return std::make_unique<ov::npuw::GQACompiledModel>(model, m_plugin, props, recorder.make_factory());
+ }
+
+ std::shared_ptr<ov::IPlugin> m_plugin;
+};
+
+TEST_F(GQACompiledModelTest, AddsExpectedNpuwDefaultsBeforeInnerCompilation) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_test_model(), {}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_ONLINE_PIPELINE").as<std::string>(), "REP");
+ EXPECT_EQ(call.props.at("NPUW_DEVICES").as<std::string>(), "NPU");
+ EXPECT_EQ(call.props.at("NPUW_ONLINE_ISOLATE").as<std::string>(), "ATTN");
+ EXPECT_EQ(call.props.at("NPUW_FOLD_ONLY").as<std::string>(), "attn");
+ EXPECT_EQ(call.props.at("NPUW_ATTN").as<std::string>(), "STATIC");
+ EXPECT_EQ(call.props.at("NPUW_ONLINE_KEEP_BLOCK_SIZE").as<std::string>(), "9");
+ EXPECT_EQ(call.props.at("NPUW_FOLD").as<std::string>(), "YES");
+ EXPECT_EQ(call.props.at(ov::cache_mode.name()).as<ov::CacheMode>(), ov::CacheMode::OPTIMIZE_SPEED);
+ EXPECT_EQ(call.props.at("NPUW_UNQDQ").as<std::string>(), "YES");
+ EXPECT_EQ(call.props.count("NPUW_FUNCALL_ASYNC"), 0u);
+ EXPECT_EQ(call.props.count("NPUW_UNFOLD_IREQS"), 0u);
+}
+
+TEST_F(GQACompiledModelTest, SkipsAttnIsolationDefaultsForGenerateStyleModels) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_hidden_states_model(1), {}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_ONLINE_PIPELINE").as<std::string>(), "REP");
+ EXPECT_EQ(call.props.at("NPUW_DEVICES").as<std::string>(), "NPU");
+ EXPECT_EQ(call.props.at("NPUW_FOLD").as<std::string>(), "YES");
+ EXPECT_EQ(call.props.at(ov::cache_mode.name()).as<ov::CacheMode>(), ov::CacheMode::OPTIMIZE_SPEED);
+ EXPECT_EQ(call.props.at("NPUW_UNQDQ").as<std::string>(), "YES");
+ EXPECT_EQ(call.props.at("NPUW_FUNCALL_ASYNC").as<std::string>(), "YES");
+ EXPECT_EQ(call.props.at("NPUW_UNFOLD_IREQS").as<std::string>(), "YES");
+ EXPECT_EQ(call.props.count("NPUW_ONLINE_ISOLATE"), 0u);
+ EXPECT_EQ(call.props.count("NPUW_FOLD_ONLY"), 0u);
+ EXPECT_EQ(call.props.count("NPUW_ATTN"), 0u);
+ EXPECT_EQ(call.props.count("NPUW_ONLINE_KEEP_BLOCK_SIZE"), 0u);
+}
+
+TEST_F(GQACompiledModelTest, KeepsAttnIsolationDefaultsForPrefillStyleModels) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_hidden_states_model(8), {}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_DEVICES").as<std::string>(), "NPU");
+ EXPECT_EQ(call.props.at("NPUW_ONLINE_ISOLATE").as<std::string>(), "ATTN");
+ EXPECT_EQ(call.props.at("NPUW_FOLD_ONLY").as<std::string>(), "attn");
+ EXPECT_EQ(call.props.at("NPUW_FOLD").as<std::string>(), "YES");
+ EXPECT_EQ(call.props.count("NPUW_FUNCALL_ASYNC"), 0u);
+ EXPECT_EQ(call.props.count("NPUW_UNFOLD_IREQS"), 0u);
+}
+
+TEST_F(GQACompiledModelTest, KeepsUserProvidedLowLevelOverrides) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_test_model(),
+ {{"NPUW_ONLINE_PIPELINE", "REG"},
+ {"NPUW_DEVICES", "CPU"},
+ {"NPUW_ONLINE_ISOLATE", "COMPUTE"},
+ {"NPUW_ATTN", "STATIC"},
+ {"NPUW_FOLD", "NO"},
+ {"NPUW_FUNCALL_ASYNC", "NO"},
+ {"NPUW_UNFOLD_IREQS", "NO"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_ONLINE_PIPELINE").as<std::string>(), "REG");
+ EXPECT_EQ(call.props.at("NPUW_DEVICES").as<std::string>(), "CPU");
+ EXPECT_EQ(call.props.at("NPUW_ONLINE_ISOLATE").as<std::string>(), "COMPUTE");
+ EXPECT_EQ(call.props.at("NPUW_ATTN").as<std::string>(), "STATIC");
+ EXPECT_EQ(call.props.at("NPUW_FOLD").as<std::string>(), "NO");
+ EXPECT_EQ(call.props.at("NPUW_FUNCALL_ASYNC").as<std::string>(), "NO");
+ EXPECT_EQ(call.props.at("NPUW_UNFOLD_IREQS").as<std::string>(), "NO");
+}
+
+TEST_F(GQACompiledModelTest, PassesGqaModelThroughWithoutDecomposition) {
+ auto model = build_group_query_attention_model();
+ ASSERT_GT(count_ops<ov::op::internal::GroupQueryAttention>(model), 0u);
+
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(model, {}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ // GQA model is passed through unchanged — the online partitioner handles
+ // isolation and folding of GQA blocks via the NPUW_FOLD_ONLY=attn path.
+ const auto& call = recorder.only_call();
+ EXPECT_GT(count_ops<ov::op::internal::GroupQueryAttention>(call.model), 0u);
+}
+
+TEST_F(GQACompiledModelTest, RunsUNQDQBeforeInnerCompilation) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_unqdq_model(ov::element::f16), {{"NPUW_UNQDQ", "YES"}}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_UNQDQ").as<std::string>(), "YES");
+ EXPECT_EQ(count_ops<ov::op::v1::Multiply>(call.model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v1::Subtract>(call.model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::FakeQuantize>(call.model), 0u);
+}
+
+TEST_F(GQACompiledModelTest, RunsConvToMatmulBeforeInnerCompilation) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_conv_to_matmul_model(), {{"NPUW_UNQDQ", "NO"}}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_UNQDQ").as<std::string>(), "NO");
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(call.model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(call.model), 1u);
+}
+
+TEST_F(GQACompiledModelTest, RunsConvToMatmulOnDumpedGQAShapeBeforeInnerCompilation) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_dumped_gqa_conv_model(), {{"NPUW_UNQDQ", "YES"}}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_UNQDQ").as<std::string>(), "YES");
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(call.model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(call.model), 1u);
+}
+
+TEST_F(GQACompiledModelTest, RunsConvToMatmulAndUNQDQBeforeInnerCompilation) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::GQACompiledModel> compiled;
+
+ ASSERT_NO_THROW(
+ compiled = create_compiled_model(build_conv_to_matmul_and_unqdq_model(), {{"NPUW_UNQDQ", "YES"}}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& call = recorder.only_call();
+ EXPECT_EQ(call.props.at("NPUW_UNQDQ").as<std::string>(), "YES");
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(call.model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(call.model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v1::Subtract>(call.model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::FakeQuantize>(call.model), 0u);
+}
+
+TEST_F(GQACompiledModelTest, ForwardsPropertyAccessToInnerCompiledModel) {
+ auto inner = std::make_shared<PropertyForwardingMockCompiledModel>(build_llm_test_model(), m_plugin);
+ auto factory = [inner](const std::shared_ptr<ov::Model>&,
+ const std::shared_ptr<const ov::IPlugin>&,
+ const ov::AnyMap&) -> std::shared_ptr<ov::npuw::ICompiledModel> {
+ return inner;
+ };
+
+ ov::npuw::GQACompiledModel compiled(build_llm_test_model(), m_plugin, base_props(), factory);
+
+ compiled.set_property({{"NPUW_CWAI", "YES"}});
+ EXPECT_EQ(inner->last_set_properties.at("NPUW_CWAI").as<std::string>(), "YES");
+ EXPECT_TRUE(compiled.get_property("NPUW_FOLD").as<bool>());
+}
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npuw/npuw_options_smoke_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/npuw_options_smoke_test.cpp
index a48cf6af5f5..7afbd482ac8 100644
--- a/src/plugins/intel_npu/tests/unit/npuw/npuw_options_smoke_test.cpp
+++ b/src/plugins/intel_npu/tests/unit/npuw/npuw_options_smoke_test.cpp
@@ -129,6 +129,8 @@ std::vector<Case> make_cases() {
bool_case<::intel_npu::NPUW_ACC_CHECK>("NPUW_ACC_CHECK", "YES", true),
double_case<::intel_npu::NPUW_ACC_THRESH>("NPUW_ACC_THRESH", "0.25", 0.25),
string_case<::intel_npu::NPUW_ACC_DEVICE>("NPUW_ACC_DEVICE", "CPU", "CPU"),
+ bool_case<::intel_npu::NPUW_GQA>("NPUW_GQA", "YES", true),
+ bool_case<::intel_npu::NPUW_UNQDQ>("NPUW_UNQDQ", "YES", true),
bool_case<::intel_npu::NPUW_LLM>("NPUW_LLM", "YES", true),
numeric_case<::intel_npu::NPUW_LLM_BATCH_DIM>("NPUW_LLM_BATCH_DIM", "1", uint32_t{1}),
numeric_case<::intel_npu::NPUW_LLM_SEQ_LEN_DIM>("NPUW_LLM_SEQ_LEN_DIM", "3", uint32_t{3}),
diff --git a/src/plugins/intel_npu/tests/unit/npuw/pipeline_passes/collapse_unqdq_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/pipeline_passes/collapse_unqdq_test.cpp
new file mode 100644
index 00000000000..92629e67ef4
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/pipeline_passes/collapse_unqdq_test.cpp
@@ -0,0 +1,252 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "npuw_transformations/collapse_unqdq.hpp"
+#include "npuw_transformations/conv_to_matmul.hpp"
+#include "npuw_transformations/drop_zp_subtract.hpp"
+
+#include <algorithm>
+
+#include <gtest/gtest.h>
+
+#include "openvino/core/validation_util.hpp"
+#include "openvino/op/convolution.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/convert.hpp"
+#include "openvino/op/fake_quantize.hpp"
+#include "openvino/op/matmul.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/subtract.hpp"
+#include "openvino/op/transpose.hpp"
+
+namespace {
+
+template <class Op>
+std::size_t count_ops(const std::shared_ptr<ov::Model>& model) {
+ const auto ops = model->get_ops();
+ return std::count_if(ops.begin(), ops.end(), [](const auto& op) {
+ return ov::is_type<Op>(op);
+ });
+}
+
+std::shared_ptr<ov::Model> build_unqdq_model(const ov::element::Type& input_type = ov::element::f32) {
+ auto input = std::make_shared<ov::op::v0::Parameter>(input_type, ov::Shape{1, 4});
+ auto input_low = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {-1.0f});
+ auto input_high = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {1.0f});
+ auto output_low = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {0.0f});
+ auto output_high = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {255.0f});
+ auto fake_quantize =
+ std::make_shared<ov::op::v0::FakeQuantize>(input, input_low, input_high, output_low, output_high, 256);
+ auto quantized_convert = std::make_shared<ov::op::v0::Convert>(fake_quantize, ov::element::u16);
+ auto dequantized_convert = std::make_shared<ov::op::v0::Convert>(quantized_convert, ov::element::f32);
+ auto zero_point = std::make_shared<ov::op::v0::Convert>(
+ ov::op::v0::Constant::create(ov::element::u16, ov::Shape{}, {128}),
+ ov::element::f32);
+ auto subtract = std::make_shared<ov::op::v1::Subtract>(dequantized_convert, zero_point);
+ auto scale = std::make_shared<ov::op::v0::Convert>(
+ ov::op::v0::Constant::create(ov::element::f16, ov::Shape{}, {0.1f}),
+ ov::element::f32);
+ auto multiply = std::make_shared<ov::op::v1::Multiply>(subtract, scale);
+ multiply->set_friendly_name("unqdq_out");
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(multiply)},
+ ov::ParameterVector{input},
+ "unqdq_model");
+}
+
+std::shared_ptr<ov::Model> build_zero_point_subtract_model(bool zero_point_is_zero) {
+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 4});
+ auto zero_point = std::make_shared<ov::op::v0::Convert>(
+ ov::op::v0::Constant::create(ov::element::u16, ov::Shape{4}, zero_point_is_zero ? std::vector<uint16_t>{0, 0, 0, 0}
+ : std::vector<uint16_t>{0, 1, 0, 0}),
+ ov::element::f32);
+ auto subtract = std::make_shared<ov::op::v1::Subtract>(input, zero_point);
+ subtract->set_friendly_name("zp_subtract");
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(subtract)},
+ ov::ParameterVector{input},
+ "zero_point_subtract_model");
+}
+
+std::shared_ptr<ov::Model> build_conv_to_matmul_model(bool per_output_channel_scale,
+ bool with_output_transpose,
+ bool with_input_transpose = true,
+ bool use_scale_parameter_chain = false) {
+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32,
+ with_input_transpose ? ov::Shape{1, 1, 3, 4}
+ : ov::Shape{1, 4, 1, 3});
+ auto weights = std::make_shared<ov::op::v0::Parameter>(ov::element::i8, ov::Shape{2, 4, 1, 1});
+ std::shared_ptr<ov::Node> scale_source;
+ std::shared_ptr<ov::op::v0::Parameter> scale_parameter;
+ if (use_scale_parameter_chain) {
+ scale_parameter = std::make_shared<ov::op::v0::Parameter>(
+ ov::element::f32,
+ per_output_channel_scale ? ov::Shape{2} : ov::Shape{8});
+ auto scale_reshape_1 = std::make_shared<ov::op::v1::Reshape>(
+ scale_parameter,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{1}, std::vector<int32_t>{per_output_channel_scale ? 2 : 8}),
+ false);
+ scale_source = std::make_shared<ov::op::v1::Reshape>(
+ scale_reshape_1,
+ ov::op::v0::Constant::create(ov::element::i32,
+ ov::Shape{4},
+ per_output_channel_scale ? std::vector<int32_t>{2, 1, 1, 1}
+ : std::vector<int32_t>{2, 4, 1, 1}),
+ false);
+ } else {
+ scale_source = std::make_shared<ov::op::v1::Reshape>(
+ ov::op::v0::Constant::create(ov::element::f32,
+ per_output_channel_scale ? ov::Shape{2} : ov::Shape{8},
+ per_output_channel_scale ? std::vector<float>{0.25f, 0.5f}
+ : std::vector<float>{0.25f, 0.5f, 0.75f, 1.0f,
+ 1.25f, 1.5f, 1.75f, 2.0f}),
+ ov::op::v0::Constant::create(ov::element::i32,
+ ov::Shape{4},
+ per_output_channel_scale ? std::vector<int32_t>{2, 1, 1, 1}
+ : std::vector<int32_t>{2, 4, 1, 1}),
+ false);
+ }
+
+ std::shared_ptr<ov::Node> conv_input = data;
+ if (with_input_transpose) {
+ conv_input = std::make_shared<ov::op::v1::Transpose>(
+ data,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, {0, 3, 1, 2}));
+ }
+ auto converted_weights = std::make_shared<ov::op::v0::Convert>(weights, ov::element::f32);
+ auto scaled_weights = std::make_shared<ov::op::v1::Multiply>(converted_weights, scale_source);
+ auto convolution = std::make_shared<ov::op::v1::Convolution>(conv_input,
+ scaled_weights,
+ ov::Strides{1, 1},
+ ov::CoordinateDiff{0, 0},
+ ov::CoordinateDiff{0, 0},
+ ov::Strides{1, 1});
+ convolution->set_friendly_name("conv_to_matmul_out");
+
+ std::shared_ptr<ov::Node> output = convolution;
+ if (with_output_transpose) {
+ output = std::make_shared<ov::op::v1::Transpose>(
+ convolution,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, {0, 2, 3, 1}));
+ output->set_friendly_name("conv_to_matmul_output");
+ }
+
+ ov::ParameterVector parameters{data, weights};
+ if (scale_parameter != nullptr) {
+ parameters.push_back(scale_parameter);
+ }
+
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(output)},
+ parameters,
+ "conv_to_matmul_model");
+}
+
+std::shared_ptr<ov::Model> build_conv_to_matmul_and_unqdq_model() {
+ const auto conv_model = build_conv_to_matmul_model(true, true);
+ const auto unqdq_model = build_unqdq_model();
+
+ ov::ResultVector results;
+ for (const auto& result : conv_model->get_results()) {
+ results.push_back(std::make_shared<ov::op::v0::Result>(result->input_value(0)));
+ }
+ for (const auto& result : unqdq_model->get_results()) {
+ results.push_back(std::make_shared<ov::op::v0::Result>(result->input_value(0)));
+ }
+
+ ov::ParameterVector parameters = conv_model->get_parameters();
+ const auto unqdq_parameters = unqdq_model->get_parameters();
+ parameters.insert(parameters.end(), unqdq_parameters.begin(), unqdq_parameters.end());
+
+ return std::make_shared<ov::Model>(results, parameters, "conv_to_matmul_and_unqdq_model");
+}
+
+void expect_conv_to_matmul_and_unqdq_rewritten(const std::shared_ptr<ov::Model>& model) {
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v0::FakeQuantize>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v1::Subtract>(model), 0u);
+}
+
+TEST(CollapseUNQDQPassTest, DropsEntireUnqdqChainFromModel) {
+ const auto model = build_unqdq_model();
+ ASSERT_EQ(count_ops<ov::op::v0::FakeQuantize>(model), 1u);
+ ASSERT_EQ(count_ops<ov::op::v1::Multiply>(model), 1u);
+
+ ov::npuw::CollapseUNQDQ pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v0::FakeQuantize>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v1::Multiply>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v1::Subtract>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::Convert>(model), 0u);
+
+ const auto output_node = model->get_results().front()->input_value(0).get_node_shared_ptr();
+ EXPECT_TRUE(ov::is_type<ov::op::v0::Parameter>(output_node));
+}
+
+TEST(CollapseUNQDQPassTest, PreservesOriginalOutputElementType) {
+ const auto model = build_unqdq_model(ov::element::f16);
+
+ ov::npuw::CollapseUNQDQ pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v0::FakeQuantize>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v1::Multiply>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v1::Subtract>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::Convert>(model), 1u);
+ EXPECT_EQ(model->get_results().front()->input_value(0).get_element_type(), ov::element::f32);
+}
+
+TEST(DropZPSubtractPassTest, DropsSubtractWhenZeroPointIsAllZeros) {
+ const auto model = build_zero_point_subtract_model(true);
+
+ ov::npuw::DropZPSubtract pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Subtract>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::Convert>(model), 0u);
+ EXPECT_TRUE(ov::is_type<ov::op::v0::Parameter>(model->get_results().front()->input_value(0).get_node_shared_ptr()));
+}
+
+TEST(DropZPSubtractPassTest, KeepsSubtractWhenZeroPointIsNotAllZeros) {
+ const auto model = build_zero_point_subtract_model(false);
+
+ ov::npuw::DropZPSubtract pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Subtract>(model), 1u);
+}
+
+TEST(CollapseUNQDQPassTest, ConvToMatMulAndUNQDQOrderDoesNotMatter) {
+ {
+ const auto model = build_conv_to_matmul_and_unqdq_model();
+ ov::npuw::ConvToMatMul conv_to_matmul;
+ ov::npuw::CollapseUNQDQ collapse_unqdq;
+
+ conv_to_matmul.run_on_model(model);
+ collapse_unqdq.run_on_model(model);
+
+ expect_conv_to_matmul_and_unqdq_rewritten(model);
+ }
+
+ {
+ const auto model = build_conv_to_matmul_and_unqdq_model();
+ ov::npuw::ConvToMatMul conv_to_matmul;
+ ov::npuw::CollapseUNQDQ collapse_unqdq;
+
+ collapse_unqdq.run_on_model(model);
+ conv_to_matmul.run_on_model(model);
+
+ expect_conv_to_matmul_and_unqdq_rewritten(model);
+ }
+}
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npuw/pipeline_passes/conv_to_matmul_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/pipeline_passes/conv_to_matmul_test.cpp
new file mode 100644
index 00000000000..7858a974b0c
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/pipeline_passes/conv_to_matmul_test.cpp
@@ -0,0 +1,286 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "npuw_transformations/conv_to_matmul.hpp"
+
+#include <algorithm>
+#include <memory>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include "openvino/op/convolution.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/convert.hpp"
+#include "openvino/op/matmul.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/op/unsqueeze.hpp"
+
+namespace {
+
+template <class Op>
+std::size_t count_ops(const std::shared_ptr<ov::Model>& model) {
+ const auto ops = model->get_ops();
+ return std::count_if(ops.begin(), ops.end(), [](const auto& op) {
+ return ov::is_type<Op>(op);
+ });
+}
+
+std::shared_ptr<ov::Model> build_conv_to_matmul_model(bool per_output_channel_scale,
+ bool with_output_transpose,
+ bool with_input_transpose = true,
+ bool use_scale_parameter_chain = false) {
+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32,
+ with_input_transpose ? ov::Shape{1, 1, 3, 4}
+ : ov::Shape{1, 4, 1, 3});
+ auto weights = std::make_shared<ov::op::v0::Parameter>(ov::element::i8, ov::Shape{2, 4, 1, 1});
+ std::shared_ptr<ov::Node> scale_source;
+ std::shared_ptr<ov::op::v0::Parameter> scale_parameter;
+ if (use_scale_parameter_chain) {
+ scale_parameter = std::make_shared<ov::op::v0::Parameter>(ov::element::f32,
+ per_output_channel_scale ? ov::Shape{2} : ov::Shape{8});
+ auto scale_reshape_1 = std::make_shared<ov::op::v1::Reshape>(
+ scale_parameter,
+ ov::op::v0::Constant::create(ov::element::i32,
+ ov::Shape{1},
+ std::vector<int32_t>{per_output_channel_scale ? 2 : 8}),
+ false);
+ scale_source = std::make_shared<ov::op::v1::Reshape>(
+ scale_reshape_1,
+ ov::op::v0::Constant::create(ov::element::i32,
+ ov::Shape{4},
+ per_output_channel_scale ? std::vector<int32_t>{2, 1, 1, 1}
+ : std::vector<int32_t>{2, 4, 1, 1}),
+ false);
+ } else {
+ scale_source = std::make_shared<ov::op::v1::Reshape>(
+ ov::op::v0::Constant::create(ov::element::f32,
+ per_output_channel_scale ? ov::Shape{2} : ov::Shape{8},
+ per_output_channel_scale ? std::vector<float>{0.25f, 0.5f}
+ : std::vector<float>{0.25f,
+ 0.5f,
+ 0.75f,
+ 1.0f,
+ 1.25f,
+ 1.5f,
+ 1.75f,
+ 2.0f}),
+ ov::op::v0::Constant::create(ov::element::i32,
+ ov::Shape{4},
+ per_output_channel_scale ? std::vector<int32_t>{2, 1, 1, 1}
+ : std::vector<int32_t>{2, 4, 1, 1}),
+ false);
+ }
+
+ std::shared_ptr<ov::Node> conv_input = data;
+ if (with_input_transpose) {
+ conv_input = std::make_shared<ov::op::v1::Transpose>(
+ data,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, {0, 3, 1, 2}));
+ }
+ auto converted_weights = std::make_shared<ov::op::v0::Convert>(weights, ov::element::f32);
+ auto scaled_weights = std::make_shared<ov::op::v1::Multiply>(converted_weights, scale_source);
+ auto convolution = std::make_shared<ov::op::v1::Convolution>(conv_input,
+ scaled_weights,
+ ov::Strides{1, 1},
+ ov::CoordinateDiff{0, 0},
+ ov::CoordinateDiff{0, 0},
+ ov::Strides{1, 1});
+ convolution->set_friendly_name("conv_to_matmul_out");
+
+ std::shared_ptr<ov::Node> output = convolution;
+ if (with_output_transpose) {
+ output = std::make_shared<ov::op::v1::Transpose>(
+ convolution,
+ ov::op::v0::Constant::create(ov::element::i32, ov::Shape{4}, {0, 2, 3, 1}));
+ output->set_friendly_name("conv_to_matmul_output");
+ }
+
+ ov::ParameterVector parameters{data, weights};
+ if (scale_parameter != nullptr) {
+ parameters.push_back(scale_parameter);
+ }
+
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(output)},
+ parameters,
+ "conv_to_matmul_model");
+}
+
+std::shared_ptr<ov::Model> build_dumped_gqa_conv_model() {
+ auto activation = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 512, 5120});
+ auto weights = std::make_shared<ov::op::v0::Parameter>(ov::element::i4, ov::Shape{5120, 5120, 1, 1});
+ auto scale = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{5120});
+
+ auto converted_activation = std::make_shared<ov::op::v0::Convert>(activation, ov::element::f32);
+ auto unsqueezed_activation = std::make_shared<ov::op::v0::Unsqueeze>(
+ converted_activation,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {1}));
+ auto transposed_activation = std::make_shared<ov::op::v1::Transpose>(
+ unsqueezed_activation,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 3, 1, 2}));
+ auto converted_weights = std::make_shared<ov::op::v0::Convert>(weights, ov::element::f32);
+ auto reshaped_scale = std::make_shared<ov::op::v1::Reshape>(
+ scale,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {5120, 1, 1, 1}),
+ true);
+ auto scaled_weights = std::make_shared<ov::op::v1::Multiply>(converted_weights, reshaped_scale);
+ auto convolution = std::make_shared<ov::op::v1::Convolution>(transposed_activation,
+ scaled_weights,
+ ov::Strides{1, 1},
+ ov::CoordinateDiff{0, 0},
+ ov::CoordinateDiff{0, 0},
+ ov::Strides{1, 1});
+ auto output = std::make_shared<ov::op::v1::Transpose>(
+ convolution,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 2, 3, 1}));
+
+ return std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(output)},
+ ov::ParameterVector{activation, weights, scale},
+ "dumped_gqa_conv_model");
+}
+
+TEST(ConvToMatMulPassTest, RewritesPointwiseConvolutionToMatMulWithPostMatMulScale) {
+ const auto model = build_conv_to_matmul_model(true, true);
+
+ ov::npuw::ConvToMatMul pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v1::Multiply>(model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v1::Transpose>(model), 0u);
+ EXPECT_EQ(model->get_results().front()->input_value(0).get_shape(), ov::Shape({1, 1, 3, 2}));
+
+ const auto result_node = model->get_results().front()->input_value(0).get_node_shared_ptr();
+ const auto output_multiply = ov::as_type_ptr<ov::op::v1::Multiply>(result_node);
+ ASSERT_NE(output_multiply, nullptr);
+ EXPECT_TRUE(ov::is_type<ov::op::v0::MatMul>(output_multiply->input_value(0).get_node_shared_ptr()) ||
+ ov::is_type<ov::op::v0::MatMul>(output_multiply->input_value(1).get_node_shared_ptr()));
+}
+
+TEST(ConvToMatMulPassTest, KeepsConvolutionWhenScaleIsNotPerOutputChannel) {
+ const auto model = build_conv_to_matmul_model(false, true);
+
+ ov::npuw::ConvToMatMul pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 0u);
+}
+
+TEST(ConvToMatMulPassTest, RewritesDirectConvolutionToMatMulWithOutputTranspose) {
+ const auto model = build_conv_to_matmul_model(true, false, false);
+
+ ov::npuw::ConvToMatMul pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v1::Multiply>(model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v1::Transpose>(model), 2u);
+ EXPECT_EQ(model->get_results().front()->input_value(0).get_shape(), ov::Shape({1, 2, 1, 3}));
+}
+
+TEST(ConvToMatMulPassTest, RewritesConvolutionWithScaleParameterReshapeChain) {
+ const auto model = build_conv_to_matmul_model(true, true, false, true);
+
+ ov::npuw::ConvToMatMul pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 1u);
+ EXPECT_EQ(count_ops<ov::op::v1::Multiply>(model), 1u);
+ EXPECT_EQ(model->get_results().front()->input_value(0).get_shape(), ov::Shape({1, 1, 3, 2}));
+}
+
+TEST(ConvToMatMulPassTest, RewritesDumpedGQAConvolutionShape) {
+ const auto model = build_dumped_gqa_conv_model();
+
+ ov::npuw::ConvToMatMul pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 1u);
+ EXPECT_EQ(model->get_results().front()->input_value(0).get_shape(), ov::Shape({1, 1, 512, 5120}));
+}
+
+TEST(ConvToMatMulPassTest, RewritesFrontendWeightsAsInputsConvolutionShape) {
+ auto activation = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 1, 512, 5120});
+ auto weights = std::make_shared<ov::op::v0::Parameter>(ov::element::i4, ov::Shape{5120, 5120, 1, 1});
+ auto scale = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{5120});
+
+ auto transposed_activation = std::make_shared<ov::op::v1::Transpose>(
+ activation,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 3, 1, 2}));
+ auto converted_weights = std::make_shared<ov::op::v0::Convert>(weights, ov::element::f32);
+ auto reshaped_scale = std::make_shared<ov::op::v1::Reshape>(
+ scale,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {5120, 1, 1, 1}),
+ true);
+ auto scaled_weights = std::make_shared<ov::op::v1::Multiply>(converted_weights, reshaped_scale);
+ auto convolution = std::make_shared<ov::op::v1::Convolution>(transposed_activation,
+ scaled_weights,
+ ov::Strides{1, 1},
+ ov::CoordinateDiff{0, 0},
+ ov::CoordinateDiff{0, 0},
+ ov::Strides{1, 1});
+ auto output = std::make_shared<ov::op::v1::Transpose>(
+ convolution,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 2, 3, 1}));
+ const auto model = std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(output)},
+ ov::ParameterVector{activation, weights, scale},
+ "frontend_weights_as_inputs_conv_model");
+
+ ov::npuw::ConvToMatMul pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 1u);
+ EXPECT_EQ(model->get_results().front()->input_value(0).get_shape(), ov::Shape({1, 1, 512, 5120}));
+}
+
+TEST(ConvToMatMulPassTest, RewritesDumpedMlpDownProjectionShape) {
+ auto activation = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 17920, 1, 512});
+ auto weights = std::make_shared<ov::op::v0::Parameter>(ov::element::i4, ov::Shape{5120, 17920, 1, 1});
+ auto scale = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{5120});
+
+ auto scaled_weights = std::make_shared<ov::op::v1::Multiply>(
+ std::make_shared<ov::op::v0::Convert>(weights, ov::element::f32),
+ std::make_shared<ov::op::v1::Reshape>(
+ scale,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {5120, 1, 1, 1}),
+ true));
+ auto convolution = std::make_shared<ov::op::v1::Convolution>(activation,
+ scaled_weights,
+ ov::Strides{1, 1},
+ ov::CoordinateDiff{0, 0},
+ ov::CoordinateDiff{0, 0},
+ ov::Strides{1, 1});
+ auto output = std::make_shared<ov::op::v1::Transpose>(
+ convolution,
+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 2, 3, 1}));
+ const auto model = std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(output)},
+ ov::ParameterVector{activation, weights, scale},
+ "dumped_mlp_down_projection_conv_model");
+
+ ov::npuw::ConvToMatMul pass;
+ pass.run_on_model(model);
+ model->validate_nodes_and_infer_types();
+
+ EXPECT_EQ(count_ops<ov::op::v1::Convolution>(model), 0u);
+ EXPECT_EQ(count_ops<ov::op::v0::MatMul>(model), 1u);
+ EXPECT_EQ(model->get_results().front()->input_value(0).get_shape(), ov::Shape({1, 1, 512, 5120}));
+}
+
+} // namespace