Skip to content

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

NPUW: Cover NPUW options with tests (#34788)

Dmitry Matveev45907b753f1a
diff --git a/src/plugins/intel_npu/tests/unit/CMakeLists.txt b/src/plugins/intel_npu/tests/unit/CMakeLists.txt
index cfa362f3458..ac85f492c13 100644
--- a/src/plugins/intel_npu/tests/unit/CMakeLists.txt
+++ b/src/plugins/intel_npu/tests/unit/CMakeLists.txt
@@ -101,3 +101,9 @@ install(TARGETS ${TARGET_NAME}
COMPONENT tests
EXCLUDE_FROM_ALL
)
+
+target_sources(${TARGET_NAME} PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/npuw/llm_compiled_model_graph_options_test.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/npuw/partitioning_options_test.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/npuw/npuw_options_smoke_test.cpp
+)
diff --git a/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_factory_options_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_factory_options_test.cpp
new file mode 100644
index 00000000000..99ac37d0457
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_factory_options_test.cpp
@@ -0,0 +1,478 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <algorithm>
+#include <memory>
+#include <string>
+#include <string_view>
+#include <utility>
+#include <vector>
+
+#include "embedding_model_utils.hpp"
+#include "llm_test_helpers.hpp"
+#include "llm_compiled_model_utils.hpp"
+#include "openvino/pass/stateful_to_stateless.hpp"
+
+namespace {
+using ov::test::npuw::CompileCall;
+using ov::test::npuw::NullPlugin;
+using ov::test::npuw::RecordingFactory;
+
+class LLMCompiledModelFactoryOptionsTest : public ::testing::Test {
+protected:
+ void SetUp() override {
+ m_plugin = std::make_shared<NullPlugin>();
+ }
+
+ std::shared_ptr<ov::Model> build_llm_model() const {
+ return ov::test::npuw::build_llm_test_model();
+ }
+
+ std::shared_ptr<ov::Model> build_whisper_decoder_model() const {
+ return ov::test::npuw::build_whisper_decoder_test_model();
+ }
+
+ std::shared_ptr<ov::Model> build_embedding_model() const {
+ return ov::test::npuw::build_embedding_test_model();
+ }
+
+ static ov::AnyMap base_props() {
+ return {{"NPUW_LLM", "YES"}, {"NPUW_LLM_MAX_PROMPT_LEN", "128"}, {"NPUW_LLM_MIN_RESPONSE_LEN", "64"}};
+ }
+
+ 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::LLMCompiledModel> 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::LLMCompiledModel>(model, m_plugin, props, recorder.make_factory());
+ }
+
+ static const CompileCall& require_call(const RecordingFactory& recorder, std::string_view suffix) {
+ const auto* call = recorder.find_suffix(suffix);
+ OPENVINO_ASSERT(call != nullptr, "Missing compile call with suffix: ", std::string(suffix));
+ return *call;
+ }
+
+ static std::string prop_string(const ov::AnyMap& props, const std::string& key) {
+ const auto it = props.find(key);
+ OPENVINO_ASSERT(it != props.end(), "Missing property: ", key);
+ return it->second.as<std::string>();
+ }
+
+ static void expect_prop(const ov::AnyMap& props, const std::string& key, const std::string& expected) {
+ EXPECT_EQ(prop_string(props, key), expected);
+ }
+
+ static void expect_missing_prop(const ov::AnyMap& props, const std::string& key) {
+ EXPECT_EQ(props.count(key), 0u) << "Unexpected property present: " << key;
+ }
+
+ static bool has_input_name(const std::shared_ptr<ov::Model>& model, const std::string& name) {
+ const auto inputs = model->inputs();
+ return std::any_of(inputs.begin(), inputs.end(), [&name](const auto& input) {
+ const auto& names = input.get_names();
+ return std::any_of(names.begin(), names.end(), [&name](const auto& candidate) {
+ return candidate.find(name) != std::string::npos;
+ });
+ });
+ }
+
+ static bool has_output_name(const std::shared_ptr<ov::Model>& model, const std::string& name) {
+ const auto outputs = model->outputs();
+ return std::any_of(outputs.begin(), outputs.end(), [&name](const auto& output) {
+ const auto& names = output.get_names();
+ return std::any_of(names.begin(), names.end(), [&name](const auto& candidate) {
+ return candidate.find(name) != std::string::npos;
+ });
+ });
+ }
+
+ std::shared_ptr<ov::IPlugin> m_plugin;
+};
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, TwoModelPipeline) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), {{"NPUW_LLM_SHARED_HEAD", "NO"}}, recorder));
+ ASSERT_NE(compiled, nullptr);
+ EXPECT_EQ(recorder.calls().size(), 2u);
+ EXPECT_EQ(recorder.count_suffix("_kv192"), 1u);
+ EXPECT_EQ(recorder.count_suffix("_prefill"), 1u);
+ EXPECT_EQ(recorder.find_suffix("_lm_head"), nullptr);
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, ThreeModelPipeline) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), {{"NPUW_LLM_SHARED_HEAD", "YES"}}, recorder));
+ ASSERT_NE(compiled, nullptr);
+ EXPECT_EQ(recorder.calls().size(), 3u);
+ EXPECT_EQ(recorder.count_suffix("_prefill"), 1u);
+ EXPECT_EQ(recorder.count_suffix("_lm_head"), 1u);
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, GeneratePyramidCompilesMultipleGenerateVariants) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ov::AnyMap props = {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_GENERATE_PYRAMID", "YES"},
+ {"NPUW_LLM_MAX_PROMPT_LEN", "2048"},
+ {"NPUW_LLM_MIN_RESPONSE_LEN", "128"}};
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), props, recorder));
+ ASSERT_NE(compiled, nullptr);
+ EXPECT_GT(recorder.calls().size(), 2u);
+ EXPECT_GT(std::count_if(recorder.calls().begin(), recorder.calls().end(), [](const CompileCall& call) {
+ return call.friendly_name.find("_kv") != std::string::npos;
+ }),
+ 1);
+ EXPECT_TRUE(compiled->get_property("NPUW_LLM_GENERATE_PYRAMID").as<bool>());
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, ConfigOverridesAndAdditionsArePassedToFactory) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ov::AnyMap props = {
+ {"NPUW_LLM_SHARED_HEAD", "YES"},
+ {"NPUW_DEVICES", "CPU"},
+ {"NPUW_LLM_PREFILL_CONFIG", ov::AnyMap{{"NPUW_ONLINE_PIPELINE", "NONE"}, {"NPUW_DEVICES", "CPU"}}},
+ {"++NPUW_LLM_PREFILL_CONFIG", ov::AnyMap{{"NPUW_DEVICES", "CPU,NPU"}, {"NPUW_UNFOLD_IREQS", "YES"}}},
+ {"NPUW_LLM_GENERATE_CONFIG", ov::AnyMap{{"NPUW_ONLINE_PIPELINE", "NONE"}, {"NPUW_FALLBACK_EXEC", "YES"}}},
+ {"++NPUW_LLM_GENERATE_CONFIG", ov::AnyMap{{"NPUW_FALLBACK_EXEC", "NO"}, {"NPUW_FUNCALL_ASYNC", "NO"}}},
+ {"NPUW_LLM_SHARED_HEAD_CONFIG", ov::AnyMap{{"NPUW_DEVICES", "CPU"}}},
+ {"++NPUW_LLM_SHARED_HEAD_CONFIG", ov::AnyMap{{"NPUW_DEVICES", "NPU"}}},
+ };
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), props, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& prefill = require_call(recorder, "_prefill");
+ expect_prop(prefill.props, "NPUW_ONLINE_PIPELINE", "NONE");
+ expect_prop(prefill.props, "NPUW_DEVICES", "CPU,NPU");
+ expect_prop(prefill.props, "NPUW_UNFOLD_IREQS", "YES");
+
+ const auto& generate = require_call(recorder, "_kv192");
+ expect_prop(generate.props, "NPUW_ONLINE_PIPELINE", "NONE");
+ expect_prop(generate.props, "NPUW_FALLBACK_EXEC", "NO");
+ expect_prop(generate.props, "NPUW_FUNCALL_ASYNC", "NO");
+
+ const auto& head = require_call(recorder, "_lm_head");
+ expect_prop(head.props, "NPUW_DEVICES", "NPU");
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, AttentionHintsPropagateToStageConfigs) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ov::AnyMap props = {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_PREFILL_ATTENTION_HINT", "PYRAMID"},
+ {"NPUW_LLM_GENERATE_ATTENTION_HINT", "DYNAMIC"}};
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), props, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& prefill = require_call(recorder, "_prefill");
+ expect_prop(prefill.props, "NPUW_ATTN", "PYRAMID");
+ expect_prop(prefill.props, "NPUW_ONLINE_PIPELINE", "REP");
+ expect_prop(prefill.props, "NPUW_ONLINE_ISOLATE", "ATTN");
+ expect_prop(prefill.props, "NPUW_ONLINE_KEEP_BLOCK_SIZE", "4");
+ expect_prop(prefill.props, "NPUW_UNFOLD_IREQS", "NO");
+ expect_prop(prefill.props, "NPUW_FALLBACK_EXEC", "NO");
+
+ const auto& generate = require_call(recorder, "_kv192");
+ expect_prop(generate.props, "NPUW_ATTN", "DYNAMIC");
+ expect_prop(generate.props, "NPUW_ONLINE_PIPELINE", "REP");
+ expect_prop(generate.props, "NPUW_ONLINE_ISOLATE", "ATTN");
+ expect_prop(generate.props, "NPUW_ONLINE_KEEP_BLOCK_SIZE", "4");
+ expect_prop(generate.props, "NPUW_UNFOLD_IREQS", "NO");
+ expect_prop(generate.props, "NPUW_FALLBACK_EXEC", "NO");
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, VisibleLlmPropertiesRoundTripThroughCompiledModel) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ov::AnyMap props = {{"NPUW_LLM_MAX_PROMPT_LEN", "160"},
+ {"NPUW_LLM_MIN_RESPONSE_LEN", "96"},
+ {"NPUW_LLM_GENERATE_PYRAMID", "YES"},
+ {"NPUW_LLM_PREFILL_HINT", "STATIC"},
+ {"NPUW_LLM_GENERATE_HINT", "BEST_PERF"},
+ {"NPUW_LLM_PREFILL_ATTENTION_HINT", "STATIC"},
+ {"NPUW_LLM_GENERATE_ATTENTION_HINT", "HFA"},
+ {"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_PREFILL_CHUNK_SIZE", "0"}};
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), props, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ EXPECT_TRUE(compiled->get_property("NPUW_LLM").as<bool>());
+ EXPECT_EQ(compiled->get_property("NPUW_LLM_MAX_PROMPT_LEN").as<uint32_t>(), 160u);
+ EXPECT_EQ(compiled->get_property("NPUW_LLM_MIN_RESPONSE_LEN").as<uint32_t>(), 96u);
+ EXPECT_TRUE(compiled->get_property("NPUW_LLM_GENERATE_PYRAMID").as<bool>());
+ EXPECT_EQ(compiled->get_property("NPUW_LLM_PREFILL_HINT").as<std::string>(), "STATIC");
+ EXPECT_EQ(compiled->get_property("NPUW_LLM_GENERATE_HINT").as<std::string>(), "BEST_PERF");
+ EXPECT_EQ(compiled->get_property("NPUW_LLM_PREFILL_ATTENTION_HINT").as<std::string>(), "STATIC");
+ EXPECT_EQ(compiled->get_property("NPUW_LLM_GENERATE_ATTENTION_HINT").as<std::string>(), "HFA");
+ EXPECT_FALSE(compiled->get_property("NPUW_LLM_SHARED_HEAD").as<bool>());
+ EXPECT_EQ(compiled->get_property("NPUW_LLM_PREFILL_CHUNK_SIZE").as<uint64_t>(), 0u);
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, DefaultStageConfigsCarryBaselineNpuwOptions) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), {{"NPUW_LLM_SHARED_HEAD", "YES"}}, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto& prefill = require_call(recorder, "_prefill");
+ const auto& generate = require_call(recorder, "_kv192");
+ const auto& head = require_call(recorder, "_lm_head");
+
+ for (const auto* call : {&prefill, &generate, &head}) {
+ expect_prop(call->props, "NPU_USE_NPUW", "YES");
+ expect_prop(call->props, "NPUW_DEVICES", "NPU");
+ expect_prop(call->props, "NPUW_FOLD", "YES");
+ expect_prop(call->props, "NPUW_DCOFF_TYPE", "f16");
+ expect_prop(call->props, "NPUW_DCOFF_SCALE", "YES");
+ EXPECT_FALSE(prop_string(call->props, "NPUW_WEIGHTS_BANK").empty());
+ }
+
+ expect_prop(prefill.props, "NPUW_SLICE_OUT", "YES");
+ expect_prop(prefill.props, "NPUW_FUNCALL_ASYNC", "YES");
+
+ expect_missing_prop(generate.props, "NPUW_SLICE_OUT");
+ expect_prop(generate.props, "NPUW_FUNCALL_ASYNC", "YES");
+
+ expect_missing_prop(head.props, "NPUW_SLICE_OUT");
+ expect_missing_prop(head.props, "NPUW_FUNCALL_ASYNC");
+ expect_prop(head.props, "NPUW_ONLINE_PIPELINE", "NONE");
+
+ EXPECT_EQ(prop_string(prefill.props, "NPUW_WEIGHTS_BANK"), prop_string(generate.props, "NPUW_WEIGHTS_BANK"));
+ EXPECT_EQ(prop_string(prefill.props, "NPUW_WEIGHTS_BANK"), prop_string(head.props, "NPUW_WEIGHTS_BANK"));
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, CommonRuntimeAndDebugOptionsForwardToAllStages) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ov::AnyMap props = {
+ {"NPUW_LLM_SHARED_HEAD", "YES"},
+ {"NPU_USE_NPUW", "YES"},
+ {"NPUW_DEVICES", "CPU,NPU"},
+ {"NPUW_SUBMODEL_DEVICE", "0:CPU,last:NPU"},
+ {"NPUW_WEIGHTS_BANK_ALLOC", "CPU"},
+ {"NPUW_CACHE_DIR", "/tmp/npuw-cache"},
+ {"NPUW_PARALLEL_COMPILE", "YES"},
+ {"NPUW_FUNCALL_ASYNC", "NO"},
+ {"NPUW_UNFOLD_IREQS", "YES"},
+ {"NPUW_FALLBACK_EXEC", "YES"},
+ {"NPUW_ACC_CHECK", "YES"},
+ {"NPUW_ACC_THRESH", "0.25"},
+ {"NPUW_ACC_DEVICE", "CPU"},
+ {"NPUW_DUMP_FULL", "YES"},
+ {"NPUW_DUMP_SUBS", "YES"},
+ {"NPUW_DUMP_SUBS_DIR", "/tmp/npuw-dumps"},
+ {"NPUW_DUMP_SUBS_ON_FAIL", "last"},
+ {"NPUW_DUMP_IO", "0,last"},
+ {"NPUW_DUMP_IO_ITERS", "YES"},
+ };
+
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), props, recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ for (const auto& suffix : {"_prefill", "_kv192", "_lm_head"}) {
+ const auto& call = require_call(recorder, suffix);
+ expect_prop(call.props, "NPU_USE_NPUW", "YES");
+ expect_prop(call.props, "NPUW_DEVICES", "CPU,NPU");
+ expect_prop(call.props, "NPUW_SUBMODEL_DEVICE", "0:CPU,last:NPU");
+ expect_prop(call.props, "NPUW_WEIGHTS_BANK_ALLOC", "CPU");
+ expect_prop(call.props, "NPUW_CACHE_DIR", "/tmp/npuw-cache");
+ expect_prop(call.props, "NPUW_PARALLEL_COMPILE", "YES");
+ expect_prop(call.props, "NPUW_FUNCALL_ASYNC", "NO");
+ expect_prop(call.props, "NPUW_UNFOLD_IREQS", "YES");
+ expect_prop(call.props, "NPUW_FALLBACK_EXEC", "YES");
+ expect_prop(call.props, "NPUW_ACC_CHECK", "YES");
+ expect_prop(call.props, "NPUW_ACC_THRESH", "0.25");
+ expect_prop(call.props, "NPUW_ACC_DEVICE", "CPU");
+ expect_prop(call.props, "NPUW_DUMP_FULL", "YES");
+ expect_prop(call.props, "NPUW_DUMP_SUBS", "YES");
+ expect_prop(call.props, "NPUW_DUMP_SUBS_DIR", "/tmp/npuw-dumps");
+ expect_prop(call.props, "NPUW_DUMP_SUBS_ON_FAIL", "last");
+ expect_prop(call.props, "NPUW_DUMP_IO", "0,last");
+ expect_prop(call.props, "NPUW_DUMP_IO_ITERS", "YES");
+ }
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, GenerateHintModesSelectDifferentGenerateDefaults) {
+ {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(),
+ {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_GENERATE_HINT", "FAST_COMPILE"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+ const auto& generate = require_call(recorder, "_kv192");
+ expect_prop(generate.props, "NPUW_UNFOLD_IREQS", "YES");
+ expect_missing_prop(generate.props, "NPUW_SLICE_OUT");
+ }
+
+ {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(),
+ {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_GENERATE_HINT", "BEST_PERF"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+ const auto& generate = require_call(recorder, "_kv192");
+ expect_prop(generate.props, "NPUW_ONLINE_PIPELINE", "NONE");
+ expect_missing_prop(generate.props, "NPUW_SLICE_OUT");
+ }
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, StaticAndHfaAttentionHintsCoverDistinctValuePaths) {
+ {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(),
+ {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_PREFILL_ATTENTION_HINT", "STATIC"},
+ {"NPUW_LLM_GENERATE_ATTENTION_HINT", "STATIC"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+ const auto& prefill = require_call(recorder, "_prefill");
+ const auto& generate = require_call(recorder, "_kv192");
+ expect_prop(prefill.props, "NPUW_ATTN", "STATIC");
+ expect_prop(generate.props, "NPUW_ATTN", "STATIC");
+ // Static attention must not inject REP partitioning knobs into the stage configs.
+ EXPECT_EQ(prefill.props.count("NPUW_ONLINE_PIPELINE"), 0u);
+ EXPECT_EQ(generate.props.count("NPUW_ONLINE_PIPELINE"), 0u);
+ }
+
+ {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(),
+ {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_PREFILL_ATTENTION_HINT", "HFA"},
+ {"NPUW_LLM_GENERATE_ATTENTION_HINT", "HFA"},
+ {"NPUW_ATTN_HFA_FUSED", "YES"},
+ {"NPUW_ATTN_DYN", "YES"},
+ {"NPUW_ATTN_NO_COPY", "YES"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+ const auto& prefill = require_call(recorder, "_prefill");
+ const auto& generate = require_call(recorder, "_kv192");
+ for (const auto* call : {&prefill, &generate}) {
+ expect_prop(call->props, "NPUW_ATTN", "HFA");
+ expect_prop(call->props, "NPUW_ONLINE_PIPELINE", "REP");
+ expect_prop(call->props, "NPUW_ONLINE_ISOLATE", "ATTN");
+ expect_prop(call->props, "NPUW_ONLINE_KEEP_BLOCK_SIZE", "4");
+ expect_prop(call->props, "NPUW_UNFOLD_IREQS", "NO");
+ expect_prop(call->props, "NPUW_ATTN_HFA_FUSED", "YES");
+ expect_prop(call->props, "NPUW_ATTN_DYN", "YES");
+ expect_prop(call->props, "NPUW_ATTN_NO_COPY", "YES");
+ }
+ }
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, CacheRopePropertyRoundTripsForEnabledAndDisabledValues) {
+ {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(),
+ {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_CACHE_ROPE", "YES"},
+ {"NPUW_LLM_MAX_PROMPT_LEN", "2048"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+ EXPECT_TRUE(compiled->get_property("NPUW_LLM_CACHE_ROPE").as<bool>());
+ EXPECT_NE(recorder.find_suffix("_prefill"), nullptr);
+ EXPECT_NE(recorder.find_suffix("_kv2112"), nullptr);
+ }
+
+ {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+ ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(),
+ {{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_CACHE_ROPE", "NO"},
+ {"NPUW_LLM_MAX_PROMPT_LEN", "2048"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+ EXPECT_FALSE(compiled->get_property("NPUW_LLM_CACHE_ROPE").as<bool>());
+ EXPECT_NE(recorder.find_suffix("_prefill"), nullptr);
+ EXPECT_NE(recorder.find_suffix("_kv2112"), nullptr);
+ }
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, WhisperOptionRejectsCurrentSyntheticDecoderModel) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ EXPECT_ANY_THROW(compiled = create_compiled_model(build_whisper_decoder_model(),
+ {{"NPUW_WHISPER", "YES"}, {"NPUW_WHISPER_EOS_TOKEN", "42"}},
+ recorder));
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, TextEmbeddingOptionRejectsCurrentSyntheticEmbeddingModel) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ EXPECT_ANY_THROW(compiled = create_compiled_model(build_embedding_model(), {{"NPUW_TEXT_EMBED", "YES"}}, recorder));
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, WhisperKvCachePreparationAddsCacheInputsAndPresentOutputs) {
+ auto model = build_whisper_decoder_model();
+ ov::pass::StatefulToStateless().run_on_model(model);
+ model = model->clone();
+
+ const auto input_count_before = model->inputs().size();
+ const auto output_count_before = model->outputs().size();
+
+ EXPECT_TRUE(ov::npuw::util::PrepareWhisperKVCacheModel().run_on_model(model));
+ auto prepared = model;
+
+ EXPECT_GT(prepared->inputs().size(), input_count_before);
+ EXPECT_EQ(prepared->outputs().size(), output_count_before);
+ EXPECT_TRUE(has_input_name(prepared, "attention_mask"));
+ EXPECT_TRUE(has_input_name(prepared, "cache_position"));
+ EXPECT_TRUE(has_input_name(prepared, "past_key_values"));
+ EXPECT_TRUE(has_output_name(prepared, "present"));
+ EXPECT_EQ(prepared->input("input_ids").get_partial_shape()[1].get_length(), 1);
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, WhisperPrefillPreparationAddsCrossAttentionMaskAndKeepsNoCachePosition) {
+ auto model = build_whisper_decoder_model();
+ ov::pass::StatefulToStateless().run_on_model(model);
+ model = model->clone();
+
+ EXPECT_TRUE(ov::npuw::util::PrepareWhisperPrefillModel(128, 256).run_on_model(model));
+ auto prepared = model;
+
+ EXPECT_TRUE(has_input_name(prepared, "attention_mask"));
+ EXPECT_FALSE(has_input_name(prepared, "cache_position"));
+ EXPECT_TRUE(has_output_name(prepared, "present"));
+}
+
+TEST_F(LLMCompiledModelFactoryOptionsTest, TextEmbeddingPreparationRejectsCurrentSyntheticEmbeddingModel) {
+ auto model = build_embedding_model();
+ EXPECT_ANY_THROW(ov::npuw::util::PrepareTextEmbeddingModel(2).run_on_model(model));
+}
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_factory_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_factory_test.cpp
deleted file mode 100644
index 884057aade4..00000000000
--- a/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_factory_test.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright (C) 2018-2026 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-// Tests for LLMCompiledModel's CompiledModelFactory injection point.
-//
-// We build a tiny stateful LLM with ModelBuilder, then construct
-// LLMCompiledModel with a counting factory that returns MockSubCompiledModel
-// instead of a real npuw::CompiledModel. No hardware or ICore is required:
-//
-// - NullPlugin is a minimal ov::IPlugin stub (no hardware, no core).
-// - extract_npu_descriptor() returns std::nullopt when plugin->get_core()
-// is null (our null guard), so all NPU-HW-specific branches are skipped.
-//
-// Expected factory call counts:
-// NPUW_LLM_SHARED_HEAD=NO (two-model pipeline) → 2
-// NPUW_LLM_SHARED_HEAD=YES (three-model pipeline) → 3
-
-#include <gtest/gtest.h>
-
-#include <atomic>
-#include <memory>
-#include <string>
-
-#include "compiled_model.hpp" // ov::npuw::ICompiledModel_v0
-#include "llm_compiled_model.hpp" // ov::npuw::LLMCompiledModel
-#include "model_builder.hpp" // ov::test::npuw::ModelBuilder/Config
-#include "openvino/runtime/iplugin.hpp"
-#include "serialization.hpp" // ov::npuw::s11n::CompiledContext
-#include "weights_bank.hpp" // ov::npuw::weights::Bank
-
-namespace {
-
-// ---------------------------------------------------------------------------
-// NullPlugin — the minimum ov::IPlugin needed to construct LLMCompiledModel.
-// get_core() returns nullptr → extract_npu_descriptor() skips all HW queries.
-// ---------------------------------------------------------------------------
-class NullPlugin : public ov::IPlugin {
-public:
- std::shared_ptr<ov::ICompiledModel> compile_model(
- const std::shared_ptr<const ov::Model>&, const ov::AnyMap&) const override { return {}; }
- std::shared_ptr<ov::ICompiledModel> compile_model(
- const std::shared_ptr<const ov::Model>&,
- const ov::AnyMap&,
- const ov::SoPtr<ov::IRemoteContext>&) const override { return {}; }
- std::shared_ptr<ov::ICompiledModel> import_model(
- std::istream&, const ov::AnyMap&) const override { return {}; }
- std::shared_ptr<ov::ICompiledModel> import_model(
- std::istream&, const ov::SoPtr<ov::IRemoteContext>&,
- const ov::AnyMap&) const override { return {}; }
- std::shared_ptr<ov::ICompiledModel> import_model(
- const ov::Tensor&, const ov::AnyMap&) const override { return {}; }
- std::shared_ptr<ov::ICompiledModel> import_model(
- const ov::Tensor&, const ov::SoPtr<ov::IRemoteContext>&,
- const ov::AnyMap&) const override { return {}; }
- ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>&,
- const ov::AnyMap&) const override { return {}; }
- void set_property(const ov::AnyMap&) override {}
- ov::Any get_property(const std::string&, const ov::AnyMap&) const override { return {}; }
- ov::SoPtr<ov::IRemoteContext> create_context(const ov::AnyMap&) const override { return {}; }
- ov::SoPtr<ov::IRemoteContext> get_default_context(const ov::AnyMap&) const override { return {}; }
-};
-
-// ---------------------------------------------------------------------------
-// MockSubCompiledModel — minimal ICompiledModel_v0 returned by the factory.
-// LLMCompiledModel only stores the pointer during construction; no methods
-// are called on it before the constructor returns.
-// ---------------------------------------------------------------------------
-class MockSubCompiledModel : public ov::npuw::ICompiledModel_v0 {
-public:
- MockSubCompiledModel(const std::shared_ptr<ov::Model>& m,
- const std::shared_ptr<const ov::IPlugin>& p,
- const ov::AnyMap& /*props*/)
- : ov::npuw::ICompiledModel_v0(m, p) {}
-
- // ov::ICompiledModel pure virtuals
- 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&) override {}
- ov::Any get_property(const std::string&) const override { return {}; }
- std::shared_ptr<ov::ISyncInferRequest> create_sync_infer_request() const override { return {}; }
-
- // ov::npuw::ICompiledModel_v0 pure virtuals
- std::shared_ptr<ov::npuw::IBaseInferRequest> create_base_infer_request() const override { return {}; }
- std::shared_ptr<ov::IAsyncInferRequest> wrap_async_infer_request(
- std::shared_ptr<ov::npuw::IBaseInferRequest>) const override { return {}; }
- std::string submodel_device(std::size_t) const override { return "CPU"; }
- std::size_t num_submodels() const override { return 0; }
- std::shared_ptr<ov::npuw::weights::Bank> get_weights_bank() const override { return {}; }
- void set_weights_bank(std::shared_ptr<ov::npuw::weights::Bank>) override {}
- void finalize_weights_bank() override {}
- void reconstruct_closure() override {}
- void serialize(std::ostream&, const ov::npuw::s11n::CompiledContext&) const override {}
-};
-
-// ---------------------------------------------------------------------------
-// Test fixture
-// ---------------------------------------------------------------------------
-class LLMCompiledModelFactoryTest : public ::testing::Test {
-protected:
- void SetUp() override {
- ov::test::npuw::ModelConfig cfg;
- cfg.num_layers = 2;
- cfg.hidden_size = 64;
- cfg.num_heads = 4;
- cfg.head_dim = 16;
- cfg.num_kv_heads = 4;
- cfg.vocab_size = 256;
-
- ov::test::npuw::ModelBuilder mb;
- m_model = mb.build_model(cfg);
- m_plugin = std::make_shared<NullPlugin>();
- }
-
- ov::npuw::LLMCompiledModel::CompiledModelFactory make_counting_factory(std::atomic<int>& n) {
- return [&n](const std::shared_ptr<ov::Model>& m,
- const std::shared_ptr<const ov::IPlugin>& p,
- const ov::AnyMap& props) -> std::shared_ptr<ov::npuw::ICompiledModel_v0> {
- ++n;
- return std::make_shared<MockSubCompiledModel>(m, p, props);
- };
- }
-
- static ov::AnyMap base_props() {
- return {{"NPUW_LLM", "YES"},
- {"NPUW_LLM_MAX_PROMPT_LEN", "128"},
- {"NPUW_LLM_MIN_RESPONSE_LEN", "64"}};
- }
-
- std::shared_ptr<ov::Model> m_model;
- std::shared_ptr<ov::IPlugin> m_plugin;
-};
-
-// ---------------------------------------------------------------------------
-// Tests
-// ---------------------------------------------------------------------------
-
-TEST_F(LLMCompiledModelFactoryTest, TwoModelPipeline) {
- std::atomic<int> calls{0};
- auto props = base_props();
- props["NPUW_LLM_SHARED_HEAD"] = std::string("NO");
-
- ASSERT_NO_THROW(ov::npuw::LLMCompiledModel(m_model, m_plugin, props,
- make_counting_factory(calls)));
- EXPECT_EQ(calls.load(), 2) << "Expected 2 factory calls: generate + prefill";
-}
-
-TEST_F(LLMCompiledModelFactoryTest, ThreeModelPipeline) {
- std::atomic<int> calls{0};
- auto props = base_props();
- props["NPUW_LLM_SHARED_HEAD"] = std::string("YES");
-
- ASSERT_NO_THROW(ov::npuw::LLMCompiledModel(m_model, m_plugin, props,
- make_counting_factory(calls)));
- EXPECT_EQ(calls.load(), 3) << "Expected 3 factory calls: generate + prefill + lm_head";
-}
-
-} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_graph_options_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_graph_options_test.cpp
new file mode 100644
index 00000000000..49cef8d4199
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/llm_compiled_model_graph_options_test.cpp
@@ -0,0 +1,223 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <algorithm>
+#include <optional>
+#include <memory>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "llm_test_helpers.hpp"
+#include "openvino/op/slice.hpp"
+
+namespace {
+using ov::test::npuw::CompileCall;
+using ov::test::npuw::NullPlugin;
+using ov::test::npuw::RecordingFactory;
+
+class LLMCompiledModelGraphOptionsTest : public ::testing::Test {
+protected:
+ void SetUp() override {
+ m_plugin = std::make_shared<NullPlugin>();
+ }
+
+ std::shared_ptr<ov::Model> build_model() const {
+ return ov::test::npuw::build_llm_test_model();
+ }
+
+ static ov::AnyMap base_props() {
+ return {{"NPUW_LLM", "YES"}, {"NPUW_LLM_MAX_PROMPT_LEN", "128"}, {"NPUW_LLM_MIN_RESPONSE_LEN", "64"}};
+ }
+
+ 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::LLMCompiledModel> create_compiled_model(const ov::AnyMap& extra_props,
+ RecordingFactory& recorder) const {
+ auto props = base_props();
+ merge_props(props, extra_props);
+ return std::make_unique<ov::npuw::LLMCompiledModel>(build_model(), m_plugin, props, recorder.make_factory());
+ }
+
+ template <class Port>
+ static bool port_has_name(const Port& port, std::string_view needle) {
+ const auto& names = port.get_names();
+ return std::any_of(names.begin(), names.end(), [needle](const std::string& name) {
+ return name.find(needle) != std::string::npos;
+ });
+ }
+
+ static std::optional<ov::Output<const ov::Node>> find_input(const std::shared_ptr<ov::Model>& model,
+ std::string_view needle) {
+ const auto inputs = model->inputs();
+ const auto it = std::find_if(inputs.begin(), inputs.end(), [needle](const auto& input) {
+ return port_has_name(input, needle);
+ });
+ if (it == inputs.end()) {
+ return std::nullopt;
+ }
+ return *it;
+ }
+
+ static std::optional<ov::Output<const ov::Node>> find_output(const std::shared_ptr<ov::Model>& model,
+ std::string_view needle) {
+ const auto outputs = model->outputs();
+ const auto it = std::find_if(outputs.begin(), outputs.end(), [needle](const auto& output) {
+ return port_has_name(output, needle);
+ });
+ if (it == outputs.end()) {
+ return std::nullopt;
+ }
+ return *it;
+ }
+
+ static std::size_t count_inputs(const std::shared_ptr<ov::Model>& model, std::string_view needle) {
+ const auto inputs = model->inputs();
+ return std::count_if(inputs.begin(), inputs.end(), [needle](const auto& input) {
+ return port_has_name(input, needle);
+ });
+ }
+
+ static std::size_t count_outputs(const std::shared_ptr<ov::Model>& model, std::string_view needle) {
+ const auto outputs = model->outputs();
+ return std::count_if(outputs.begin(), outputs.end(), [needle](const auto& output) {
+ return port_has_name(output, needle);
+ });
+ }
+
+ template <class Op>
+ static 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::IPlugin> m_plugin;
+};
+
+TEST_F(LLMCompiledModelGraphOptionsTest, SharedHeadAddsHeadModelAndSlicesPrefillEmbeds) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model({{"NPUW_LLM_SHARED_HEAD", "YES"},
+ {"NPUW_LLM_MAX_GENERATION_TOKEN_LEN", "8"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto* prefill = recorder.find_suffix("_prefill");
+ const auto* lm_head = recorder.find_suffix("_lm_head");
+ ASSERT_NE(prefill, nullptr);
+ ASSERT_NE(lm_head, nullptr);
+
+ const auto embeds = find_output(prefill->model, ov::npuw::LLMCompiledModel::output_embeds);
+ ASSERT_TRUE(embeds.has_value());
+ ASSERT_TRUE(embeds->get_partial_shape().is_static());
+ EXPECT_EQ(embeds->get_shape(), (ov::Shape{1, 8, 64}));
+
+ const auto head_input = lm_head->model->input(0);
+ ASSERT_TRUE(head_input.get_partial_shape().is_static());
+ EXPECT_EQ(head_input.get_shape(), (ov::Shape{1, 8, 64}));
+ EXPECT_GE(count_ops<ov::op::v8::Slice>(prefill->model), 1u);
+}
+
+TEST_F(LLMCompiledModelGraphOptionsTest, PromptResponseAndGenerationLengthsDriveStaticShapes) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model({{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_MAX_PROMPT_LEN", "128"},
+ {"NPUW_LLM_MIN_RESPONSE_LEN", "64"},
+ {"NPUW_LLM_MAX_GENERATION_TOKEN_LEN", "8"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto* prefill = recorder.find_suffix("_prefill");
+ const auto* generate = recorder.find_suffix("_kv192");
+ ASSERT_NE(prefill, nullptr);
+ ASSERT_NE(generate, nullptr);
+
+ const auto prefill_ids = find_input(prefill->model, "input_ids");
+ const auto prefill_mask = find_input(prefill->model, "attention_mask");
+ const auto generate_ids = find_input(generate->model, "input_ids");
+ const auto generate_mask = find_input(generate->model, "attention_mask");
+ ASSERT_TRUE(prefill_ids.has_value());
+ ASSERT_TRUE(prefill_mask.has_value());
+ ASSERT_TRUE(generate_ids.has_value());
+ ASSERT_TRUE(generate_mask.has_value());
+ EXPECT_EQ(prefill_ids->get_shape(), (ov::Shape{1, 128}));
+ EXPECT_EQ(prefill_mask->get_shape(), (ov::Shape{1, 128}));
+ EXPECT_EQ(generate_ids->get_shape(), (ov::Shape{1, 8}));
+ EXPECT_EQ(generate_mask->get_shape(), (ov::Shape{1, 192}));
+}
+
+TEST_F(LLMCompiledModelGraphOptionsTest, DynamicChunkPrefillKeepsPastKvInputsAndExportsPresentKvOutputs) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model({{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_PREFILL_HINT", "DYNAMIC"},
+ {"NPUW_LLM_PREFILL_CHUNK_SIZE", "32"},
+ {"NPUW_LLM_MAX_PROMPT_LEN", "128"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto* prefill = recorder.find_suffix("_prefill");
+ ASSERT_NE(prefill, nullptr);
+ EXPECT_GT(count_inputs(prefill->model, "past_key_values"), 0u);
+ EXPECT_GT(count_outputs(prefill->model, "present"), 0u);
+ const auto ids = find_input(prefill->model, "input_ids");
+ ASSERT_TRUE(ids.has_value());
+ EXPECT_EQ(ids->get_shape(), (ov::Shape{1, 32}));
+}
+
+TEST_F(LLMCompiledModelGraphOptionsTest, StaticPrefillRemovesPastKvInputsAndKeepsPresentKvOutputs) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model({{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_PREFILL_HINT", "STATIC"},
+ {"NPUW_LLM_PREFILL_CHUNK_SIZE", "32"},
+ {"NPUW_LLM_MAX_PROMPT_LEN", "128"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ const auto* prefill = recorder.find_suffix("_prefill");
+ ASSERT_NE(prefill, nullptr);
+ EXPECT_EQ(count_inputs(prefill->model, "past_key_values"), 0u);
+ EXPECT_GT(count_outputs(prefill->model, "present"), 0u);
+ const auto ids = find_input(prefill->model, "input_ids");
+ ASSERT_TRUE(ids.has_value());
+ EXPECT_EQ(ids->get_shape(), (ov::Shape{1, 128}));
+}
+
+TEST_F(LLMCompiledModelGraphOptionsTest, GeneratePyramidCreatesIntermediateKvVariants) {
+ RecordingFactory recorder;
+ std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;
+
+ ASSERT_NO_THROW(compiled = create_compiled_model({{"NPUW_LLM_SHARED_HEAD", "NO"},
+ {"NPUW_LLM_GENERATE_PYRAMID", "YES"},
+ {"NPUW_LLM_MAX_PROMPT_LEN", "2048"},
+ {"NPUW_LLM_MIN_RESPONSE_LEN", "128"}},
+ recorder));
+ ASSERT_NE(compiled, nullptr);
+
+ std::vector<std::string> kv_names;
+ for (const auto& call : recorder.calls()) {
+ if (call.friendly_name.find("_kv") != std::string::npos) {
+ kv_names.push_back(call.friendly_name);
+ }
+ }
+ EXPECT_THAT(kv_names, ::testing::UnorderedElementsAre(::testing::EndsWith("_kv1152"),
+ ::testing::EndsWith("_kv2176")));
+}
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npuw/llm_test_helpers.hpp b/src/plugins/intel_npu/tests/unit/npuw/llm_test_helpers.hpp
new file mode 100644
index 00000000000..9b5f05afb45
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/llm_test_helpers.hpp
@@ -0,0 +1,174 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <algorithm>
+#include <memory>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "compiled_model.hpp"
+#include "llm_compiled_model.hpp"
+#include "model_builder.hpp"
+#include "openvino/runtime/iplugin.hpp"
+#include "serialization.hpp"
+#include "weights_bank.hpp"
+
+namespace ov::test::npuw {
+
+inline ModelConfig make_llm_test_model_config() {
+ ModelConfig cfg;
+ cfg.num_layers = 2;
+ cfg.hidden_size = 64;
+ cfg.num_heads = 4;
+ cfg.head_dim = 16;
+ cfg.num_kv_heads = 4;
+ cfg.vocab_size = 256;
+ return cfg;
+}
+
+inline std::shared_ptr<ov::Model> build_llm_test_model() {
+ ModelBuilder mb;
+ return mb.build_model(make_llm_test_model_config());
+}
+
+inline std::shared_ptr<ov::Model> build_whisper_decoder_test_model() {
+ auto cfg = make_llm_test_model_config();
+ cfg.use_cross_attention = true;
+ ModelBuilder mb;
+ return mb.build_model(cfg);
+}
+
+inline std::shared_ptr<ov::Model> build_embedding_test_model() {
+ auto cfg = make_llm_test_model_config();
+ cfg.use_token_type_embedding = true;
+ ModelBuilder mb;
+ return mb.build_model(cfg);
+}
+
+class NullPlugin : public ov::IPlugin {
+public:
+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>&,
+ const ov::AnyMap&) const override {
+ return {};
+ }
+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>&,
+ const ov::AnyMap&,
+ const ov::SoPtr<ov::IRemoteContext>&) const override {
+ return {};
+ }
+ std::shared_ptr<ov::ICompiledModel> import_model(std::istream&, const ov::AnyMap&) const override {
+ return {};
+ }
+ std::shared_ptr<ov::ICompiledModel> import_model(std::istream&,
+ const ov::SoPtr<ov::IRemoteContext>&,
+ const ov::AnyMap&) const override {
+ return {};
+ }
+ std::shared_ptr<ov::ICompiledModel> import_model(const ov::Tensor&, const ov::AnyMap&) const override {
+ return {};
+ }
+ std::shared_ptr<ov::ICompiledModel> import_model(const ov::Tensor&,
+ const ov::SoPtr<ov::IRemoteContext>&,
+ const ov::AnyMap&) const override {
+ return {};
+ }
+ ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>&, const ov::AnyMap&) const override {
+ return {};
+ }
+ void set_property(const ov::AnyMap&) override {}
+ ov::Any get_property(const std::string&, const ov::AnyMap&) const override {
+ return {};
+ }
+ ov::SoPtr<ov::IRemoteContext> create_context(const ov::AnyMap&) const override {
+ return {};
+ }
+ ov::SoPtr<ov::IRemoteContext> get_default_context(const ov::AnyMap&) const override {
+ return {};
+ }
+};
+
+class MockSubCompiledModel : public ov::npuw::ICompiledModel_v0 {
+public:
+ MockSubCompiledModel(const std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<const ov::IPlugin>& plugin,
+ const ov::AnyMap&)
+ : ov::npuw::ICompiledModel_v0(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&) override {}
+ ov::Any get_property(const std::string&) const override {
+ return {};
+ }
+ std::shared_ptr<ov::ISyncInferRequest> create_sync_infer_request() const override {
+ return {};
+ }
+ std::shared_ptr<ov::npuw::IBaseInferRequest> create_base_infer_request() const override {
+ return {};
+ }
+ std::shared_ptr<ov::IAsyncInferRequest> wrap_async_infer_request(
+ std::shared_ptr<ov::npuw::IBaseInferRequest>) const override {
+ return {};
+ }
+ std::string submodel_device(std::size_t) const override {
+ return "CPU";
+ }
+ std::size_t num_submodels() const override {
+ return 0;
+ }
+ std::shared_ptr<ov::npuw::weights::Bank> get_weights_bank() const override {
+ return {};
+ }
+ void set_weights_bank(std::shared_ptr<ov::npuw::weights::Bank>) override {}
+ void finalize_weights_bank() override {}
+ void reconstruct_closure() override {}
+ void serialize(std::ostream&, const ov::npuw::s11n::CompiledContext&) const override {}
+};
+
+struct CompileCall {
+ std::string friendly_name;
+ ov::AnyMap props;
+ std::shared_ptr<ov::Model> model;
+};
+
+class RecordingFactory {
+public:
+ ov::npuw::LLMCompiledModel::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_v0> {
+ m_calls.push_back({model->get_friendly_name(), props, model});
+ return std::make_shared<MockSubCompiledModel>(model, plugin, props);
+ };
+ }
+
+ const std::vector<CompileCall>& calls() const {
+ return m_calls;
+ }
+
+ std::size_t count_suffix(std::string_view suffix) const {
+ return std::count_if(m_calls.begin(), m_calls.end(), [suffix](const CompileCall& call) {
+ return call.friendly_name.size() >= suffix.size() &&
+ call.friendly_name.compare(call.friendly_name.size() - suffix.size(), suffix.size(), suffix) == 0;
+ });
+ }
+
+ const CompileCall* find_suffix(std::string_view suffix) const {
+ const auto it = std::find_if(m_calls.begin(), m_calls.end(), [suffix](const CompileCall& call) {
+ return call.friendly_name.size() >= suffix.size() &&
+ call.friendly_name.compare(call.friendly_name.size() - suffix.size(), suffix.size(), suffix) == 0;
+ });
+ return it == m_calls.end() ? nullptr : &(*it);
+ }
+
+private:
+ std::vector<CompileCall> m_calls;
+};
+
+} // namespace ov::test::npuw
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
new file mode 100644
index 00000000000..fc998213569
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/npuw_options_smoke_test.cpp
@@ -0,0 +1,205 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <functional>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "intel_npu/config/config.hpp"
+#include "intel_npu/config/npuw.hpp"
+#include "intel_npu/npuw_private_properties.hpp"
+
+namespace {
+
+struct ConfigAssertionCase {
+ std::string test_name;
+ ::intel_npu::Config::ConfigMap options;
+ std::function<void(const ::intel_npu::Config&)> verify;
+};
+
+using Case = ConfigAssertionCase;
+
+std::shared_ptr<const ::intel_npu::OptionsDesc> make_options_desc() {
+ auto desc = std::make_shared<::intel_npu::OptionsDesc>();
+ ::intel_npu::registerNPUWOptions(*desc);
+ ::intel_npu::registerNPUWLLMOptions(*desc);
+ ::intel_npu::registerNPUWKokoroOptions(*desc);
+ return desc;
+}
+
+::intel_npu::Config make_config(const ::intel_npu::Config::ConfigMap& options = {}) {
+ ::intel_npu::Config cfg(make_options_desc());
+ cfg.update(options);
+ return cfg;
+}
+
+template <class Opt>
+Case bool_case(std::string test_name, std::string value, bool expected) {
+ return {std::move(test_name),
+ {{std::string(Opt::key()), std::move(value)}},
+ [expected](const ::intel_npu::Config& cfg) {
+ EXPECT_EQ(cfg.get<Opt>(), expected);
+ }};
+}
+
+template <class Opt>
+Case string_case(std::string test_name, std::string value, std::string expected) {
+ return {std::move(test_name),
+ {{std::string(Opt::key()), std::move(value)}},
+ [expected = std::move(expected)](const ::intel_npu::Config& cfg) {
+ EXPECT_EQ(cfg.get<Opt>(), expected);
+ }};
+}
+
+template <class Opt, class ValueT>
+Case numeric_case(std::string test_name, std::string value, ValueT expected) {
+ return {std::move(test_name),
+ {{std::string(Opt::key()), std::move(value)}},
+ [expected](const ::intel_npu::Config& cfg) {
+ EXPECT_EQ(cfg.get<Opt>(), expected);
+ }};
+}
+
+template <class Opt>
+Case double_case(std::string test_name, std::string value, double expected) {
+ return {std::move(test_name),
+ {{std::string(Opt::key()), std::move(value)}},
+ [expected](const ::intel_npu::Config& cfg) {
+ EXPECT_DOUBLE_EQ(cfg.get<Opt>(), expected);
+ }};
+}
+
+template <class Opt>
+Case enum_case(std::string test_name, std::string value, std::string expected) {
+ return {std::move(test_name),
+ {{std::string(Opt::key()), std::move(value)}},
+ [expected = std::move(expected)](const ::intel_npu::Config& cfg) {
+ EXPECT_EQ(cfg.getString<Opt>(), expected);
+ }};
+}
+
+std::vector<Case> make_cases() {
+ std::vector<Case> cases = {
+ bool_case<::intel_npu::NPU_USE_NPUW>("NPU_USE_NPUW", "YES", true),
+ string_case<::intel_npu::NPUW_DEVICES>("NPUW_DEVICES", "CPU,NPU", "CPU,NPU"),
+ string_case<::intel_npu::NPUW_SUBMODEL_DEVICE>("NPUW_SUBMODEL_DEVICE", "0:CPU,last:NPU", "0:CPU,last:NPU"),
+ string_case<::intel_npu::NPUW_WEIGHTS_BANK>("NPUW_WEIGHTS_BANK", "shared-bank", "shared-bank"),
+ string_case<::intel_npu::NPUW_WEIGHTS_BANK_ALLOC>("NPUW_WEIGHTS_BANK_ALLOC", "CPU", "CPU"),
+ string_case<::intel_npu::NPUW_CACHE_DIR>("NPUW_CACHE_DIR", "/tmp/npuw-cache", "/tmp/npuw-cache"),
+ string_case<::intel_npu::NPUW_ONLINE_PIPELINE>("NPUW_ONLINE_PIPELINE", "SPATIAL", "SPATIAL"),
+ string_case<::intel_npu::NPUW_ONLINE_AVOID>("NPUW_ONLINE_AVOID", "Op:Select/NPU", "Op:Select/NPU"),
+ string_case<::intel_npu::NPUW_ONLINE_ISOLATE>("NPUW_ONLINE_ISOLATE", "Op:Select/compute", "Op:Select/compute"),
+ string_case<::intel_npu::NPUW_ONLINE_NO_FOLD>("NPUW_ONLINE_NO_FOLD", "compute", "compute"),
+ numeric_case<::intel_npu::NPUW_ONLINE_MIN_SIZE>("NPUW_ONLINE_MIN_SIZE", "12", std::size_t{12}),
+ numeric_case<::intel_npu::NPUW_ONLINE_KEEP_BLOCKS>("NPUW_ONLINE_KEEP_BLOCKS", "2", std::size_t{2}),
+ numeric_case<::intel_npu::NPUW_ONLINE_KEEP_BLOCK_SIZE>("NPUW_ONLINE_KEEP_BLOCK_SIZE", "4", std::size_t{4}),
+ string_case<::intel_npu::NPUW_ONLINE_DUMP_PLAN>("NPUW_ONLINE_DUMP_PLAN", "/tmp/plan.xml", "/tmp/plan.xml"),
+ string_case<::intel_npu::NPUW_PLAN>("NPUW_PLAN", "/tmp/plan.xml", "/tmp/plan.xml"),
+ bool_case<::intel_npu::NPUW_FOLD>("NPUW_FOLD", "YES", true),
+ bool_case<::intel_npu::NPUW_CWAI>("NPUW_CWAI", "YES", true),
+ bool_case<::intel_npu::NPUW_DQ>("NPUW_DQ", "YES", true),
+ bool_case<::intel_npu::NPUW_DQ_FULL>("NPUW_DQ_FULL", "NO", false),
+ string_case<::intel_npu::NPUW_PMM>("NPUW_PMM", "0,2", "0,2"),
+ bool_case<::intel_npu::NPUW_MM_GATED>("NPUW_MM_GATED", "NO", false),
+ bool_case<::intel_npu::NPUW_SLICE_OUT>("NPUW_SLICE_OUT", "YES", true),
+ bool_case<::intel_npu::NPUW_F16IC>("NPUW_F16IC", "NO", false),
+ string_case<::intel_npu::NPUW_DCOFF_TYPE>("NPUW_DCOFF_TYPE", "f16", "f16"),
+ bool_case<::intel_npu::NPUW_DCOFF_SCALE>("NPUW_DCOFF_SCALE", "YES", true),
+ bool_case<::intel_npu::NPUW_FUNCALL_FOR_ALL>("NPUW_FUNCALL_FOR_ALL", "YES", true),
+ bool_case<::intel_npu::NPUW_HOST_GATHER>("NPUW_HOST_GATHER", "NO", false),
+ bool_case<::intel_npu::NPUW_SPATIAL>("NPUW_SPATIAL", "YES", true),
+ numeric_case<::intel_npu::NPUW_SPATIAL_NWAY>("NPUW_SPATIAL_NWAY", "16", std::size_t{16}),
+ bool_case<::intel_npu::NPUW_SPATIAL_DYN>("NPUW_SPATIAL_DYN", "NO", false),
+ numeric_case<::intel_npu::NPUW_MOE_TOKEN_CHUNK_SIZE>("NPUW_MOE_TOKEN_CHUNK_SIZE", "32", uint64_t{32}),
+ numeric_case<::intel_npu::NPUW_MOE_POOL_SIZE>("NPUW_MOE_POOL_SIZE", "4", std::size_t{4}),
+ string_case<::intel_npu::NPUW_ATTN>("NPUW_ATTN", "HFA", "HFA"),
+ bool_case<::intel_npu::NPUW_ATTN_DYN>("NPUW_ATTN_DYN", "NO", false),
+ bool_case<::intel_npu::NPUW_ATTN_NO_COPY>("NPUW_ATTN_NO_COPY", "YES", true),
+ bool_case<::intel_npu::NPUW_ATTN_HFA_FUSED>("NPUW_ATTN_HFA_FUSED", "YES", true),
+ bool_case<::intel_npu::NPUW_PARALLEL_COMPILE>("NPUW_PARALLEL_COMPILE", "YES", true),
+ bool_case<::intel_npu::NPUW_FUNCALL_ASYNC>("NPUW_FUNCALL_ASYNC", "YES", true),
+ bool_case<::intel_npu::NPUW_UNFOLD_IREQS>("NPUW_UNFOLD_IREQS", "YES", true),
+ bool_case<::intel_npu::NPUW_FALLBACK_EXEC>("NPUW_FALLBACK_EXEC", "NO", false),
+ 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_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}),
+ numeric_case<::intel_npu::NPUW_LLM_MAX_PROMPT_LEN>("NPUW_LLM_MAX_PROMPT_LEN", "2048", uint32_t{2048}),
+ numeric_case<::intel_npu::NPUW_LLM_MAX_GENERATION_TOKEN_LEN>("NPUW_LLM_MAX_GENERATION_TOKEN_LEN",
+ "8",
+ uint32_t{8}),
+ numeric_case<::intel_npu::NPUW_LLM_MIN_RESPONSE_LEN>("NPUW_LLM_MIN_RESPONSE_LEN", "192", uint32_t{192}),
+ numeric_case<::intel_npu::NPUW_LLM_MAX_LORA_RANK>("NPUW_LLM_MAX_LORA_RANK", "64", uint32_t{64}),
+ bool_case<::intel_npu::NPUW_LLM_OPTIMIZE_V_TENSORS>("NPUW_LLM_OPTIMIZE_V_TENSORS", "NO", false),
+ bool_case<::intel_npu::NPUW_LLM_OPTIMIZE_FP8>("NPUW_LLM_OPTIMIZE_FP8", "YES", true),
+ bool_case<::intel_npu::NPUW_LLM_CACHE_ROPE>("NPUW_LLM_CACHE_ROPE", "NO", false),
+ enum_case<::intel_npu::NPUW_LLM_PREFILL_MOE_HINT>("NPUW_LLM_PREFILL_MOE_HINT", "HOST_ROUTED", "HOST_ROUTED"),
+ enum_case<::intel_npu::NPUW_LLM_GENERATE_MOE_HINT>("NPUW_LLM_GENERATE_MOE_HINT",
+ "DEVICE_ROUTED",
+ "DEVICE_ROUTED"),
+ bool_case<::intel_npu::NPUW_LLM_GENERATE_PYRAMID>("NPUW_LLM_GENERATE_PYRAMID", "YES", true),
+ numeric_case<::intel_npu::NPUW_LLM_PREFILL_CHUNK_SIZE>("NPUW_LLM_PREFILL_CHUNK_SIZE", "256", uint64_t{256}),
+ bool_case<::intel_npu::NPUW_LLM_ENABLE_PREFIX_CACHING>("NPUW_LLM_ENABLE_PREFIX_CACHING", "YES", true),
+ numeric_case<::intel_npu::NPUW_LLM_PREFIX_CACHING_BLOCK_SIZE>("NPUW_LLM_PREFIX_CACHING_BLOCK_SIZE",
+ "128",
+ uint64_t{128}),
+ numeric_case<::intel_npu::NPUW_LLM_PREFIX_CACHING_MAX_NUM_BLOCKS>(
+ "NPUW_LLM_PREFIX_CACHING_MAX_NUM_BLOCKS",
+ "32",
+ uint64_t{32}),
+ enum_case<::intel_npu::NPUW_LLM_PREFILL_HINT>("NPUW_LLM_PREFILL_HINT", "STATIC", "STATIC"),
+ enum_case<::intel_npu::NPUW_LLM_PREFILL_ATTENTION_HINT>("NPUW_LLM_PREFILL_ATTENTION_HINT",
+ "DYNAMIC",
+ "DYNAMIC"),
+ enum_case<::intel_npu::NPUW_LLM_GENERATE_HINT>("NPUW_LLM_GENERATE_HINT", "BEST_PERF", "BEST_PERF"),
+ enum_case<::intel_npu::NPUW_LLM_GENERATE_ATTENTION_HINT>("NPUW_LLM_GENERATE_ATTENTION_HINT",
+ "PYRAMID",
+ "PYRAMID"),
+ bool_case<::intel_npu::NPUW_LLM_SHARED_HEAD>("NPUW_LLM_SHARED_HEAD", "NO", false),
+ bool_case<::intel_npu::NPUW_WHISPER>("NPUW_WHISPER", "YES", true),
+ numeric_case<::intel_npu::NPUW_WHISPER_EOS_TOKEN>("NPUW_WHISPER_EOS_TOKEN", "42", uint64_t{42}),
+ bool_case<::intel_npu::NPUW_EAGLE>("NPUW_EAGLE", "YES", true),
+ bool_case<::intel_npu::NPUW_TEXT_EMBED>("NPUW_TEXT_EMBED", "YES", true),
+ bool_case<::intel_npu::NPUW_KOKORO>("NPUW_KOKORO", "YES", true),
+ numeric_case<::intel_npu::NPUW_KOKORO_BLOCK_SIZE>("NPUW_KOKORO_BLOCK_SIZE", "256", uint64_t{256}),
+ numeric_case<::intel_npu::NPUW_KOKORO_OVERLAP_SIZE>("NPUW_KOKORO_OVERLAP_SIZE", "32", uint64_t{32}),
+ {"NPUW_WEIGHTS_HANDLE_PROVIDER",
+ {},
+ [](const ::intel_npu::Config&) {
+ EXPECT_EQ(std::string(ov::intel_npu::npuw::weights_handle_provider.name()),
+ "NPUW_WEIGHTS_HANDLE_PROVIDER");
+ }},
+ };
+
+#ifdef NPU_PLUGIN_DEVELOPER_BUILD
+ cases.push_back(bool_case<::intel_npu::NPUW_DUMP_FULL>("NPUW_DUMP_FULL", "YES", true));
+ cases.push_back(string_case<::intel_npu::NPUW_DUMP_SUBS>("NPUW_DUMP_SUBS", "YES", "YES"));
+ cases.push_back(string_case<::intel_npu::NPUW_DUMP_SUBS_DIR>("NPUW_DUMP_SUBS_DIR", "/tmp/dumps", "/tmp/dumps"));
+ cases.push_back(string_case<::intel_npu::NPUW_DUMP_SUBS_ON_FAIL>("NPUW_DUMP_SUBS_ON_FAIL", "last", "last"));
+ cases.push_back(string_case<::intel_npu::NPUW_DUMP_IO>("NPUW_DUMP_IO", "0,last", "0,last"));
+ cases.push_back(bool_case<::intel_npu::NPUW_DUMP_IO_ITERS>("NPUW_DUMP_IO_ITERS", "YES", true));
+#endif
+
+ return cases;
+}
+
+class SmokeTest : public ::testing::TestWithParam<Case> {};
+
+TEST_P(SmokeTest, ParsesDocumentedOption) {
+ auto cfg = make_config(GetParam().options);
+ GetParam().verify(cfg);
+}
+
+std::string case_name(const testing::TestParamInfo<Case>& info) {
+ return info.param.test_name;
+}
+
+INSTANTIATE_TEST_SUITE_P(NPUWOptions, SmokeTest, ::testing::ValuesIn(make_cases()), case_name);
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npuw/partitioning_options_test.cpp b/src/plugins/intel_npu/tests/unit/npuw/partitioning_options_test.cpp
new file mode 100644
index 00000000000..c85981b8dc9
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npuw/partitioning_options_test.cpp
@@ -0,0 +1,311 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <algorithm>
+#include <chrono>
+#include <filesystem>
+#include <fstream>
+#include <map>
+#include <memory>
+#include <string>
+
+#include "attention.hpp"
+#include "intel_npu/config/config.hpp"
+#include "intel_npu/config/npuw.hpp"
+#include "model_builder.hpp"
+#include "openvino/op/ops.hpp"
+#include "openvino/pass/stateful_to_stateless.hpp"
+#include "partitioning/online/compiler.hpp"
+#include "partitioning/partitioning.hpp"
+#include "pyramid_attention.hpp"
+
+using ov::test::npuw::ModelBuilder;
+using ov::test::npuw::ModelConfig;
+
+namespace {
+
+::intel_npu::Config make_cfg(const ::intel_npu::Config::ConfigMap& cfg_map) {
+ auto opt_desc = std::make_shared<::intel_npu::OptionsDesc>();
+ ::intel_npu::registerNPUWOptions(*opt_desc);
+ auto cfg = ::intel_npu::Config(opt_desc);
+ cfg.update(cfg_map);
+ return cfg;
+}
+
+std::filesystem::path make_unique_temp_path(const std::string& stem, const std::string& extension) {
+ const auto nonce = std::chrono::steady_clock::now().time_since_epoch().count();
+ return std::filesystem::temp_directory_path() / (stem + "_" + std::to_string(nonce) + extension);
+}
+
+std::shared_ptr<ov::Model> build_unary_chain_model() {
+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, ov::Shape{1});
+ input->set_friendly_name("input");
+
+ auto n1 = std::make_shared<ov::op::v1::Add>(input, input);
+ n1->set_friendly_name("n1");
+ auto n2 = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{1}, std::vector<int>{1});
+ n2->set_friendly_name("n2");
+ auto n3 = std::make_shared<ov::op::v1::Divide>(n1, n2, true);
+ n3->set_friendly_name("n3");
+ auto n4 = std::make_shared<ov::op::v0::Sin>(n1);
+ n4->set_friendly_name("n4");
+ auto n5 = std::make_shared<ov::op::v0::Cos>(n1);
+ n5->set_friendly_name("n5");
+ auto n6 = std::make_shared<ov::op::v0::Sin>(n3);
+ n6->set_friendly_name("n6");
+ auto n7 = std::make_shared<ov::op::v0::Cos>(n3);
+ n7->set_friendly_name("n7");
+ auto n8 = std::make_shared<ov::op::v0::Concat>(std::vector<std::shared_ptr<ov::Node>>{n1, n4, n5, n6, n7}, -1);
+ n8->set_friendly_name("n8");
+
+ auto result = std::make_shared<ov::op::v0::Result>(n8);
+ result->set_friendly_name("res");
+
+ return std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input});
+}
+
+std::shared_ptr<ov::Model> build_static_llm_model(const int64_t query_len, const int64_t past_len) {
+ ModelConfig config;
+ config.num_layers = 4;
+ config.hidden_size = 64;
+ config.num_heads = 4;
+ config.head_dim = 16;
+ config.num_kv_heads = 4;
+ config.vocab_size = 256;
+
+ ModelBuilder mb;
+ auto model = mb.build_model(config);
+
+ ov::pass::StatefulToStateless().run_on_model(model);
+ model = model->clone();
+
+ const int64_t total = query_len + past_len;
+ std::map<std::string, ov::PartialShape> new_shapes;
+ for (const auto& input : model->inputs()) {
+ const auto& name = input.get_any_name();
+ auto shape = input.get_partial_shape();
+ if (name.find("input_ids") != std::string::npos || name.find("token_type_ids") != std::string::npos) {
+ new_shapes[name] = {1, query_len};
+ } else if (name.find("attention_mask") != std::string::npos) {
+ new_shapes[name] = {1, total};
+ } else if (name.find("position_ids") != std::string::npos) {
+ new_shapes[name] =
+ shape.rank().get_length() == 3 ? ov::PartialShape{3, 1, query_len} : ov::PartialShape{1, query_len};
+ } else {
+ shape[0] = 1;
+ shape[2] = past_len;
+ new_shapes[name] = shape;
+ }
+ }
+ model->reshape(new_shapes);
+ return model;
+}
+
+std::shared_ptr<ov::Model> build_static_prefill_model() {
+ return build_static_llm_model(8, 8);
+}
+
+std::shared_ptr<ov::Model> build_static_generate_model() {
+ return build_static_llm_model(1, 2047);
+}
+
+std::shared_ptr<ov::Model> build_repeated_model(std::size_t repetitions = 10) {
+ ModelBuilder mb;
+ return mb.get_model_with_repeated_blocks(repetitions);
+}
+
+TEST(PartitioningOptionsTest, PipelineNoneMergesUnaryModelIntoSingleGroup) {
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "NONE"}});
+ auto ens = ov::npuw::online::buildPartitioning(build_unary_chain_model(), cfg);
+ EXPECT_EQ(ens.groups.size(), 1u);
+}
+
+TEST(PartitioningOptionsTest, AvoidsOnNonePipelineSplitUnaryModel) {
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "NONE"}, {"NPUW_ONLINE_AVOID", "Op:Sin/NPU,Op:Cos/NPU"}});
+ auto ens = ov::npuw::online::buildPartitioning(build_unary_chain_model(), cfg);
+ EXPECT_EQ(ens.groups.size(), 3u);
+}
+
+TEST(PartitioningOptionsTest, IsolateOptionTagsUnaryGroups) {
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "REP"}, {"NPUW_ONLINE_ISOLATE", "Op:Sin/compute"}});
+ auto ens = ov::npuw::online::buildPartitioning(build_unary_chain_model(), cfg);
+ EXPECT_TRUE(std::any_of(ens.groups.begin(), ens.groups.end(), [](const ov::npuw::Group& group) {
+ return group.gettag() == "compute";
+ }));
+}
+
+TEST(PartitioningOptionsTest, DumpPlanWritesXmlFile) {
+ const auto dump_path = make_unique_temp_path("npuw_partitioning_effect_dump", ".xml");
+
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "NONE"}, {"NPUW_ONLINE_DUMP_PLAN", dump_path.string()}});
+ (void)ov::npuw::online::buildPartitioning(build_unary_chain_model(), cfg);
+
+ ASSERT_TRUE(std::filesystem::exists(dump_path));
+ {
+ std::ifstream stream(dump_path);
+ std::string xml((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
+ EXPECT_NE(xml.find("<ensemble"), std::string::npos);
+ }
+
+ std::filesystem::remove(dump_path);
+}
+
+TEST(PartitioningOptionsTest, ComputePipelineMarksComputeGroupsAsNoFold) {
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "COMPUTE"}});
+ auto ens = ov::npuw::online::buildPartitioning(build_static_prefill_model(), cfg);
+
+ bool seen_compute = false;
+ for (const auto& group : ens.groups) {
+ if (group.gettag() == "compute") {
+ seen_compute = true;
+ EXPECT_TRUE(group.repeated_id.empty());
+ }
+ }
+ EXPECT_TRUE(seen_compute);
+}
+
+TEST(PartitioningOptionsTest, SpatialPipelineDoesNotAnnotateFullPrefillModelWithoutSpatialRange) {
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "SPATIAL"}, {"NPUW_SPATIAL_NWAY", "16"}});
+ auto partitioning = ov::npuw::getPartitioning(build_static_prefill_model(), cfg);
+
+ bool seen_spatial = false;
+ for (const auto& [_, function] : partitioning.functions) {
+ seen_spatial |= function._spatial.has_value();
+ }
+ EXPECT_FALSE(seen_spatial);
+}
+
+TEST(PartitioningOptionsTest, DynamicAttentionRejectsUnisolatedPrefillGraph) {
+ auto model = build_static_prefill_model();
+ const auto attention = ov::npuw::function::Attention::from(model);
+
+ EXPECT_FALSE(attention.has_value());
+}
+
+TEST(PartitioningOptionsTest, PyramidAttentionRejectsUnisolatedGenerateGraph) {
+ auto model = build_static_generate_model();
+ const auto pyramid = ov::npuw::function::PyramidAttention::from(model);
+
+ EXPECT_FALSE(pyramid.has_value());
+}
+
+TEST(PartitioningOptionsTest, OnlineKeepBlockSizeControlsRepeatedBlockDetection) {
+ auto repeated = build_repeated_model(10);
+
+ auto keep_cfg = make_cfg({{"NPUW_ONLINE_KEEP_BLOCK_SIZE", "4"}});
+ auto drop_cfg = make_cfg({{"NPUW_ONLINE_KEEP_BLOCK_SIZE", "100"}});
+
+ auto keep_ens = ov::npuw::online::buildPartitioning(repeated, keep_cfg);
+ auto drop_ens = ov::npuw::online::buildPartitioning(repeated, drop_cfg);
+
+ EXPECT_GE(keep_ens.repeated.size(), 1u);
+ EXPECT_EQ(drop_ens.repeated.size(), 0u);
+}
+
+TEST(PartitioningOptionsTest, OnlineKeepBlocksControlsRepeatedBlockDetection) {
+ auto repeated = build_repeated_model(3);
+
+ auto keep_cfg = make_cfg({{"NPUW_ONLINE_KEEP_BLOCKS", "2"}, {"NPUW_ONLINE_KEEP_BLOCK_SIZE", "4"}});
+ auto drop_cfg = make_cfg({{"NPUW_ONLINE_KEEP_BLOCKS", "5"}, {"NPUW_ONLINE_KEEP_BLOCK_SIZE", "4"}});
+
+ auto keep_ens = ov::npuw::online::buildPartitioning(repeated, keep_cfg);
+ auto drop_ens = ov::npuw::online::buildPartitioning(repeated, drop_cfg);
+
+ EXPECT_GE(keep_ens.repeated.size(), 1u);
+ EXPECT_EQ(drop_ens.repeated.size(), 0u);
+}
+
+TEST(PartitioningOptionsTest, OnlineMinSizeStopsPartitioningEarlierOnLargerGraphs) {
+ auto repeated = build_repeated_model(20);
+
+ auto compact_cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "REP"}, {"NPUW_ONLINE_MIN_SIZE", "10"}});
+ auto early_stop_cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "REP"}, {"NPUW_ONLINE_MIN_SIZE", "100"}});
+
+ auto compact_ens = ov::npuw::online::buildPartitioning(repeated, compact_cfg);
+ auto early_stop_ens = ov::npuw::online::buildPartitioning(repeated, early_stop_cfg);
+
+ EXPECT_GT(early_stop_ens.groups.size(), compact_ens.groups.size());
+}
+
+TEST(PartitioningOptionsTest, OnlineNoFoldPreventsTaggedGroupsFromBecomingRepeatedFunctions) {
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "REP"},
+ {"NPUW_ONLINE_ISOLATE", "Op:Sin/compute"},
+ {"NPUW_ONLINE_NO_FOLD", "compute"}});
+ auto ens = ov::npuw::online::buildPartitioning(build_unary_chain_model(), cfg);
+
+ EXPECT_TRUE(std::any_of(ens.groups.begin(), ens.groups.end(), [](const ov::npuw::Group& group) {
+ return group.gettag() == "compute" && group.repeated_id.empty();
+ }));
+}
+
+TEST(PartitioningOptionsTest, FuncallForAllPromotesUnaryGroupsToFunctions) {
+ auto cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "NONE"}, {"NPUW_FUNCALL_FOR_ALL", "YES"}});
+ auto partitioning = ov::npuw::getPartitioning(build_unary_chain_model(), cfg);
+
+ EXPECT_TRUE(std::any_of(partitioning.subgraphs.begin(), partitioning.subgraphs.end(), [](const ov::npuw::Subgraph& sg) {
+ return sg._forced_to_fcall || !sg._funcall.empty() || !sg._repeated_id.empty();
+ }));
+}
+
+TEST(PartitioningOptionsTest, FoldCreatesFunctionCallsForRepeatedBlocks) {
+ auto cfg = make_cfg({{"NPUW_FOLD", "YES"}, {"NPUW_ONLINE_KEEP_BLOCK_SIZE", "4"}});
+ auto partitioning = ov::npuw::getPartitioning(build_repeated_model(10), cfg);
+
+ EXPECT_FALSE(partitioning.functions.empty());
+ EXPECT_TRUE(std::any_of(partitioning.subgraphs.begin(), partitioning.subgraphs.end(), [](const ov::npuw::Subgraph& sg) {
+ return !sg._funcall.empty();
+ }));
+}
+
+TEST(PartitioningOptionsTest, CwaiCreatesFunctionCallsForRepeatedBlocks) {
+ auto cfg = make_cfg({{"NPUW_CWAI", "YES"}, {"NPUW_ONLINE_KEEP_BLOCK_SIZE", "4"}});
+ auto partitioning = ov::npuw::getPartitioning(build_repeated_model(10), cfg);
+
+ EXPECT_FALSE(partitioning.functions.empty());
+ EXPECT_TRUE(std::any_of(partitioning.subgraphs.begin(), partitioning.subgraphs.end(), [](const ov::npuw::Subgraph& sg) {
+ return !sg._funcall.empty();
+ }));
+}
+
+TEST(PartitioningOptionsTest, PlanFileReusesDumpedPartitioningStructure) {
+ const auto plan_path = make_unique_temp_path("npuw_partitioning_effect_plan", ".xml");
+
+ auto online_cfg = make_cfg({{"NPUW_ONLINE_PIPELINE", "NONE"}, {"NPUW_ONLINE_DUMP_PLAN", plan_path.string()}});
+ auto online_ens = ov::npuw::online::buildPartitioning(build_unary_chain_model(), online_cfg);
+
+ auto plan_cfg = make_cfg({{"NPUW_PLAN", plan_path.string()}});
+ auto partitioning = ov::npuw::getPartitioning(build_unary_chain_model(), plan_cfg);
+
+ ASSERT_TRUE(std::filesystem::exists(plan_path));
+ EXPECT_EQ(partitioning.subgraphs.size(), online_ens.groups.size());
+
+ std::filesystem::remove(plan_path);
+}
+
+#ifdef NPU_PLUGIN_DEVELOPER_BUILD
+TEST(PartitioningOptionsTest, DumpFullWritesModelXmlIntoCurrentDirectory) {
+ const auto temp_dir = make_unique_temp_path("npuw_dump_full_effect", "");
+ std::filesystem::create_directories(temp_dir);
+ const auto old_cwd = std::filesystem::current_path();
+
+ auto model = build_unary_chain_model();
+ model->set_friendly_name("npuw_dump_full_effect_model");
+
+ std::filesystem::current_path(temp_dir);
+ auto cfg = make_cfg({{"NPUW_DUMP_FULL", "YES"}});
+ (void)ov::npuw::getPartitioning(model, cfg);
+ std::filesystem::current_path(old_cwd);
+
+ const auto dumped = temp_dir / "npuw_dump_full_effect_model.xml";
+ EXPECT_TRUE(std::filesystem::exists(dumped));
+
+ std::filesystem::remove(dumped);
+ std::filesystem::remove(temp_dir / "npuw_dump_full_effect_model.bin");
+ std::filesystem::remove(temp_dir);
+}
+#endif
+
+} // namespace