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
[NPU] Add compiler options cache (#37233)
Bogdan Pereanu926b5202fc7a
diff --git a/src/plugins/intel_npu/src/common/CMakeLists.txt b/src/plugins/intel_npu/src/common/CMakeLists.txtindex f5cfd5c96c4..9b42c23cd72 100644--- a/src/plugins/intel_npu/src/common/CMakeLists.txt+++ b/src/plugins/intel_npu/src/common/CMakeLists.txt@@ -6,6 +6,7 @@ set(TARGET_NAME "openvino_npu_common")set(SOURCES${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/compiler_adapter_factory.hpp+ ${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/option_support_cache.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/device_helpers.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/filtered_config.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/icompiled_model.hppdiff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/compiler_adapter_factory.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/compiler_adapter_factory.hppindex 2c95a9b7a6e..d3c0996404e 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/compiler_adapter_factory.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/compiler_adapter_factory.hpp@@ -7,9 +7,11 @@#include <atomic>#include <memory>#include <string_view>+#include <vector>#include "intel_npu/common/icompiler_adapter.hpp"#include "intel_npu/common/npu.hpp"+#include "intel_npu/common/option_support_cache.hpp"#include "openvino/runtime/intel_npu/properties.hpp"namespace intel_npu {@@ -18,9 +20,13 @@ class CompilerAdapterFactory final {public:ov::intel_npu::CompilerType determineAppropriateCompilerTypeBasedOnPlatform(std::string_view platform) const;- std::unique_ptr<ICompilerAdapter> getCompiler(const ov::SoPtr<IEngineBackend>& engineBackend,- ov::intel_npu::CompilerType& compilerType,- std::string_view platform) const;+ std::unique_ptr<ICompilerAdapter> getCompiler(+ const ov::SoPtr<IEngineBackend>& engineBackend,+ ov::intel_npu::CompilerType& compilerType,+ std::string_view platform,+ const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr) const;++ static const std::vector<ov::intel_npu::CompilerType>& getSupportedCompilerTypes();private:inline static std::atomic<bool> _pluginCompilerIsPresent{true};diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/option_support_cache.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/option_support_cache.hppnew file mode 100644index 00000000000..4e693934a9a--- /dev/null+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/option_support_cache.hpp@@ -0,0 +1,40 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <cstdint>+#include <mutex>+#include <optional>+#include <string>+#include <vector>++namespace intel_npu {++class OptionSupportCache final {+public:+ using CacheKey = uint32_t;++ struct OptionSupportState final {+ std::string optionCacheKey;+ bool supported;+ };++ std::optional<bool> isOptionSupported(CacheKey key, const std::string& optionName);+ void addSupportedOption(CacheKey key, const std::string& optionName, bool supported = true);+ void setSupportedOptions(CacheKey key, const std::vector<std::string>& supportedOptions);++private:+ struct KeyOptionsState final {+ CacheKey key;+ std::vector<OptionSupportState> supportedOptions;+ };++ KeyOptionsState& getStateForKey(CacheKey key);++ std::mutex _mutex;+ std::vector<KeyOptionsState> _optionSupportStates;+};++} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/compiler_adapter/CMakeLists.txt b/src/plugins/intel_npu/src/compiler_adapter/CMakeLists.txtindex f7d59650e53..6ad1cff7d3e 100644--- a/src/plugins/intel_npu/src/compiler_adapter/CMakeLists.txt+++ b/src/plugins/intel_npu/src/compiler_adapter/CMakeLists.txt@@ -19,6 +19,7 @@ set(SOURCES${CMAKE_CURRENT_SOURCE_DIR}/include/xml_serializer.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/ze_graph_ext_wrappers.hpp${CMAKE_CURRENT_SOURCE_DIR}/src/compiler_adapter_factory.cpp+ ${CMAKE_CURRENT_SOURCE_DIR}/src/option_support_cache.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/compiler_impl.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/driver_compiler_adapter.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/dynamic_graph.cppdiff --git a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hppindex afae2a0b78d..5d90c27ab55 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp@@ -10,6 +10,7 @@#include <string>#include "intel_npu/common/icompiler_adapter.hpp"+#include "intel_npu/common/option_support_cache.hpp"#include "intel_npu/config/config.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "intel_npu/utils/zero/zero_init.hpp"@@ -19,7 +20,8 @@ namespace intel_npu {class DriverCompilerAdapter final : public ICompilerAdapter {public:- DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct);+ DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,+ const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr);std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model,const FilteredConfig& config) const override;@@ -43,6 +45,7 @@ private:std::optional<std::string> get_compatibility_descriptor(ze_graph_handle_t graphHandle) const;std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;+ std::shared_ptr<OptionSupportCache> _optionSupportCache;std::shared_ptr<ZeGraphExtWrappers> _zeGraphExt;ze_device_graph_properties_t _compilerProperties = {};diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hppindex 3253e124b65..a91a3a05552 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp@@ -11,6 +11,7 @@#include "compiler_impl.hpp"#include "intel_npu/common/icompiler_adapter.hpp"#include "intel_npu/common/npu.hpp"+#include "intel_npu/common/option_support_cache.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "intel_npu/utils/zero/zero_init.hpp"#include "openvino/runtime/so_ptr.hpp"@@ -21,6 +22,7 @@ namespace intel_npu {class PluginCompilerAdapter final : public ICompilerAdapter {public:PluginCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,+ const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr,const std::optional<IDevice::DeviceProperties>& deviceProperties = std::nullopt);std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model,@@ -40,7 +42,7 @@ public:private:std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;-+ std::shared_ptr<OptionSupportCache> _optionSupportCache;std::shared_ptr<ZeGraphExtWrappers> _zeGraphExt;ov::SoPtr<VCLCompilerImpl> _compiler;diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cppindex eecd4444ba8..68feca6bc83 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp@@ -20,9 +20,11 @@ ov::intel_npu::CompilerType CompilerAdapterFactory::determineAppropriateCompilerreturn ov::intel_npu::CompilerType::DRIVER;}-std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(const ov::SoPtr<IEngineBackend>& engineBackend,- ov::intel_npu::CompilerType& compilerType,- std::string_view platform) const {+std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(+ const ov::SoPtr<IEngineBackend>& engineBackend,+ ov::intel_npu::CompilerType& compilerType,+ std::string_view platform,+ const std::shared_ptr<OptionSupportCache>& optionSupportCache) const {const auto device = engineBackend != nullptr ? engineBackend->getDevice() : nullptr;if (compilerType == ov::intel_npu::CompilerType::PREFER_PLUGIN) {@@ -32,6 +34,7 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(const ov::if (_pluginCompilerIsPresent) {try {return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs(),+ optionSupportCache,device->getDeviceProperties());} catch (...) {_pluginCompilerIsPresent = false;@@ -50,10 +53,12 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(const ov::if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {if (device == nullptr) {- return std::make_unique<PluginCompilerAdapter>(nullptr);+ return std::make_unique<PluginCompilerAdapter>(nullptr, optionSupportCache);}- return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs(), device->getDeviceProperties());+ return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs(),+ optionSupportCache,+ device->getDeviceProperties());} else if (compilerType == ov::intel_npu::CompilerType::DRIVER) {if (device == nullptr) {OPENVINO_THROW("Could not find an NPU device. The driver compiler requires a valid device to be present in "@@ -67,10 +72,17 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(const ov::OPENVINO_THROW("Could not find a valid NPU device for the provided configuration.");}- return std::make_unique<DriverCompilerAdapter>(engineBackend->getInitStructs());+ return std::make_unique<DriverCompilerAdapter>(engineBackend->getInitStructs(), optionSupportCache);} else {OPENVINO_THROW("Invalid NPU_COMPILER_TYPE");}}+const std::vector<ov::intel_npu::CompilerType>& CompilerAdapterFactory::getSupportedCompilerTypes() {+ static const std::vector<ov::intel_npu::CompilerType> supportedCompilerTypes = {+ ov::intel_npu::CompilerType::DRIVER,+ ov::intel_npu::CompilerType::PLUGIN};+ return supportedCompilerTypes;+}+} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cppindex 0d757d33e3d..7ff65d7d8f4 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp@@ -13,6 +13,7 @@#include "graph.hpp"#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/itt.hpp"+#include "intel_npu/common/option_support_cache.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "mem_usage.hpp"@@ -23,6 +24,11 @@namespace intel_npu {+namespace {+constexpr OptionSupportCache::CacheKey driverOptionSupportKey =+ static_cast<OptionSupportCache::CacheKey>(ov::intel_npu::CompilerType::DRIVER);+}+namespace {struct PropertySupportInfo {@@ -39,10 +45,8 @@ bool isVersionSupportedByCompiler(uint32_t version, const ze_graph_compiler_versconst std::vector<PropertySupportInfo> _supportedPropertiesWithVersions = {{ov::compilation_num_threads.name(), ONEAPI_MAKE_VERSION(0, 0)},{ov::enable_profiling.name(), ONEAPI_MAKE_VERSION(0, 0)},- {ov::device::id.name(), ONEAPI_MAKE_VERSION(0, 0)},{ov::hint::execution_mode.name(), ONEAPI_MAKE_VERSION(5, 6)},{ov::hint::inference_precision.name(), ONEAPI_MAKE_VERSION(5, 4)},- {ov::hint::num_requests.name(), ONEAPI_MAKE_VERSION(0, 0)},{ov::hint::performance_mode.name(), ONEAPI_MAKE_VERSION(0, 0)},{ov::log::level.name(), ONEAPI_MAKE_VERSION(0, 0)},{ov::intel_npu::batch_compiler_mode_settings.name(), ONEAPI_MAKE_VERSION(7, 4)},@@ -63,8 +67,10 @@ const std::vector<PropertySupportInfo> _supportedPropertiesWithVersions = {} // namespace-DriverCompilerAdapter::DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct)+DriverCompilerAdapter::DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,+ const std::shared_ptr<OptionSupportCache>& optionSupportCache): _zeroInitStruct(zeroInitStruct),+ _optionSupportCache(optionSupportCache),_logger("DriverCompilerAdapter", Logger::global().level()) {_logger.info("initialize DriverCompilerAdapter start");@@ -327,6 +333,10 @@ std::vector<std::string> DriverCompilerAdapter::get_supported_options() const {while (suppstream >> option) {compilerOpts.push_back(option);}++ if (_optionSupportCache) {+ _optionSupportCache->setSupportedOptions(driverOptionSupportKey, compilerOpts);+ }return compilerOpts;}@@ -341,21 +351,42 @@ std::vector<std::string> DriverCompilerAdapter::get_supported_options() const {if (compilerOpts.empty()) {return {};}++ if (_optionSupportCache) {+ _optionSupportCache->setSupportedOptions(driverOptionSupportKey, compilerOpts);+ }return compilerOpts;}bool DriverCompilerAdapter::is_option_supported(const std::string& optName,const std::optional<std::string>& optValue) const {+ bool optionSupportCache = _optionSupportCache && !optValue.has_value();+ if (optionSupportCache) {+ const auto cachedSupport = _optionSupportCache->isOptionSupported(driverOptionSupportKey, optName);+ if (cachedSupport.has_value()) {+ return cachedSupport.value();+ }+ }+auto isOptionSupported = _zeGraphExt->isOptionSupported(optName, optValue);if (isOptionSupported.has_value()) {- return isOptionSupported.value();+ const bool supported = isOptionSupported.value();+ if (optionSupportCache) {+ _optionSupportCache->addSupportedOption(driverOptionSupportKey, optName, supported);+ }++ return supported;}// legacy pathconst auto& compilerVersion = _compilerProperties.compilerVersion;for (const auto& prop : _supportedPropertiesWithVersions) {if (prop.name == optName) {- return isVersionSupportedByCompiler(prop.version, compilerVersion);+ const bool supported = isVersionSupportedByCompiler(prop.version, compilerVersion);+ if (_optionSupportCache) {+ _optionSupportCache->addSupportedOption(driverOptionSupportKey, optName, supported);+ }+ return supported;}}return false;diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/option_support_cache.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/option_support_cache.cppnew file mode 100644index 00000000000..15d78ff5bbf--- /dev/null+++ b/src/plugins/intel_npu/src/compiler_adapter/src/option_support_cache.cpp@@ -0,0 +1,91 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "intel_npu/common/option_support_cache.hpp"++#include <algorithm>++#include "openvino/core/except.hpp"++namespace {++std::optional<bool> getCachedOptionSupportFromVector(+ const std::vector<intel_npu::OptionSupportCache::OptionSupportState>& options,+ const std::string& optionCacheKey) {+ const auto it = std::find_if(options.begin(),+ options.end(),+ [&](const intel_npu::OptionSupportCache::OptionSupportState& value) {+ return value.optionCacheKey == optionCacheKey;+ });+ if (it == options.end()) {+ return std::nullopt;+ }++ return it->supported;+}++void addOptionSupportInVector(std::vector<intel_npu::OptionSupportCache::OptionSupportState>& options,+ const std::string& optionCacheKey,+ bool supported) {+ const auto it = std::find_if(options.begin(),+ options.end(),+ [&](const intel_npu::OptionSupportCache::OptionSupportState& value) {+ return value.optionCacheKey == optionCacheKey;+ });+ if (it != options.end()) {+ if (it->supported == supported) {+ return;+ }++ OPENVINO_THROW("Attempting to add an option support state for option '",+ optionCacheKey,+ "' that already exists with a different support state. Existing: ",+ it->supported,+ ", New: ",+ supported);+ }++ options.push_back({optionCacheKey, supported});+}++} // namespace++namespace intel_npu {++std::optional<bool> OptionSupportCache::isOptionSupported(const CacheKey key, const std::string& optionName) {+ std::lock_guard<std::mutex> lock(_mutex);+ auto& optionSupportState = getStateForKey(key);+ return getCachedOptionSupportFromVector(optionSupportState.supportedOptions, optionName);+}++void OptionSupportCache::addSupportedOption(const CacheKey key, const std::string& optionName, bool supported) {+ std::lock_guard<std::mutex> lock(_mutex);+ auto& optionSupportState = getStateForKey(key);+ addOptionSupportInVector(optionSupportState.supportedOptions, optionName, supported);+}++void OptionSupportCache::setSupportedOptions(const CacheKey key, const std::vector<std::string>& supportedOptions) {+ std::lock_guard<std::mutex> lock(_mutex);+ auto& optionSupportState = getStateForKey(key);++ for (const auto& option : supportedOptions) {+ addOptionSupportInVector(optionSupportState.supportedOptions, option, true);+ }+}++OptionSupportCache::KeyOptionsState& OptionSupportCache::getStateForKey(CacheKey key) {+ auto it = std::find_if(_optionSupportStates.begin(),+ _optionSupportStates.end(),+ [&](const KeyOptionsState& optionSupportState) {+ return optionSupportState.key == key;+ });+ if (it != _optionSupportStates.end()) {+ return *it;+ }++ _optionSupportStates.push_back({key, {}});+ return _optionSupportStates.back();+}++} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cppindex 1bbb5819ada..86d7d68a7fe 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp@@ -11,6 +11,7 @@#include "graph.hpp"#include "intel_npu/common/device_helpers.hpp"#include "intel_npu/common/itt.hpp"+#include "intel_npu/common/option_support_cache.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"#include "intel_npu/utils/logger/logger.hpp"@@ -27,9 +28,16 @@namespace intel_npu {+namespace {+constexpr OptionSupportCache::CacheKey pluginOptionSupportKey =+ static_cast<OptionSupportCache::CacheKey>(ov::intel_npu::CompilerType::PLUGIN);+}+PluginCompilerAdapter::PluginCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,+ const std::shared_ptr<OptionSupportCache>& optionSupportCache,const std::optional<IDevice::DeviceProperties>& deviceProperties): _zeroInitStruct(zeroInitStruct),+ _optionSupportCache(optionSupportCache),_logger("PluginCompilerAdapter", Logger::global().level()) {_logger.info("initialize PluginCompilerAdapter start");@@ -310,24 +318,35 @@ std::vector<std::string> PluginCompilerAdapter::get_supported_options() const {while (suppstream >> option) {compilerOpts.push_back(option);}++ if (_optionSupportCache) {+ _optionSupportCache->setSupportedOptions(pluginOptionSupportKey, compilerOpts);+ }return compilerOpts;}bool PluginCompilerAdapter::is_option_supported(const std::string& optname,const std::optional<std::string>& optValue) const {- const bool hasValue = optValue.has_value();- const std::string value = hasValue ? optValue.value() : "";- if (_compiler->is_option_supported(optname, optValue)) {- _logger.debug("Option %s is supported `%s` by VCLCompilerImpl",- optname.c_str(),- hasValue ? value.c_str() : "null");- return true;- } else {- _logger.debug("Option %s is not supported `%s` by VCLCompilerImpl",- optname.c_str(),- hasValue ? value.c_str() : "null");- return false;+ bool optionSupportCache = _optionSupportCache && !optValue.has_value();+ if (optionSupportCache) {+ const auto cachedSupport = _optionSupportCache->isOptionSupported(pluginOptionSupportKey, optname);+ if (cachedSupport.has_value()) {+ return cachedSupport.value();+ }+ }++ const bool supported = _compiler->is_option_supported(optname, optValue);+ if (optionSupportCache) {+ _optionSupportCache->addSupportedOption(pluginOptionSupportKey, optname, supported);}++ const char* valueForLog = optValue.has_value() ? optValue->c_str() : "null";+ _logger.debug("Option %s %s `%s` by VCLCompilerImpl",+ optname.c_str(),+ supported ? "is supported" : "is not supported",+ valueForLog);++ return supported;}} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/include/compiler_option_support_helper.hpp b/src/plugins/intel_npu/src/plugin/include/compiler_option_support_helper.hppnew file mode 100644index 00000000000..e6e9c3f33e0--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/include/compiler_option_support_helper.hpp@@ -0,0 +1,41 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <cstdint>+#include <mutex>+#include <optional>+#include <string>+#include <unordered_map>+#include <vector>++#include "intel_npu/common/compiler_adapter_factory.hpp"+#include "intel_npu/common/npu.hpp"+#include "intel_npu/common/option_support_cache.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"++namespace intel_npu {++class CompilerOptionSupportHelper final {+public:+ explicit CompilerOptionSupportHelper(const ov::SoPtr<IEngineBackend>& backend,+ const CompilerAdapterFactory& adapterFactory);++ const std::shared_ptr<OptionSupportCache>& getOptionSupportCache() const;++ bool isOptionSupported(ov::intel_npu::CompilerType compilerType,+ const std::string& optionName,+ const std::optional<std::string>& optionValue = std::nullopt);++private:+ const ov::SoPtr<IEngineBackend> _backend;+ const CompilerAdapterFactory _adapterFactory;+ std::shared_ptr<OptionSupportCache> _optionSupportCache;++ std::mutex _supportedOptionsLoadedMutex;+ std::unordered_map<OptionSupportCache::CacheKey, std::once_flag> _supportedOptionsLoaded;+};++} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hppindex 69124140950..1473006608f 100644--- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp+++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp@@ -10,6 +10,7 @@#include "backends_registry.hpp"#include "blob_format_importers.hpp"+#include "compiler_option_support_helper.hpp"#include "intel_npu/common/npu.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "openvino/runtime/iplugin.hpp"@@ -82,6 +83,7 @@ private:mutable Logger _logger;std::unique_ptr<PluginPropertyManager> _propertiesManager;+ std::shared_ptr<CompilerOptionSupportHelper> _compilerOptionSupportHelper;static std::atomic<int> _compiledModelLoadCounter;};diff --git a/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp b/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hppindex 5d632c00965..9f2e7e00d3d 100644--- a/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp+++ b/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp@@ -10,6 +10,7 @@#include <string>#include <vector>+#include "compiler_option_support_helper.hpp"#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/icompiler_adapter.hpp"#include "intel_npu/common/npu.hpp"@@ -21,7 +22,10 @@ namespace intel_npu {class PluginPropertyManager final {public:- PluginPropertyManager(const FilteredConfig& config, const ov::SoPtr<IEngineBackend>& backend, Logger& logger);+ PluginPropertyManager(const FilteredConfig& config,+ const ov::SoPtr<IEngineBackend>& backend,+ const std::shared_ptr<CompilerOptionSupportHelper>& optionSupportHelper,+ Logger& logger);PluginPropertyManager& operator=(const PluginPropertyManager& other) = delete;@@ -34,7 +38,7 @@ public:}FilteredConfig getConfigWithCompilerPropertiesDisabled(const ov::AnyMap& properties) const;- FilteredConfig getConfigForSpecificCompiler(const ov::AnyMap& properties, const ICompilerAdapter* compiler) const;+ FilteredConfig getConfigForSpecificCompiler(const ov::AnyMap& properties) const;std::string determinePlatform(const ov::AnyMap& properties) const;std::string determineDeviceId(const ov::AnyMap& properties) const;@@ -45,6 +49,7 @@ private:struct CopyState {FilteredConfig config;ov::SoPtr<IEngineBackend> backend;+ std::shared_ptr<CompilerOptionSupportHelper> optionSupportHelper;Logger& logger;ov::intel_npu::CompilerType currentlyUsedCompiler;ov::intel_npu::CompilerType _compilerForCompatibilityCheck;@@ -63,6 +68,7 @@ private:mutable FilteredConfig _config;ov::SoPtr<IEngineBackend> _backend;+ std::shared_ptr<CompilerOptionSupportHelper> _compilerOptionSupportHelper;Logger& _logger;mutable ov::intel_npu::CompilerType _currentlyUsedCompiler = ov::intel_npu::CompilerType::PREFER_PLUGIN;diff --git a/src/plugins/intel_npu/src/plugin/sources.cmake b/src/plugins/intel_npu/src/plugin/sources.cmakeindex b7a7c3e4fd6..909e0484574 100644--- a/src/plugins/intel_npu/src/plugin/sources.cmake+++ b/src/plugins/intel_npu/src/plugin/sources.cmake@@ -6,6 +6,7 @@ set(SOURCES${CMAKE_CURRENT_SOURCE_DIR}/include/async_infer_request.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/backends_registry.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/blob_format_importers.hpp+ ${CMAKE_CURRENT_SOURCE_DIR}/include/compiler_option_support_helper.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/compiled_model.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/compiled_model_property_manager.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/executor.hpp@@ -18,6 +19,7 @@ set(SOURCES${CMAKE_CURRENT_SOURCE_DIR}/src/async_infer_request.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/backends_registry.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/blob_format_importers.cpp+ ${CMAKE_CURRENT_SOURCE_DIR}/src/compiler_option_support_helper.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/compiled_model.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/compiled_model_property_manager.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/executor.cppdiff --git a/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp b/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cppnew file mode 100644index 00000000000..c1af354aa46--- /dev/null+++ b/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp@@ -0,0 +1,69 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "compiler_option_support_helper.hpp"++#include <algorithm>+#include <memory>++#include "intel_npu/common/option_support_cache.hpp"++namespace intel_npu {++namespace {+OptionSupportCache::CacheKey toCacheKey(const ov::intel_npu::CompilerType compilerType) {+ return static_cast<OptionSupportCache::CacheKey>(compilerType);+}+} // namespace++CompilerOptionSupportHelper::CompilerOptionSupportHelper(const ov::SoPtr<IEngineBackend>& backend,+ const CompilerAdapterFactory& adapterFactory)+ : _backend(backend),+ _adapterFactory(adapterFactory),+ _optionSupportCache(std::make_shared<OptionSupportCache>()) {}++const std::shared_ptr<OptionSupportCache>& CompilerOptionSupportHelper::getOptionSupportCache() const {+ return _optionSupportCache;+}++bool CompilerOptionSupportHelper::isOptionSupported(ov::intel_npu::CompilerType compilerType,+ const std::string& optionName,+ const std::optional<std::string>& optionValue) {+ const auto& supportedCompilerTypes = CompilerAdapterFactory::getSupportedCompilerTypes();+ OPENVINO_ASSERT(std::find(supportedCompilerTypes.begin(), supportedCompilerTypes.end(), compilerType) !=+ supportedCompilerTypes.end(),+ "Unsupported compiler type");++ const auto cacheKey = toCacheKey(compilerType);+ const auto getCachedSupport = [&]() -> std::optional<bool> {+ if (optionValue.has_value()) {+ return std::nullopt;+ }+ return _optionSupportCache->isOptionSupported(cacheKey, optionName);+ };++ if (const auto cachedSupport = getCachedSupport(); cachedSupport.has_value()) {+ return cachedSupport.value();+ }++ std::unique_ptr<ICompilerAdapter> compiler;+ compiler = _adapterFactory.getCompiler(_backend, compilerType, "", _optionSupportCache);++ std::once_flag* optionsLoaded = nullptr;+ {+ std::lock_guard<std::mutex> lock(_supportedOptionsLoadedMutex);+ optionsLoaded = &_supportedOptionsLoaded[cacheKey];+ }+ std::call_once(*optionsLoaded, [&compiler]() {+ compiler->get_supported_options();+ });++ if (const auto cachedSupport = getCachedSupport(); cachedSupport.has_value()) {+ return cachedSupport.value();+ }++ return compiler->is_option_supported(optionName, optionValue);+}++} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cppindex 6c34e0180b0..f704efb591a 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp@@ -277,7 +277,9 @@ Plugin::Plugin() : _logger("NPUPlugin", Logger::global().level()) {/// Init and register propertiesOV_ITT_TASK_NEXT(PLUGIN, "RegisterProperties");- _propertiesManager = std::make_unique<PluginPropertyManager>(config, _backend, _logger);+ _compilerOptionSupportHelper = std::make_shared<CompilerOptionSupportHelper>(_backend, CompilerAdapterFactory());+ _propertiesManager =+ std::make_unique<PluginPropertyManager>(config, _backend, _compilerOptionSupportHelper, _logger);}void Plugin::set_property(const ov::AnyMap& properties) {@@ -342,7 +344,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<_backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());CompilerAdapterFactory factory;- auto compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);+ auto compiler = factory.getCompiler(_backend,+ compilerType,+ compilationPlatform,+ _compilerOptionSupportHelper->getOptionSupportCache());localProperties[ov::intel_npu::compiler_type.name()] = compilerType;if (!compilationPlatform.empty()) {@@ -350,7 +355,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<}OV_ITT_TASK_CHAIN(PLUGIN_COMPILE_MODEL, itt::domains::NPUPlugin, "Plugin::compile_model", "fork_local_config");- FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties, compiler.get());+ FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties);localConfig.update({{ov::intel_npu::compiler_version.name(), std::to_string(compiler->get_version())}});auto updateBatchMode = [&](ov::intel_npu::BatchMode mode) {@@ -707,14 +712,17 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&_backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());CompilerAdapterFactory factory;- auto compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);+ auto compiler = factory.getCompiler(_backend,+ compilerType,+ compilationPlatform,+ _compilerOptionSupportHelper->getOptionSupportCache());localProperties[ov::intel_npu::compiler_type.name()] = compilerType;if (!compilationPlatform.empty()) {localProperties[ov::intel_npu::platform.name()] = compilationPlatform;}- FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties, compiler.get());+ FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties);ov::SupportedOpsMap supportedOpsMap;try {supportedOpsMap = compiler->query(model->clone(), localConfig);diff --git a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cppindex 49ecd5abf08..5ad847a3220 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp@@ -10,6 +10,7 @@#include <utility>#include <vector>+#include "compiler_option_support_helper.hpp"#include "intel_npu/common/compiler_adapter_factory.hpp"#include "intel_npu/common/device_helpers.hpp"#include "intel_npu/config/options.hpp"@@ -52,36 +53,17 @@ inline void logCpuPinningDeprecationWarning(intel_npu::Logger& logger) {}void filterPropertiesByCompilerSupport(intel_npu::FilteredConfig& config,- const intel_npu::ICompilerAdapter* compiler,+ ov::intel_npu::CompilerType compilerType,+ intel_npu::CompilerOptionSupportHelper& optionSupportHelper,const ov::SoPtr<intel_npu::IEngineBackend>& backend,const intel_npu::Logger& logger) {using namespace intel_npu;- OPENVINO_ASSERT(compiler != nullptr, "Compiler must be present to filter properties by compiler support");-- const auto& supportedOptions = compiler->get_supported_options();- logger.debug("Compiler supported options list (%zu): ", supportedOptions.size());- for (const auto& str : supportedOptions) {- logger.debug(" %s ", str.c_str());- }config.walkEnables([&](const std::string& key) {- bool isEnabled = false;// Special case for some both configs. Don't need compiler for these Both properties.// Runtime (plugin-only) options are always enabledif (config.getOpt(key).mode() != OptionMode::RunTime && !isSpecialBothProperty(key)) {- if (std::find(supportedOptions.begin(), supportedOptions.end(), key) != supportedOptions.end()) {- isEnabled = true;- } else {- // Not found in the supported options list.- if (compiler != nullptr) {- // Checking if it is a private option?- isEnabled = compiler->is_option_supported(key);- } else {- // Not in the list and not a private option = disabling- isEnabled = false;- }- }-+ bool isEnabled = optionSupportHelper.isOptionSupported(compilerType, key, std::nullopt);if (!isEnabled) {logger.debug("Config option %s not supported! Requirements not met.", key.c_str());} else {@@ -96,7 +78,7 @@ void filterPropertiesByCompilerSupport(intel_npu::FilteredConfig& config,// Special cases// NPU_TURBO which might not be supported by compiler, but driver will still use it// if it exists in config = driver supports it- // if compiler->is_option_suported is false = compiler doesn't support it and gets marked disabled by default logic+ // if compiler->is_option_supported is false = compiler doesn't support it and gets marked disabled by default logic// however, if driver supports it, we still need it (and will skip giving it to compiler) = force-enableif (backend && backend->isCommandQueueExtSupported()) {config.enable(ov::intel_npu::turbo.name(), true);@@ -148,7 +130,8 @@ std::vector<std::string> getAvailableDevicesNames(const ov::SoPtr<intel_npu::IEnreturn backend == nullptr ? std::vector<std::string>() : backend->getDeviceNames();}-bool isCompatibilityCheckSupported(const ov::SoPtr<intel_npu::IEngineBackend>& backend) {+bool isCompatibilityCheckSupported(const ov::SoPtr<intel_npu::IEngineBackend>& backend,+ intel_npu::CompilerOptionSupportHelper& optionSupportHelper) {using namespace intel_npu;if (!backend || !backend->getDevice()) {@@ -160,19 +143,19 @@ bool isCompatibilityCheckSupported(const ov::SoPtr<intel_npu::IEngineBackend>& breturn true;}- // Fallback to plugin compiler if the driver does not expose compatibility check API.- CompilerAdapterFactory compilerFactory;- auto compilerType = ov::intel_npu::CompilerType::PLUGIN;+ // Fallback to plugin compiler support check routed through the option support helper.try {- auto tempCompiler = compilerFactory.getCompiler(backend, compilerType, std::string_view{});- return tempCompiler->is_option_supported(ov::compatibility_check.name());+ return optionSupportHelper.isOptionSupported(ov::intel_npu::CompilerType::PLUGIN,+ ov::compatibility_check.name(),+ std::nullopt);} catch (...) {return false;}}ov::CompatibilityCheck validateCompatibilityDescriptor(const ov::SoPtr<intel_npu::IEngineBackend>& backend,- const ov::AnyMap& arguments) {+ const ov::AnyMap& arguments,+ intel_npu::CompilerOptionSupportHelper& optionSupportHelper) {using namespace intel_npu;if (arguments.empty() || arguments.find(ov::runtime_requirements.name()) == arguments.end()) {@@ -209,15 +192,12 @@ ov::CompatibilityCheck validateCompatibilityDescriptor(const ov::SoPtr<intel_npureturn result ? ov::CompatibilityCheck::SUPPORTED : ov::CompatibilityCheck::UNSUPPORTED;}- // fallback on compiler in plugin if driver does not support compatibility check- CompilerAdapterFactory factory;- auto compilerType = ov::intel_npu::CompilerType::PLUGIN;+ // Fallback routed through the option support helper.try {- auto compiler = factory.getCompiler(backend, compilerType, std::string_view{});-- auto result =- compiler->is_option_supported(ov::compatibility_check.name(), std::make_optional(compatibilityDescriptor));- return result ? ov::CompatibilityCheck::SUPPORTED : ov::CompatibilityCheck::UNSUPPORTED;+ const bool supported = optionSupportHelper.isOptionSupported(ov::intel_npu::CompilerType::PLUGIN,+ ov::compatibility_check.name(),+ std::make_optional(compatibilityDescriptor));+ return supported ? ov::CompatibilityCheck::SUPPORTED : ov::CompatibilityCheck::UNSUPPORTED;} catch (...) {return ov::CompatibilityCheck::NOT_APPLICABLE;}@@ -229,9 +209,11 @@ namespace intel_npu {PluginPropertyManager::PluginPropertyManager(const FilteredConfig& config,const ov::SoPtr<IEngineBackend>& backend,+ const std::shared_ptr<CompilerOptionSupportHelper>& optionSupportHelper,Logger& logger): _config(config),_backend(backend),+ _compilerOptionSupportHelper(optionSupportHelper),_logger(logger) {registerProperties();}@@ -241,6 +223,7 @@ PluginPropertyManager::PluginPropertyManager(const PluginPropertyManager& other)std::lock_guard<std::mutex> lock(other._mutex);return CopyState{other._config,other._backend,+ other._compilerOptionSupportHelper,other._logger,other._currentlyUsedCompiler,other._compilerForCompatibilityCheck,@@ -253,6 +236,7 @@ PluginPropertyManager::PluginPropertyManager(const PluginPropertyManager& other)PluginPropertyManager::PluginPropertyManager(CopyState&& state): _config(std::move(state.config)),_backend(std::move(state.backend)),+ _compilerOptionSupportHelper(std::move(state.optionSupportHelper)),_logger(state.logger),_currentlyUsedCompiler(state.currentlyUsedCompiler),_compilerForCompatibilityCheck(state._compilerForCompatibilityCheck),@@ -477,13 +461,14 @@ void PluginPropertyManager::registerProperties() const {});// clang-format on- try_register_property_with_custom_function_and_args(_properties,- ov::compatibility_check.name(),- _compatibilityCheckFiltered && _compatibilityCheckSupported,- true,- [this](const Config&, const ov::AnyMap& arguments) {- return validateCompatibilityDescriptor(_backend, arguments);- });+ try_register_property_with_custom_function_and_args(+ _properties,+ ov::compatibility_check.name(),+ _compatibilityCheckFiltered && _compatibilityCheckSupported,+ true,+ [this](const Config&, const ov::AnyMap& arguments) {+ return validateCompatibilityDescriptor(_backend, arguments, *_compilerOptionSupportHelper);+ });for (auto& property : _properties) {if (property.second.isPublic) {@@ -497,7 +482,7 @@ void PluginPropertyManager::initializeCompatibilityCheckSupportIfNeeded() constreturn;}- _compatibilityCheckSupported = isCompatibilityCheckSupported(_backend);+ _compatibilityCheckSupported = isCompatibilityCheckSupported(_backend, *_compilerOptionSupportHelper);_compatibilityCheckFiltered = true;const auto compatibilityCheckName = std::string(ov::compatibility_check.name());@@ -505,13 +490,14 @@ void PluginPropertyManager::initializeCompatibilityCheckSupportIfNeeded() const// Keep only one descriptor for this property and update it after the one-time probe._properties.erase(compatibilityCheckName);- try_register_property_with_custom_function_and_args(_properties,- compatibilityCheckName,- _compatibilityCheckSupported,- true,- [this](const Config&, const ov::AnyMap& arguments) {- return validateCompatibilityDescriptor(_backend, arguments);- });+ try_register_property_with_custom_function_and_args(+ _properties,+ compatibilityCheckName,+ _compatibilityCheckSupported,+ true,+ [this](const Config&, const ov::AnyMap& arguments) {+ return validateCompatibilityDescriptor(_backend, arguments, *_compilerOptionSupportHelper);+ });// Update supported_properties incrementally for compatibility_check only._supportedProperties.erase(@@ -590,13 +576,16 @@ void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {// Create a compiler to get the type and fetch version and supported options if neededCompilerAdapterFactory factory;- compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);+ compiler = factory.getCompiler(_backend,+ compilerType,+ compilationPlatform,+ _compilerOptionSupportHelper->getOptionSupportCache());if (!(_compilerConfigsFilteredByCompiler && compilerType == _currentlyUsedCompiler &&compilationPlatform == _currentlyUsedPlatform)) {// In case properties are not initialized or the compiler/platform was changed since last call -// filter out options again- filterPropertiesByCompilerSupport(_config, compiler.get(), _backend, _logger);+ filterPropertiesByCompilerSupport(_config, compilerType, *_compilerOptionSupportHelper, _backend, _logger);// reset properties for the new optionsregisterProperties();@@ -611,16 +600,20 @@ void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {for (auto&& value : properties) {if (_properties.find(value.first) == _properties.end()) {// property doesn't exist - checking as internal now- if (compiler != nullptr) {- if (compiler->is_option_supported(value.first)) {- // if compiler reports it supported > registering as internal- _config.addOrUpdateInternal(value.first, value.second.as<std::string>());- } else {- OPENVINO_THROW("Unsupported configuration key: ", value.first);- }- } else {+ bool isSupported = false;+ try {+ isSupported =+ _compilerOptionSupportHelper->isOptionSupported(_currentlyUsedCompiler, value.first, std::nullopt);+ } catch (...) {+ // ignore any exceptions from the compiler and treat the property as unsupported+ isSupported = false;+ }+ if (!isSupported) {OPENVINO_THROW("Unsupported configuration key: ", value.first);}++ // if compiler reports it supported > registering as internal+ _config.addOrUpdateInternal(value.first, value.second.as<std::string>());} else {if (_properties[value.first].mutability == ov::PropertyMutability::RO) {OPENVINO_THROW("READ-ONLY configuration key: ", value.first);@@ -635,7 +628,6 @@ void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {if (!cfgs_to_set.empty()) {_config.update(cfgs_to_set);}-if (!special_cfgs_to_set.empty()) {_config.updateAny(special_cfgs_to_set);}@@ -692,7 +684,10 @@ ov::Any PluginPropertyManager::getProperty(const std::string& name, const ov::An// Create a compiler to get the type and fetch version and supported options if neededCompilerAdapterFactory factory;try {- compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);+ compiler = factory.getCompiler(_backend,+ compilerType,+ compilationPlatform,+ _compilerOptionSupportHelper->getOptionSupportCache());} catch (const std::exception& ex) {if (_config.hasOpt(name) && _config.getOpt(name).mode() == OptionMode::CompileTime) {OPENVINO_THROW("Failed to create compiler for getting property ", name, " with error: ", ex.what());@@ -708,7 +703,7 @@ ov::Any PluginPropertyManager::getProperty(const std::string& name, const ov::AncompilationPlatform == _currentlyUsedPlatform)) {// In case properties are not initialized or the compiler/platform was changed since last call -// filter out options again- filterPropertiesByCompilerSupport(_config, compiler.get(), _backend, _logger);+ filterPropertiesByCompilerSupport(_config, compilerType, *_compilerOptionSupportHelper, _backend, _logger);// reset properties for the new optionsregisterProperties();@@ -788,7 +783,10 @@ bool PluginPropertyManager::isPropertySupported(const std::string& name, const o// Create a compiler to get the type and fetch version and supported options if neededCompilerAdapterFactory factory;try {- compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);+ compiler = factory.getCompiler(_backend,+ compilerType,+ compilationPlatform,+ _compilerOptionSupportHelper->getOptionSupportCache());} catch (const std::exception& ex) {if (_config.hasOpt(name) && _config.getOpt(name).mode() == OptionMode::CompileTime) {return false;@@ -804,7 +802,7 @@ bool PluginPropertyManager::isPropertySupported(const std::string& name, const ocompilationPlatform == _currentlyUsedPlatform)) {// In case properties are not initialized or the compiler/platform was changed since last call -// filter out options again- filterPropertiesByCompilerSupport(_config, compiler.get(), _backend, _logger);+ filterPropertiesByCompilerSupport(_config, compilerType, *_compilerOptionSupportHelper, _backend, _logger);// reset properties for the new optionsregisterProperties();@@ -872,8 +870,7 @@ FilteredConfig PluginPropertyManager::getConfigWithCompilerPropertiesDisabled(coreturn std::move(updatedConfig);}-FilteredConfig PluginPropertyManager::getConfigForSpecificCompiler(const ov::AnyMap& properties,- const ICompilerAdapter* compiler) const {+FilteredConfig PluginPropertyManager::getConfigForSpecificCompiler(const ov::AnyMap& properties) const {auto [updatedConfig, compilerConfigsFilteredByCompiler, currentlyUsedCompiler, currentlyUsedPlatform, logger] =[&]() {std::lock_guard<std::mutex> lock(_mutex);@@ -893,24 +890,25 @@ FilteredConfig PluginPropertyManager::getConfigForSpecificCompiler(const ov::Anystd::optional<ov::intel_npu::CompilerType> propertiesCompilerType = std::nullopt;std::optional<std::string> propertiesPlatform = std::nullopt;- if (compilerConfigsFilteredByCompiler) {- auto compilerType = pluginProperties.find(ov::intel_npu::compiler_type.name());- if (compilerType != pluginProperties.end()) {- propertiesCompilerType = compilerType->second.as<ov::intel_npu::CompilerType>();- }+ auto compilerType = pluginProperties.find(ov::intel_npu::compiler_type.name());+ if (compilerType != pluginProperties.end()) {+ propertiesCompilerType = compilerType->second.as<ov::intel_npu::CompilerType>();}auto platform = pluginProperties.find(ov::intel_npu::platform.name());if (platform != pluginProperties.end()) {propertiesPlatform = platform->second.as<std::string>();}- // filter out unsupported options- if (!(compilerConfigsFilteredByCompiler &&- propertiesCompilerType.value_or(currentlyUsedCompiler) == currentlyUsedCompiler &&+ const auto effectiveCompilerType = propertiesCompilerType.value_or(currentlyUsedCompiler);+ if (!(compilerConfigsFilteredByCompiler && effectiveCompilerType == currentlyUsedCompiler &&propertiesPlatform.value_or(currentlyUsedPlatform) == currentlyUsedPlatform)) {// In case the compiler properties are not initialized or the compiler/platform was changed since last call -// filter out options again- filterPropertiesByCompilerSupport(updatedConfig, compiler, _backend, logger);+ filterPropertiesByCompilerSupport(updatedConfig,+ effectiveCompilerType,+ *_compilerOptionSupportHelper,+ _backend,+ logger);}const std::map<std::string, std::string> rawConfig = any_copy(pluginProperties);@@ -919,7 +917,14 @@ FilteredConfig PluginPropertyManager::getConfigForSpecificCompiler(const ov::Anyfor (const auto& [key, value] : rawConfig) {if (!updatedConfig.hasOpt(key)) {// not a known config key- if (!compiler->is_option_supported(key)) {+ bool isSupported = false;+ try {+ isSupported = _compilerOptionSupportHelper->isOptionSupported(effectiveCompilerType, key, std::nullopt);+ } catch (...) {+ // ignore any exceptions from the compiler and treat the property as unsupported+ isSupported = false;+ }+ if (!isSupported) {OPENVINO_THROW("[ NOT_FOUND ] Option '", key, "' is not supported for current configuration");}updatedConfig.addOrUpdateInternal(key, value);diff --git a/src/plugins/intel_npu/tests/functional/CMakeLists.txt b/src/plugins/intel_npu/tests/functional/CMakeLists.txtindex a0ec90f6881..3d486717ad1 100644--- a/src/plugins/intel_npu/tests/functional/CMakeLists.txt+++ b/src/plugins/intel_npu/tests/functional/CMakeLists.txt@@ -43,6 +43,7 @@ ov_add_test_target("${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp""${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp""${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/metadata.cpp"+ "${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp""${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp""${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/remote_context.cpp""${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/transformations.cpp"diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_compiler_option_support_helper.cpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_compiler_option_support_helper.cppnew file mode 100644index 00000000000..679a57decaa--- /dev/null+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_compiler_option_support_helper.cpp@@ -0,0 +1,400 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include <gtest/gtest.h>++#include <functional>+#include <mutex>+#include <string>+#include <thread>+#include <vector>++#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"+#include "compiler_option_support_helper.hpp"+#include "functional_test_utils/ov_plugin_cache.hpp"+#include "intel_npu/common/compiler_adapter_factory.hpp"+#include "intel_npu/common/icompiler_adapter.hpp"+#include "intel_npu/common/npu.hpp"+#include "openvino/core/any.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"+#include "zero_backend.hpp"++namespace ov {+namespace test {+namespace behavior {++namespace {+// Log markers emitted once per adapter, when its constructor runs (see driver_compiler_adapter.cpp /+// plugin_compiler_adapter.cpp). Used to detect whether a given compiler type had to be (re)initialized.+std::string startMarkerFor(ov::intel_npu::CompilerType compilerType) {+ return compilerType == ov::intel_npu::CompilerType::DRIVER ? "initialize DriverCompilerAdapter start"+ : "initialize PluginCompilerAdapter start";+}++size_t countOccurrences(const std::string& haystack, const std::string& needle) {+ size_t count = 0;+ for (size_t pos = haystack.find(needle); pos != std::string::npos; pos = haystack.find(needle, pos + needle.size())) {+ ++count;+ }+ return count;+}++// Only PluginCompilerAdapter's successful bulk load logs a distinctive, identifiable marker (see+// "VCLCompilerImpl return supported_options" in plugin_compiler_adapter.cpp). DriverCompilerAdapter has+// no equivalent marker on its success path, so "exactly once" bulk-load checks below only apply to PLUGIN.+std::string bulkLoadMarkerFor(ov::intel_npu::CompilerType compilerType) {+ return compilerType == ov::intel_npu::CompilerType::PLUGIN ? "VCLCompilerImpl return supported_options" : "";+}+} // namespace++// Exercises CompilerOptionSupportHelper against a real backend/compiler, complementing the+// backend-agnostic unit tests in tests/unit/npu/compiler_option_support_helper_test.cpp.+class CompilerOptionSupportHelperFunctionalTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<ov::intel_npu::CompilerType> {+protected:+ ov::SoPtr<::intel_npu::IEngineBackend> backend;+ std::unique_ptr<::intel_npu::CompilerOptionSupportHelper> helper;+ ov::intel_npu::CompilerType compilerType;++ std::string targetDevice;++ void SetUp() override {+ targetDevice = ov::test::utils::DEVICE_NPU;++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();++ compilerType = GetParam();+ backend = ov::SoPtr<::intel_npu::IEngineBackend>(std::make_shared<::intel_npu::ZeroEngineBackend>());+ helper =+ std::make_unique<::intel_npu::CompilerOptionSupportHelper>(backend, ::intel_npu::CompilerAdapterFactory());+ }++ void TearDown() override {+ OVPluginTestBase::TearDown();+ }++public:+ static std::string getTestCaseName(const testing::TestParamInfo<ov::intel_npu::CompilerType>& obj) {+ std::ostringstream result;+ result << "compilerType=" << obj.param;+ return result.str();+ }+};++TEST_P(CompilerOptionSupportHelperFunctionalTests, RejectsCompilerTypeOutsideSupportedList) {+ EXPECT_THROW(helper->isOptionSupported(ov::intel_npu::CompilerType::PREFER_PLUGIN, "ANY_OPTION"), ov::Exception);+}++// Properties from DriverCompilerAdapter's legacy fallback list marked as supported since compiler+// version 0.0 (see "_supportedPropertiesWithVersions" in driver_compiler_adapter.cpp). These are safe,+// version-independent choices to exercise real (uncached) compiler lookups for both compiler types.+const std::vector<std::string> knownSupportedOptions = {ov::enable_profiling.name(),+ ov::hint::performance_mode.name(),+ ov::log::level.name(),+ ov::intel_npu::platform.name()};++TEST_P(CompilerOptionSupportHelperFunctionalTests, GetsSupportFromCompilerWhenNotCached) {+ std::string logs;+ std::mutex logsMutex;++ std::function<void(std::string_view)> logCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logsMutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard logCallbackGuard(logCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::INFO);++ for (const auto& optionName : knownSupportedOptions) {+ bool isSupported = false;+ OV_ASSERT_NO_THROW(isSupported = helper->isOptionSupported(compilerType, optionName));+ EXPECT_TRUE(isSupported) << "Option: " << optionName;+ }+ }++ // The cache was empty for these options, so the real compiler adapter must have been created.+ ASSERT_NE(logs.find(startMarkerFor(compilerType)), std::string::npos);+}++TEST_P(CompilerOptionSupportHelperFunctionalTests, CachesResultAfterRealCompilerLookup) {+ for (const auto& optionName : knownSupportedOptions) {+ OV_ASSERT_NO_THROW(helper->isOptionSupported(compilerType, optionName));+ }++ std::string logs;+ std::mutex logsMutex;+ std::function<void(std::string_view)> logCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logsMutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard logCallbackGuard(logCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::INFO);++ // Second lookup for every option: each must be served from the cache populated by the+ // previous real compiler lookup, without creating the adapter again.+ for (const auto& optionName : knownSupportedOptions) {+ bool isSupported = false;+ OV_ASSERT_NO_THROW(isSupported = helper->isOptionSupported(compilerType, optionName));+ EXPECT_TRUE(isSupported) << "Option: " << optionName;+ }+ }++ ASSERT_EQ(logs.find(startMarkerFor(compilerType)), std::string::npos);+}++TEST_P(CompilerOptionSupportHelperFunctionalTests, AddsNewOptionToCacheAndReturnsItWithoutCompilerLookup) {+ const auto cacheKey = static_cast<::intel_npu::OptionSupportCache::CacheKey>(compilerType);+ helper->getOptionSupportCache()->addSupportedOption(cacheKey, "MANUALLY_CACHED_OPTION", true);++ std::string logs;+ std::mutex logsMutex;+ std::function<void(std::string_view)> logCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logsMutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ bool isSupported = false;+ {+ utils::LogCallbackGuard logCallbackGuard(logCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::INFO);++ OV_ASSERT_NO_THROW(isSupported = helper->isOptionSupported(compilerType, "MANUALLY_CACHED_OPTION"));+ }++ EXPECT_TRUE(isSupported);+ // The answer came straight from the cache entry added above; no adapter should have been created.+ ASSERT_EQ(logs.find(startMarkerFor(compilerType)), std::string::npos);+}++// "DUMMY_OPTION_NOT_IN_BULK_LIST" is not part of any real compiler's bulk "get_supported_options()" dump,+// so unlike "knownSupportedOptions" above, the first lookup cannot be answered from the bulk-populated+// cache and must fall through to the individual "is_option_supported" probe on the real compiler adapter.+TEST_P(CompilerOptionSupportHelperFunctionalTests, ProbesCompilerDirectlyForOptionOutsideBulkList) {+ const std::string unlistedOption = "DUMMY_OPTION_NOT_IN_BULK_LIST";++ std::string firstCallLogs;+ std::mutex firstCallLogsMutex;+ std::function<void(std::string_view)> firstCallLogCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(firstCallLogsMutex);+ firstCallLogs.append(msg);+ firstCallLogs.push_back('\n');+ };++ bool firstResult = false;+ {+ utils::LogCallbackGuard logCallbackGuard(firstCallLogCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::INFO);++ OV_ASSERT_NO_THROW(firstResult = helper->isOptionSupported(compilerType, unlistedOption));+ }+ // The bulk list did not contain the option, so the individual probe must have created the adapter.+ ASSERT_NE(firstCallLogs.find(startMarkerFor(compilerType)), std::string::npos);++ std::string secondCallLogs;+ std::mutex secondCallLogsMutex;+ std::function<void(std::string_view)> secondCallLogCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(secondCallLogsMutex);+ secondCallLogs.append(msg);+ secondCallLogs.push_back('\n');+ };++ bool secondResult = false;+ {+ utils::LogCallbackGuard logCallbackGuard(secondCallLogCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::INFO);++ OV_ASSERT_NO_THROW(secondResult = helper->isOptionSupported(compilerType, unlistedOption));+ }+ EXPECT_EQ(firstResult, secondResult);+ // The individual probe above populated the shared cache, so the repeat lookup must not recreate+ // the adapter.+ ASSERT_EQ(secondCallLogs.find(startMarkerFor(compilerType)), std::string::npos);+}++// Cross-checks BATCH_MODE support: first against a freshly created compiler adapter directly (ground+// truth, bypassing the helper's cache), then through CompilerOptionSupportHelper, and asserts both agree.+// Finally, repeats the helper lookup to confirm the second call is served from cache.+TEST_P(CompilerOptionSupportHelperFunctionalTests, BatchModeSupportMatchesDirectCompilerProbe) {+ const std::string batchModeOption = ov::intel_npu::batch_mode.name();++ ::intel_npu::CompilerAdapterFactory factory;+ auto adapterCompilerType = compilerType;+ std::unique_ptr<::intel_npu::ICompilerAdapter> compilerAdapter;+ OV_ASSERT_NO_THROW(compilerAdapter = factory.getCompiler(backend, adapterCompilerType, ""));++ bool supportedByCompiler = false;+ OV_ASSERT_NO_THROW(supportedByCompiler = compilerAdapter->is_option_supported(batchModeOption));++ bool supportedByHelper = false;+ OV_ASSERT_NO_THROW(supportedByHelper = helper->isOptionSupported(compilerType, batchModeOption));++ EXPECT_EQ(supportedByCompiler, supportedByHelper);++ std::string logs;+ std::mutex logsMutex;+ std::function<void(std::string_view)> logCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logsMutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ bool cachedResult = false;+ {+ utils::LogCallbackGuard logCallbackGuard(logCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::INFO);++ // Repeat lookup for the same option: it must be served from the cache populated above,+ // without recreating the adapter.+ OV_ASSERT_NO_THROW(cachedResult = helper->isOptionSupported(compilerType, batchModeOption));+ }++ EXPECT_EQ(supportedByHelper, cachedResult);+ ASSERT_EQ(logs.find(startMarkerFor(compilerType)), std::string::npos);+}++// Stresses the shared, per-compiler-type once_flag/cache guard in CompilerOptionSupportHelper::isOptionSupported+// with concurrent lookups for the same key. Bulk loading ("get_supported_options") must still run exactly once.+TEST_P(CompilerOptionSupportHelperFunctionalTests, ConcurrentLookupsForSameKeyLoadOptionsOnceWithoutRaces) {+ constexpr int kThreadCount = 8;+ std::vector<std::thread> threads;+ std::vector<bool> results(kThreadCount, false);+ std::vector<std::exception_ptr> failures(kThreadCount);++ std::string logs;+ std::mutex logsMutex;+ std::function<void(std::string_view)> logCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logsMutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard logCallbackGuard(logCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::DEBUG);++ for (int i = 0; i < kThreadCount; ++i) {+ threads.emplace_back([&, i]() {+ try {+ // Mixing options already known to be part of the bulk list, queried concurrently+ // for the same compiler type/key.+ const auto& optionName = knownSupportedOptions[i % knownSupportedOptions.size()];+ results[i] = helper->isOptionSupported(compilerType, optionName);+ } catch (...) {+ failures[i] = std::current_exception();+ }+ });+ }+ for (auto& thread : threads) {+ thread.join();+ }+ }++ for (int i = 0; i < kThreadCount; ++i) {+ ASSERT_FALSE(failures[i]) << "Thread " << i << " threw an exception";+ EXPECT_TRUE(results[i]) << "Thread " << i;+ }++ const auto marker = bulkLoadMarkerFor(compilerType);+ if (!marker.empty()) {+ // Regardless of how many threads raced past the cache-miss check, the expensive bulk+ // "get_supported_options" retrieval, guarded by the per-key once_flag, must run exactly once.+ EXPECT_EQ(countOccurrences(logs, marker), 1u);+ }+}++INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,+ CompilerOptionSupportHelperFunctionalTests,+ ::testing::Values(ov::intel_npu::CompilerType::DRIVER, ov::intel_npu::CompilerType::PLUGIN),+ CompilerOptionSupportHelperFunctionalTests::getTestCaseName);++// Single helper instance shared by concurrent lookups against two independent compiler-type keys+// (DRIVER and PLUGIN), to verify the once_flag/cache map has no cross-key races or deadlocks.+class CompilerOptionSupportHelperConcurrencyTests : public ov::test::behavior::OVPluginTestBase {+protected:+ ov::SoPtr<::intel_npu::IEngineBackend> backend;+ std::unique_ptr<::intel_npu::CompilerOptionSupportHelper> helper;++ std::string targetDevice;++ void SetUp() override {+ targetDevice = ov::test::utils::DEVICE_NPU;++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();++ backend = ov::SoPtr<::intel_npu::IEngineBackend>(std::make_shared<::intel_npu::ZeroEngineBackend>());+ helper =+ std::make_unique<::intel_npu::CompilerOptionSupportHelper>(backend, ::intel_npu::CompilerAdapterFactory());+ }++ void TearDown() override {+ OVPluginTestBase::TearDown();+ }+};++TEST_F(CompilerOptionSupportHelperConcurrencyTests,+ ConcurrentLookupsForDifferentKeysLoadOptionsOncePerKeyWithoutDeadlock) {+ constexpr int kThreadsPerType = 4;+ std::vector<std::thread> threads;+ std::vector<bool> results(kThreadsPerType * 2, false);+ std::vector<std::exception_ptr> failures(kThreadsPerType * 2);++ std::string logs;+ std::mutex logsMutex;+ std::function<void(std::string_view)> logCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logsMutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard logCallbackGuard(logCb);+ utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::DEBUG);++ for (int i = 0; i < kThreadsPerType; ++i) {+ threads.emplace_back([&, i]() {+ try {+ results[i] = helper->isOptionSupported(ov::intel_npu::CompilerType::DRIVER,+ knownSupportedOptions[i % knownSupportedOptions.size()]);+ } catch (...) {+ failures[i] = std::current_exception();+ }+ });+ threads.emplace_back([&, i]() {+ const int idx = kThreadsPerType + i;+ try {+ results[idx] = helper->isOptionSupported(ov::intel_npu::CompilerType::PLUGIN,+ knownSupportedOptions[i % knownSupportedOptions.size()]);+ } catch (...) {+ failures[idx] = std::current_exception();+ }+ });+ }+ for (auto& thread : threads) {+ thread.join();+ }+ }++ for (size_t i = 0; i < results.size(); ++i) {+ ASSERT_FALSE(failures[i]) << "Thread " << i << " threw an exception";+ EXPECT_TRUE(results[i]) << "Thread " << i;+ }++ // Concurrent traffic on the DRIVER key must not block or interfere with the independent+ // once_flag/cache entry for the PLUGIN key (and vice versa): PLUGIN must still bulk-load exactly once.+ EXPECT_EQ(countOccurrences(logs, bulkLoadMarkerFor(ov::intel_npu::CompilerType::PLUGIN)), 1u);+}++} // namespace behavior+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cppindex 3ac8ea79bc7..f6e6d529fcb 100644--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp@@ -2,13 +2,14 @@// SPDX-License-Identifier: Apache-2.0//+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <algorithm>#include <array>#include <cstddef>#include <exception>-#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>#include <memory>#include <random>#include <thread>@@ -16,6 +17,7 @@#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "compiler_option_support_helper.hpp"#include "functional_test_utils/ov_plugin_cache.hpp"#include "intel_npu/common/compiler_adapter_factory.hpp"#include "intel_npu/common/filtered_config.hpp"@@ -179,8 +181,11 @@ public:}}- propertiesManager =- std::make_unique<PluginPropertyManager>(npu_config, backend, ::intel_npu::Logger::global());+ propertiesManager = std::make_unique<PluginPropertyManager>(+ npu_config,+ backend,+ std::make_shared<::intel_npu::CompilerOptionSupportHelper>(backend, CompilerAdapterFactory()),+ ::intel_npu::Logger::global());}void TearDown() override {diff --git a/src/plugins/intel_npu/tests/unit/CMakeLists.txt b/src/plugins/intel_npu/tests/unit/CMakeLists.txtindex f15da2723d6..e12db008469 100644--- a/src/plugins/intel_npu/tests/unit/CMakeLists.txt+++ b/src/plugins/intel_npu/tests/unit/CMakeLists.txt@@ -45,6 +45,7 @@ ov_add_test_target(${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/executor.cpp${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/metadata.cpp${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/blob_format_importers.cpp+ ${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp# npuw core${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/flux2_compiled_model.cpp@@ -154,6 +155,8 @@ install(TARGETS ${TARGET_NAME}target_sources(${TARGET_NAME} PRIVATE${CMAKE_CURRENT_SOURCE_DIR}/npu/executor_test.cpp+ ${CMAKE_CURRENT_SOURCE_DIR}/npu/compiler_option_support_helper_test.cpp+ ${CMAKE_CURRENT_SOURCE_DIR}/npu/option_support_cache_test.cpp${CMAKE_CURRENT_SOURCE_DIR}/npuw/llm_compiled_model_graph_options_test.cpp${CMAKE_CURRENT_SOURCE_DIR}/npuw/flux2_compiled_model_test.cpp${CMAKE_CURRENT_SOURCE_DIR}/npuw/gqa_compiled_model_test.cppdiff --git a/src/plugins/intel_npu/tests/unit/npu/compiler_option_support_helper_test.cpp b/src/plugins/intel_npu/tests/unit/npu/compiler_option_support_helper_test.cppnew file mode 100644index 00000000000..6e4b3e5d995--- /dev/null+++ b/src/plugins/intel_npu/tests/unit/npu/compiler_option_support_helper_test.cpp@@ -0,0 +1,102 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "compiler_option_support_helper.hpp"++#include <gtest/gtest.h>++#include "openvino/core/except.hpp"++namespace {++using CompilerType = ov::intel_npu::CompilerType;++// Minimal IEngineBackend double: exercises the real CompilerAdapterFactory::getCompiler() logic+// (no device available) without requiring an actual NPU driver/compiler in the test environment.+class MockEngineBackendNoDevice : public ::intel_npu::IEngineBackend {+public:+ const std::shared_ptr<::intel_npu::IDevice> getDevice() const override {+ return nullptr;+ }+ const std::string getName() const override {+ return "MOCK";+ }+ bool isCommandQueueExtSupported() const override {+ return false;+ }+ bool isLUIDExtSupported() const override {+ return false;+ }+ bool isContextExtSupported() const override {+ return false;+ }+ void updateInfo(const ov::AnyMap&) override {}+};++TEST(CompilerOptionSupportHelperTests, ReturnsCachedSupportedOptionWithoutBackend) {+ ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());+ const auto key = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::PLUGIN);+ helper.getOptionSupportCache()->addSupportedOption(key, "CACHED_OPTION", true);++ EXPECT_TRUE(helper.isOptionSupported(CompilerType::PLUGIN, "CACHED_OPTION"));+}++TEST(CompilerOptionSupportHelperTests, ReturnsCachedUnsupportedOptionWithoutBackend) {+ ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());+ const auto key = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::DRIVER);+ helper.getOptionSupportCache()->addSupportedOption(key, "CACHED_OPTION", false);++ EXPECT_FALSE(helper.isOptionSupported(CompilerType::DRIVER, "CACHED_OPTION"));+}++TEST(CompilerOptionSupportHelperTests, KeepsCompilerTypeCacheEntriesIndependent) {+ ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());+ const auto pluginKey = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::PLUGIN);+ const auto driverKey = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::DRIVER);+ helper.getOptionSupportCache()->addSupportedOption(pluginKey, "SHARED_OPTION", true);+ helper.getOptionSupportCache()->addSupportedOption(driverKey, "SHARED_OPTION", false);++ EXPECT_TRUE(helper.isOptionSupported(CompilerType::PLUGIN, "SHARED_OPTION"));+ EXPECT_FALSE(helper.isOptionSupported(CompilerType::DRIVER, "SHARED_OPTION"));+}++TEST(CompilerOptionSupportHelperTests, RejectsPreferPluginBeforeCompilerLookup) {+ ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());++ EXPECT_THROW(helper.isOptionSupported(CompilerType::PREFER_PLUGIN, "ANY_OPTION"), ov::Exception);+}++TEST(CompilerOptionSupportHelperTests, RejectsCompilerTypeOutsideSupportedList) {+ ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());++ EXPECT_THROW(helper.isOptionSupported(static_cast<CompilerType>(999), "ANY_OPTION"), ov::Exception);+}++TEST(CompilerOptionSupportHelperTests, ExposesSharedOptionSupportCache) {+ ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());++ ASSERT_NE(helper.getOptionSupportCache(), nullptr);+}++TEST(CompilerOptionSupportHelperTests, DriverLookupWithoutDeviceThrows) {+ auto backend = std::make_shared<MockEngineBackendNoDevice>();+ ov::SoPtr<::intel_npu::IEngineBackend> backendPtr(backend);+ ::intel_npu::CompilerOptionSupportHelper helper(backendPtr, ::intel_npu::CompilerAdapterFactory());++ EXPECT_THROW(helper.isOptionSupported(CompilerType::DRIVER, "ANY_OPTION"), ov::Exception);+}++TEST(CompilerOptionSupportHelperTests, OptionValueBypassesCacheAndReachesCompilerLookup) {+ auto backend = std::make_shared<MockEngineBackendNoDevice>();+ ov::SoPtr<::intel_npu::IEngineBackend> backendPtr(backend);+ ::intel_npu::CompilerOptionSupportHelper helper(backendPtr, ::intel_npu::CompilerAdapterFactory());+ const auto key = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::DRIVER);+ helper.getOptionSupportCache()->addSupportedOption(key, "ANY_OPTION", true);++ // Even though "ANY_OPTION" is cached as supported, providing a concrete value must skip the+ // cache and fall through to the real compiler lookup, which throws without a device.+ EXPECT_THROW(helper.isOptionSupported(CompilerType::DRIVER, "ANY_OPTION", std::string("1")), ov::Exception);+}++} // namespacediff --git a/src/plugins/intel_npu/tests/unit/npu/option_support_cache_test.cpp b/src/plugins/intel_npu/tests/unit/npu/option_support_cache_test.cppnew file mode 100644index 00000000000..ad4f254d399--- /dev/null+++ b/src/plugins/intel_npu/tests/unit/npu/option_support_cache_test.cpp@@ -0,0 +1,106 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "intel_npu/common/option_support_cache.hpp"++#include <gtest/gtest.h>++#include <optional>+#include <string>+#include <vector>++#include "openvino/core/except.hpp"++namespace {++using CacheKey = ::intel_npu::OptionSupportCache::CacheKey;++constexpr CacheKey kFirstKey = 1u;+constexpr CacheKey kSecondKey = 2u;+constexpr CacheKey kThirdKey = 3u;++TEST(OptionSupportCacheTests, UnknownOptionsAreReportedAsUnsupportedByDefault) {+ ::intel_npu::OptionSupportCache cache;+ EXPECT_FALSE(cache.isOptionSupported(kFirstKey, "CACHE_TEST_UNKNOWN_OPTION").has_value());+ EXPECT_FALSE(cache.isOptionSupported(kSecondKey, "CACHE_TEST_UNKNOWN_OPTION").has_value());+}++TEST(OptionSupportCacheTests, ArbitraryKeysAreSupported) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kThirdKey, "CACHE_TEST_OPT");+ EXPECT_EQ(cache.isOptionSupported(kThirdKey, "CACHE_TEST_OPT"), std::make_optional(true));+}++TEST(OptionSupportCacheTests, AddedOptionIsFound) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_A");+ EXPECT_EQ(cache.isOptionSupported(kFirstKey, "OPT_A"), std::make_optional(true));+ EXPECT_FALSE(cache.isOptionSupported(kSecondKey, "OPT_A").has_value());+}++TEST(OptionSupportCacheTests, SetOptionsAreFound) {+ ::intel_npu::OptionSupportCache cache;+ cache.setSupportedOptions(kSecondKey, {"OPT_X", "OPT_Y"});+ EXPECT_EQ(cache.isOptionSupported(kSecondKey, "OPT_X"), std::make_optional(true));+ EXPECT_EQ(cache.isOptionSupported(kSecondKey, "OPT_Y"), std::make_optional(true));+ EXPECT_FALSE(cache.isOptionSupported(kFirstKey, "OPT_X").has_value());+}++TEST(OptionSupportCacheTests, SetOptionsMergesWithExisting) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_EARLY");+ cache.setSupportedOptions(kFirstKey, {"OPT_BULK"});+ EXPECT_EQ(cache.isOptionSupported(kFirstKey, "OPT_EARLY"), std::make_optional(true));+ EXPECT_EQ(cache.isOptionSupported(kFirstKey, "OPT_BULK"), std::make_optional(true));+}++TEST(OptionSupportCacheTests, DifferentKeysAreIndependent) {+ ::intel_npu::OptionSupportCache cache;+ cache.setSupportedOptions(kFirstKey, {"FIRST_ONLY"});+ cache.setSupportedOptions(kSecondKey, {"SECOND_ONLY"});+ EXPECT_EQ(cache.isOptionSupported(kFirstKey, "FIRST_ONLY"), std::make_optional(true));+ EXPECT_FALSE(cache.isOptionSupported(kFirstKey, "SECOND_ONLY").has_value());+ EXPECT_EQ(cache.isOptionSupported(kSecondKey, "SECOND_ONLY"), std::make_optional(true));+ EXPECT_FALSE(cache.isOptionSupported(kSecondKey, "FIRST_ONLY").has_value());+}++TEST(OptionSupportCacheTests, AddDoesNotCreateDuplicates) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_DUP");+ cache.addSupportedOption(kFirstKey, "OPT_DUP");+ EXPECT_EQ(cache.isOptionSupported(kFirstKey, "OPT_DUP"), std::make_optional(true));+}++TEST(OptionSupportCacheTests, UnsupportedOptionCanBeCachedExplicitly) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_UNSUPPORTED", false);+ EXPECT_EQ(cache.isOptionSupported(kFirstKey, "OPT_UNSUPPORTED"), std::make_optional(false));+}++TEST(OptionSupportCacheTests, RepeatedUnsupportedOptionInsertIsIdempotent) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_UNSUPPORTED", false);+ cache.addSupportedOption(kFirstKey, "OPT_UNSUPPORTED", false);+ EXPECT_EQ(cache.isOptionSupported(kFirstKey, "OPT_UNSUPPORTED"), std::make_optional(false));+}++TEST(OptionSupportCacheTests, ConflictingSupportStateFromTrueToFalseThrows) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_FLIP", true);+ EXPECT_THROW(cache.addSupportedOption(kFirstKey, "OPT_FLIP", false), ov::Exception);+}++TEST(OptionSupportCacheTests, ConflictingSupportStateFromFalseToTrueThrows) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_FLIP", false);+ EXPECT_THROW(cache.addSupportedOption(kFirstKey, "OPT_FLIP", true), ov::Exception);+}++TEST(OptionSupportCacheTests, SetSupportedOptionsConflictsWithExistingUnsupportedState) {+ ::intel_npu::OptionSupportCache cache;+ cache.addSupportedOption(kFirstKey, "OPT_CONFLICT", false);+ EXPECT_THROW(cache.setSupportedOptions(kFirstKey, {"OPT_CONFLICT"}), ov::Exception);+}++} // namespace