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] Support prefill-chunk for text-embedding model (#33076)
Weiguo Menge5c24ae96542
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 0ff3c0a0fac..b41f4b7dcff 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@@ -155,6 +155,7 @@ DEFINE_OPT(NPUW_LLM_PREFIX_CACHING_BLOCK_SIZE, uint64_t, 256, npuw::llm::prefix_DEFINE_OPT(NPUW_LLM_PREFIX_CACHING_MAX_NUM_BLOCKS, uint64_t, 128, npuw::llm::prefix_caching_max_num_blocks, RunTime);DEFINE_OPT(NPUW_WHISPER, bool, false, npuw::whisper::enabled, RunTime);DEFINE_OPT(NPUW_EAGLE, bool, false, npuw::eagle::enabled, RunTime);+DEFINE_OPT(NPUW_TEXT_EMBED, bool, false, npuw::text_embed::enabled, RunTime);DEFINE_ANYMAP_OPT(NPUW_LLM_PREFILL_CONFIG, npuw::llm::prefill_config);DEFINE_ANYMAP_OPT(NPUW_LLM_ADDITIONAL_PREFILL_CONFIG, npuw::llm::additional_prefill_config);DEFINE_ANYMAP_OPT(NPUW_LLM_GENERATE_CONFIG, npuw::llm::generate_config);diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/npuw_private_properties.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/npuw_private_properties.hppindex d1904e5ea55..38ad2d7c850 100644--- a/src/plugins/intel_npu/src/al/include/intel_npu/npuw_private_properties.hpp+++ b/src/plugins/intel_npu/src/al/include/intel_npu/npuw_private_properties.hpp@@ -690,6 +690,17 @@ namespace eagle {static constexpr ov::Property<bool> enabled{"NPUW_EAGLE"};} // namespace eagle+namespace text_embed {+/**+ * @brief+ * Type: bool.+ * Tell NPUW that you want to pass text-embedding model.+ * Default value: false.+ */+static constexpr ov::Property<bool> enabled{"NPUW_TEXT_EMBED"};++} // namespace text_embed+} // namespace npuw} // namespace intel_npu} // namespace ovdiff --git a/src/plugins/intel_npu/src/al/src/config/npuw.cpp b/src/plugins/intel_npu/src/al/src/config/npuw.cppindex 5dd4387bb9a..67590bc4444 100644--- a/src/plugins/intel_npu/src/al/src/config/npuw.cpp+++ b/src/plugins/intel_npu/src/al/src/config/npuw.cpp@@ -82,6 +82,7 @@ void intel_npu::registerNPUWLLMOptions(OptionsDesc& desc) {desc.add<NPUW_LLM_SHARED_HEAD>();desc.add<NPUW_WHISPER>();desc.add<NPUW_EAGLE>();+ desc.add<NPUW_TEXT_EMBED>();}std::string ov::npuw::s11n::anyToString(const ov::Any& var) {diff --git a/src/plugins/intel_npu/src/plugin/npuw/embedding_infer_request.cpp b/src/plugins/intel_npu/src/plugin/npuw/embedding_infer_request.cppnew file mode 100644index 00000000000..32b8847235e--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/npuw/embedding_infer_request.cpp@@ -0,0 +1,245 @@+// Copyright (C) 2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "embedding_infer_request.hpp"++#include "infer_request_utils.hpp"+#include "logging.hpp"++ov::SoPtr<ov::ITensor> ov::npuw::EmbeddingInferRequest::create_prefill_output_tensor() {+ const auto& out_port = m_prefill_request->get_outputs()[0];+ auto out_shape = out_port.get_shape();+ auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;++ auto prefill_shape = ov::Shape(out_shape);+ prefill_shape[layer_ids::INPUT_IDS_SEQ_LEN_DIM] = kvcache_desc.max_prompt_size;+ return ov::get_tensor_impl(ov::Tensor(out_port.get_element_type(), prefill_shape));+}++ov::npuw::EmbeddingInferRequest::EmbeddingInferRequest(const std::shared_ptr<LLMCompiledModel>& compiled_model)+ : ov::npuw::LLMInferBaseRequest(compiled_model) {+ init_ports();++ m_prefill_request = m_npuw_llm_compiled_model->m_prefill_compiled->create_infer_request();+ for (const auto& input_port : m_prefill_request->get_compiled_model()->inputs()) {+ m_prefill_in_ports.emplace(input_port.get_any_name(), input_port);+ // Cache past_key_values ports for efficient clearing+ if (input_port.get_any_name().find(layer_names::past_key_values) != std::string::npos) {+ m_prefill_past_kv_ports.push_back(input_port);+ }+ }+ for (const auto& output_port : m_prefill_request->get_compiled_model()->outputs()) {+ m_prefill_out_ports.emplace(output_port.get_any_name(), output_port);+ }++ m_prefill_output = create_prefill_output_tensor();+}++void ov::npuw::EmbeddingInferRequest::prepare_for_new_conversation() {+ namespace uu = ov::npuw::util;++ m_attn_mask_in_tensor = m_prefill_request->get_tensor(m_prefill_in_ports.at(layer_names::attention_mask));+ m_input_ids_in_tensor = m_prefill_request->get_tensor(m_prefill_in_ports.at(layer_names::input_ids));++ if (auto pos_ids_port = m_prefill_in_ports.find(layer_names::position_ids);+ pos_ids_port != m_prefill_in_ports.end()) {+ m_pos_ids_in_tensor = m_prefill_request->get_tensor(m_prefill_in_ports.at(layer_names::position_ids));+ uu::fill_tensor<int64_t>(m_pos_ids_in_tensor, 0);+ }++ uu::fill_tensor_bytes(m_input_ids_in_tensor, 0u);+ uu::fill_tensor<int64_t>(m_attn_mask_in_tensor, 0);+ uu::fill_tensor_bytes(m_prefill_output, 0u);++ // Clear all past_key_values tensors+ for (const auto& port : m_prefill_past_kv_ports) {+ uu::fill_tensor_bytes(m_prefill_request->get_tensor(port), 0u);+ }++ m_npuw_llm_compiled_model->m_kvcache_desc.num_stored_tokens = 0u;+}++void ov::npuw::EmbeddingInferRequest::infer_chunked_prefill(ov::SoPtr<ov::ITensor> input_ids,+ ov::SoPtr<ov::ITensor> attention_mask) {+ LOG_DEBUG("Calling embedding chunked inference for prefill model.");+ LOG_BLOCK();++ const auto input_prompt_len = input_ids->get_shape()[layer_ids::INPUT_IDS_SEQ_LEN_DIM];+ const auto input_ids_elem_size = input_ids->get_element_type().size();+ const uint64_t chunk_prompt_len = m_npuw_llm_compiled_model->m_prefill_chunk_size;++ auto position_ids = ov::make_tensor(ov::element::i64, attention_mask->get_shape());+ auto ids_data = position_ids->data<int64_t>();+ std::iota(ids_data, ids_data + position_ids->get_size(), 0);++ auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;+ auto output_tensor = m_prefill_request->get_tensor(m_prefill_request->get_outputs()[0]);++ uint64_t remaining_prompts = input_prompt_len;+ while (remaining_prompts > 0) {+ auto current_prompts_len = std::min(remaining_prompts, chunk_prompt_len);++ // Populate the attention mask for the present chunk+ // For the already processed tokens, they will be added into the attention mask after inference call+ if (current_prompts_len < chunk_prompt_len) {+ size_t last_chunk_offset = m_attn_mask_in_tensor->get_size() - chunk_prompt_len;++ // We will populate current_prompts_len on the right side of attention mask for the processing tokens+ // If the current prompt length is smaller than the chunk prompt length,+ // clear the last chunk of the attention mask to ensure non-relevant tokens are masked+ ov::npuw::util::fill_tensor<int64_t>(m_attn_mask_in_tensor, 0, last_chunk_offset);+ }++ std::copy_n(attention_mask->data<int64_t>() + kvcache_desc.num_stored_tokens,+ current_prompts_len,+ m_attn_mask_in_tensor->data<int64_t>() + m_attn_mask_in_tensor->get_size() - current_prompts_len);++ const auto current_prefill_bytes = current_prompts_len * input_ids_elem_size;+ const auto prefilled_bytes = kvcache_desc.num_stored_tokens * input_ids_elem_size;++ ov::npuw::util::fill_tensor_bytes(m_input_ids_in_tensor, 0u);+ std::copy_n(reinterpret_cast<uint8_t*>(input_ids->data()) + prefilled_bytes,+ current_prefill_bytes,+ reinterpret_cast<uint8_t*>(m_input_ids_in_tensor->data()) + m_input_ids_in_tensor->get_byte_size() -+ current_prefill_bytes);++ auto last_dim = position_ids->get_shape().size() - 1;+ auto actual_position_ids_slice = ov::npuw::util::make_tensor_slice(+ position_ids,+ static_cast<uint32_t>(last_dim),+ kvcache_desc.num_stored_tokens,+ kvcache_desc.num_stored_tokens + static_cast<uint32_t>(current_prompts_len));++ auto pos_ids_slice =+ ov::npuw::util::make_tensor_slice(m_pos_ids_in_tensor,+ static_cast<uint32_t>(last_dim),+ static_cast<uint32_t>(chunk_prompt_len - current_prompts_len),+ static_cast<uint32_t>(chunk_prompt_len));++ // Copy with proper stride handling+ actual_position_ids_slice->copy_to(pos_ids_slice._ptr);++ m_prefill_request->infer();++ auto src = ov::npuw::util::make_tensor_slice(output_tensor,+ layer_ids::INPUT_IDS_SEQ_LEN_DIM,+ static_cast<uint32_t>(chunk_prompt_len - current_prompts_len),+ static_cast<uint32_t>(chunk_prompt_len));++ auto dst = ov::npuw::util::make_tensor_slice(+ m_prefill_output,+ layer_ids::INPUT_IDS_SEQ_LEN_DIM,+ static_cast<uint32_t>(kvcache_desc.num_stored_tokens),+ static_cast<uint32_t>(kvcache_desc.num_stored_tokens + current_prompts_len));+ ov::npuw::util::copy_tensor_by_dim(src,+ dst,+ layer_ids::INPUT_IDS_SEQ_LEN_DIM,+ layer_ids::INPUT_IDS_SEQ_LEN_DIM);++ remaining_prompts -= current_prompts_len;+ kvcache_desc.num_stored_tokens += static_cast<uint32_t>(current_prompts_len);++ // Do not copy last computed chunk and preserve it in present k/v layer+ if (remaining_prompts <= 0) {+ LOG_DEBUG("All prompts have been prefilled in chunks");+ break;+ }++ // Copy calculated key/values chunk from present k/v layer to past k/v layer for storage+ update_kvcache_for(m_prefill_request,+ m_prefill_in_ports,+ m_prefill_out_ports,+ static_cast<uint32_t>(current_prompts_len),+ kvcache_desc.v_tensors_transposed_pre);++ // Update attention mask for the next iteration+ std::copy_n(m_attn_mask_in_tensor->data<int64_t>() + m_attn_mask_in_tensor->get_size() - current_prompts_len,+ current_prompts_len,+ m_attn_mask_in_tensor->data<int64_t>() + kvcache_desc.num_stored_tokens - current_prompts_len);+ }++ LOG_DEBUG("Done.");+}++void ov::npuw::EmbeddingInferRequest::infer_whole_prefill(ov::SoPtr<ov::ITensor> input_ids,+ ov::SoPtr<ov::ITensor> attention_mask) {+ LOG_DEBUG("Calling inference for embedding prefill model in a single launch.");+ LOG_BLOCK();++ std::copy_n(reinterpret_cast<uint8_t*>(input_ids->data()),+ input_ids->get_byte_size(),+ reinterpret_cast<uint8_t*>(m_input_ids_in_tensor->data()) + m_input_ids_in_tensor->get_byte_size() -+ input_ids->get_byte_size());++ std::copy_n(+ attention_mask->data<int64_t>(),+ attention_mask->get_size(),+ m_attn_mask_in_tensor->data<int64_t>() + m_attn_mask_in_tensor->get_size() - attention_mask->get_size());++ m_prefill_request->infer();++ auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;+ kvcache_desc.num_stored_tokens += static_cast<uint32_t>(input_ids->get_shape()[layer_ids::INPUT_IDS_SEQ_LEN_DIM]);++ auto output_tensor = m_prefill_request->get_tensor(m_prefill_request->get_outputs()[0]);+ auto src = ov::npuw::util::make_tensor_slice(+ output_tensor,+ layer_ids::INPUT_IDS_SEQ_LEN_DIM,+ static_cast<uint32_t>(m_attn_mask_in_tensor->get_size() - attention_mask->get_size()),+ static_cast<uint32_t>(m_attn_mask_in_tensor->get_size()));++ auto dst = ov::npuw::util::make_tensor_slice(m_prefill_output,+ layer_ids::INPUT_IDS_SEQ_LEN_DIM,+ 0,+ static_cast<uint32_t>(attention_mask->get_size()));+ ov::npuw::util::copy_tensor_by_dim(src, dst, layer_ids::INPUT_IDS_SEQ_LEN_DIM, layer_ids::INPUT_IDS_SEQ_LEN_DIM);++ LOG_DEBUG("Done");+}++void ov::npuw::EmbeddingInferRequest::infer_prefill(ov::SoPtr<ov::ITensor> input_ids,+ ov::SoPtr<ov::ITensor> attention_mask) {+ LOG_DEBUG("Calling inference for embedding prefill model...");+ LOG_BLOCK();++ const auto prompt_length = input_ids->get_shape()[layer_ids::INPUT_IDS_SEQ_LEN_DIM];+ auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;+ if (prompt_length > kvcache_desc.max_prompt_size) {+ OPENVINO_THROW("Input prompt is longer than configured \"NPUW_LLM_MAX_PROMPT_LEN\": ",+ kvcache_desc.max_prompt_size,+ ".\nPlease either setup bigger "+ "\"NPUW_LLM_MAX_PROMPT_LEN\" or shorten the prompt.");+ }++ prepare_for_new_conversation();++ const bool use_chunk_prefill = m_npuw_llm_compiled_model->m_use_chunk_prefill;+ if (use_chunk_prefill) {+ infer_chunked_prefill(input_ids, attention_mask);+ } else {+ infer_whole_prefill(input_ids, attention_mask);+ }++ LOG_DEBUG("Done");+}++void ov::npuw::EmbeddingInferRequest::infer() {+ const auto& inputs = get_inputs();++ auto input_ids = get_tensor(ov::npuw::util::find_port_by_name(inputs, layer_names::input_ids).value());+ auto attention_mask = get_tensor(ov::npuw::util::find_port_by_name(inputs, layer_names::attention_mask).value());++ OPENVINO_ASSERT(ov::element::i64 == input_ids->get_element_type());+ OPENVINO_ASSERT(ov::element::i64 == attention_mask->get_element_type());++ infer_prefill(input_ids, attention_mask);+}++ov::SoPtr<ov::ITensor> ov::npuw::EmbeddingInferRequest::get_tensor(const ov::Output<const ov::Node>& port) const {+ if (port == get_outputs()[0]) {+ return m_prefill_output;+ }++ return ov::ISyncInferRequest::get_tensor(port);+}diff --git a/src/plugins/intel_npu/src/plugin/npuw/embedding_infer_request.hpp b/src/plugins/intel_npu/src/plugin/npuw/embedding_infer_request.hppnew file mode 100644index 00000000000..b4bf2316afe--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/npuw/embedding_infer_request.hpp@@ -0,0 +1,47 @@+// Copyright (C) 2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "base_sync_infer_request.hpp"+#include "llm_compiled_model.hpp"+#include "llm_infer_base_request.hpp"+#include "openvino/core/descriptor/output.hpp"++namespace ov {+namespace npuw {++class EmbeddingInferRequest : public ov::npuw::LLMInferBaseRequest {+public:+ explicit EmbeddingInferRequest(const std::shared_ptr<LLMCompiledModel>& compiled_model);++ void infer() override;+ ov::SoPtr<ov::ITensor> get_tensor(const ov::Output<const ov::Node>& port) const override;++protected:+ ov::SoPtr<ov::ITensor> create_prefill_output_tensor();+ void prepare_for_new_conversation();++ void infer_chunked_prefill(ov::SoPtr<ov::ITensor> input_ids, ov::SoPtr<ov::ITensor> attention_mask);++ void infer_whole_prefill(ov::SoPtr<ov::ITensor> input_ids, ov::SoPtr<ov::ITensor> attention_mask);++ void infer_prefill(ov::SoPtr<ov::ITensor> input_ids, ov::SoPtr<ov::ITensor> attention_mask);++private:+ std::unordered_map<std::string, ov::Output<const ov::Node>> m_prefill_in_ports;+ std::unordered_map<std::string, ov::Output<const ov::Node>> m_prefill_out_ports;+ std::vector<ov::Output<const ov::Node>> m_prefill_past_kv_ports;++ std::shared_ptr<ov::IAsyncInferRequest> m_prefill_request;++ ov::SoPtr<ov::ITensor> m_input_ids_in_tensor;+ ov::SoPtr<ov::ITensor> m_attn_mask_in_tensor;+ ov::SoPtr<ov::ITensor> m_pos_ids_in_tensor;++ ov::SoPtr<ov::ITensor> m_prefill_output;+};++} // namespace npuw+} // namespace ovdiff --git a/src/plugins/intel_npu/src/plugin/npuw/embedding_model_utils.cpp b/src/plugins/intel_npu/src/plugin/npuw/embedding_model_utils.cppnew file mode 100644index 00000000000..493b9ab8704--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/npuw/embedding_model_utils.cpp@@ -0,0 +1,363 @@+// Copyright (C) 2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "embedding_model_utils.hpp"++#include <cfloat>+#include <optional>+#include <regex>++#include "logging.hpp"+#include "openvino/op/ops.hpp"+#include "openvino/openvino.hpp"+#include "openvino/opsets/opset13.hpp"+#include "openvino/pass/graph_rewrite.hpp"+#include "openvino/pass/manager.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pass.hpp"+#include "openvino/pass/pattern/op/optional.hpp"+#include "openvino/pass/pattern/op/or.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/pass/validate.hpp"+#include "transformations/utils/utils.hpp"++namespace opp = ov::pass::pattern;++namespace {++using NodePair = std::pair<std::shared_ptr<ov::Node>, std::shared_ptr<ov::Node>>;++std::string combine_key_value_name(std::string prefix, std::string layer_id, std::string key_or_value) {+ return prefix + "." + layer_id + "." + key_or_value;+}++void set_node_name(std::shared_ptr<ov::Node> node, const std::string& name) {+ node->set_friendly_name(name);+ node->get_output_tensor(0).set_names({name});+}++// Generate Qwen3 LLM mask matrix using ngraph ops+// Qwen3 uses a 4D attention mask with shape (batch, 1, seq_len, seq_len + cache_len)+// The mask combines causal attention pattern with input attention_mask values+// Inputs:+// - input_ids: shape [batch, seq_len]+// - attention_mask: shape [batch, seq_len + cache_len], values are 0 (masked) or 1 (valid)+// Output: 4D mask tensor of shape (batch, 1, seq_len, seq_len + cache_len)+// - Values are 0.0 for positions that can be attended to+// - Values are -inf for masked positions+ov::Output<ov::Node> create_new_mask(std::shared_ptr<ov::Model> model,+ ov::element::Type element_type = ov::element::f32) {+ using namespace ov::op;++ auto input_ids = model->input("input_ids");+ auto attention_mask = model->input("attention_mask");++ // Constants+ auto zero_i = std::make_shared<v0::Constant>(ov::element::i64, ov::Shape{}, 0);+ auto one_i = std::make_shared<v0::Constant>(ov::element::i64, ov::Shape{}, 1);+ auto two_i = std::make_shared<v0::Constant>(ov::element::i64, ov::Shape{}, 2);+ auto minus_one = std::make_shared<v0::Constant>(ov::element::i64, ov::Shape{}, -1);+ auto minus_two = std::make_shared<v0::Constant>(ov::element::i64, ov::Shape{}, -2);+ auto zero_f = std::make_shared<v0::Constant>(element_type, ov::Shape{}, 0.0f);+ auto one_f = std::make_shared<v0::Constant>(element_type, ov::Shape{}, 1.0f);+ auto minus_inf = std::make_shared<v0::Constant>(element_type, ov::Shape{}, -FLT_MAX);++ // Extract shapes+ // input_ids: [batch, seq_len]+ auto input_ids_shape = std::make_shared<v3::ShapeOf>(input_ids, ov::element::i64);+ auto batch_size = std::make_shared<v8::Gather>(input_ids_shape, zero_i, zero_i);+ auto seq_len = std::make_shared<v8::Gather>(input_ids_shape, one_i, zero_i);++ // attention_mask: [batch, total_seq_len] where total_seq_len = cache_len + seq_len+ auto attn_mask_shape = std::make_shared<v3::ShapeOf>(attention_mask, ov::element::i64);+ auto total_seq_len = std::make_shared<v8::Gather>(attn_mask_shape, one_i, zero_i);++ // Calculate cache_len+ auto cache_len = std::make_shared<v1::Subtract>(total_seq_len, seq_len);++ auto query_positions = std::make_shared<v4::Range>(zero_i, seq_len, one_i, ov::element::i64);+ auto query_pos_unsqueeze = std::make_shared<v0::Unsqueeze>(query_positions, one_i);++ // Create key positions: [0, 1, 2, ..., total_seq_len-1] with shape (1, total_seq_len)+ auto key_positions = std::make_shared<v4::Range>(zero_i, total_seq_len, one_i, ov::element::i64);+ auto key_pos_unsqueeze = std::make_shared<v0::Unsqueeze>(key_positions, zero_i);++ auto causal_threshold = std::make_shared<v1::Add>(cache_len, query_pos_unsqueeze);+ auto causal_condition = std::make_shared<v1::LessEqual>(key_pos_unsqueeze, causal_threshold);+ auto attn_mask_bool = std::make_shared<v0::Convert>(attention_mask, ov::element::boolean);++ // Expand attention_mask from [batch, total_seq_len] to [batch, 1, total_seq_len]+ auto attn_mask_expanded = std::make_shared<v0::Unsqueeze>(attn_mask_bool, one_i);+ // (1, seq_len, total_seq_len)+ auto causal_expanded = std::make_shared<v0::Unsqueeze>(causal_condition, zero_i);++ auto combined_condition = std::make_shared<v1::LogicalAnd>(causal_expanded, attn_mask_expanded);+ auto float_mask = std::make_shared<v1::Select>(combined_condition, zero_f, minus_inf);+ // (batch, 1, seq_len, total_seq_len)+ auto final_mask = std::make_shared<v0::Unsqueeze>(float_mask, one_i);++ return final_mask;+}++// diagnostics warnings on OPENVINO_MATCHER_PASS_RTTI() definition: visibility hidden+#ifdef __GNUC__+# pragma GCC diagnostic push+# pragma GCC diagnostic ignored "-Wattributes"+#endif++class AddKVCacheNodes : public ov::pass::MatcherPass {+public:+ OPENVINO_MATCHER_PASS_RTTI("npuw::LLMCompiledModel::AddKVCacheNodes");+ explicit AddKVCacheNodes(std::vector<NodePair>& node_pair,+ ov::ParameterVector& new_params,+ ov::ResultVector& new_results,+ uint32_t seq_len_dim) {+ const auto unsqueeze_axes = opp::wrap_type<ov::op::v0::Constant>();+ const auto transpose_order = opp::wrap_type<ov::op::v0::Constant>();+ const std::regex layer_id_convertion = std::regex(R"(layers\.(\d+)\.self_attn)");++ auto shape_concat = opp::wrap_type<ov::op::v0::Concat>(+ {opp::any_input(), opp::any_input(), opp::any_input(), opp::any_input()});++ auto k_add = opp::wrap_type<ov::op::v1::Add>({opp::any_input(), opp::any_input()});+ auto k_unsqueeze = opp::wrap_type<ov::op::v0::Unsqueeze>({k_add, unsqueeze_axes});+ auto k_broadcast = opp::wrap_type<ov::op::v1::Broadcast, ov::op::v3::Broadcast>({k_unsqueeze, shape_concat});+ auto k_reshape = opp::wrap_type<ov::op::v1::Reshape>({k_broadcast, opp::any_input()});++ auto v_transpose = opp::wrap_type<ov::op::v1::Transpose>({opp::any_input(), transpose_order});+ auto v_unsqueeze = opp::wrap_type<ov::op::v0::Unsqueeze>({v_transpose, unsqueeze_axes});+ auto v_broadcast = opp::wrap_type<ov::op::v1::Broadcast, ov::op::v3::Broadcast>({v_unsqueeze, shape_concat});+ auto v_reshape = opp::wrap_type<ov::op::v1::Reshape>({v_broadcast, opp::any_input()});++ auto sdpa = opp::wrap_type<ov::op::v13::ScaledDotProductAttention>(+ {opp::any_input(), k_reshape, v_reshape, opp::any_input(), opp::any_input()});++ ov::matcher_pass_callback callback = [=, &node_pair, &new_params, &new_results](ov::pass::pattern::Matcher& m) {+ auto& pattern_to_output = m.get_pattern_value_map();+ auto sdpa_node = pattern_to_output.at(sdpa).get_node_shared_ptr();+ auto k_add_node = pattern_to_output.at(k_add).get_node_shared_ptr();+ auto k_unsqueeze_node = pattern_to_output.at(k_unsqueeze).get_node_shared_ptr();+ auto v_transpose_node = pattern_to_output.at(v_transpose).get_node_shared_ptr();+ auto v_unsqueeze_node = pattern_to_output.at(v_unsqueeze).get_node_shared_ptr();++ auto k_broadcast_node = pattern_to_output.at(k_broadcast).get_node_shared_ptr();+ auto v_broadcast_node = pattern_to_output.at(v_broadcast).get_node_shared_ptr();++ std::smatch match;+ if (!std::regex_search(sdpa_node->get_friendly_name(), match, layer_id_convertion)) {+ return false;+ }++ auto layer_id = std::string(match[1]);+ auto k_add_out_shape = k_add_node->get_output_partial_shape(0);+ auto k_add_type = k_add_node->get_output_element_type(0);+ auto k_cache = std::make_shared<ov::op::v0::Parameter>(k_add_type, k_add_out_shape);+ set_node_name(k_cache, combine_key_value_name("past_key_values", layer_id, "key"));++ auto k_concat = register_new_node<ov::op::v0::Concat>(ov::OutputVector{k_cache, k_add_node}, seq_len_dim);+ set_node_name(k_concat, combine_key_value_name("concat", layer_id, "key"));++ auto k_cache_out = std::make_shared<ov::op::v0::Result>(k_add_node);+ set_node_name(k_cache_out, combine_key_value_name("present", layer_id, "key"));++ auto v_transpose_out_shape = v_transpose_node->get_output_partial_shape(0);+ auto v_transpose_type = v_transpose_node->get_output_element_type(0);+ auto v_cache = std::make_shared<ov::op::v0::Parameter>(v_transpose_type, v_transpose_out_shape);+ set_node_name(v_cache, combine_key_value_name("past_key_values", layer_id, "value"));++ auto v_concat =+ register_new_node<ov::op::v0::Concat>(ov::OutputVector{v_cache, v_transpose_node}, seq_len_dim);+ set_node_name(v_concat, combine_key_value_name("concat", layer_id, "value"));++ auto v_cache_out = std::make_shared<ov::op::v0::Result>(v_transpose_node);+ set_node_name(v_cache_out, combine_key_value_name("present", layer_id, "value"));++ node_pair.push_back(std::pair{k_unsqueeze_node, k_concat});+ node_pair.push_back(std::pair{v_unsqueeze_node, v_concat});++ new_params.push_back(k_cache);+ new_params.push_back(v_cache);+ new_results.push_back(k_cache_out);+ new_results.push_back(v_cache_out);+ return true;+ };++ auto m = std::make_shared<ov::pass::pattern::Matcher>(sdpa, "AddKVCacheNodes");+ register_matcher(m, std::move(callback));+ }+};++class AddPositionIdsNode : public ov::pass::MatcherPass {+public:+ OPENVINO_MATCHER_PASS_RTTI("npuw::LLMCompiledModel::AddPositionIdsNode");+ explicit AddPositionIdsNode(std::vector<NodePair>& node_pair, ov::ParameterVector& new_params) {+ auto range = opp::wrap_type<ov::op::v4::Range>();+ auto unsqueeze_axes = opp::wrap_type<ov::op::v0::Constant>();+ auto unsqueeze = opp::wrap_type<ov::op::v0::Unsqueeze>({range, unsqueeze_axes});++ auto unsqueeze1_axes = opp::wrap_type<ov::op::v0::Constant>();+ auto unsqueeze1 = opp::wrap_type<ov::op::v0::Unsqueeze>({unsqueeze, unsqueeze1_axes});++ auto convert = opp::wrap_type<ov::op::v0::Convert>({unsqueeze1});+ auto matmul = opp::wrap_type<ov::op::v0::MatMul>({opp::any_input(), convert});+ auto transpose = opp::wrap_type<ov::op::v1::Transpose>({matmul, opp::any_input()});++ auto concat = opp::wrap_type<ov::op::v0::Concat>({transpose, transpose});+ auto sin = opp::wrap_type<ov::op::v0::Sin>(concat);+ auto cos = opp::wrap_type<ov::op::v0::Cos>(concat);++ ov::matcher_pass_callback callback = [=, &node_pair, &new_params](ov::pass::pattern::Matcher& m) {+ auto& pattern_to_output = m.get_pattern_value_map();++ auto unsqueeze1_node = pattern_to_output.at(unsqueeze1).get_node_shared_ptr();+ auto position_ids = std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::PartialShape{-1, -1});+ set_node_name(position_ids, "position_ids");++ node_pair.push_back(std::pair{unsqueeze1_node, position_ids});+ new_params.push_back(position_ids);+ return true;+ };++ auto m = std::make_shared<ov::pass::pattern::Matcher>(cos, "AddPositionIdsNode");+ register_matcher(m, std::move(callback));+ }+};++class ReConstructEmbeddingModel : public ov::pass::ModelPass {+public:+ OPENVINO_MODEL_PASS_RTTI("ReConstructEmbeddingModel");++ explicit ReConstructEmbeddingModel(uint32_t seq_len_dim) : m_seq_len_dim(seq_len_dim) {}++ std::optional<std::shared_ptr<ov::Node>> check_kv_concat_nodes(std::shared_ptr<ov::Node> sdpa_node) {+ // Key input is at index 1+ // Concat->Broadcast->Reshape->SDPA+ auto reshape_node = sdpa_node->input(1).get_source_output().get_node();+ if (strstr(reshape_node->get_type_name(), "Reshape") == nullptr) {+ return std::nullopt;+ }++ auto broadcast_node = reshape_node->input(0).get_source_output().get_node();+ if (strstr(broadcast_node->get_type_name(), "Broadcast") == nullptr) {+ return std::nullopt;+ }++ auto concat_node = broadcast_node->input(1).get_source_output().get_node();+ if (strstr(concat_node->get_type_name(), "Concat") == nullptr) {+ return std::nullopt;+ }++ return concat_node->shared_from_this();+ }++ bool check_sdpa_nodes(const std::shared_ptr<ov::Model> model) {+ for (const auto& op : model->get_ops()) {+ if (ov::is_type<ov::op::v13::ScaledDotProductAttention>(op)) {+ auto sdpa = ov::as_type_ptr<ov::op::v13::ScaledDotProductAttention>(op);++ // Check all SDPA nodes share the same attention mask input+ if (!m_sdpa_front.has_value()) {+ m_sdpa_front = sdpa;+ }++ if (m_sdpa_front.value() != sdpa &&+ m_sdpa_front.value()->input(3).get_source_output() != sdpa->input(3).get_source_output()) {+ return false;+ }++ // Check all SDPA nodes share the same kv concat node+ auto concat_node = check_kv_concat_nodes(sdpa);+ if (!concat_node.has_value()) {+ return false;+ }+ if (!m_kv_concat.has_value()) {+ m_kv_concat = concat_node.value();+ } else if (m_kv_concat.value() != concat_node.value()) {+ return false;+ }+ }+ }++ return true;+ }++ bool update_kv_concat_shape(ov::Output<ov::Node>& mask_node) {+ if (!m_kv_concat.has_value()) {+ return false;+ }+ auto minus_one =+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{1}, std::vector<int64_t>{-1});+ auto zero_i = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{1}, std::vector<int64_t>{0});+ auto one_i = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{1}, std::vector<int64_t>{1});++ auto mask_shapeof = std::make_shared<ov::op::v3::ShapeOf>(mask_node, ov::element::i64);+ auto s_len = std::make_shared<ov::op::v8::Gather>(mask_shapeof, minus_one, zero_i);+ auto s_len_reshape = std::make_shared<ov::op::v1::Reshape>(s_len, one_i, false);+ // Update the concat node shape input with seq_len of mask+ m_kv_concat.value()->input(2).replace_source_output(s_len_reshape);++ return true;+ }++ bool update_sdpa_nodes(const std::shared_ptr<ov::Model>& model) {+ if (!m_sdpa_front.has_value()) {+ return false;+ }++ // Replace attention mask input with new mask+ auto mask_node = model->input("attention_mask");+ auto new_mask = create_new_mask(model);+ auto old_mask = m_sdpa_front.value()->input(3).get_source_output().get_node_shared_ptr();+ ov::replace_node(old_mask, new_mask.get_node_shared_ptr());++ return update_kv_concat_shape(mask_node);+ }++ void update_model(const std::shared_ptr<ov::Model>& model) {+ for (auto& node_pair : m_node_pair_vector) {+ node_pair.first->input(0).replace_source_output(node_pair.second);+ }++ model->add_parameters(m_new_parameters);+ model->add_results(m_new_results);+ }++ bool run_on_model(const std::shared_ptr<ov::Model>& model) override {+ OPENVINO_ASSERT(ov::op::util::has_op_with_type<ov::op::v13::ScaledDotProductAttention>(model),+ "No ScaledDotProductAttention operation observed in the graph");++ OPENVINO_ASSERT(check_sdpa_nodes(model), "Failed to check SDPA nodes");++ ov::pass::Manager manager("construct-embedding");+ manager.register_pass<AddPositionIdsNode>(m_node_pair_vector, m_new_parameters);+ manager.register_pass<AddKVCacheNodes>(m_node_pair_vector, m_new_parameters, m_new_results, m_seq_len_dim);+ OPENVINO_ASSERT(manager.run_passes(model), "Failed to add position_ids or kv cache nodes");++ update_model(model);+ OPENVINO_ASSERT(update_sdpa_nodes(model), "Failed to update SDPA nodes");+ model->validate_nodes_and_infer_types();+ return true;+ }++private:+ uint32_t m_seq_len_dim;+ std::optional<std::shared_ptr<ov::Node>> m_kv_concat;+ std::optional<std::shared_ptr<ov::Node>> m_sdpa_front;+ ov::ParameterVector m_new_parameters;+ ov::ResultVector m_new_results;+ std::vector<NodePair> m_node_pair_vector;+};++#ifdef __GNUC__+# pragma GCC diagnostic pop+#endif++} // namespace++void ov::npuw::util::prepare_text_embedding_model(std::shared_ptr<ov::Model> model, uint32_t seq_len_dim) {+ ov::pass::Manager manager("prepare-embedding");+ manager.set_per_pass_validation(true);+ manager.register_pass<ReConstructEmbeddingModel>(seq_len_dim);+ manager.run_passes(model);+}diff --git a/src/plugins/intel_npu/src/plugin/npuw/embedding_model_utils.hpp b/src/plugins/intel_npu/src/plugin/npuw/embedding_model_utils.hppnew file mode 100644index 00000000000..422c5684d3d--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/npuw/embedding_model_utils.hpp@@ -0,0 +1,13 @@+// Copyright (C) 2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "openvino/openvino.hpp"++namespace ov ::npuw ::util {++void prepare_text_embedding_model(std::shared_ptr<ov::Model> model, uint32_t seq_len_dim);++} // namespace ov::npuw::utildiff --git a/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.cpp b/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.cppindex eda5f5fcaf9..bc0dfb3a839 100644--- a/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.cpp+++ b/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.cpp@@ -158,3 +158,39 @@ std::optional<ov::Output<const ov::Node>> ov::npuw::util::find_port_by_name(}return std::make_optional(*it);}++void ov::npuw::util::pad_position_ids(const ov::SoPtr<ov::ITensor>& padded_position_ids,+ const ov::SoPtr<ov::ITensor>& position_ids) {+ // NB: Regular LLM uses 2D position_ids [BATCH, SEQ_LEN], Qwen2.5 VL/Omni uses 3D position_ids [3, BATCH, SEQ_LEN]+ // The first dimension (3) represents the three components of position encoding: time, height, and width+ // enabling alignment across multimodal inputs like text, audio, and video+ auto padded_shape = padded_position_ids->get_shape();+ auto position_shape = position_ids->get_shape();++ OPENVINO_ASSERT(position_shape.size() <= 3);++ size_t diff_dim = position_shape.size() - 1;+ for (size_t i = 0; i < diff_dim; ++i) {+ OPENVINO_ASSERT(padded_shape[i] == position_shape[i]);+ }++ size_t keep_elements = padded_shape[diff_dim] - position_shape[diff_dim];++ size_t batch_size = 1;+ for (size_t i = 0; i < padded_shape.size(); ++i) {+ if (i != diff_dim) {+ batch_size *= padded_shape[i];+ }+ }++ int64_t* padded_data = padded_position_ids->data<int64_t>();+ const int64_t* position_data = position_ids->data<int64_t>();++ for (size_t batch = 0; batch < batch_size; ++batch) {+ size_t padded_offset = batch * padded_shape[diff_dim];+ size_t position_offset = batch * position_shape[diff_dim];+ std::copy_n(position_data + position_offset,+ position_shape[diff_dim],+ padded_data + padded_offset + keep_elements);+ }+}diff --git a/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.hpp b/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.hppindex e46567593c9..98e08ad47cb 100644--- a/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.hpp+++ b/src/plugins/intel_npu/src/plugin/npuw/infer_request_utils.hpp@@ -36,6 +36,8 @@ void copy_tensor_by_dim(ov::SoPtr<ov::ITensor> src_tensor,std::optional<ov::Output<const ov::Node>> find_port_by_name(const std::vector<ov::Output<const ov::Node>>& ports,const std::string& name);+void pad_position_ids(const ov::SoPtr<ov::ITensor>& padded_position_ids, const ov::SoPtr<ov::ITensor>& position_ids);+} // namespace util} // namespace npuw} // namespace ovdiff --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 40a1367c082..88255938ba2 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@@ -3,6 +3,8 @@//#include "llm_compiled_model.hpp"+#include "embedding_infer_request.hpp"+#include "embedding_model_utils.hpp"#include "llm_infer_request.hpp"#include "logging.hpp"#include "openvino/op/convert.hpp"@@ -1259,6 +1261,10 @@ void update_config_for_whisper(ov::AnyMap& config) {config.erase("NPUW_SLICE_OUT");}+void update_config_for_text_embed(ov::AnyMap& config) {+ config.erase("NPUW_SLICE_OUT");+}+std::map<std::string, std::string> any_copy(const ov::AnyMap& params) {std::map<std::string, std::string> result;for (auto&& value : params) {@@ -1491,48 +1497,12 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& mLOG_INFO("Eagle3 speculative decoding mode enabled");}- LOG_DEBUG("Creating kvcache model as clone of passed one.");- auto kvcache_model = model->clone();- LOG_DEBUG("Transform kvcache model from stateful to stateless.");- ov::pass::StatefulToStateless().run_on_model(kvcache_model);- convert_stateful_lora_to_stateless(kvcache_model);- LOG_DEBUG(" ...also convert BF16 to FP16");- // Note: we need to identify original bf16 constants for potential weightless deserialization later- // And only then do bf16 to f16 transformation- m_bf16_consts = ov::npuw::s11n::get_bf16_consts(model);- ov::pass::ConvertPrecision(ov::element::bf16, ov::element::f16).run_on_model(kvcache_model);-- bool shared_head_enabled = m_cfg.get<::intel_npu::NPUW_LLM_SHARED_HEAD>();- std::shared_ptr<ov::Model> lm_head_model = nullptr;- if (shared_head_enabled) {- LOG_DEBUG("Trying to separate Vocabulary matrix multiplication op into additional model...");- lm_head_model = cut_lm_head(kvcache_model);- if (lm_head_model) {- LOG_INFO("Three-model pipeline will be created: LM head will be shared between prefill and generate.");- } else {- LOG_WARN("Three-model pipeline is requested, but LM head cutting is failed,"- " two-model pipeline will be created!");- }- } else {- LOG_INFO("Two-model pipeline will be created.");- }-- LOG_DEBUG("Try patch Phi-3 sliding window mask, if it exists.");- patch_phi3_sliding_mask(kvcache_model);-- LOG_DEBUG("Creating prefill model as clone of transformed kvcache one.");- auto prefill_model = kvcache_model->clone();- prefill_model->set_friendly_name(kvcache_model->get_friendly_name() + "_prefill");-// NB: PREFILL_HINT is now compatible with the PREFILL_CONFIG section, unlike for// the generate model they're not mutually exclusiveconst ::intel_npu::npuw::llm::PrefillHint prefill_hint = m_cfg.get<::intel_npu::NPUW_LLM_PREFILL_HINT>();m_prefill_chunk_size = m_cfg.get<::intel_npu::NPUW_LLM_PREFILL_CHUNK_SIZE>();m_use_chunk_prefill = (prefill_hint == ::intel_npu::npuw::llm::PrefillHint::DYNAMIC && m_prefill_chunk_size > 0);- const uint32_t batch_dim = m_cfg.get<::intel_npu::NPUW_LLM_BATCH_DIM>();- const uint32_t seq_len_dim = m_cfg.get<::intel_npu::NPUW_LLM_SEQ_LEN_DIM>();- KVAxesPosition axes{batch_dim, seq_len_dim};uint32_t max_prompt_len = align_to(m_cfg.get<::intel_npu::NPUW_LLM_MAX_PROMPT_LEN>(), 64u);const uint32_t min_response_len = align_to(m_cfg.get<::intel_npu::NPUW_LLM_MIN_RESPONSE_LEN>(), 64u);uint32_t max_generation_token_len = m_cfg.get<::intel_npu::NPUW_LLM_MAX_GENERATION_TOKEN_LEN>();@@ -1576,6 +1546,56 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& mLOG_VERB("Prefill chunk size: " << m_prefill_chunk_size);LOG_VERB("Maximum prompt length: " << max_prompt_len);+ const uint32_t batch_dim = m_cfg.get<::intel_npu::NPUW_LLM_BATCH_DIM>();+ const uint32_t seq_len_dim = m_cfg.get<::intel_npu::NPUW_LLM_SEQ_LEN_DIM>();+ KVAxesPosition axes{batch_dim, seq_len_dim};++ LOG_DEBUG("Creating kvcache model as clone of passed one.");+ auto kvcache_model = model->clone();++ auto use_text_embed_key = pop_option(other_props, std::string("NPUW_TEXT_EMBED"));+ m_is_embedding = use_text_embed_key.value_or(false).as<bool>() == true;++ if (m_is_embedding) {+ if (m_use_chunk_prefill) {+ LOG_DEBUG("Text-embedding chunk rebuild");+ ov::npuw::util::prepare_text_embedding_model(kvcache_model, seq_len_dim);+ }+ } else {+ LOG_DEBUG("Transform kvcache model from stateful to stateless.");+ ov::pass::StatefulToStateless().run_on_model(kvcache_model);+ }++ convert_stateful_lora_to_stateless(kvcache_model);++ LOG_DEBUG(" ...also convert BF16 to FP16");+ // Note: we need to identify original bf16 constants for potential weightless deserialization later+ // And only then do bf16 to f16 transformation+ m_bf16_consts = ov::npuw::s11n::get_bf16_consts(model);+ ov::pass::ConvertPrecision(ov::element::bf16, ov::element::f16).run_on_model(kvcache_model);++ bool shared_head_enabled = m_cfg.get<::intel_npu::NPUW_LLM_SHARED_HEAD>();+ std::shared_ptr<ov::Model> lm_head_model = nullptr;+ if (shared_head_enabled) {+ LOG_DEBUG("Trying to separate Vocabulary matrix multiplication op into additional model...");+ lm_head_model = cut_lm_head(kvcache_model);+ if (lm_head_model) {+ LOG_INFO("Three-model pipeline will be created: LM head will be shared between prefill and generate.");+ } else {+ LOG_WARN("Three-model pipeline is requested, but LM head cutting is failed,"+ " two-model pipeline will be created!");+ }+ } else {+ LOG_INFO("Two-model pipeline will be created.");+ }++ LOG_DEBUG("Try patch Phi-3 sliding window mask, if it exists.");+ patch_phi3_sliding_mask(kvcache_model);++ LOG_DEBUG("Creating prefill model as clone of transformed kvcache one.");+ auto prefill_model = kvcache_model->clone();+ prefill_model->set_friendly_name(kvcache_model->get_friendly_name() + "_prefill");+m_kvcache_desc =KVCacheDesc{max_prompt_len, max_prompt_len + min_response_len, 0u, seq_len_dim, max_generation_token_len};@@ -1592,6 +1612,14 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& mov::npuw::util::prepare_whisper_kvcache_model(kvcache_model); // Whisper decoder_with_past model}+ if (m_is_embedding) {+ m_kvcache_desc = KVCacheDesc{max_prompt_len,+ max_prompt_len + min_response_len,+ 0u,+ seq_len_dim,+ max_prompt_len + min_response_len};+ }+LOG_DEBUG("Make prefill model with static shapes");m_max_lora_rank = m_cfg.get<::intel_npu::NPUW_LLM_MAX_LORA_RANK>();if (m_use_chunk_prefill) {@@ -1684,18 +1712,21 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& mLOG_DEBUG("Check and apply opt layout --- SKIPPED");}- if (!m_use_chunk_prefill) {- NPUW_ASSERT(remove_empty_kv_inputs(prefill_model));- } else {- LOG_DEBUG("Don't remove input key/values from prefill model.");- LOG_DEBUG("Ask prefill model to output key/values for prefill chunk size tokens.");- prefill_model = redirect_new_kv_to_output(prefill_model);- }+ if (!m_is_embedding) {+ if (!m_use_chunk_prefill) {+ NPUW_ASSERT(remove_empty_kv_inputs(prefill_model));+ } else {+ LOG_DEBUG("Don't remove input key/values from prefill model.");+ LOG_DEBUG("Ask prefill model to output key/values for prefill chunk size tokens.");+ prefill_model = redirect_new_kv_to_output(prefill_model);+ }- LOG_DEBUG("Optimize generate model to output key/values for new token.");- for (size_t i = 0; i < generate_model_variants.size(); ++i) {- generate_model_variants[i] = redirect_new_kv_to_output(generate_model_variants[i]);+ LOG_DEBUG("Optimize generate model to output key/values for new token.");+ for (size_t i = 0; i < generate_model_variants.size(); ++i) {+ generate_model_variants[i] = redirect_new_kv_to_output(generate_model_variants[i]);+ }}+LOG_DEBUG("Converting KV-cache in generate model to FP16.");for (size_t i = 0; i < generate_model_variants.size(); ++i) {generate_model_variants[i] = cvt_kvcache_to_fp16(generate_model_variants[i]);@@ -1769,6 +1800,10 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& mupdate_config_for_whisper(prefill_config);}+ if (m_is_embedding) {+ update_config_for_text_embed(prefill_config);+ }+if (m_cfg.get<::intel_npu::NPUW_LLM_CACHE_ROPE>()) {LOG_DEBUG("Caching preROPE ");const uint32_t CACHE_ROPE_START = 2048;@@ -1948,6 +1983,7 @@ void ov::npuw::LLMCompiledModel::serialize(std::ostream& stream, const ov::npuw:write(model_stream, m_gemma_sliding_window_size);write(model_stream, m_is_whisper);write(model_stream, m_is_eagle);+ write(model_stream, m_is_embedding);// Write configwrite(model_stream, m_cfg);@@ -2173,6 +2209,7 @@ std::shared_ptr<ov::npuw::LLMCompiledModel> ov::npuw::LLMCompiledModel::deserialread(model_stream, compiled->m_gemma_sliding_window_size);read(model_stream, compiled->m_is_whisper);read(model_stream, compiled->m_is_eagle);+ read(model_stream, compiled->m_is_embedding);// Deserialize configread(model_stream, compiled->m_cfg);@@ -2207,6 +2244,7 @@ std::shared_ptr<ov::npuw::LLMCompiledModel> ov::npuw::LLMCompiledModel::deserialcompiled->m_lm_head_compiled =ov::npuw::CompiledModel::deserialize(model_stream, plugin, properties, enc_ctx);}+return compiled;};@@ -2251,7 +2289,13 @@ ov::Any ov::npuw::LLMCompiledModel::get_property(const std::string& name) conststd::shared_ptr<ov::ISyncInferRequest> ov::npuw::LLMCompiledModel::create_sync_infer_request() const {auto* non_const_this = const_cast<ov::npuw::LLMCompiledModel*>(this); // because of const in API- return m_is_whisper ? non_const_this->create_whisper_infer_request() : non_const_this->create_llm_infer_request();+ if (m_is_whisper) {+ return non_const_this->create_whisper_infer_request();+ } else if (m_is_embedding) {+ return non_const_this->create_embedding_infer_request();+ } else {+ return non_const_this->create_llm_infer_request();+ }}std::shared_ptr<ov::ISyncInferRequest> ov::npuw::LLMCompiledModel::create_llm_infer_request() {@@ -2264,6 +2308,11 @@ std::shared_ptr<ov::ISyncInferRequest> ov::npuw::LLMCompiledModel::create_whispereturn std::make_shared<ov::npuw::WhisperInferRequest>(this_sptr);}+std::shared_ptr<ov::ISyncInferRequest> ov::npuw::LLMCompiledModel::create_embedding_infer_request() {+ auto this_sptr = std::static_pointer_cast<ov::npuw::LLMCompiledModel>(shared_from_this());+ return std::make_shared<ov::npuw::EmbeddingInferRequest>(this_sptr);+}+void ov::npuw::LLMCompiledModel::implement_properties() {#define BIND(N, T, GETTER) \{ \@@ -2289,6 +2338,7 @@ void ov::npuw::LLMCompiledModel::implement_properties() {BIND(npuw::llm::generate_attn_hint, NPUW_LLM_GENERATE_ATTENTION_HINT, getString),BIND(npuw::llm::shared_lm_head, NPUW_LLM_SHARED_HEAD, get),BIND(npuw::whisper::enabled, NPUW_WHISPER, get),- BIND(npuw::eagle::enabled, NPUW_EAGLE, get)});+ BIND(npuw::eagle::enabled, NPUW_EAGLE, get),+ BIND(npuw::text_embed::enabled, NPUW_TEXT_EMBED, get)});#undef BIND}diff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.hpp b/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.hppindex c1aaedfeec2..f40bdacc515 100644--- a/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.hpp+++ b/src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.hpp@@ -62,11 +62,14 @@ public:ov::Any get_property(const std::string& name) const override;private:+ friend class LLMInferBaseRequest;friend class LLMInferRequest;friend class WhisperInferRequest;+ friend class EmbeddingInferRequest;std::shared_ptr<ov::ISyncInferRequest> create_llm_infer_request();std::shared_ptr<ov::ISyncInferRequest> create_whisper_infer_request();+ std::shared_ptr<ov::ISyncInferRequest> create_embedding_infer_request();std::shared_ptr<ov::ISyncInferRequest> create_sync_infer_request() const override;void implement_properties();@@ -113,6 +116,7 @@ private:int32_t m_gemma_sliding_window_size = 0;bool m_is_whisper = false;+ bool m_is_embedding = false;// Create generate model variants with different sizesstd::vector<std::shared_ptr<ov::Model>> create_generate_model_variants(diff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_infer_base_request.cpp b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_base_request.cppnew file mode 100644index 00000000000..dc28a17e4d4--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_base_request.cpp@@ -0,0 +1,78 @@+// Copyright (C) 2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "llm_infer_base_request.hpp"++#include <regex>++#include "infer_request_utils.hpp"++void ov::npuw::LLMInferBaseRequest::update_kvcache_for(+ std::shared_ptr<ov::IAsyncInferRequest> request,+ const std::unordered_map<std::string, ov::Output<const ov::Node>>& in_ports,+ const std::unordered_map<std::string, ov::Output<const ov::Node>>& out_ports,+ uint32_t num_tokens,+ bool v_transposed) {+ namespace uu = ov::npuw::util;+ auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;+ auto& compiled = request->get_compiled_model();+ // FIXME: Find only matching by names outputs and copy them, having previously checked that such inputs exist+ for (std::size_t i = layer_ids::kStartOutputKVCacheLayers; i < compiled->outputs().size(); ++i) {+ const auto& output_name = compiled->outputs()[i].get_any_name();+ const auto& input_name = std::regex_replace(output_name, std::regex("present"), layer_names::past_key_values);+ if (in_ports.find(input_name) == in_ports.end()) {+ // FIXME: Totally wrong debug message. input_name is an invalid name of input layer.+ LOG_DEBUG("Input name " << input_name << " doesn't contain kv cache. Skipping.");+ continue;+ }+ auto dst_tensor = request->get_tensor(in_ports.at(input_name));+ const auto& kv_dim = (output_name.find("value") != std::string::npos && v_transposed) ? 3u : kvcache_desc.dim;+ auto dst_slice = uu::make_tensor_slice(dst_tensor,+ kv_dim,+ kvcache_desc.num_stored_tokens - num_tokens,+ kvcache_desc.num_stored_tokens);+ auto src_tensor = request->get_tensor(out_ports.at(output_name));++ // NOTE: Sometimes present kv layer can contain greater seq_len+ // than was sent to be processed+ uint32_t src_seq_len = static_cast<uint32_t>(src_tensor->get_shape()[kv_dim]);+ OPENVINO_ASSERT(num_tokens <= src_seq_len);+ if (src_seq_len > num_tokens) {+ auto src_slice = uu::make_tensor_slice(src_tensor, kv_dim, src_seq_len - num_tokens, src_seq_len);+ uu::copy_tensor_by_dim(src_slice, dst_slice, kv_dim, kv_dim);+ } else {+ uu::copy_tensor_by_dim(src_tensor, dst_slice, kv_dim, kv_dim);+ }+ }+}++void ov::npuw::LLMInferBaseRequest::init_tensor(const ov::Output<const ov::Node>& port) {+ ov::SoPtr<ITensor> tensor;+ tensor = ov::ISyncInferRequest::get_tensor(port);++ if (!tensor) {+ const auto& shape = port.get_partial_shape();+ const bool is_dynamic = shape.is_dynamic();+ ov::Shape tensor_shape;+ if (is_dynamic) {+ for (auto&& item : shape) {+ tensor_shape.push_back(item.is_static() ? item.get_length() : 0);+ }+ } else {+ tensor_shape = shape.to_shape();+ }++ tensor = ov::make_tensor(port.get_element_type(), tensor_shape);+ set_tensor(port, tensor);+ }+}++void ov::npuw::LLMInferBaseRequest::init_ports() {+ for (const auto& input_port : m_npuw_llm_compiled_model->inputs()) {+ init_tensor(input_port);+ }+ for (const auto& output_port : m_npuw_llm_compiled_model->outputs()) {+ init_tensor(output_port);+ }+}diff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_infer_base_request.hpp b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_base_request.hppnew file mode 100644index 00000000000..8b99e86b91c--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_base_request.hpp@@ -0,0 +1,59 @@+// Copyright (C) 2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "llm_compiled_model.hpp"+#include "openvino/core/descriptor/output.hpp"+#include "openvino/runtime/isync_infer_request.hpp"++namespace ov {+namespace npuw {++class LLMInferBaseRequest : public ov::ISyncInferRequest {+public:+ struct layer_names {+ static constexpr const char* input_ids = "input_ids";+ static constexpr const char* inputs_embeds = "inputs_embeds";+ static constexpr const char* attention_mask = "attention_mask";+ static constexpr const char* position_ids = "position_ids";+ static constexpr const char* past_key_values = "past_key_values";+ static constexpr const char* output_embeds = "npuw_output_embed";+ static constexpr const char* logits = "logits";+ static constexpr const char* token_type_ids = "token_type_ids";+ static constexpr const char* gemma_sliding_mask = "npuw_gemma_sliding_mask";+ };++ struct layer_ids {+ static constexpr uint32_t INPUT_IDS_SEQ_LEN_DIM = 1;+ static constexpr std::size_t kStartOutputKVCacheLayers = 1;+ };++ explicit LLMInferBaseRequest(const std::shared_ptr<LLMCompiledModel>& compiled_model)+ : ISyncInferRequest(compiled_model),+ m_npuw_llm_compiled_model(compiled_model) {}++ void check_tensors() const override {};+ std::vector<ov::ProfilingInfo> get_profiling_info() const override {+ return {};+ }+ std::vector<ov::SoPtr<ov::IVariableState>> query_state() const override {+ return {};+ }++protected:+ void update_kvcache_for(std::shared_ptr<ov::IAsyncInferRequest> request,+ const std::unordered_map<std::string, ov::Output<const ov::Node>>& in_ports,+ const std::unordered_map<std::string, ov::Output<const ov::Node>>& out_ports,+ uint32_t num_tokens,+ bool v_transposed);+ void init_tensor(const ov::Output<const ov::Node>& port);+ void init_ports();++protected:+ std::shared_ptr<LLMCompiledModel> m_npuw_llm_compiled_model;+};++} // namespace npuw+} // namespace ovdiff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.cpp b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.cppindex dc53a182d2e..8e6feb3bbd5 100644--- a/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.cpp+++ b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.cpp@@ -44,41 +44,6 @@ void copy_columns_by_row_chunks_2d(ov::SoPtr<ov::ITensor> src, ov::SoPtr<ov::ITe}}-void pad_position_ids(const ov::SoPtr<ov::ITensor>& padded_position_ids, const ov::SoPtr<ov::ITensor>& position_ids) {- // NB: Regular LLM uses 2D position_ids [BATCH, SEQ_LEN], Qwen2.5 VL/Omni uses 3D position_ids [3, BATCH, SEQ_LEN]- // The first dimension (3) represents the three components of position encoding: time, height, and width- // enabling alignment across multimodal inputs like text, audio, and video- auto padded_shape = padded_position_ids->get_shape();- auto position_shape = position_ids->get_shape();-- OPENVINO_ASSERT(position_shape.size() <= 3);-- size_t diff_dim = position_shape.size() - 1;- for (size_t i = 0; i < diff_dim; ++i) {- OPENVINO_ASSERT(padded_shape[i] == position_shape[i]);- }-- size_t keep_elements = padded_shape[diff_dim] - position_shape[diff_dim];-- size_t batch_size = 1;- for (size_t i = 0; i < padded_shape.size(); ++i) {- if (i != diff_dim) {- batch_size *= padded_shape[i];- }- }-- int64_t* padded_data = padded_position_ids->data<int64_t>();- const int64_t* position_data = position_ids->data<int64_t>();-- for (size_t batch = 0; batch < batch_size; ++batch) {- size_t padded_offset = batch * padded_shape[diff_dim];- size_t position_offset = batch * position_shape[diff_dim];- std::copy_n(position_data + position_offset,- position_shape[diff_dim],- padded_data + padded_offset + keep_elements);- }-}-void check_tensor_shape_compatibility(const ov::Shape& state_tensor_shape,const ov::Shape& infer_tensor_shape,size_t full_rank_dim,@@ -151,14 +116,8 @@ void ov::npuw::LLMInferRequest::init_lora_states() {}ov::npuw::LLMInferRequest::LLMInferRequest(const std::shared_ptr<ov::npuw::LLMCompiledModel>& compiled_model)- : ov::ISyncInferRequest(compiled_model),- m_npuw_llm_compiled_model(compiled_model) {- for (const auto& input_port : m_npuw_llm_compiled_model->inputs()) {- init_tensor(input_port);- }- for (const auto& output_port : m_npuw_llm_compiled_model->outputs()) {- init_tensor(output_port);- }+ : ov::npuw::LLMInferBaseRequest(compiled_model) {+ init_ports();auto input_ids_port =ov::npuw::util::find_port_by_name(compiled_model->m_prefill_compiled->inputs(), layer_names::input_ids);@@ -413,27 +372,6 @@ std::shared_ptr<ov::IAsyncInferRequest> ov::npuw::LLMInferRequest::select_generareturn m_generate_requests.back();}-void ov::npuw::LLMInferRequest::init_tensor(const ov::Output<const ov::Node>& port) {- ov::SoPtr<ITensor> tensor;- tensor = ov::ISyncInferRequest::get_tensor(port);-- if (!tensor) {- const auto& shape = port.get_partial_shape();- const bool is_dynamic = shape.is_dynamic();- ov::Shape tensor_shape;- if (is_dynamic) {- for (auto&& item : shape) {- tensor_shape.push_back(item.is_static() ? item.get_length() : 0);- }- } else {- tensor_shape = shape.to_shape();- }-- tensor = ov::make_tensor(port.get_element_type(), tensor_shape);- set_tensor(port, tensor);- }-}-void ov::npuw::LLMInferRequest::apply_lora() {uint32_t max_low_rank_dim_size = m_npuw_llm_compiled_model->m_max_lora_rank;@@ -646,49 +584,6 @@ void ov::npuw::LLMInferRequest::copy_kvcache() {LOG_DEBUG("Done.");}-void ov::npuw::LLMInferRequest::update_kvcache_for(- std::shared_ptr<ov::IAsyncInferRequest> request,- const std::unordered_map<std::string, ov::Output<const ov::Node>>& in_ports,- const std::unordered_map<std::string, ov::Output<const ov::Node>>& out_ports,- uint32_t num_tokens,- bool v_transposed) {- namespace uu = ov::npuw::util;- LOG_DEBUG("Store computed key and values for passed number of tokens in the input kv-cache"- " layers.");- LOG_BLOCK();- auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;- auto& compiled = request->get_compiled_model();- // FIXME: Find only matching by names outputs and copy them, having previously checked that such inputs exist- for (std::size_t i = layer_ids::kStartOutputKVCacheLayers; i < compiled->outputs().size(); ++i) {- const auto& output_name = compiled->outputs()[i].get_any_name();- const auto& input_name = std::regex_replace(output_name, std::regex("present"), layer_names::past_key_values);- if (in_ports.find(input_name) == in_ports.end()) {- // FIXME: Totally wrong debug message. input_name is an invalid name of input layer.- LOG_DEBUG("Input name " << input_name << " doesn't contain kv cache. Skipping.");- continue;- }- auto dst_tensor = request->get_tensor(in_ports.at(input_name));- const auto& kv_dim = (output_name.find("value") != std::string::npos && v_transposed) ? 3u : kvcache_desc.dim;- auto dst_slice = uu::make_tensor_slice(dst_tensor,- kv_dim,- kvcache_desc.num_stored_tokens - num_tokens,- kvcache_desc.num_stored_tokens);- auto src_tensor = request->get_tensor(out_ports.at(output_name));-- // NOTE: Sometimes present kv layer can contain greater seq_len- // than was sent to be processed- uint32_t src_seq_len = static_cast<uint32_t>(src_tensor->get_shape()[kv_dim]);- OPENVINO_ASSERT(num_tokens <= src_seq_len);- if (src_seq_len > num_tokens) {- auto src_slice = uu::make_tensor_slice(src_tensor, kv_dim, src_seq_len - num_tokens, src_seq_len);- uu::copy_tensor_by_dim(src_slice, dst_slice, kv_dim, kv_dim);- } else {- uu::copy_tensor_by_dim(src_tensor, dst_slice, kv_dim, kv_dim);- }- }- LOG_DEBUG("Done.");-}-void ov::npuw::LLMInferRequest::trim_kvcache_for_speculative_decoding(ov::SoPtr<ov::ITensor> position_ids) {auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;// FIXME: It won't work with Qwen2.5-VL/Omni for now.@@ -888,7 +783,7 @@ void ov::npuw::LLMInferRequest::infer_whole_prefill(ov::SoPtr<ov::ITensor> input}auto padded_position_ids = m_prefill_request->get_tensor(m_prefill_in_ports.at(layer_names::position_ids));- pad_position_ids(padded_position_ids, position_ids);+ ov::npuw::util::pad_position_ids(padded_position_ids, position_ids);if (m_eagle3_ext.is_eagle3_model()) {m_eagle3_ext.prepare_inputs(m_prefill_request, m_prefill_in_ports);@@ -1027,7 +922,7 @@ void ov::npuw::LLMInferRequest::infer_generate(ov::SoPtr<ov::ITensor> input_ids,std::fill_n(kv_attn_mask->data<int64_t>() + kv_attn_mask->get_size() - input_tokens_len, input_tokens_len, 1);auto kv_pos_ids = m_kvcache_request->get_tensor(m_kvcache_in_ports.at(layer_names::position_ids));- pad_position_ids(kv_pos_ids, position_ids);+ ov::npuw::util::pad_position_ids(kv_pos_ids, position_ids);if (m_eagle3_ext.is_eagle3_model()) {m_eagle3_ext.prepare_inputs(m_kvcache_request, m_kvcache_in_ports);diff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.hpp b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.hppindex 118be1b9629..48e50e41d9e 100644--- a/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.hpp+++ b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.hpp@@ -9,55 +9,28 @@#include "base_sync_infer_request.hpp"#include "llm_compiled_model.hpp"#include "llm_eagle3_extension.hpp"+#include "llm_infer_base_request.hpp"#include "llm_lora_states.hpp"#include "llm_prefix_caching.hpp"#include "openvino/core/descriptor/output.hpp"-#include "openvino/runtime/isync_infer_request.hpp"namespace ov {namespace npuw {-class LLMInferRequest : public ov::ISyncInferRequest {+class LLMInferRequest : public ov::npuw::LLMInferBaseRequest {public:- struct layer_names {- static constexpr const char* input_ids = "input_ids";- static constexpr const char* inputs_embeds = "inputs_embeds";- static constexpr const char* attention_mask = "attention_mask";- static constexpr const char* position_ids = "position_ids";- static constexpr const char* past_key_values = "past_key_values";- static constexpr const char* output_embeds = "npuw_output_embed";- static constexpr const char* logits = "logits";- static constexpr const char* token_type_ids = "token_type_ids";- static constexpr const char* gemma_sliding_mask = "npuw_gemma_sliding_mask";- };-- struct layer_ids {- static constexpr uint32_t INPUT_IDS_SEQ_LEN_DIM = 1;- static constexpr std::size_t kStartOutputKVCacheLayers = 1;- };-explicit LLMInferRequest(const std::shared_ptr<ov::npuw::LLMCompiledModel>& compiled_model);void infer() override;ov::SoPtr<ov::ITensor> get_tensor(const ov::Output<const ov::Node>& port) const override;-- void check_tensors() const override {};-- std::vector<ov::ProfilingInfo> get_profiling_info() const override {- return {};- }std::vector<ov::SoPtr<ov::IVariableState>> query_state() const override;protected:virtual void prepare_for_new_conversation();void prepare_for_new_conversation(int64_t prompt_length);-void apply_lora();-void clear_chunk_prefill_kv_cache();-- void init_tensor(const ov::Output<const ov::Node>& port);void copy_kvcache();// Create and initialize generate variant requests with memory sharing@@ -68,11 +41,6 @@ protected:// sufficient capacity for both input prompt and minimum response generationstd::shared_ptr<ov::IAsyncInferRequest> select_generate_request(int64_t prompt_length);- void update_kvcache_for(std::shared_ptr<ov::IAsyncInferRequest> request,- const std::unordered_map<std::string, ov::Output<const ov::Node>>& in_ports,- const std::unordered_map<std::string, ov::Output<const ov::Node>>& out_ports,- uint32_t tokens,- bool v_transposed);void trim_kvcache_for_speculative_decoding(ov::SoPtr<ov::ITensor> position_ids);void infer_chunked_prefill(ov::SoPtr<ov::ITensor> input_ids,@@ -108,7 +76,6 @@ protected:std::shared_ptr<ov::npuw::IBaseInferRequest> m_prefill_base_request;// This infer request is optional, so can be null.std::shared_ptr<ov::IAsyncInferRequest> m_lm_head_request;- std::shared_ptr<LLMCompiledModel> m_npuw_llm_compiled_model;ov::SoPtr<ov::ITensor> m_logits;std::unordered_map<std::string, ov::Output<const ov::Node>> m_prefill_in_ports;diff --git a/src/plugins/intel_npu/src/plugin/npuw/serialization.hpp b/src/plugins/intel_npu/src/plugin/npuw/serialization.hppindex 16eee6aec55..676b19e5c0a 100644--- a/src/plugins/intel_npu/src/plugin/npuw/serialization.hpp+++ b/src/plugins/intel_npu/src/plugin/npuw/serialization.hpp@@ -36,7 +36,7 @@ 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.16";+const constexpr char* NPUW_SERIALIZATION_VERSION = "0.17";// Forward declarationnamespace intel_npu {diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cppindex c763dafeb6a..db613aec82e 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp@@ -386,6 +386,7 @@ void Plugin::init_options() {REGISTER_OPTION(NPUW_LLM_PREFIX_CACHING_MAX_NUM_BLOCKS);REGISTER_OPTION(NPUW_WHISPER);REGISTER_OPTION(NPUW_EAGLE);+ REGISTER_OPTION(NPUW_TEXT_EMBED);REGISTER_OPTION(NPUW_LLM_PREFILL_HINT);REGISTER_OPTION(NPUW_LLM_PREFILL_CONFIG);REGISTER_OPTION(NPUW_LLM_ADDITIONAL_PREFILL_CONFIG);diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cppindex 1537ab0ae5c..0a778a62061 100644--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp@@ -490,6 +490,7 @@ void Properties::registerPluginProperties() {NPUW_LLM_ADDITIONAL_SHARED_LM_HEAD_CONFIG);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::npuw::whisper::enabled, NPUW_WHISPER);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::npuw::eagle::enabled, NPUW_EAGLE);+ TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::npuw::text_embed::enabled, NPUW_TEXT_EMBED);// 2. Metrics (static device and enviroment properties)// ========