OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
NPUW: Switch to PYRAMID attention by default for prefill (#33736)
Dmitry Matveevefcc4ca0ca5e
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hppindex 52a409686b1..c74626f3f50 100644--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hpp+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hpp@@ -194,6 +194,10 @@ struct NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::GenerateHint> {}};+struct PrefillHintOptionTraits : NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::PrefillHint> {};++struct GenerateHintOptionTraits : NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::GenerateHint> {};+template <>struct NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::AttentionHint> {using ValueType = ::intel_npu::npuw::llm::AttentionHint;@@ -235,6 +239,18 @@ struct NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::AttentionHint> {}};+struct PrefillAttentionHintOptionTraits : NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::AttentionHint> {+ static ValueType defaultValue() {+ return ValueType::PYRAMID;+ }+};++struct GenerateAttentionHintOptionTraits : NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::AttentionHint> {+ static ValueType defaultValue() {+ return ValueType::STATIC;+ }+};+template <>struct NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::MoEHint> {using ValueType = ::intel_npu::npuw::llm::MoEHint;@@ -272,6 +288,8 @@ struct NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::MoEHint> {}};+struct MoEHintOptionTraits : NPUWStringEnumOptionTraits<::intel_npu::npuw::llm::MoEHint> {};+template <class ActualOpt, class Traits>struct NPUWStringEnumOptionBase : OptionBase<ActualOpt, typename Traits::ValueType> {using ValueType = typename Traits::ValueType;@@ -311,7 +329,7 @@ struct NPUWStringEnumOptionBase : OptionBase<ActualOpt, typename Traits::ValueTy#define INTEL_NPU_NPUW_SIMPLE_OPT(OPT, TYPE, DEFAULT, NS, VARNAME, KEY, GROUP, SURFACE, CACHING, BUILD) \DEFINE_NPUW_SIMPLE_OPT(OPT, TYPE, DEFAULT, KEY)#define INTEL_NPU_NPUW_STRING_ENUM_OPT(OPT, TYPE, TRAITS, NS, VARNAME, KEY, GROUP, SURFACE, CACHING, BUILD) \- DEFINE_NPUW_STRING_ENUM_OPT(OPT, NPUWStringEnumOptionTraits<TYPE>, KEY)+ DEFINE_NPUW_STRING_ENUM_OPT(OPT, TRAITS, KEY)#define INTEL_NPU_NPUW_ANYMAP_OPT(OPT, NS, VARNAME, KEY, GROUP, SURFACE, CACHING, BUILD) \DEFINE_NPUW_ANYMAP_OPT(OPT, KEY)#include "intel_npu/config/npuw_option_defs.inc"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.incindex 8b3272672d1..4c4f8f836ef 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@@ -68,8 +68,8 @@ INTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_PREFILL_MOE_HINT, ::intel_npu::npuw::llmINTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_GENERATE_MOE_HINT, ::intel_npu::npuw::llm::MoEHint, MoEHintOptionTraits, ov::intel_npu::npuw::llm, generate_moe_hint, "NPUW_LLM_GENERATE_MOE_HINT", LLM, EXPOSED, CACHED, ALL)INTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_PREFILL_HINT, ::intel_npu::npuw::llm::PrefillHint, PrefillHintOptionTraits, ov::intel_npu::npuw::llm, prefill_hint, "NPUW_LLM_PREFILL_HINT", LLM, EXPOSED, CACHED, ALL)INTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_GENERATE_HINT, ::intel_npu::npuw::llm::GenerateHint, GenerateHintOptionTraits, ov::intel_npu::npuw::llm, generate_hint, "NPUW_LLM_GENERATE_HINT", LLM, EXPOSED, CACHED, ALL)-INTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_PREFILL_ATTENTION_HINT, ::intel_npu::npuw::llm::AttentionHint, AttentionHintOptionTraits, ov::intel_npu::npuw::llm, prefill_attn_hint, "NPUW_LLM_PREFILL_ATTENTION_HINT", LLM, EXPOSED, CACHED, ALL)-INTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_GENERATE_ATTENTION_HINT, ::intel_npu::npuw::llm::AttentionHint, AttentionHintOptionTraits, ov::intel_npu::npuw::llm, generate_attn_hint, "NPUW_LLM_GENERATE_ATTENTION_HINT", LLM, EXPOSED, CACHED, ALL)+INTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_PREFILL_ATTENTION_HINT, ::intel_npu::npuw::llm::AttentionHint, PrefillAttentionHintOptionTraits, ov::intel_npu::npuw::llm, prefill_attn_hint, "NPUW_LLM_PREFILL_ATTENTION_HINT", LLM, EXPOSED, CACHED, ALL)+INTEL_NPU_NPUW_STRING_ENUM_OPT(NPUW_LLM_GENERATE_ATTENTION_HINT, ::intel_npu::npuw::llm::AttentionHint, GenerateAttentionHintOptionTraits, ov::intel_npu::npuw::llm, generate_attn_hint, "NPUW_LLM_GENERATE_ATTENTION_HINT", LLM, EXPOSED, CACHED, ALL)INTEL_NPU_NPUW_ANYMAP_OPT(NPUW_LLM_PREFILL_CONFIG, ov::intel_npu::npuw::llm, prefill_config, "NPUW_LLM_PREFILL_CONFIG", LLM, EXPOSED, CACHED, ALL)INTEL_NPU_NPUW_ANYMAP_OPT(NPUW_LLM_ADDITIONAL_PREFILL_CONFIG, ov::intel_npu::npuw::llm, additional_prefill_config, "++NPUW_LLM_PREFILL_CONFIG", LLM, EXPOSED, CACHED, ALL)INTEL_NPU_NPUW_ANYMAP_OPT(NPUW_LLM_GENERATE_CONFIG, ov::intel_npu::npuw::llm, generate_config, "NPUW_LLM_GENERATE_CONFIG", LLM, EXPOSED, CACHED, ALL)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.cppindex 7f4c4ce759d..a533a111c5c 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@@ -515,21 +515,45 @@ ov::npuw::v1::subgraphs::RuntimeBehaviorFactory make_runtime_factory() {} else if (is_kv_param) {const auto& param = *param_it;using namespace ov::npuw::runtime;+ // iport comes from the main compiled model (full KV shape).+ // For set_tensor we must use the port from the pyramid model's compiled+ // model so the zero backend shape check passes. For the last pyramid model+ // _compiled_models[pyramid_id] == the main compiled model, so pyramid_iport+ // == iport and there is no behavioural difference.+ // get_tensor calls below intentionally keep iport: they look up by index /+ // name without strict shape validation.+ const auto& pyramid_iport = pyramid->_compiled_models[pyramid_id]->inputs()[input_idx];if (state.pyramid_selector->length() == -1) {// Fallback: dynamic range not identified — bind directly- ctx.target_request->set_tensor(iport, tensor);+ ctx.target_request->set_tensor(pyramid_iport, tensor);} else {+ // Pyramid dynamic range identifiedconst auto past_len = state.pyramid_selector->past_length();const auto this_case = state.pyramid_selector->this_case();++ // Strided I/O is available for non-last pyramid models compiled with+ // enable_strides_for. The last model reuses the main compiled subgraph (compiled+ // without enable_strides_for), so it always falls back to the copy path.+ const bool use_tensor_view =+ pyramid->_can_use_tensor_view && (pyramid_id < pyramid->num_models() - 1);+const auto& input_shape = tensor->get_shape();if (this_case == pyramid_attention::Selector::Case::PREFILL) {if (static_cast<int64_t>(input_shape[param.dim]) == past_len) {- ctx.target_request->set_tensor(iport, tensor);+ ctx.target_request->set_tensor(pyramid_iport, tensor);} else {const auto& view = ov::npuw::util::view(tensor, param.dim, 0, past_len);const auto& shape = view->get_shape();if (ov::shape_size(shape) == 0) {ctx.target_request->get_tensor(iport)->set_shape(shape);+ } else if (use_tensor_view) {+ const auto model_past_len = static_cast<int64_t>(info.context_length) -+ static_cast<int64_t>(info.query_size);+ LOG_DEBUG("Use tensor view: past_len=" << past_len << " model_past_len="+ << model_past_len);+ ctx.target_request->set_tensor(+ pyramid_iport,+ ov::npuw::util::view(tensor, param.dim, 0, model_past_len));} else {const auto& dst = ctx.target_request->get_tensor(iport);ov::npuw::util::copy_tensor_by_dim(view,@@ -543,7 +567,15 @@ ov::npuw::v1::subgraphs::RuntimeBehaviorFactory make_runtime_factory() {NPUW_ASSERT(static_cast<int64_t>(input_shape[param.dim]) != past_len);const auto& dst = ctx.target_request->get_tensor(iport);if (dst->get_shape() == input_shape) {- ctx.target_request->set_tensor(iport, tensor);+ ctx.target_request->set_tensor(pyramid_iport, tensor);+ } else if (use_tensor_view) {+ const auto model_past_len = static_cast<int64_t>(info.context_length) -+ static_cast<int64_t>(info.query_size);+ LOG_DEBUG("Use tensor view: past_len=" << past_len+ << " model_past_len=" << model_past_len);+ ctx.target_request->set_tensor(+ pyramid_iport,+ ov::npuw::util::view(tensor, param.dim, 0, model_past_len));} else {const auto& view = ov::npuw::util::view(tensor, param.dim, 0, past_len);const auto& dst_slice = ov::npuw::util::view(dst, param.dim, 0, past_len);diff --git a/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cppindex cde62397084..d1ecd675b12 100644--- a/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp+++ b/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp@@ -1686,11 +1686,47 @@ bool ov::npuw::CompiledModel::compile_for_success(std::size_t id, const std::vecstd::vector<ov::SoPtr<ov::ICompiledModel>> compiled_models(total_models);+ // Check if device supports strided I/O for non-last pyramid models.+ // The last model reuses the already-compiled main subgraph model (compiled without+ // enable_strides_for), so strided I/O only applies to the explicitly compiled models.+ bool support_strides_for = false;+ std::string npu_device_str;+ std::string saved_strides;+ for (const auto& device : devices) {+ if (ov::npuw::util::starts_with(device, "NPU") && models_to_compile > 0 &&+ !pyramid_attn->_attention_infos.empty()) {+ const auto supported_properties =+ get_npuw_plugin()->get_core()->get_property(device, ov::supported_properties);+ support_strides_for = std::find(supported_properties.begin(),+ supported_properties.end(),+ ov::intel_npu::enable_strides_for.name()) != supported_properties.end();+ if (support_strides_for) {+ pyramid_attn->_can_use_tensor_view = true;+ const auto& first_model = pyramid_attn_models[0];+ const auto& first_info = pyramid_attn->_attention_infos[0];+ npu_device_str = device;+ const auto& strides_key = ov::intel_npu::enable_strides_for.name();+ const ov::Any existing_any =+ ov::npuw::util::at::_(m_meta_devices[npu_device_str]).at_or(strides_key, std::string{});+ saved_strides = existing_any.as<std::string>();+ std::string strided_inputs = saved_strides;+ for (const auto& param : first_info.params) {+ if (!strided_inputs.empty()) {+ strided_inputs += ",";+ }+ strided_inputs += first_model->inputs()[param.idx].get_any_name();+ }+ m_meta_devices[npu_device_str][strides_key] = strided_inputs;+ LOG_INFO("Enabled using tensor view for device: " << device+ << " for pyramid inputs: " << strided_inputs);+ } // if(support_strides_for)+ } // if(npu)+ } // for(devices)+auto compile_one = [&](size_t model_id) {compiled_models[model_id] =make_wrapped(pyramid_attn_models[model_id], "/pyramid_" + std::to_string(model_id), devices);};-const bool par_opt = m_cfg.get<::intel_npu::NPUW_PARALLEL_COMPILE>();if (par_opt && models_to_compile > 0) {ov::parallel_for(models_to_compile, compile_one);@@ -1707,7 +1743,16 @@ bool ov::npuw::CompiledModel::compile_for_success(std::size_t id, const std::vecpyramid_attn->set_compiled_models(std::move(compiled_models));LOG_INFO("Pyramid attention compilation complete for Subgraph[" << id << "]");- }++ if (support_strides_for && !npu_device_str.empty()) {+ const auto& strides_key = ov::intel_npu::enable_strides_for.name();+ if (saved_strides.empty()) {+ m_meta_devices[npu_device_str].erase(strides_key);+ } else {+ m_meta_devices[npu_device_str][strides_key] = saved_strides;+ }+ }+ } // if (pyramid_attn)if (auto* hfa = ov::npuw::attn::get_compiled_hfa(desc.pipeline.context)) {LOG_INFO("Compiling host flash attention tile models for Subgraph[" << id << "]...");@@ -1716,6 +1761,9 @@ bool ov::npuw::CompiledModel::compile_for_success(std::size_t id, const std::vecif (!hfa->_tile_model_to_compile) {LOG_WARN("Host flash attention tile model is null, skipping compilation");} else {+ bool supports_strides_for = false;+ std::string npu_device_str;+ std::string saved_strides;for (const auto& device : devices) {if (!ov::npuw::util::starts_with(device, "NPU")) {continue;@@ -1723,26 +1771,45 @@ bool ov::npuw::CompiledModel::compile_for_success(std::size_t id, const std::vecconst auto supported_properties =get_npuw_plugin()->get_core()->get_property(device, ov::supported_properties);- const auto support_strides_for =+ const bool support_strides_for =std::find(supported_properties.begin(),supported_properties.end(),ov::intel_npu::enable_strides_for.name()) != supported_properties.end();if (!support_strides_for) {- continue;+ break;}hfa->_can_use_tensor_view = true;- auto strided_inputs_name = std::string(hfa_tile_input_id_to_string(HFATileInputId::K_TILE)) + "," +- std::string(hfa_tile_input_id_to_string(HFATileInputId::V_TILE));- m_meta_devices[device][ov::intel_npu::enable_strides_for.name()] = strided_inputs_name;- LOG_INFO("Enabled using tensor view for device: " << device << " for inputs: " << strided_inputs_name);+ npu_device_str = device;+ const auto& strides_key = ov::intel_npu::enable_strides_for.name();+ const ov::Any existing_any =+ ov::npuw::util::at::_(m_meta_devices[device]).at_or(strides_key, std::string{});+ saved_strides = existing_any.as<std::string>();+ std::string strided_inputs = saved_strides;+ if (!strided_inputs.empty()) {+ strided_inputs += ",";+ }+ strided_inputs += std::string(hfa_tile_input_id_to_string(HFATileInputId::K_TILE)) + "," ++ std::string(hfa_tile_input_id_to_string(HFATileInputId::V_TILE));+ m_meta_devices[device][strides_key] = strided_inputs;+ supports_strides_for = true;+ LOG_INFO("Enabled using tensor view for device: " << device << " for inputs: " << strided_inputs);}hfa->set_compiled_tile_model(make_wrapped(hfa->_tile_model_to_compile, "/hfa_tile", devices));hfa->set_compiled_final_tile_model(desc.compiled_model);LOG_INFO("Host flash attention compilation complete for Subgraph[" << id << "]");++ if (supports_strides_for && !npu_device_str.empty()) {+ const auto& strides_key = ov::intel_npu::enable_strides_for.name();+ if (saved_strides.empty()) {+ m_meta_devices[npu_device_str].erase(strides_key);+ } else {+ m_meta_devices[npu_device_str][strides_key] = saved_strides;+ }+ }}- }+ } // if (hfa)return true;}diff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp b/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cppindex e8d4cbf9100..7073bee0507 100644--- a/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp+++ b/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp@@ -963,14 +963,6 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& mmerge_config_with(prefill_config, prefill_config_addition_value);merge_config_with(generate_config, generate_config_addition_value);- // Convert LLM-specific attention hints to NPUW_ATTN- if (npuw_llm_props.count("NPUW_LLM_PREFILL_ATTENTION_HINT")) {- prefill_config["NPUW_ATTN"] = npuw_llm_props["NPUW_LLM_PREFILL_ATTENTION_HINT"];- }- if (npuw_llm_props.count("NPUW_LLM_GENERATE_ATTENTION_HINT")) {- generate_config["NPUW_ATTN"] = npuw_llm_props["NPUW_LLM_GENERATE_ATTENTION_HINT"];- }-// Generate a random weights bank name unique to this LLMCompiledModel objectauto weights_bank_name = ov::npuw::util::generate_random_string();LOG_VERB("Generated a unique weights bank name: " << weights_bank_name);@@ -985,12 +977,28 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& m{"NPUW_ONLINE_KEEP_BLOCK_SIZE", "4"},{"NPUW_UNFOLD_IREQS", "NO"},};- if (prefill_attn_dyn || prefill_attn_pyramid || prefill_attn_hfa) {++ if (m_use_chunk_prefill && (prefill_attn_pyramid || prefill_attn_hfa || prefill_attn_dyn)) {+ prefill_config["NPUW_ATTN"] = ::intel_npu::NPUW_LLM_PREFILL_ATTENTION_HINT::toString(prefill_attn_hint);merge_config_with(prefill_config, dyn_attn_opts);}- if (generate_attn_dyn || generate_attn_pyramid || generate_attn_hfa) {++ if (generate_attn_pyramid || generate_attn_hfa || generate_attn_dyn) {+ generate_config["NPUW_ATTN"] = ::intel_npu::NPUW_LLM_GENERATE_ATTENTION_HINT::toString(generate_attn_hint);merge_config_with(generate_config, dyn_attn_opts);}++ // Note: with dynamic attention in EITHER STAGE, we have to+ // explicitly disable the run-time fallback to so extra ov::Model+ // references won't be held by the npuw::CompiledModel, resulting+ // in a higher memory consumption. This behavior should be reworked!+ // The reason here is that NPUW_DEVICES may come as a global setting,+ // impacting all the stages.+ if (prefill_attn_dyn || generate_attn_dyn) {+ prefill_config["NPUW_FALLBACK_EXEC"] = "NO";+ generate_config["NPUW_FALLBACK_EXEC"] = "NO";+ }+if (is_moe) {// Apply MoE configuration for prefill stageconst auto prefill_moe_hint = m_cfg.get<::intel_npu::NPUW_LLM_PREFILL_MOE_HINT>();@@ -1009,17 +1017,6 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& mLOG_INFO("DEVICE_ROUTED MoE transformations completed");}}- // Note: with dynamic attention in EITHER STAGE, we have to- // explicitly disable the run-time fallback to so extra ov::Model- // references won't be held by the npuw::CompiledModel, resulting- // in a higher memory consumption. This behavior should be reworked!- // The reason here is that NPUW_DEVICES may come as a global setting,- // impacting all the stages.- if (prefill_attn_dyn || generate_attn_dyn) {- const ov::AnyMap no_runtime_fallback = {{"NPUW_FALLBACK_EXEC", "NO"}};- merge_config_with(prefill_config, no_runtime_fallback);- merge_config_with(generate_config, no_runtime_fallback);- }if (m_is_whisper) {update_config_for_whisper(prefill_config);diff --git a/src/plugins/intel_npu/src/plugin/npuw/pyramid_attention.hpp b/src/plugins/intel_npu/src/plugin/npuw/pyramid_attention.hppindex 4899df76989..4edadfd9aae 100644--- a/src/plugins/intel_npu/src/plugin/npuw/pyramid_attention.hpp+++ b/src/plugins/intel_npu/src/plugin/npuw/pyramid_attention.hpp@@ -109,6 +109,12 @@ struct PyramidAttention {std::size_t query_size = 0u;std::size_t full_context_size = 0u;+ /// Whether non-last pyramid models were compiled with strided-input support.+ /// When true, KV inputs can be passed as strided tensor views (avoiding copies).+ /// The last pyramid model reuses the already-compiled main subgraph model and+ /// therefore never participates in strided I/O.+ bool _can_use_tensor_view = false;+// Store models temporarily for compilation - cleared after compilation completes in set_compiled_models()std::vector<std::shared_ptr<ov::Model>> _models_to_compile;diff --git a/src/plugins/intel_npu/src/plugin/npuw/util.hpp b/src/plugins/intel_npu/src/plugin/npuw/util.hppindex d5359e0aa39..fdfffd65a10 100644--- a/src/plugins/intel_npu/src/plugin/npuw/util.hpp+++ b/src/plugins/intel_npu/src/plugin/npuw/util.hpp@@ -139,6 +139,12 @@ struct Impl {const V& at_or_at_or_at(const K& k1, const K& k2, const K& k3) const {return const_cast<Impl*>(this)->at_or_at_or_at(k1, k2, k3);}++ template <typename K>+ V at_or(const K& k, const V& default_val) const {+ const auto iter = m->find(k);+ return iter != m->end() ? iter->second : default_val;+ }};template <typename M>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.cppindex 4183693c0a5..2811e77b94e 100644--- 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@@ -194,7 +194,9 @@ TEST_F(LLMCompiledModelFactoryOptionsTest, AttentionHintsPropagateToStageConfigsov::AnyMap props = {{"NPUW_LLM_SHARED_HEAD", "NO"},{"NPUW_LLM_PREFILL_ATTENTION_HINT", "PYRAMID"},- {"NPUW_LLM_GENERATE_ATTENTION_HINT", "DYNAMIC"}};+ {"NPUW_LLM_GENERATE_ATTENTION_HINT", "DYNAMIC"},+ {"NPUW_LLM_PREFILL_HINT", "DYNAMIC"},+ {"NPUW_LLM_PREFILL_CHUNK_SIZE", "64"}};ASSERT_NO_THROW(compiled = create_compiled_model(build_llm_model(), props, recorder));ASSERT_NE(compiled, nullptr);@@ -249,7 +251,11 @@ TEST_F(LLMCompiledModelFactoryOptionsTest, DefaultStageConfigsCarryBaselineNpuwORecordingFactory 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_NO_THROW(compiled = create_compiled_model(build_llm_model(),+ {{"NPUW_LLM_SHARED_HEAD", "YES"},+ {"NPUW_LLM_PREFILL_HINT", "DYNAMIC"},+ {"NPUW_LLM_PREFILL_CHUNK_SIZE", "64"}},+ recorder));ASSERT_NE(compiled, nullptr);const auto& prefill = require_call(recorder, "_prefill");@@ -267,9 +273,16 @@ TEST_F(LLMCompiledModelFactoryOptionsTest, DefaultStageConfigsCarryBaselineNpuwOexpect_prop(prefill.props, "NPUW_SLICE_OUT", "YES");expect_prop(prefill.props, "NPUW_FUNCALL_ASYNC", "YES");+ 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_missing_prop(prefill.props, "NPUW_FALLBACK_EXEC");expect_missing_prop(generate.props, "NPUW_SLICE_OUT");expect_prop(generate.props, "NPUW_FUNCALL_ASYNC", "YES");+ expect_missing_prop(generate.props, "NPUW_ATTN");expect_missing_prop(head.props, "NPUW_SLICE_OUT");expect_missing_prop(head.props, "NPUW_FUNCALL_ASYNC");@@ -279,6 +292,13 @@ TEST_F(LLMCompiledModelFactoryOptionsTest, DefaultStageConfigsCarryBaselineNpuwOEXPECT_EQ(prop_string(prefill.props, "NPUW_WEIGHTS_BANK"), prop_string(head.props, "NPUW_WEIGHTS_BANK"));}+TEST(NPUWAttentionHintOptionDefaultsTest, PrefillAndGenerateAttentionHintsHaveIndependentDefaults) {+ EXPECT_EQ(::intel_npu::NPUW_LLM_PREFILL_ATTENTION_HINT::defaultValue(),+ ::intel_npu::npuw::llm::AttentionHint::PYRAMID);+ EXPECT_EQ(::intel_npu::NPUW_LLM_GENERATE_ATTENTION_HINT::defaultValue(),+ ::intel_npu::npuw::llm::AttentionHint::STATIC);+}+TEST_F(LLMCompiledModelFactoryOptionsTest, CommonRuntimeAndDebugOptionsForwardToAllStages) {RecordingFactory recorder;std::unique_ptr<ov::npuw::LLMCompiledModel> compiled;@@ -396,8 +416,8 @@ TEST_F(LLMCompiledModelFactoryOptionsTest, StaticAttentionHintsAvoidAttentionIsoASSERT_NE(compiled, nullptr);const auto& prefill = require_call(recorder, "_prefill");const auto& generate = require_call_containing(recorder, "_kv");- expect_prop(prefill.props, "NPUW_ATTN", "STATIC");- expect_prop(generate.props, "NPUW_ATTN", "STATIC");+ expect_missing_prop(prefill.props, "NPUW_ATTN");+ expect_missing_prop(generate.props, "NPUW_ATTN");// Static attention should leave partitioning defaults unchanged rather than forcing attention isolation.EXPECT_EQ(prefill.props.count("NPUW_ONLINE_PIPELINE"), 0u);EXPECT_EQ(generate.props.count("NPUW_ONLINE_PIPELINE"), 0u);@@ -413,7 +433,9 @@ TEST_F(LLMCompiledModelFactoryOptionsTest, HfaAttentionHintsEnableAttentionIsola{"NPUW_LLM_GENERATE_ATTENTION_HINT", "HFA"},{"NPUW_ATTN_HFA_FUSED", "YES"},{"NPUW_ATTN_DYN", "YES"},- {"NPUW_ATTN_NO_COPY", "YES"}},+ {"NPUW_ATTN_NO_COPY", "YES"},+ {"NPUW_LLM_PREFILL_HINT", "DYNAMIC"},+ {"NPUW_LLM_PREFILL_CHUNK_SIZE", "64"}},recorder));ASSERT_NE(compiled, nullptr);const auto& prefill = require_call(recorder, "_prefill");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.cppindex f5244939d39..afee9e54b73 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@@ -203,4 +203,11 @@ std::string case_name(const testing::TestParamInfo<Case>& info) {INSTANTIATE_TEST_SUITE_P(NPUWOptions, SmokeTest, ::testing::ValuesIn(make_cases()), case_name);+TEST(NPUWConfigOptionsSmokeTest, AttentionHintDefaultsCanDifferPerOption) {+ const auto cfg = make_config();++ EXPECT_EQ(cfg.getString<::intel_npu::NPUW_LLM_PREFILL_ATTENTION_HINT>(), "PYRAMID");+ EXPECT_EQ(cfg.getString<::intel_npu::NPUW_LLM_GENERATE_ATTENTION_HINT>(), "STATIC");+}+} // namespace