Skip to content

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

[NPU] Add compile log level property (#37093)

Alexandru Enache759ccd162bcc
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 191ec179fe2..f45071814e1 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
@@ -233,6 +233,47 @@ struct LOG_LEVEL final : OptionBase<LOG_LEVEL, ov::log::Level> {
}
};
+// The option is intentionally left without a default value: an unset option means it inherits LOG_LEVEL, which
+// cannot be expressed from defaultValue() alone (it has no visibility of other options). resolve() implements
+// that fallback.
+struct COMPILE_LOG_LEVEL final : OptionBase<COMPILE_LOG_LEVEL, ov::log::Level> {
+ static std::string_view key() {
+ return ov::intel_npu::compile_log_level.name();
+ }
+
+ static constexpr std::string_view getTypeName() {
+ return "ov::log::Level";
+ }
+
+ static std::string_view envVar() {
+ return "OV_NPU_COMPILE_LOG_LEVEL";
+ }
+
+ // RunTime despite its name: this is a plugin-side knob, never serialized to the compiler under its own key.
+ // serializeConfig() resolves it and forwards the result to the compiler under the compiler-understood
+ // LOG_LEVEL key instead.
+ static OptionMode mode() {
+ return OptionMode::RunTime;
+ }
+
+ static bool isPublic() {
+ return false;
+ }
+
+ /**
+ * @brief Returns the effective compile log level.
+ * @param config The configuration to resolve the compile log level against.
+ * @return The explicitly-set COMPILE_LOG_LEVEL when present (via property or OV_NPU_COMPILE_LOG_LEVEL env
+ * var), otherwise the plugin LOG_LEVEL it inherits from.
+ */
+ static ov::log::Level resolve(const Config& config) {
+ if (config.has<COMPILE_LOG_LEVEL>()) {
+ return config.get<COMPILE_LOG_LEVEL>();
+ }
+ return config.get<LOG_LEVEL>();
+ }
+};
+
struct PLATFORM final : OptionBase<PLATFORM, std::string> {
static std::string_view key() {
return ov::intel_npu::platform.name();
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
index 6bbdaaf2a9a..836e9f66e83 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
@@ -293,6 +293,18 @@ static constexpr ov::Property<int64_t> stepping{"NPU_STEPPING"};
*/
static constexpr ov::Property<std::string> compilation_mode{"NPU_COMPILATION_MODE"};
+/**
+ * @brief [Only for NPU Plugin]
+ * Type: ov::log::Level
+ * Controls the verbosity of the NPU compiler's own logging for a single compile() call, independently of
+ * ov::log::level (which controls the plugin-side logging). This lets a user raise plugin logging without also
+ * enabling the compiler's much more verbose internal logging, and vice versa. Like other compile-time properties,
+ * it can also be set persistently via ov::Core::set_property() / plugin set_property(), in which case it affects
+ * every subsequent compile_model() call until changed again.
+ * @note If this property is not set, the compile log level inherits the value of ov::log::level.
+ */
+static constexpr ov::Property<ov::log::Level> compile_log_level{"NPU_COMPILE_LOG_LEVEL"};
+
/**
* @brief [Only for NPU Plugin]
* Type: integer, default is -1
diff --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.hpp
index 8e362452225..2c95a9b7a6e 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
@@ -6,7 +6,6 @@
#include <atomic>
#include <memory>
-#include <optional>
#include <string_view>
#include "intel_npu/common/icompiler_adapter.hpp"
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 6d924775b02..23a9ec02a26 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
@@ -698,11 +698,25 @@ std::string serializeIOInfo(const std::shared_ptr<const ov::Model>& model, const
outputsPrecisionSS.str() + VALUES_SEPARATOR.data() + outputsLayoutSS.str();
}
-std::string serializeConfig(const FilteredConfig& config,
+std::string serializeConfig(const FilteredConfig& originalConfig,
const ze_graph_compiler_version_info_t& compilerVersion,
const std::function<bool(const std::string&)>& isOptionSupportedByCompiler) {
Logger logger("serializeConfig", Logger::global().level());
+ // Compiler log level decoupling: the compiler only understands the LOG_LEVEL key. When the user explicitly set
+ // NPU_COMPILE_LOG_LEVEL, copy the config and overwrite LOG_LEVEL on the copy with that (resolved) value, then
+ // use the copy for the remainder of this function so every subsequent read observes the compiler-specific
+ // level instead of the plugin one. When NPU_COMPILE_LOG_LEVEL is unset, no copy
+ // is made and the compiler keeps inheriting the plugin LOG_LEVEL exactly as before.
+ std::optional<FilteredConfig> configWithCompileLogLevel;
+ if (originalConfig.has<COMPILE_LOG_LEVEL>()) {
+ std::ostringstream levelStr;
+ levelStr << originalConfig.get<COMPILE_LOG_LEVEL>();
+ configWithCompileLogLevel = originalConfig;
+ configWithCompileLogLevel->update({{ov::log::level.name(), levelStr.str()}});
+ }
+ const FilteredConfig& config = configWithCompileLogLevel.has_value() ? *configWithCompileLogLevel : originalConfig;
+
std::string content = {};
content += config.toStringForCompiler();
diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp
index f110dbdf395..209734bb37f 100644
--- a/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp
@@ -176,6 +176,7 @@ void CompiledModelPropertyManager::registerProperties() {
try_register_property_based_on_config_if_set_as_read_only<ENABLE_STRIDES_FOR>(_config, _properties, ov::intel_npu::enable_strides_for.name());
try_register_property_based_on_config_if_set_as_read_only<BATCH_MODE>(_config, _properties, ov::intel_npu::batch_mode.name());
try_register_property_based_on_config_if_set_as_read_only<SHARED_COMMON_QUEUE>(_config, _properties, ov::intel_npu::shared_common_queue.name());
+ try_register_property_based_on_config_if_set_as_read_only<COMPILE_LOG_LEVEL>(_config, _properties, ov::intel_npu::compile_log_level.name());
try_register_property_based_on_config_with_custom_function(_config, _properties, ov::cache_encryption_callbacks.name(), [](const Config&) {
return ov::EncryptionCallbacks{nullptr, nullptr};
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 827a37a422a..4eab984c711 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -139,6 +139,7 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCo
} while (0)
REGISTER_OPTION(LOG_LEVEL);
+ REGISTER_OPTION(COMPILE_LOG_LEVEL);
REGISTER_OPTION(CACHE_DIR);
REGISTER_OPTION(CACHE_MODE);
REGISTER_OPTION(COMPILED_BLOB);
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.cpp
index cbd35d71ade..a15d9aa97d4 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
@@ -368,6 +368,8 @@ void PluginPropertyManager::registerProperties() const {
try_register_property_based_on_config_with_custom_function(_config, _properties, ov::cache_encryption_callbacks.name(), [](const Config&) {
return ov::EncryptionCallbacks{nullptr, nullptr};
});
+ try_register_property_based_on_config_with_custom_function(_config, _properties, ov::intel_npu::compile_log_level.name(),
+ [](const Config& config) -> ov::Any { return COMPILE_LOG_LEVEL::resolve(config); });
// clang-format on
// Special case: this property is always registered because it's supported by the implementation,
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 3734e18a68f..ee4c44885b5 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
@@ -9,6 +9,7 @@
#include <vector>
#include "common/npu_test_env_cfg.hpp"
+#include "intel_npu/npu_private_properties.hpp"
using namespace ov::test::behavior;
@@ -51,7 +52,8 @@ std::vector<std::pair<std::string, ov::Any>> compat_plugin_internal_mutable_prop
};
std::vector<std::pair<std::string, ov::Any>> plugin_internal_mutable_properties = {
- {ov::intel_npu::stepping.name(), ov::Any(4)}};
+ {ov::intel_npu::stepping.name(), ov::Any(4)},
+ {ov::intel_npu::compile_log_level.name(), ov::Any(ov::log::Level::ERR)}};
std::vector<std::pair<std::string, ov::Any>> plugin_public_immutable_properties = {
{ov::device::uuid.name(), ov::Any("deadbeef")},
diff --git a/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.hpp b/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.hpp
index ae3e696b0fa..53294d2cb59 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.hpp
@@ -5,8 +5,8 @@
#pragma once
#include <algorithm>
-#include <cstring>
#include <common_test_utils/ov_tensor_utils.hpp>
+#include <cstring>
#include <functional>
#include <iostream>
#include <sstream>
@@ -15,10 +15,12 @@
#include <tuple>
#include <vector>
+#include "intel_npu/npu_private_properties.hpp"
#include "openvino/openvino.hpp"
#include "openvino/opsets/opset6.hpp"
#include "openvino/pass/manager.hpp"
#include "openvino/pass/serialize.hpp"
+#include "openvino/runtime/intel_npu/properties.hpp"
#include "openvino/runtime/make_tensor.hpp"
#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
@@ -30,16 +32,18 @@ inline std::shared_ptr<ov::Model> createMaxPoolModel(bool dynamicBatch = false,
std::shared_ptr<ov::op::v0::Parameter> input;
if (dynamicBatch) {
input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16,
- ov::PartialShape{ov::Dimension(1, 10), 16, 720, 1280});
+ ov::PartialShape{ov::Dimension(1, 10), 16, 720, 1280});
} else {
- input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16,
- ov::PartialShape{1, 16, ov::Dimension(10, 720), ov::Dimension(10, 1280)});
+ input = std::make_shared<ov::op::v0::Parameter>(
+ ov::element::f16,
+ ov::PartialShape{1, 16, ov::Dimension(10, 720), ov::Dimension(10, 1280)});
}
std::string inputName = "input1";
input->set_friendly_name(inputName);
input->get_output_tensor(0).set_names({inputName});
- if (!nhwcLayout) input->set_layout("NCHW");
+ if (!nhwcLayout)
+ input->set_layout("NCHW");
auto maxpool = std::make_shared<ov::op::v1::MaxPool>(input,
Strides{1, 1},
Shape{0, 0},
@@ -51,12 +55,13 @@ inline std::shared_ptr<ov::Model> createMaxPoolModel(bool dynamicBatch = false,
auto result = std::make_shared<ov::op::v0::Result>(maxpool);
std::string outputName = "output";
- if (!nhwcLayout) result->set_layout("NCHW");
+ if (!nhwcLayout)
+ result->set_layout("NCHW");
result->set_friendly_name(outputName);
result->get_output_tensor(0).set_names({outputName});
auto model = std::make_shared<Model>(ResultVector{result}, ParameterVector{input}, "MaxPool");
-
+
// making input and output to be NHWC
if (nhwcLayout) {
auto preProc = ov::preprocess::PrePostProcessor(model);
@@ -72,8 +77,9 @@ inline std::shared_ptr<ov::Model> createMaxPoolModel(bool dynamicBatch = false,
}
inline std::shared_ptr<ov::Model> createCustomNetModel() {
- auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16,
- ov::PartialShape{1, 16, ov::Dimension(1, 1080), ov::Dimension(10, 1920)});
+ auto input = std::make_shared<ov::op::v0::Parameter>(
+ ov::element::f16,
+ ov::PartialShape{1, 16, ov::Dimension(1, 1080), ov::Dimension(10, 1920)});
input->set_friendly_name("Parameter_59");
auto make_conv_add = [](const ov::Output<ov::Node>& data,
@@ -223,10 +229,11 @@ public:
void SetUp() {
// Skip test according to plugin specific disabledTestPatterns() (if any)
- SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
std::tie(target_device, configuration, selectedModelName) = this->GetParam();
+ configuration[ov::intel_npu::compile_log_level.name()] = ov::log::Level::ERR;
std::vector<std::string> deviceNames =
core->get_property("NPU", ov::available_devices.name()).as<std::vector<std::string>>();
for (auto name : deviceNames) {
@@ -708,12 +715,9 @@ TEST_P(InferWithDefaultHostCompileTests, CompileDynamicModelWithNoHostCompileMod
}
if (selectedModelName == "MaxPool_NCHW_DynBatch") {
- ASSERT_TRUE(isElfBlob(modelStream.str()))
- << "Expected exported model to be an ELF blob";
- }
- else if (selectedModelName == "MaxPool_NCHW") {
- ASSERT_TRUE(isByteCodeBlob(modelStream.str()))
- << "Expected exported model to be a bytecode";
+ ASSERT_TRUE(isElfBlob(modelStream.str())) << "Expected exported model to be an ELF blob";
+ } else if (selectedModelName == "MaxPool_NCHW") {
+ ASSERT_TRUE(isByteCodeBlob(modelStream.str())) << "Expected exported model to be a bytecode";
}
ov::InferRequest reqDynamic;
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/compile_log_level.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/compile_log_level.cpp
new file mode 100644
index 00000000000..ab3b868dda3
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/compile_log_level.cpp
@@ -0,0 +1,82 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <memory>
+#include <string>
+
+#include "intel_npu/common/filtered_config.hpp"
+#include "intel_npu/config/config.hpp"
+#include "intel_npu/config/options.hpp"
+#include "model_serializer.hpp"
+#include "openvino/runtime/intel_npu/properties.hpp"
+
+namespace {
+
+class CompileLogLevelSerializeConfigTests : public ::testing::Test {
+protected:
+ std::shared_ptr<::intel_npu::OptionsDesc> options;
+ std::unique_ptr<::intel_npu::FilteredConfig> config;
+
+ void SetUp() override {
+ using namespace ::intel_npu;
+
+ options = std::make_shared<OptionsDesc>();
+ options->add<LOG_LEVEL>();
+ options->add<COMPILE_LOG_LEVEL>();
+
+ config = std::make_unique<FilteredConfig>(options);
+
+ config->enable(ov::log::level.name(), true);
+ config->enableRuntimeOptions();
+ }
+
+ static ze_graph_compiler_version_info_t modernCompilerVersion() {
+ ze_graph_compiler_version_info_t version{};
+ version.major = 7;
+ version.minor = 0;
+ return version;
+ }
+
+ std::string serialize() const {
+ const auto allSupported = [](const std::string&) {
+ return true;
+ };
+ return ::intel_npu::compiler_utils::serializeConfig(*config, modernCompilerVersion(), allSupported);
+ }
+};
+
+TEST_F(CompileLogLevelSerializeConfigTests, BackwardCompatibleCompilerLogUnsetPluginLogSet) {
+ config->update({{ov::log::level.name(), "LOG_DEBUG"}});
+
+ const std::string flags = serialize();
+
+ EXPECT_NE(flags.find(std::string(ov::log::level.name()) + "=\"LOG_DEBUG\""), std::string::npos) << flags;
+ EXPECT_EQ(flags.find(ov::intel_npu::compile_log_level.name()), std::string::npos)
+ << "NPU_COMPILE_LOG_LEVEL must never be serialized under its own key: " << flags;
+}
+
+TEST_F(CompileLogLevelSerializeConfigTests, CompileLogLevelSetPrioritizedOverUnchangedPluginLogLevel) {
+ config->update({{ov::log::level.name(), "LOG_DEBUG"}, {ov::intel_npu::compile_log_level.name(), "LOG_ERROR"}});
+
+ const std::string flags = serialize();
+
+ EXPECT_NE(flags.find(std::string(ov::log::level.name()) + "=\"LOG_ERROR\""), std::string::npos) << flags;
+ EXPECT_EQ(flags.find(std::string(ov::log::level.name()) + "=\"LOG_DEBUG\""), std::string::npos) << flags;
+ EXPECT_EQ(flags.find(ov::intel_npu::compile_log_level.name()), std::string::npos)
+ << "NPU_COMPILE_LOG_LEVEL must never be serialized under its own key: " << flags;
+}
+
+TEST_F(CompileLogLevelSerializeConfigTests, CompileLogLevelSetPrioritizedOverChangedPluginLogLevel) {
+ config->update({{ov::intel_npu::compile_log_level.name(), "LOG_TRACE"}});
+
+ const std::string flags = serialize();
+
+ EXPECT_NE(flags.find(std::string(ov::log::level.name()) + "=\"LOG_TRACE\""), std::string::npos) << flags;
+ EXPECT_EQ(flags.find(ov::intel_npu::compile_log_level.name()), std::string::npos)
+ << "NPU_COMPILE_LOG_LEVEL must never be serialized under its own key: " << flags;
+}
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp
index 0fe58f6735b..9a479ab02f4 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
@@ -38,3 +38,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
::testing::ValuesIn(unsupported_compiler_configs)),
PropertiesManagerTests::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
+ CompileLogLevelPropertyTests,
+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::Values(std::string{})),
+ PropertiesManagerTests::getTestCaseName);
diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp
index cf7a1816963..f79dbb471da 100644
--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp
@@ -8,12 +8,14 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <algorithm>
#include <array>
#include <cstddef>
#include <exception>
#include <memory>
#include <random>
#include <thread>
+#include <vector>
#include "common/npu_test_env_cfg.hpp"
#include "common/utils.hpp"
@@ -89,6 +91,7 @@ public:
npu_config.enable(std::move(o_name), false); \
} while (0)
REGISTER_OPTION(LOG_LEVEL);
+ REGISTER_OPTION(COMPILE_LOG_LEVEL);
REGISTER_OPTION(CACHE_DIR);
REGISTER_OPTION(CACHE_MODE);
REGISTER_OPTION(COMPILED_BLOB);
@@ -213,6 +216,29 @@ TEST_P(PropertiesManagerTests, ExpectRunTimeSpecialBothPropertyIsSupported) {
ASSERT_TRUE(isSupported);
}
+using CompileLogLevelPropertyTests = PropertiesManagerTests;
+
+TEST_P(CompileLogLevelPropertyTests, InheritsPluginLogLevelWhenUnset) {
+ propertiesManager->setProperty({{ov::log::level(ov::log::Level::DEBUG)}});
+
+ ov::Any retrieved;
+ OV_ASSERT_NO_THROW(retrieved = propertiesManager->getProperty(ov::intel_npu::compile_log_level.name()));
+ ASSERT_EQ(retrieved.as<ov::log::Level>(), ov::log::Level::DEBUG);
+}
+
+TEST_P(CompileLogLevelPropertyTests, IsIndependentFromLogLevel) {
+ propertiesManager->setProperty(
+ {{ov::log::level(ov::log::Level::DEBUG)}, {ov::intel_npu::compile_log_level(ov::log::Level::ERR)}});
+
+ ov::Any compilerLevel;
+ OV_ASSERT_NO_THROW(compilerLevel = propertiesManager->getProperty(ov::intel_npu::compile_log_level.name()));
+ ASSERT_EQ(compilerLevel.as<ov::log::Level>(), ov::log::Level::ERR);
+
+ ov::Any pluginLevel;
+ OV_ASSERT_NO_THROW(pluginLevel = propertiesManager->getProperty(ov::log::level.name()));
+ ASSERT_EQ(pluginLevel.as<ov::log::Level>(), ov::log::Level::DEBUG);
+}
+
using CompatibilityCheckTests = PropertiesManagerTests;
TEST_P(CompatibilityCheckTests, ExpectArgumentIsNotSupported) {