Skip to content

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

[NPU] Properties refactoring (#34315)

Bogdan Pereanue04a0cdb7518
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp
index 04df1e9ea63..ebae7615239 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp
@@ -430,7 +430,7 @@ public:
std::vector<ov::PropertyName> getSupportedOptions(bool includePrivate = false) const;
std::string getSupportedAsString(bool includePrivate = false) const;
- details::OptionConcept get(std::string_view key, OptionMode mode = OptionMode::Both) const;
+ details::OptionConcept get(std::string_view key) const;
void walk(std::function<void(const details::OptionConcept&)> cb) const;
private:
@@ -464,7 +464,7 @@ public:
explicit Config(const std::shared_ptr<const OptionsDesc>& desc);
- virtual void update(const ConfigMap& options, OptionMode mode = OptionMode::Both);
+ virtual void update(const ConfigMap& options);
void parseEnvVars();
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
index 9cf98f42795..52741f598db 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
@@ -40,7 +40,7 @@ struct PERFORMANCE_HINT final : OptionBase<PERFORMANCE_HINT, ov::hint::Performan
}
static OptionMode mode() {
- return OptionMode::CompileTime;
+ return OptionMode::Both;
}
static ov::hint::PerformanceMode parse(std::string_view val) {
diff --git a/src/plugins/intel_npu/src/al/src/config/config.cpp b/src/plugins/intel_npu/src/al/src/config/config.cpp
index 58ca92f7df9..a505f3a602f 100644
--- a/src/plugins/intel_npu/src/al/src/config/config.cpp
+++ b/src/plugins/intel_npu/src/al/src/config/config.cpp
@@ -149,7 +149,7 @@ details::OptionValue::~OptionValue() = default;
// OptionsDesc
//
-details::OptionConcept OptionsDesc::get(std::string_view key, OptionMode mode) const {
+details::OptionConcept OptionsDesc::get(std::string_view key) const {
std::string searchKey{key};
const auto itDeprecated = _deprecated.find(std::string(key));
if (itDeprecated != _deprecated.end()) {
@@ -163,18 +163,7 @@ details::OptionConcept OptionsDesc::get(std::string_view key, OptionMode mode) c
key.data(),
"' is not supported for current configuration");
- const auto& desc = itMain->second;
-
- if (mode == OptionMode::RunTime) {
- if (desc.mode() == OptionMode::CompileTime) {
- _log.warning("%s option '%s' was used in %s mode",
- stringifyEnum(desc.mode()).data(),
- key.data(),
- stringifyEnum(mode).data());
- }
- }
-
- return desc;
+ return itMain->second;
}
void OptionsDesc::reset() {
@@ -266,11 +255,11 @@ bool Config::has(std::string key) const {
return _impl.count(key) != 0;
}
-void Config::update(const ConfigMap& options, OptionMode mode) {
+void Config::update(const ConfigMap& options) {
for (const auto& p : options) {
_log.trace("Update option '%s' to value '%s'", p.first.c_str(), p.second.c_str());
- const auto opt = _desc->get(p.first, mode);
+ const auto opt = _desc->get(p.first);
_impl[opt.key().data()] = opt.validateAndParse(p.second);
}
}
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp
index 6da0c3f7335..ee5cda6ea5d 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp
@@ -32,9 +32,8 @@ public:
/**
* @brief Updates the configuration with new options if the key is enabled state
* @param options A map of key-value pairs representing the new configuration options.
- * @param mode Specifies the mode in which the options should be updated (default is `OptionMode::Both`).
*/
- void update(const ConfigMap& options, OptionMode mode = OptionMode::Both) override;
+ void update(const ConfigMap& options) override;
/**
* @brief Checks if a specific option exists in the configuration's descriptorDesc.
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp
index 253f0b05e30..f47f1798534 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp
@@ -53,7 +53,7 @@ public:
virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,
const FilteredConfig& config) const = 0;
virtual uint32_t get_version() const = 0;
- virtual std::vector<std::string> get_supported_options() const = 0;
+ virtual std::optional<std::vector<std::string>> get_supported_options() const = 0;
virtual bool is_option_supported(std::string optName, std::optional<std::string> optValue = std::nullopt) const = 0;
virtual ~ICompilerAdapter() = default;
diff --git a/src/plugins/intel_npu/src/common/src/filtered_config.cpp b/src/plugins/intel_npu/src/common/src/filtered_config.cpp
index f594677868c..0c3f92995d7 100644
--- a/src/plugins/intel_npu/src/common/src/filtered_config.cpp
+++ b/src/plugins/intel_npu/src/common/src/filtered_config.cpp
@@ -24,14 +24,14 @@ bool FilteredConfig::isOptPublic(std::string_view key) const {
}
}
-void FilteredConfig::update(const ConfigMap& options, OptionMode mode) {
+void FilteredConfig::update(const ConfigMap& options) {
auto log = Logger::global().clone("Config");
for (const auto& p : options) {
log.trace("Update option '%s' to value '%s'", p.first.c_str(), p.second.c_str());
if (isAvailable(p.first)) {
- const auto opt = _desc->get(p.first, mode);
+ const auto opt = _desc->get(p.first);
_impl[opt.key().data()] = opt.validateAndParse(p.second);
} else {
OPENVINO_THROW("[ NOT_FOUND ] Option '" + p.first + "' is not supported for current configuration");
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp
index 1cc676acd17..abf2117ce0b 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp
@@ -86,6 +86,10 @@ public:
std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
const std::vector<uint8_t>& network) const;
+ /**
+ * @brief Returns the compiler supported options list
+ * @return false if the API is not supported, true otherwise
+ */
bool get_supported_options(std::vector<char>& options) const;
bool is_option_supported(const std::string& option, std::optional<std::string> optValue = std::nullopt) const;
diff --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.hpp
index a37733d0fb5..5dbe01ca8f7 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
@@ -32,7 +32,7 @@ public:
ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,
const FilteredConfig& config) const override;
- std::vector<std::string> get_supported_options() const override;
+ std::optional<std::vector<std::string>> get_supported_options() const override;
bool is_option_supported(std::string optName, std::optional<std::string> optValue = std::nullopt) const override;
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.hpp
index 322ae6a2058..41a48d7c3a0 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
@@ -33,7 +33,7 @@ public:
ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,
const FilteredConfig& config) const override;
- std::vector<std::string> get_supported_options() const override;
+ std::optional<std::vector<std::string>> get_supported_options() const override;
bool is_option_supported(std::string optName, std::optional<std::string> optValue = std::nullopt) const override;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
index 04abd6de88c..5cd14cd3e3b 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
@@ -49,7 +49,12 @@ public:
void destroyGraph(GraphDescriptor& graphDescriptor);
- std::string getCompilerSupportedOptions() const;
+ /**
+ * @brief Returns the list of compiler options supported by the driver.
+ * @return `std::optional<std::string>` containing the list of supported options if the query is supported,
+ * or `std::nullopt` if the query itself is not supported.
+ */
+ std::optional<std::string> getCompilerSupportedOptions() const;
/**
* @brief Checks whether the specified driver/compiler option is supported by the driver.
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
index e07e6ca6b2f..622d3c8124a 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
@@ -651,32 +651,31 @@ ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model
bool VCLCompilerImpl::get_supported_options(std::vector<char>& options) const {
_logger.debug("get_supported_options start");
- // 1. get size of compiler supported options list
size_t str_size = 0;
try {
THROW_ON_FAIL_FOR_VCL("vclGetCompilerSupportedOptions",
vclGetCompilerSupportedOptions(_compilerHandle, nullptr, &str_size),
_logHandle);
- if (str_size > 0) {
- _logger.debug("obtain list");
- // 2. allocate buffer for it
- options.resize(str_size);
- // 3. populate char list
- THROW_ON_FAIL_FOR_VCL("vclGetCompilerSupportedOptions",
- vclGetCompilerSupportedOptions(_compilerHandle, options.data(), &str_size),
- _logHandle);
-
- _logger.debug("Option list size %d, got option list", str_size);
+ if (str_size == 0) {
+ _logger.debug("Option list size 0!");
return true;
- } else {
- _logger.debug("Option list size 0 - skipping!");
}
+
+ _logger.debug("obtain list");
+ options.resize(str_size);
+ THROW_ON_FAIL_FOR_VCL("vclGetCompilerSupportedOptions",
+ vclGetCompilerSupportedOptions(_compilerHandle, options.data(), &str_size),
+ _logHandle);
+
+ _logger.debug("Option list size %d, got option list", str_size);
+
+ return true;
} catch (const std::exception& e) {
// The API is only supported in new version, just add log here
_logger.debug("Exception in get_supported_options: %s", e.what());
}
- _logger.debug("get_supported_options end, no options found");
+
return false;
}
diff --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.cpp
index a4f4ed4a925..6788803e151 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
@@ -310,11 +310,16 @@ uint32_t DriverCompilerAdapter::get_version() const {
return _zeroInitStruct->getCompilerVersion();
}
-std::vector<std::string> DriverCompilerAdapter::get_supported_options() const {
- std::string compilerOptionsStr;
+std::optional<std::vector<std::string>> DriverCompilerAdapter::get_supported_options() const {
+ std::optional<std::string> compilerOptionsStr;
compilerOptionsStr = _zeGraphExt->getCompilerSupportedOptions();
+
+ if (!compilerOptionsStr.has_value()) {
+ return std::nullopt;
+ }
+
// vectorize string
- std::istringstream suppstream(compilerOptionsStr);
+ std::istringstream suppstream(compilerOptionsStr.value());
std::vector<std::string> compilerOpts;
std::string option;
while (suppstream >> option) {
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
index 8bc5663b628..6bbae970318 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
@@ -687,10 +687,19 @@ std::string serializeConfig(const FilteredConfig& config,
}
};
- // NPU_TURBO is a special option in the sense that by default it is a driver-setting, but certain compilers
- // support and make use of it too If we have turbo in the config string, we check if compiler supports it. If it
- // doesn't support it, we remove it
+ // Options with OptionMode::Both may be used by the plugin even when the compiler does not support them.
+ // Remove them from the config string before sending it to the compiler if they are unsupported.
+
+ // NPU_TURBO is a special option in the sense that by default it is a
+ // driver-setting, but certain compilers support and make use of it too If we have turbo in the config string, we
+ // check if compiler supports it. If it doesn't support it, we remove it
removeOptionIfUnsupported(ov::intel_npu::turbo.name());
+ // LOG_LEVEL must not be sent to the compiler if not supported
+ removeOptionIfUnsupported(ov::log::level.name());
+ // PERFORMANCE_HINT must not be sent to the compiler if not supported
+ removeOptionIfUnsupported(ov::hint::performance_mode.name());
+ // PERF_COUNT must not be sent to the compiler if not supported
+ removeOptionIfUnsupported(ov::enable_profiling.name());
// FINAL step to convert prefixes of remaining params, to ensure backwards compatibility
// From 5.0.0, driver compiler start to use NPU_ prefix, the old version uses VPU_ prefix
diff --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.cpp
index 6e8120b9b27..256669be8c7 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
@@ -352,25 +352,16 @@ uint32_t PluginCompilerAdapter::get_version() const {
return _compiler->get_version();
}
-std::vector<std::string> PluginCompilerAdapter::get_supported_options() const {
- // For VCL, we can return the supported options from compiler
- VCLCompilerImpl* vclCompiler = dynamic_cast<VCLCompilerImpl*>(_compiler.operator->());
- if (vclCompiler == nullptr) {
- // If _compiler cannot be cast to VCLCompilerImpl, it should use the mlir library.
- // PluginCompiler has all the same options as plugin
- // Returing empty string to let the plugin fallback to legacy registration
- _logger.warning("Failed to cast compiler to VCLCompilerImpl. Returning empty supported options.");
- return {};
- }
+std::optional<std::vector<std::string>> PluginCompilerAdapter::get_supported_options() const {
std::vector<char> options;
- if (!vclCompiler->get_supported_options(options)) {
+ if (!_compiler->get_supported_options(options)) {
_logger.warning("VCLCompilerImpl get_supported_options failed. Returning empty supported options.");
- return {};
+ return std::nullopt;
}
if (options.empty()) {
- _logger.warning("get_supported_options returned empty options.");
- return {};
+ _logger.warning("get_supported_options returned no options; returning an empty supported options vector.");
+ return std::vector<std::string>{};
}
std::string compilerOptionsStr(options.data(), options.size());
@@ -386,17 +377,8 @@ std::vector<std::string> PluginCompilerAdapter::get_supported_options() const {
}
bool PluginCompilerAdapter::is_option_supported(std::string optname, std::optional<std::string> optValue) const {
- VCLCompilerImpl* vclCompiler = dynamic_cast<VCLCompilerImpl*>(_compiler.operator->());
- if (vclCompiler == nullptr) {
- // If _compiler cannot be cast to VCLCompilerImpl, it should use the mlir library.
- // This functions has no utility in PluginCompiler
- // returning false for any request to avoid the option of spamming the plugin
- _logger.warning("Failed to cast compiler to VCLCompilerImpl. Returning false for check.");
- return false;
- }
-
const char* optvalue_ch = optValue.has_value() ? optValue.value().c_str() : nullptr;
- if (vclCompiler->is_option_supported(optname, optValue)) {
+ if (_compiler->is_option_supported(optname, optValue)) {
_logger.debug("Option %s is supported `%s` by VCLCompilerImpl",
optname.c_str(),
optvalue_ch ? optvalue_ch : "null");
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
index e623fd1c09c..a4d83621e28 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
@@ -567,11 +567,11 @@ NetworkMetadata ZeGraphExtWrappers::getNetworkMeta(GraphDescriptor& graphDescrip
return meta;
}
-std::string ZeGraphExtWrappers::getCompilerSupportedOptions() const {
+std::optional<std::string> ZeGraphExtWrappers::getCompilerSupportedOptions() const {
// Early exit if api is not supported
if (!_isCompilerOptionQuerySupported) {
_logger.debug("Compiler options query is not supported by the driver - skipping!");
- return {};
+ return std::nullopt;
}
// 1. ask driver for size of compiler supported options list
@@ -595,26 +595,23 @@ std::string ZeGraphExtWrappers::getCompilerSupportedOptions() const {
if (result == ZE_RESULT_SUCCESS) {
// convert received buff to string
std::string supported_options_list_str(sup_options_chr.data());
- // cleanup
return supported_options_list_str;
} else if (result == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
- // cleanup
- return {};
+ return std::nullopt;
} else {
- // cleanup
THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCompilerGetSupportedOptions",
result,
_zeroInitStruct->getGraphDdiTable())
}
}
} else if ((result == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) || (result == ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE)) {
- return {};
+ return std::nullopt;
} else {
THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCompilerGetSupportedOptions", result, _zeroInitStruct->getGraphDdiTable())
}
- _logger.debug("pfnCompilerGetSupportedOptions - list size 0 - skipping!");
- return {};
+ _logger.debug("pfnCompilerGetSupportedOptions - list size 0!");
+ return "";
}
std::optional<bool> ZeGraphExtWrappers::isOptionSupported(std::string optName,
diff --git a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp b/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp
index bc06f083aec..df8b9eddde4 100644
--- a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp
@@ -65,7 +65,7 @@ private:
const std::shared_ptr<IDevice> _device;
std::shared_ptr<ov::threading::ITaskExecutor> _resultExecutor;
- std::unique_ptr<Properties> _properties;
+ std::unique_ptr<Properties> _propertiesManager;
std::shared_ptr<IGraph> _graph;
diff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hpp
index 623644f1708..c32d29bd177 100644
--- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp
@@ -9,14 +9,9 @@
#include <string>
#include "backends_registry.hpp"
-#include "intel_npu/common/filtered_config.hpp"
-#include "intel_npu/common/icompiler_adapter.hpp"
#include "intel_npu/common/npu.hpp"
-#include "intel_npu/config/config.hpp"
-#include "intel_npu/config/options.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "metadata.hpp"
-#include "metrics.hpp"
#include "openvino/runtime/iplugin.hpp"
#include "openvino/runtime/so_ptr.hpp"
#include "properties.hpp"
@@ -65,7 +60,6 @@ public:
const ov::AnyMap& properties) const override;
private:
- void init_options(FilteredConfig& filteredConfig);
void update_log_level(const ov::AnyMap& properties) const;
/**
@@ -90,9 +84,7 @@ private:
// Appropriate checks are needed in plugin/metrics/properties when actions depend on a backend.
ov::SoPtr<IEngineBackend> _backend;
- std::shared_ptr<OptionsDesc> _options;
mutable Logger _logger;
- std::shared_ptr<Metrics> _metrics;
std::unique_ptr<Properties> _propertiesManager;
static std::atomic<int> _compiledModelLoadCounter;
diff --git a/src/plugins/intel_npu/src/plugin/include/properties.hpp b/src/plugins/intel_npu/src/plugin/include/properties.hpp
index 03e005be13c..d84a667ead3 100644
--- a/src/plugins/intel_npu/src/plugin/include/properties.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/properties.hpp
@@ -29,20 +29,6 @@ public:
Properties(const Properties& other);
Properties& operator=(const Properties& other) = delete;
- /**
- * @brief Initialize the properties map and try registering the properties for npu-plugin and compiled-model
- * Can be used for both plugin and compiled-model properties maps, based on the provided pType param to the
- * constructor of this object
- * @details
- * - it will reset the properties map
- * - it will try registering config-backed option-based properties, with data from global configuration (supported,
- * visibilty, mutability, value)
- * - if an option is not present in the global config, it assumes it is not supported and will skip it
- * - it will register metric-based properties, with data from the metrics interface
- * - at the end it populates supported_properties with the now dynamically registered public properties
- */
- void registerProperties();
-
/**
* @brief Get the values of a property in a map
*/
@@ -56,11 +42,6 @@ public:
*/
void setProperty(const ov::AnyMap& properties);
- /**
- * @brief Checks whether a property was registered by its name
- */
- bool isPropertyRegistered(const std::string& propertyName) const;
-
/**
* @brief Get a const reference to the stored config
*/
@@ -69,27 +50,24 @@ public:
}
/**
- * @brief Update the config map and register properties for the plugin.
+ * @brief Updates a copy of the config list based on the provided properties, and returns it.
* @details
- * - Checks if the compiler has changed; if so, re-filters properties.
- * - Checks whether arguments are already registered; if not, checks if the options are supported.
- * - Filters compiler options based on the current compiler.
- * - Updates the config with the provided arguments.
+ * - Updates the config with the provided arguments and returns it.
*/
- void updateConfig(const ov::AnyMap& properties,
- const ICompilerAdapter* compiler,
- OptionMode mode = OptionMode::Both);
+ FilteredConfig getConfigWithCompilerPropertiesDisabled(const ov::AnyMap& properties);
/**
- * @brief Update the config map.
+ * @brief Updates a copy of the config list based on the provided properties and compiler, and returns it.
* @details
- * - Updates the config with the provided arguments.
+ * - Checks if the compiler has changed; if so, re-filters configs.
+ * - Filters compiler options based on the current compiler.
+ * - Updates the config with the provided arguments and returns it.
*/
- void updateConfig(const ov::AnyMap& properties, OptionMode mode = OptionMode::Both);
+ FilteredConfig getConfigForSpecificCompiler(const ov::AnyMap& properties, const ICompilerAdapter* compiler);
- ov::intel_npu::CompilerType determineCompilerType(const ov::AnyMap& properties) const;
std::string determinePlatform(const ov::AnyMap& properties) const;
std::string determineDeviceId(const ov::AnyMap& properties) const;
+ ov::intel_npu::CompilerType determineCompilerType(const ov::AnyMap& properties) const;
private:
PropertiesType _pType;
@@ -101,18 +79,34 @@ private:
ov::intel_npu::CompilerType _currentlyUsedCompiler = ov::intel_npu::CompilerType::PREFER_PLUGIN;
std::string _currentlyUsedPlatform;
- bool _initialized = false; ///< Boolean to check whether properties was filtered with compiler supported properties
+ bool _compilerConfigsFilteredByCompiler =
+ false; ///< Boolean to check whether properties was filtered with compiler supported properties
// properties map: {name -> [supported, mutable, eval function]}
std::map<std::string, std::tuple<bool, ov::PropertyMutability, std::function<ov::Any(const Config&)>>> _properties;
std::vector<ov::PropertyName> _supportedProperties;
+ /**
+ * @brief Checks whether a property was registered by its name
+ */
+ bool isPropertyRegistered(const std::string& propertyName) const;
+
// internal registration functions based on client object
+ /**
+ * @brief Initialize the properties map and try registering the properties for npu-plugin and compiled-model
+ * Can be used for both plugin and compiled-model properties maps, based on the provided pType param to the
+ * constructor of this object
+ * @details
+ * - it will reset the properties map
+ * - it will try registering config-backed option-based properties, with data from global configuration (supported,
+ * visibilty, mutability, value)
+ * - if an option is not present in the global config, it assumes it is not supported and will skip it
+ * - it will register metric-based properties, with data from the metrics interface
+ * - at the end it populates supported_properties with the now dynamically registered public properties
+ */
+ void registerProperties();
void registerPluginProperties();
void registerCompiledModelProperties();
- void filterPropertiesByCompilerSupport(const ICompilerAdapter* compiler,
- const ov::intel_npu::CompilerType compilerType,
- const std::string& compilationPlatform);
const std::vector<ov::PropertyName> _cachingProperties = {
ov::cache_mode.name(),
diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp
index 2c40fe221c8..f5355517532 100644
--- a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp
@@ -36,8 +36,7 @@ CompiledModel::CompiledModel(const std::shared_ptr<const ov::Model>& model,
OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "CompiledModel::CompiledModel");
OV_ITT_TASK_CHAIN(COMPILED_MODEL, itt::domains::NPUPlugin, "CompiledModel::CompiledModel", "initialize_properties");
- _properties = std::make_unique<Properties>(PropertiesType::COMPILED_MODEL, config);
- _properties->registerProperties();
+ _propertiesManager = std::make_unique<Properties>(PropertiesType::COMPILED_MODEL, config);
configure_stream_executors();
@@ -57,11 +56,12 @@ std::shared_ptr<ov::IAsyncInferRequest> CompiledModel::create_infer_request() co
OPENVINO_THROW("No available devices. Failed to create infer request!");
}
- if (!_properties->getConfig().get<CREATE_EXECUTOR>() || _properties->getConfig().get<DEFER_WEIGHTS_LOAD>()) {
+ if (!_propertiesManager->getConfig().get<CREATE_EXECUTOR>() ||
+ _propertiesManager->getConfig().get<DEFER_WEIGHTS_LOAD>()) {
if (_graph == nullptr) {
OPENVINO_THROW("Invalid graph handle! Failed to create infer request!");
}
- _graph->initialize(_properties->getConfig());
+ _graph->initialize(_propertiesManager->getConfig());
}
if (!_graph->init_completed()) {
@@ -70,7 +70,7 @@ std::shared_ptr<ov::IAsyncInferRequest> CompiledModel::create_infer_request() co
}
const std::shared_ptr<SyncInferRequest>& syncInferRequest =
- _device->createInferRequest(shared_from_this(), _properties->getConfig());
+ _device->createInferRequest(shared_from_this(), _propertiesManager->getConfig());
syncInferRequest->initialize_states();
return std::make_shared<AsyncInferRequest>(syncInferRequest,
@@ -90,7 +90,7 @@ void CompiledModel::export_model(std::ostream& stream) const {
auto [blobSizesBeforeVersioning, initBlobSizes] = _graph->export_blob(stream);
- if (!_properties->getConfig().get<EXPORT_RAW_BLOB>()) {
+ if (!_propertiesManager->getConfig().get<EXPORT_RAW_BLOB>()) {
std::optional<std::vector<ov::Layout>> inputLayouts = std::vector<ov::Layout>();
std::optional<std::vector<ov::Layout>> outputLayouts = std::vector<ov::Layout>();
@@ -160,7 +160,7 @@ std::shared_ptr<const ov::Model> CompiledModel::get_runtime_model() const {
void CompiledModel::set_property(const ov::AnyMap& properties) {
// 1. Set the property via Properties interface
- _properties->setProperty(properties);
+ _propertiesManager->setProperty(properties);
// 2. Extra hooks
if (properties.count(std::string(WORKLOAD_TYPE::key())) != 0) {
@@ -178,7 +178,7 @@ ov::Any CompiledModel::get_property(const std::string& name) const {
return _graph->get_metadata().name;
} else {
// default behaviour
- return _properties->getProperty(name);
+ return _propertiesManager->getProperty(name);
}
}
@@ -187,7 +187,7 @@ const std::shared_ptr<IGraph>& CompiledModel::get_graph() const {
}
const FilteredConfig& CompiledModel::get_config() const {
- return _properties->getConfig();
+ return _propertiesManager->getConfig();
}
void CompiledModel::configure_stream_executors() {
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 6bdcec9592c..1669e57fb67 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -10,28 +10,30 @@
#include "compiler_adapter_factory.hpp"
#include "driver_compiler_adapter.hpp"
#include "intel_npu/common/device_helpers.hpp"
+#include "intel_npu/common/filtered_config.hpp"
#include "intel_npu/common/icompiler_adapter.hpp"
#include "intel_npu/common/igraph.hpp"
#include "intel_npu/common/itt.hpp"
#include "intel_npu/config/npuw.hpp"
+#include "intel_npu/config/options.hpp"
#include "intel_npu/utils/utils.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
+#include "metrics.hpp"
#include "npuw/compiled_model.hpp"
#include "npuw/llm_compiled_model.hpp"
#include "npuw/serialization.hpp"
#include "openvino/core/rt_info/weightless_caching_attributes.hpp"
-#include "openvino/util/file_util.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
#include "openvino/runtime/properties.hpp"
#include "openvino/runtime/shared_buffer.hpp"
+#include "openvino/util/file_util.hpp"
#include "remote_context.hpp"
#include "transformations.hpp"
-using namespace intel_npu;
-
namespace {
+using namespace intel_npu;
const std::vector<size_t> CONSTANT_NODE_DUMMY_SHAPE{1};
@@ -207,55 +209,16 @@ int get_ir_version(const std::shared_ptr<const ov::Model>& model, const intel_np
return 11;
}
-} // namespace
-
-namespace intel_npu {
-
-Plugin::Plugin() : _options(std::make_shared<OptionsDesc>()), _logger("NPUPlugin", Logger::global().level()) {
- OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::Plugin");
- set_device_name("NPU");
-
- // parse env_variables to get LOG_LEVEL if needed
- _options->add<LOG_LEVEL>();
-
- FilteredConfig filteredConfig(_options);
-
- filteredConfig.parseEnvVars();
- Logger::global().setLevel(filteredConfig.get<LOG_LEVEL>());
- _logger.setLevel(filteredConfig.get<LOG_LEVEL>());
-
- OV_ITT_TASK_CHAIN(PLUGIN, itt::domains::NPUPlugin, "Plugin::Plugin", "GetBackend");
- // backend registry shall be created after configs are updated
- _backendsRegistry = std::make_unique<BackendsRegistry>();
- _backend = _backendsRegistry->getEngineBackend();
-
- if (_backend) {
- OV_ITT_TASK_NEXT(PLUGIN, "registerBackendOptions");
- _backend->registerOptions(*_options);
- }
-
- OV_ITT_TASK_NEXT(PLUGIN, "createMetrics");
- _metrics = std::make_unique<Metrics>(_backend);
-
- OV_ITT_TASK_NEXT(PLUGIN, "InitOptions");
- init_options(filteredConfig);
-
- /// Init and register properties
- OV_ITT_TASK_NEXT(PLUGIN, "RegisterProperties");
- _propertiesManager = std::make_unique<Properties>(PropertiesType::PLUGIN, filteredConfig, _metrics, _backend);
- _propertiesManager->registerProperties();
-}
-
-void Plugin::init_options(FilteredConfig& filteredConfig) {
+void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredConfig& config) {
// Initialize (note: it will reset registered options)
- _options->reset();
+ options.reset();
#define REGISTER_OPTION(OPT_TYPE) \
do { \
auto dummyopt = details::makeOptionModel<OPT_TYPE>(); \
std::string o_name = dummyopt.key().data(); \
- _options->add<OPT_TYPE>(); \
- filteredConfig.enable(std::move(o_name), false); \
+ options.add<OPT_TYPE>(); \
+ config.enable(std::move(o_name), false); \
} while (0)
REGISTER_OPTION(LOG_LEVEL);
@@ -306,19 +269,17 @@ void Plugin::init_options(FilteredConfig& filteredConfig) {
REGISTER_OPTION(MODEL_SERIALIZER_VERSION);
REGISTER_OPTION(ENABLE_STRIDES_FOR);
- if (_backend) {
- if (_backend->isCommandQueueExtSupported()) {
+ if (backend) {
+ if (backend->isCommandQueueExtSupported()) {
REGISTER_OPTION(WORKLOAD_TYPE);
}
- if (_backend->isContextExtSupported()) {
+ if (backend->isContextExtSupported()) {
REGISTER_OPTION(DISABLE_IDLE_MEMORY_PRUNING);
}
- // register backend options
- _backend->registerOptions(*_options);
}
// parse again env_variables to update registered configs which have env vars set
- filteredConfig.parseEnvVars();
+ config.parseEnvVars();
// NPUW properties are requested by OV Core during caching and have no effect on the NPU plugin. But we still need
// to enable those for OV Core to query. Note: do this last to not filter them out. register npuw caching properties
@@ -387,28 +348,73 @@ void Plugin::init_options(FilteredConfig& filteredConfig) {
REGISTER_OPTION(NPUW_KOKORO_BLOCK_SIZE);
REGISTER_OPTION(NPUW_KOKORO_OVERLAP_SIZE);
- filteredConfig.enableRuntimeOptions();
-
- // Special cases
- filteredConfig.enable(ov::log::level.name(), true); // needed also by runtime options
-
- if (filteredConfig.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- if (_backend) {
- auto device = _backend->getDevice();
- if (device) {
- auto platformName = device->getName();
- CompilerAdapterFactory compilerFactory;
- auto compileType = compilerFactory.determinteAppropriateCompilerTypeBasedOnPlatform(platformName);
- if (compileType == ov::intel_npu::CompilerType::DRIVER) {
- filteredConfig.update(
- {{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType)}});
- _logger.info("Use %s as default compiler", COMPILER_TYPE::toString(compileType).c_str());
- }
+ config.enableRuntimeOptions();
+
+ // Special cases - options with OptionMode::Both must be enabled for the plugin even if the compiler does not
+ // support them, because they may be used by the plugin itself or by the driver.
+ // We still check compiler support to decide whether these options should be removed from the config string.
+
+ // NPU_TURBO might be supported by the driver
+ if (backend && backend->isCommandQueueExtSupported()) {
+ config.enable(ov::intel_npu::turbo.name(), true);
+ }
+
+ // LOG_LEVEL, PERFORMANCE_HINT and PERF_COUNT are needed by runtime options
+ config.enable(ov::log::level.name(), true);
+ config.enable(ov::hint::performance_mode.name(), true);
+ config.enable(ov::enable_profiling.name(), true);
+
+ if (config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN && backend != nullptr) {
+ auto device = backend->getDevice();
+ if (device) {
+ auto platformName = device->getName();
+ CompilerAdapterFactory compilerFactory;
+ auto compileType = compilerFactory.determinteAppropriateCompilerTypeBasedOnPlatform(platformName);
+ if (compileType == ov::intel_npu::CompilerType::DRIVER) {
+ config.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType)}});
}
}
}
}
+} // namespace
+
+namespace intel_npu {
+
+Plugin::Plugin() : _logger("NPUPlugin", Logger::global().level()) {
+ OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::Plugin");
+ set_device_name("NPU");
+
+ std::shared_ptr<OptionsDesc> options = std::make_shared<OptionsDesc>();
+ // parse env_variables to get LOG_LEVEL if needed
+ options->add<LOG_LEVEL>();
+
+ FilteredConfig config(options);
+ config.parseEnvVars();
+ Logger::global().setLevel(config.get<LOG_LEVEL>());
+ _logger.setLevel(config.get<LOG_LEVEL>());
+
+ OV_ITT_TASK_CHAIN(PLUGIN, itt::domains::NPUPlugin, "Plugin::Plugin", "GetBackend");
+ // backend registry shall be created after configs are updated
+ _backendsRegistry = std::make_unique<BackendsRegistry>();
+ _backend = _backendsRegistry->getEngineBackend();
+
+ OV_ITT_TASK_NEXT(PLUGIN, "InitConfig");
+ init_config(_backend._ptr.get(), *options, config);
+
+ if (_backend) {
+ OV_ITT_TASK_NEXT(PLUGIN, "RegisterBackendOptions");
+ _backend->registerOptions(*options);
+ }
+
+ OV_ITT_TASK_NEXT(PLUGIN, "CreateMetrics");
+ auto metrics = std::make_shared<Metrics>(_backend);
+
+ /// Init and register properties
+ OV_ITT_TASK_NEXT(PLUGIN, "RegisterProperties");
+ _propertiesManager = std::make_unique<Properties>(PropertiesType::PLUGIN, config, metrics, _backend);
+}
+
void Plugin::set_property(const ov::AnyMap& properties) {
if (properties.empty()) {
return;
@@ -520,10 +526,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");
- auto copyPropertiesManager = std::make_unique<Properties>(*_propertiesManager);
- copyPropertiesManager->updateConfig(localProperties, compiler.get());
- FilteredConfig localConfig = copyPropertiesManager->getConfig();
- copyPropertiesManager.reset();
+ FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties, compiler.get());
auto updateBatchMode = [&](ov::intel_npu::BatchMode mode) {
std::stringstream strStream;
@@ -903,10 +906,7 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
localProperties[ov::intel_npu::platform.name()] = compilationPlatform;
}
- auto copyPropertiesManager = std::make_unique<Properties>(*_propertiesManager);
- copyPropertiesManager->updateConfig(localProperties, compiler.get(), OptionMode::CompileTime);
- FilteredConfig localConfig = copyPropertiesManager->getConfig();
- copyPropertiesManager.reset();
+ FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties, compiler.get());
if (modelSerializerChosenExplicitly) {
if (localConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
@@ -970,10 +970,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
auto compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);
OV_ITT_TASK_CHAIN(PLUGIN_PARSE_MODEL, itt::domains::NPUPlugin, "Plugin::parse", "fork_local_config");
- auto copyPropertiesManager = std::make_unique<Properties>(*_propertiesManager);
- copyPropertiesManager->updateConfig(localProperties, OptionMode::RunTime);
- FilteredConfig localConfig = copyPropertiesManager->getConfig();
- copyPropertiesManager.reset();
+ FilteredConfig localConfig = _propertiesManager->getConfigWithCompilerPropertiesDisabled(localProperties);
const auto loadedFromCache = localConfig.get<LOADED_FROM_CACHE>();
if (!loadedFromCache) {
diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp
index de300e03ff9..352425d7d31 100644
--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp
@@ -25,6 +25,111 @@ std::map<std::string, std::string> any_copy(const ov::AnyMap& params) {
return result;
}
+void filterPropertiesByCompilerSupport(intel_npu::FilteredConfig& config,
+ const intel_npu::ICompilerAdapter* compiler,
+ const ov::SoPtr<intel_npu::IEngineBackend>& backend,
+ const intel_npu::Logger& logger) {
+ using namespace intel_npu;
+ bool legacy = false;
+ std::optional<std::vector<std::string>> compilerSupportList{};
+ uint32_t compilerVersion = 0;
+
+ OPENVINO_ASSERT(compiler != nullptr, "Compiler must be present to filter properties by compiler support");
+
+ compilerVersion = compiler->get_version();
+ compilerSupportList = compiler->get_supported_options();
+
+ if (!compilerSupportList.has_value()) {
+ logger.info("No compiler support options list received! Fallback to version-based option registration");
+ legacy = true;
+ }
+
+ // Logs
+ logger.debug("Compiler version: %u", compilerVersion);
+ logger.debug("Legacy registration: %s", legacy ? "true" : "false");
+ if (!legacy) {
+ const auto& supportedOptions = compilerSupportList.value();
+ logger.debug("Compiler supported options list (%zu): ", supportedOptions.size());
+ for (const auto& str : supportedOptions) {
+ logger.debug(" %s ", str.c_str());
+ }
+ }
+
+ // Parse enables
+ config.walkEnables([&](const std::string& key) {
+ bool isEnabled = false;
+ auto opt = config.getOpt(key);
+ // Special case for some both configs. Don't need compiler for these Both properties.
+ const bool isNotSpecialBothProperty = key != ov::hint::performance_mode.name() &&
+ key != ov::enable_profiling.name() && key != ov::log::level.name();
+ // Runtime (plugin-only) options are always enabled
+ if (opt.mode() != OptionMode::RunTime && isNotSpecialBothProperty) {
+ if (legacy) {
+ // Compiler or common option in Legacy mode? Checking its supported version
+ if (compilerVersion >= opt.compilerSupportVersion()) {
+ isEnabled = true;
+ }
+ } else {
+ // We have compiler, we are not in legacy mode = we have a valid list of supported options
+ // Searching in the list
+ const auto& supportedOptions = compilerSupportList.value();
+ auto it = std::find(supportedOptions.begin(), supportedOptions.end(), key);
+ if (it != 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;
+ }
+ }
+ }
+ if (!isEnabled) {
+ logger.debug("Config option %s not supported! Requirements not met.", key.c_str());
+ } else {
+ logger.debug("Enabled config option %s", key.c_str());
+ }
+ // update enable flag
+ config.enable(key, isEnabled);
+ }
+ });
+
+ // 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
+ // however, if driver supports it, we still need it (and will skip giving it to compiler) = force-enable
+ if (backend && backend->isCommandQueueExtSupported()) {
+ config.enable(ov::intel_npu::turbo.name(), true);
+ }
+}
+
+void disableCompilerProperties(intel_npu::FilteredConfig& config, const ov::SoPtr<intel_npu::IEngineBackend>& backend) {
+ using namespace intel_npu;
+ // Parse enables
+ config.walkEnables([&](const std::string& key) {
+ auto opt = config.getOpt(key);
+
+ // Special case for some both configs. Don't need compiler for these Both properties.
+ const bool isNotSpecialBothProperty = key != ov::hint::performance_mode.name() &&
+ key != ov::enable_profiling.name() && key != ov::log::level.name();
+ // Runtime (plugin-only) options are always enabled
+ if (opt.mode() != OptionMode::RunTime && isNotSpecialBothProperty) { // Compiler and common options
+ // Disable all compiler options
+ config.enable(key, false);
+ }
+ });
+
+ // Special cases
+ // NPU_TURBO might be supported by the driver
+ if (backend && backend->isCommandQueueExtSupported()) {
+ config.enable(ov::intel_npu::turbo.name(), true);
+ }
+}
+
} // namespace
namespace intel_npu {
@@ -323,7 +428,9 @@ Properties::Properties(const PropertiesType pType,
_config(config),
_metrics(metrics),
_backend(backend),
- _logger("Properties", _config.get<LOG_LEVEL>()) {}
+ _logger("Properties", _config.get<LOG_LEVEL>()) {
+ registerProperties();
+}
Properties::Properties(const Properties& other)
: _pType(other._pType),
@@ -333,7 +440,7 @@ Properties::Properties(const Properties& other)
_logger("Properties", _config.get<LOG_LEVEL>()),
_currentlyUsedCompiler(other._currentlyUsedCompiler),
_currentlyUsedPlatform(other._currentlyUsedPlatform),
- _initialized(other._initialized),
+ _compilerConfigsFilteredByCompiler(other._compilerConfigsFilteredByCompiler),
_properties(other._properties),
_supportedProperties(other._supportedProperties) {}
@@ -735,7 +842,9 @@ ov::Any Properties::getProperty(const std::string& name) {
} else {
// Property is already registered but need to re-check if the CompilerTime config is still supported by the
// current compiler.
- if (_config.hasOpt(name) && name != ov::log::level.name()) {
+ const bool isNotSpecialBothProperty = name != ov::hint::performance_mode.name() &&
+ name != ov::enable_profiling.name() && name != ov::log::level.name();
+ if (_config.hasOpt(name) && isNotSpecialBothProperty) {
auto opt = _config.getOpt(name);
if (opt.mode() != OptionMode::RunTime) {
propertyIsCompilerConfig = true;
@@ -759,23 +868,28 @@ ov::Any Properties::getProperty(const std::string& name) {
try {
compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);
} catch (const std::exception& ex) {
- if (name == ov::supported_properties.name() || name == ov::internal::supported_properties.name()) {
- // In case of supported_properties query, we want to return at least the runtime properties even if
- // compiler creation failed
- _logger.warning("Failed to create compiler for getting supported properties with error: %s."
- "Returning only runtime supported properties.",
- ex.what());
- auto&& configIterator = _properties.find(name);
- if (configIterator != _properties.cend()) {
- return std::get<2>(configIterator->second)(_config);
- }
+ if (_config.hasOpt(name) && _config.getOpt(name).mode() == OptionMode::CompileTime) {
+ OPENVINO_THROW("Failed to create compiler for getting property ", name, " with error: ", ex.what());
}
- OPENVINO_THROW("Failed to create compiler for getting property ", name, " with error: ", ex.what());
- }
- compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);
+ _logger.warning("Failed to create compiler for getting property %s with error: %s."
+ "Returning only runtime properties and metrics that do not require compiler support.",
+ name.c_str(),
+ ex.what());
+ }
- filterPropertiesByCompilerSupport(compiler.get(), compilerType, compilationPlatform);
+ if (compiler != nullptr && !(_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);
+
+ // reset properties for the new options
+ registerProperties();
+ _compilerConfigsFilteredByCompiler = true;
+ _currentlyUsedCompiler = compilerType;
+ _currentlyUsedPlatform = compilationPlatform;
+ }
}
}
@@ -791,6 +905,10 @@ ov::Any Properties::getProperty(const std::string& name) {
}
void Properties::setProperty(const ov::AnyMap& properties) {
+ if (properties.count(ov::log::level.name()) != 0) {
+ _logger.setLevel(properties.at(ov::log::level.name()).as<ov::log::Level>());
+ }
+
std::unique_ptr<ICompilerAdapter> compiler = nullptr;
std::lock_guard<std::mutex> lock(_mutex);
if (_pType == PropertiesType::PLUGIN) {
@@ -801,7 +919,11 @@ void Properties::setProperty(const ov::AnyMap& properties) {
propertyIsRegistered = false;
break;
}
- if (_config.hasOpt(property.first) && property.first != ov::log::level.name()) {
+ // Special case for some both configs. Don't need to check compiler support for these Both properties.
+ const bool isNotSpecialBothProperty = property.first != ov::hint::performance_mode.name() &&
+ property.first != ov::enable_profiling.name() &&
+ property.first != ov::log::level.name();
+ if (_config.hasOpt(property.first) && isNotSpecialBothProperty) {
auto opt = _config.getOpt(property.first);
if (opt.mode() != OptionMode::RunTime) {
propertyIsCompilerConfig = true;
@@ -826,7 +948,18 @@ void Properties::setProperty(const ov::AnyMap& properties) {
CompilerAdapterFactory factory;
compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);
- filterPropertiesByCompilerSupport(compiler.get(), compilerType, compilationPlatform);
+ 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);
+
+ // reset properties for the new options
+ registerProperties();
+ _compilerConfigsFilteredByCompiler = true;
+ _currentlyUsedCompiler = compilerType;
+ _currentlyUsedPlatform = compilationPlatform;
+ }
}
}
@@ -863,148 +996,92 @@ bool Properties::isPropertyRegistered(const std::string& propertyName) const {
return _properties.find(propertyName) != _properties.end();
}
-void Properties::filterPropertiesByCompilerSupport(const ICompilerAdapter* compiler,
- const ov::intel_npu::CompilerType compilerType,
- const std::string& compilationPlatform) {
- // In case properties are not initialized or the compiler/platform was changed since last call -
- // filter out options again
- if (_initialized && compilerType == _currentlyUsedCompiler && compilationPlatform == _currentlyUsedPlatform) {
- return;
- }
-
- bool legacy = false;
- std::vector<std::string> compilerSupportList{};
- uint32_t compilerVersion = 0;
-
- if (compiler != nullptr) {
- compilerVersion = compiler->get_version();
- compilerSupportList = compiler->get_supported_options();
- }
- if (compilerSupportList.size() == 0) {
- _logger.info("No compiler support options list received! Fallback to version-based option registration");
- legacy = true;
- }
-
- // Logs
- _logger.debug("Compiler version: %ld", compilerVersion);
- _logger.debug("Compiler supported options list (%ld): ", compilerSupportList.size());
- for (const auto& str : compilerSupportList) {
- _logger.debug(" %s ", str.c_str());
- }
- _logger.debug("Legacy registration: %s", legacy ? "true" : "false");
-
- // Parse enables
- _config.walkEnables([&](const std::string& key) {
- bool isEnabled = false;
- auto opt = _config.getOpt(key);
- // Runtime (plugin-only) options are always enabled
- if (opt.mode() == OptionMode::RunTime) {
- isEnabled = true;
- } else { // Compiler and common options
- if (compiler == nullptr && opt.mode() == OptionMode::CompileTime) {
- // we do not register compileTime options if there is no compiler
- isEnabled = false;
- } else if (legacy) {
- // Compiler or common option in Legacy mode? Checking its supported version
- if (compilerVersion >= opt.compilerSupportVersion()) {
- isEnabled = true;
- }
- } else {
- // We have compiler, we are not in legacy mode = we have a valid list of supported options
- // Searching in the list
- auto it = std::find(compilerSupportList.begin(), compilerSupportList.end(), key);
- if (it != compilerSupportList.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;
- }
- }
- }
- }
- if (!isEnabled) {
- _logger.debug("Config option %s not supported! Requirements not met.", key.c_str());
- } else {
- _logger.debug("Enabled config option %s", key.c_str());
- }
- // update enable flag
- _config.enable(key, isEnabled);
- });
-
- // Special case for 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
- // however, if driver supports it, we still need it (and will skip giving it to compiler) = force-enable
- if (_backend && _backend->isCommandQueueExtSupported()) {
- _config.enable(ov::intel_npu::turbo.name(), true);
- }
-
- // reset properties for the new options
- registerProperties();
- _initialized = true;
- _currentlyUsedCompiler = compilerType;
- _currentlyUsedPlatform = compilationPlatform;
-}
-
-void Properties::updateConfig(const ov::AnyMap& properties, const ICompilerAdapter* compiler, OptionMode mode) {
- {
+FilteredConfig Properties::getConfigForSpecificCompiler(const ov::AnyMap& properties,
+ const ICompilerAdapter* compiler) {
+ auto [updatedConfig, compilerConfigsFilteredByCompiler, currentlyUsedCompiler, currentlyUsedPlatform] = [&]() {
std::lock_guard<std::mutex> lock(_mutex);
- std::optional<ov::intel_npu::CompilerType> propertiesCompilerType = std::nullopt;
- std::optional<std::string> propertiesPlatform = std::nullopt;
- if (_initialized) {
- auto compilerType = properties.find(ov::intel_npu::compiler_type.name());
- if (compilerType != properties.end()) {
- propertiesCompilerType = compilerType->second.as<ov::intel_npu::CompilerType>();
- }
- }
- auto platform = properties.find(ov::intel_npu::platform.name());
- if (platform != properties.end()) {
- propertiesPlatform = platform->second.as<std::string>();
+ return std::make_tuple(_config,
+ _compilerConfigsFilteredByCompiler,
+ _currentlyUsedCompiler,
+ _currentlyUsedPlatform);
+ }();
+
+ std::optional<ov::intel_npu::CompilerType> propertiesCompilerType = std::nullopt;
+ std::optional<std::string> propertiesPlatform = std::nullopt;
+ if (compilerConfigsFilteredByCompiler) {
+ auto compilerType = properties.find(ov::intel_npu::compiler_type.name());
+ if (compilerType != properties.end()) {
+ propertiesCompilerType = compilerType->second.as<ov::intel_npu::CompilerType>();
}
+ }
+ auto platform = properties.find(ov::intel_npu::platform.name());
+ if (platform != properties.end()) {
+ propertiesPlatform = platform->second.as<std::string>();
+ }
- // filter out unsupported options
- filterPropertiesByCompilerSupport(compiler,
- propertiesCompilerType.value_or(_currentlyUsedCompiler),
- propertiesPlatform.value_or(_currentlyUsedPlatform));
+ // filter out unsupported options
+ if (!(compilerConfigsFilteredByCompiler &&
+ propertiesCompilerType.value_or(currentlyUsedCompiler) == 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);
}
const std::map<std::string, std::string> rawConfig = any_copy(properties);
std::map<std::string, std::string> cfgsToSet;
for (const auto& [key, value] : rawConfig) {
- if (!_config.hasOpt(key)) {
+ if (!updatedConfig.hasOpt(key)) {
// not a known config key
if (!compiler->is_option_supported(key)) {
OPENVINO_THROW("[ NOT_FOUND ] Option '", key, "' is not supported for current configuration");
} else {
- _config.addOrUpdateInternal(key, value);
+ updatedConfig.addOrUpdateInternal(key, value);
}
} else {
cfgsToSet.emplace(key, value);
}
}
- _config.update(cfgsToSet, mode);
+ updatedConfig.update(cfgsToSet);
+
+ return updatedConfig;
}
-void Properties::updateConfig(const ov::AnyMap& properties, OptionMode mode) {
+FilteredConfig Properties::getConfigWithCompilerPropertiesDisabled(const ov::AnyMap& properties) {
+ auto [updatedConfig, compilerConfigsFilteredByCompiler] = [&]() {
+ std::lock_guard<std::mutex> lock(_mutex);
+ return std::make_tuple(_config, _compilerConfigsFilteredByCompiler);
+ }();
+
+ if (compilerConfigsFilteredByCompiler) {
+ disableCompilerProperties(updatedConfig, _backend);
+ }
+
+ // Special case for NPU_COMPILER_TYPE - don't need it in the config for this case.
+ updatedConfig.enable(ov::intel_npu::compiler_type.name(), false);
+
+ if (properties.empty()) {
+ return updatedConfig;
+ }
+
const std::map<std::string, std::string> rawConfig = any_copy(properties);
std::map<std::string, std::string> cfgsToSet;
for (const auto& [key, value] : rawConfig) {
- if (!_config.hasOpt(key)) {
+ if ((updatedConfig.hasOpt(key) && updatedConfig.getOpt(key).mode() == OptionMode::CompileTime) ||
+ key == ov::intel_npu::compiler_type.name()) {
_logger.info(
- "Config key '%s' is not recognized as a known option, will not be used for current configuration.",
+ "Config key '%s' is recognized as a compiler option, will not be used for current configuration.",
key.c_str());
- } else {
- cfgsToSet.emplace(key, value);
+ continue;
}
+
+ cfgsToSet.emplace(key, value);
}
- _config.update(cfgsToSet, mode);
+ updatedConfig.update(cfgsToSet);
+
+ return updatedConfig;
}
ov::intel_npu::CompilerType Properties::determineCompilerType(const ov::AnyMap& properties) const {
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp
index 4ca603f40ee..6a8a04138d1 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp
@@ -147,4 +147,10 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_CheckCompilerType,
::testing::ValuesIn(valid_device_ids)),
CheckCompilerTypeProperty::getTestCaseName);
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_CheckCompilerType,
+ CheckCompilerPropertyWhenImporting,
+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::ValuesIn(valid_device_ids)),
+ CheckCompilerTypeProperty::getTestCaseName);
+
} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
index 21057d54d99..11c8f29949f 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
@@ -479,4 +479,97 @@ TEST_P(CheckCompilerTypeProperty, GetCompilerVersion) {
logs.clear();
}
+using CheckCompilerPropertyWhenImporting = ClassExecutableNetworkGetPropertiesTestNPU;
+
+TEST_P(CheckCompilerPropertyWhenImporting, ExpectedThrowFromImportWithUnsupportedProperty) {
+ ov::Core core_compile, core_import;
+ ov::CompiledModel compiled_model;
+ std::stringstream export_stream;
+
+ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));
+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));
+ compiled_model = {};
+
+ ASSERT_THROW(core_import.import_model(export_stream, deviceName, {{{"DUMMY_PROPERTY", ov::Any("DUMMY_VALUE")}}}),
+ ov::Exception); // Expect to throw due to unsupported property
+}
+
+TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithCompilerProperty) {
+ std::string logs;
+ std::mutex logs_mutex;
+ ov::Core core_compile, core_import;
+ ov::CompiledModel compiled_model;
+ std::stringstream export_stream;
+
+ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));
+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));
+ compiled_model = {};
+
+ // Keep this std::function alive while logging is active.
+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {
+ std::lock_guard<std::mutex> lock(logs_mutex);
+ logs.append(msg);
+ logs.push_back('\n');
+ };
+
+ ov::util::set_log_callback(log_cb);
+ core_import.set_property(deviceName, ov::log::level(ov::log::Level::INFO));
+ OV_ASSERT_NO_THROW(core_import.import_model(export_stream, deviceName, {{ov::intel_npu::qdq_optimization(true)}}));
+ ov::util::reset_log_callback();
+
+ ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used"),
+ std::string::npos);
+}
+
+TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithBothProperty) {
+ ov::Core core_compile, core_import;
+ ov::CompiledModel compiled_model, imported_model;
+ std::stringstream export_stream0, export_stream1;
+
+ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));
+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream0));
+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream1));
+ compiled_model = {};
+
+ OV_ASSERT_NO_THROW(imported_model =
+ core_import.import_model(export_stream0, deviceName, {{ov::intel_npu::turbo(true)}}));
+ bool turbo = false;
+ OV_ASSERT_NO_THROW(turbo = imported_model.get_property(ov::intel_npu::turbo));
+ ASSERT_TRUE(turbo == true);
+
+ OV_ASSERT_NO_THROW(imported_model = core_import.import_model(
+ export_stream1,
+ deviceName,
+ {{ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT)}}));
+ ASSERT_THROW(imported_model.get_property(ov::intel_npu::turbo),
+ ov::Exception); // Expect to throw due to unsupported property
+
+ ov::hint::PerformanceMode perf_mode = ov::hint::PerformanceMode::LATENCY;
+ OV_ASSERT_NO_THROW(perf_mode = imported_model.get_property(ov::hint::performance_mode));
+ ASSERT_TRUE(perf_mode == ov::hint::PerformanceMode::THROUGHPUT);
+}
+
+TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithRuntimeProperty) {
+ ov::Core core_compile, core_import;
+ ov::CompiledModel compiled_model, imported_model;
+ std::stringstream export_stream;
+
+ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));
+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));
+ compiled_model = {};
+
+ OV_ASSERT_NO_THROW(imported_model =
+ core_import.import_model(export_stream,
+ deviceName,
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::workload_type(ov::WorkloadType::EFFICIENT)}}));
+
+ ASSERT_THROW(imported_model.get_property(ov::intel_npu::compiler_type),
+ ov::Exception); // Expect to throw due to unsupported property
+
+ ov::WorkloadType workload_type = ov::WorkloadType::DEFAULT;
+ OV_ASSERT_NO_THROW(workload_type = imported_model.get_property(ov::workload_type));
+ ASSERT_TRUE(workload_type == ov::WorkloadType::EFFICIENT);
+}
+
} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
index 5f300c87ebd..bcbccc38028 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
@@ -372,6 +372,16 @@ TEST_P(ZeroGraphTest, CheckNoThrowOnUnsupportedFeature) {
using IsOptionSupported = ZeroGraphTest;
+TEST_P(IsOptionSupported, GetCompilerSupportedOptions) {
+ std::optional<std::string> compilerSupportedOptions;
+ OV_ASSERT_NO_THROW(compilerSupportedOptions = zeGraphExt->getCompilerSupportedOptions());
+ if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {
+ ASSERT_FALSE(compilerSupportedOptions.has_value());
+ } else {
+ ASSERT_TRUE(compilerSupportedOptions.has_value());
+ }
+}
+
TEST_P(IsOptionSupported, PropertyNotSupportedByDriver) {
std::optional<bool> isOptionSupportedResult;
OV_ASSERT_NO_THROW(isOptionSupportedResult = zeGraphExt->isOptionSupported("FAKE_OPTION"));