Skip to content

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

[NPUW] Whisper: WA when model is stuck (#34175)

Ekaterina Shiryaeva2de7eacb51fc
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.hpp
index 4773cf0c06c..7cfdaaef6ef 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
@@ -162,6 +162,7 @@ DEFINE_OPT(NPUW_LLM_ENABLE_PREFIX_CACHING, bool, false, npuw::llm::enable_prefix
DEFINE_OPT(NPUW_LLM_PREFIX_CACHING_BLOCK_SIZE, uint64_t, 256, npuw::llm::prefix_caching_block_size, RunTime);
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_WHISPER_EOS_TOKEN, uint64_t, 50257, npuw::whisper::whisper_eos_token, 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);
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.hpp
index 7771184166b..3ded9984841 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
@@ -748,6 +748,14 @@ namespace whisper {
* Default value: false.
*/
static constexpr ov::Property<bool> enabled{"NPUW_WHISPER"};
+
+/**
+ * @brief
+ * Type: uint64_t.
+ * Provide eos_token for Whisper model (WA).
+ * Default value: 50257.
+ */
+static constexpr ov::Property<uint64_t> whisper_eos_token{"NPUW_WHISPER_EOS_TOKEN"};
} // namespace whisper
namespace eagle {
diff --git a/src/plugins/intel_npu/src/al/src/config/npuw.cpp b/src/plugins/intel_npu/src/al/src/config/npuw.cpp
index bdd984c2aac..4a85e562fd8 100644
--- a/src/plugins/intel_npu/src/al/src/config/npuw.cpp
+++ b/src/plugins/intel_npu/src/al/src/config/npuw.cpp
@@ -87,6 +87,7 @@ void intel_npu::registerNPUWLLMOptions(OptionsDesc& desc) {
desc.add<NPUW_LLM_GENERATE_ATTENTION_HINT>();
desc.add<NPUW_LLM_SHARED_HEAD>();
desc.add<NPUW_WHISPER>();
+ desc.add<NPUW_WHISPER_EOS_TOKEN>();
desc.add<NPUW_EAGLE>();
desc.add<NPUW_TEXT_EMBED>();
}
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.cpp
index b00973605e5..3e60ef32d93 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
@@ -1569,6 +1569,7 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& m
ov::AnyMap other_props;
split_llm_properties(properties, npuw_llm_props, other_props);
auto use_whisper_key = pop_option(other_props, std::string("NPUW_WHISPER"));
+ auto whisper_eos_token = pop_option(other_props, std::string("NPUW_WHISPER_EOS_TOKEN"));
auto use_eagle_key = pop_option(other_props, std::string("NPUW_EAGLE"));
auto kv_cache_precision_hint = pop_option(other_props, ov::hint::kv_cache_precision.name());
@@ -1611,6 +1612,8 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& m
m_cfg.update({{"NPUW_LLM_PREFILL_CHUNK_SIZE", "0"}});
m_cfg.update({{"NPUW_LLM_CACHE_ROPE", "NO"}});
m_cfg.update({{"NPUW_LLM_OPTIMIZE_V_TENSORS", "NO"}});
+
+ m_eos_token_id = whisper_eos_token.value_or(50257).as<uint64_t>();
}
m_is_eagle = use_eagle_key.value_or(false).as<bool>() == true;
@@ -2482,6 +2485,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::whisper::whisper_eos_token, NPUW_WHISPER_EOS_TOKEN, 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.hpp
index 9a890da6d07..f5a0c415305 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
@@ -113,6 +113,8 @@ private:
friend class PrefixCachingHelper;
bool m_is_whisper = false;
+ uint64_t m_eos_token_id = 0;
+
bool m_is_embedding = false;
// Create generate model variants with different sizes
diff --git a/src/plugins/intel_npu/src/plugin/npuw/whisper_infer_request.cpp b/src/plugins/intel_npu/src/plugin/npuw/whisper_infer_request.cpp
index b5dbc931d82..0b469b1c710 100644
--- a/src/plugins/intel_npu/src/plugin/npuw/whisper_infer_request.cpp
+++ b/src/plugins/intel_npu/src/plugin/npuw/whisper_infer_request.cpp
@@ -155,6 +155,11 @@ void ov::npuw::WhisperInferRequest::infer_generate(ov::SoPtr<ov::ITensor> input_
kvcache_desc.num_stored_tokens += 1;
if (kvcache_desc.num_stored_tokens == kvcache_desc.total_size) {
+ // KV-cache is full, but it's not expected, so force eos_token as WA
+ std::cout << "[WARNING] Whisper model stuck (KVcache is full), not full audio chunk could be processed !"
+ << std::endl;
+ float* logits_data = m_logits->data<float>(); // logits for generate model has shape [1, 1, vocab_size]
+ logits_data[m_npuw_llm_compiled_model->m_eos_token_id] = std::numeric_limits<float>::infinity();
return;
}
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 85b73eaec38..94481f7623d 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -335,6 +335,7 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCo
REGISTER_OPTION(NPUW_LLM_PREFIX_CACHING_BLOCK_SIZE);
REGISTER_OPTION(NPUW_LLM_PREFIX_CACHING_MAX_NUM_BLOCKS);
REGISTER_OPTION(NPUW_WHISPER);
+ REGISTER_OPTION(NPUW_WHISPER_EOS_TOKEN);
REGISTER_OPTION(NPUW_EAGLE);
REGISTER_OPTION(NPUW_TEXT_EMBED);
REGISTER_OPTION(NPUW_LLM_PREFILL_HINT);
diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp
index c46b3b80c26..363f4eae32c 100644
--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp
@@ -637,6 +637,7 @@ void Properties::registerPluginProperties() {
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::npuw::llm::additional_shared_lm_head_config,
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::whisper::whisper_eos_token, NPUW_WHISPER_EOS_TOKEN);
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);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::npuw::kokoro::enabled, NPUW_KOKORO);