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] Turn off the shared vocabulary by default on NPU37XX (MTL) (#40213)
Eugene Smirnov62b6251ba0d2
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 11c040afed8..c7eba35b18f 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@@ -179,6 +179,15 @@ bool compiler_supports_dynamic_zp_decomposition(const int64_t compiler_ver) {return compiler_ver >= ONEAPI_MAKE_VERSION(8, 5);}+// NPU37XX (Meteor Lake) compiles the weights-as-inputs LM head with an asymmetric vocabulary to SHAVE-only+// DynamicDequantize: its zero point decomposition does not handle the 3D MatMul the head becomes there, regardless+// of the compiler version (about 1300 ms instead of about 30 ms per token with the shared vocabulary).+bool platform_supports_shared_vocab(const std::string& arch) {+ const auto platform =+ arch != ov::intel_npu::Platform::AUTO_DETECT ? ov::intel_npu::Platform::standardize(arch) : arch;+ return platform != ov::intel_npu::Platform::NPU3720;+}+std::optional<NPUDesc> extract_npu_descriptor(const std::shared_ptr<const ov::IPlugin>& plugin,const ov::AnyMap& config) {if (!plugin->get_core()) {@@ -1682,6 +1691,8 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& m: int64_t{0};const bool compiler_supports =!npudesc.has_value() || set_by_user || compiler_supports_dynamic_zp_decomposition(head_compiler_ver);+ const bool platform_supports =+ !npudesc.has_value() || set_by_user || platform_supports_shared_vocab(npudesc->arch);const bool vocab_is_closure_in_all_stages = vocab_is_closure(prefill_config) &&vocab_is_closure(generate_config) &&(lm_head_model && vocab_is_closure(lm_head_config));@@ -1691,6 +1702,10 @@ ov::npuw::LLMCompiledModel::LLMCompiledModel(const std::shared_ptr<ov::Model>& m// model and does not run ConvertDQVocab, so the Sub128 shifts of the LM head reach the compiler.LOG_INFO("NPUW_LLM_VOCAB_ASYM_SHARED is turned off: it needs NPUW_LLM_SHARED_HEAD.");m_cfg.update({{"NPUW_LLM_VOCAB_ASYM_SHARED", "NO"}});+ } else if (!platform_supports) {+ LOG_INFO("NPUW_LLM_VOCAB_ASYM_SHARED is turned off: the NPU37XX compiler keeps the LM head dequantization "+ "on SHAVE.");+ m_cfg.update({{"NPUW_LLM_VOCAB_ASYM_SHARED", "NO"}});} else if (!compiler_supports) {LOG_INFO("NPUW_LLM_VOCAB_ASYM_SHARED is turned off: it needs NPU compiler 8.5 or newer for the LM head, ""the compiler is "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 549f88db050..36a5e2e3972 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@@ -1450,6 +1450,24 @@ TEST_F(LLMCompiledModelSharedVocabularyTest, ExplicitSharedVocabularyIsUsedWithOEXPECT_EQ(shifts.lm_head, 2u);}+// NPU37XX (MTL) lowers the asymmetric weights-as-inputs LM head to SHAVE-only DynamicDequantize even with a+// new compiler, so the shared vocabulary is off there by default. An explicit YES is kept.+TEST_F(LLMCompiledModelSharedVocabularyTest, SharedVocabularyIsNotUsedOnNpu37xxEvenWithNewCompiler) {+ m_plugin = std::make_shared<ArchAwarePlugin>("3720", 1, ONEAPI_MAKE_VERSION(8, 6));+ const auto core = attach_mock_core_with_npu_device(m_plugin);+ const auto shifts = compile_llm({});+ EXPECT_EQ(shifts.lm_head, 0u);+ EXPECT_EQ(shifts.prefill, 0u);+ EXPECT_EQ(shifts.generate, 0u);+}++TEST_F(LLMCompiledModelSharedVocabularyTest, ExplicitSharedVocabularyIsUsedOnNpu37xx) {+ m_plugin = std::make_shared<ArchAwarePlugin>("3720", 1, ONEAPI_MAKE_VERSION(8, 6));+ const auto core = attach_mock_core_with_npu_device(m_plugin);+ const auto shifts = compile_llm({{"NPUW_LLM_VOCAB_ASYM_SHARED", "YES"}});+ EXPECT_EQ(shifts.lm_head, 2u);+}+// The compiler that matters is the one of the final LM head config, not the top-level one: the plugin// compiler is new (8.5), the driver compiler is old (8.2).TEST_F(LLMCompiledModelSharedVocabularyTest, SharedVocabularyIsNotUsedIfHeadOverridesCompilerWithOldOne) {