Skip to content

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

[intel-npu] Molding NPU_TURBO into a shared option between driver and compiler (#30471)

Attila Csokd0dd380323dd
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 dbb1a8b0ba0..7b81d238343 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
@@ -792,7 +792,7 @@ struct TURBO final : OptionBase<TURBO, bool> {
}
static OptionMode mode() {
- return OptionMode::RunTime;
+ return OptionMode::Both;
}
static ov::PropertyMutability mutability() {
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 848ae74a614..d62431c3145 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
@@ -493,6 +493,28 @@ std::string DriverCompilerAdapter::serializeConfig(const Config& config,
getStringReplacement(ov::intel_npu::LegacyPriority::HIGH));
}
+ // Special case for compiler Turbo
+ // 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
+ if (std::regex_search(content, std::regex("NPU_TURBO"))) {
+ bool is_supported = false;
+ try {
+ is_supported = is_option_supported("NPU_TURBO");
+ } catch (...) {
+ // mute it, not critical
+ is_supported = false;
+ }
+ if (!is_supported) {
+ std::ostringstream turbostr;
+ turbostr << ov::intel_npu::turbo.name() << KEY_VALUE_SEPARATOR << VALUE_DELIMITER << "\\S+"
+ << VALUE_DELIMITER;
+ logger.info("NPU_TURBO property is not supported by this compiler. Removing from "
+ "parameters");
+ content = std::regex_replace(content, std::regex(turbostr.str()), "");
+ }
+ }
+
// 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
if (compilerVersion.major < 5) {
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index c726aeee1ea..4adf9997a50 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -307,6 +307,14 @@ void Plugin::filter_config_by_compiler_support(FilteredConfig& cfg) const {
// update enable flag
cfg.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 (cfg.hasOpt(ov::intel_npu::turbo.name())) {
+ cfg.enable(ov::intel_npu::turbo.name(), true);
+ }
}
FilteredConfig Plugin::fork_local_config(const std::map<std::string, std::string>& rawConfig,