Skip to content

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

Raise exception if passed prompt exceeds its configured max size on NPU (#29890)

Anastasiya(Asya) Proninac993cfacd75e
diff --git a/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.cpp b/src/plugins/intel_npu/src/plugin/npuw/llm_infer_request.cpp
index a8c29511be8..5034be60e53 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
@@ -192,6 +192,13 @@ void ov::npuw::LLMInferRequest::infer_prefill(ov::SoPtr<ov::ITensor> input_ids,
LOG_DEBUG("Calling inference for prefill model...");
LOG_BLOCK();
+ auto& kvcache_desc = m_npuw_llm_compiled_model->m_kvcache_desc;
+ if (input_ids->get_size() > 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 longer \"NPUW_LLM_MAX_PROMPT_LEN\" or shorten the prompt.");
+ }
+
prepare_for_new_conversation();
auto padded_input = m_prefill_request->get_tensor(m_prefill_in_ports.at(m_input_ids_name));