Skip to content

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

[NPU] Disable layer profiling in case of infer profiling at compile-time (#37877)

Alexandru Enacheff92c0dbcc03
diff --git a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
index cb96f2a8a0b..2fd1a39151d 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
@@ -87,11 +87,13 @@ IPipeline::IPipeline(const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
"profiling type is 'INFER'");
enable_profiling();
}
- } else if (compiled_with_profiling.value_or(false)) {
- _logger.warning("IPipeline - model was compiled with layer profiling enabled, PERF_COUNT is NOT set and "
- "timestamps will "
- "not be extracted");
- enable_profiling();
+ } else {
+ _logger.warning("IPipeline - PROFILING_TYPE=INFER requires PERF_COUNT=ON; inference profiling is disabled");
+ if (compiled_with_profiling.value_or(false)) {
+ _logger.warning("IPipeline - model was compiled with layer profiling enabled, PERF_COUNT is NOT set "
+ "and timestamps will not be extracted");
+ enable_profiling();
+ }
}
} else {
if (compiled_with_profiling.has_value()) {
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.hpp
index 29035972eb7..a1aad5015d7 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
@@ -63,6 +63,7 @@ private:
std::vector<ov::PropertyName> properties = {
ov::cache_mode.name(),
ov::enable_profiling.name(),
+ ov::intel_npu::profiling_type.name(),
ov::device::architecture.name(),
ov::hint::execution_mode.name(),
ov::hint::inference_precision.name(),
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 39219ad72a7..3ce9b1e9ed4 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -479,6 +479,17 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
const bool shouldForceThroughput = successfullyDebatched && !performanceHintSetByUser;
const bool shouldWarnAboutLatency = successfullyDebatched && performanceHintSetByUser &&
localConfig.get<PERFORMANCE_HINT>() == ov::hint::PerformanceMode::LATENCY;
+ const bool shouldDisablePerfCountForInferProfiling =
+ localConfig.get<PROFILING_TYPE>() == ov::intel_npu::ProfilingType::INFER && localConfig.get<PERF_COUNT>();
+
+ FilteredConfig compilerConfig = localConfig;
+
+ if (shouldDisablePerfCountForInferProfiling) {
+ _logger.info(
+ "%s=INFER: overriding compiler-only PERF_COUNT from YES to NO; runtime configuration remains unchanged",
+ ov::intel_npu::profiling_type.name());
+ compilerConfig.update(ov::enable_profiling.name(), PERF_COUNT::toString(false));
+ }
if (shouldWarnAboutLatency) {
_logger.warning("PERFORMANCE_HINT is explicitly set to LATENCY mode, but batch dimension (N) is "
@@ -492,13 +503,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
if (shouldForceThroughput) {
_logger.info("Setting performance mode to THROUGHPUT for batched model compilation.");
-
- auto modifiedConfig = localConfig; // Copy only when needed
- modifiedConfig.updateAny(ov::hint::performance_mode.name(), ov::hint::PerformanceMode::THROUGHPUT);
- graph = compileWithConfig(std::move(modelToCompile), modifiedConfig);
- } else {
- graph = compileWithConfig(std::move(modelToCompile), localConfig);
+ compilerConfig.updateAny(ov::hint::performance_mode.name(), ov::hint::PerformanceMode::THROUGHPUT);
}
+
+ graph = compileWithConfig(std::move(modelToCompile), compilerConfig);
} catch (const std::exception& ex) {
OPENVINO_THROW(ex.what());
} catch (...) {
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp
index b0a4518cef4..649734cdca3 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp
@@ -561,6 +561,59 @@ TEST_P(ProfilingBlob, ProfilingCompileProfilingImport) {
OV_ASSERT_NO_THROW(inferReq.infer());
}
+using ProfilingBlobInferOnly = InferRequestRunTests;
+
+TEST_P(ProfilingBlobInferOnly, PerfCountOnInferProfilingCompilesUnprofiledBlob) {
+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();
+ if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {
+ GTEST_SKIP() << "Skip since driver extension version is lower than expected";
+ }
+
+ configuration[ov::intel_npu::profiling_type.name()] = ov::intel_npu::ProfilingType::INFER;
+ configuration[ov::enable_profiling.name()] = true;
+ ov::CompiledModel compiled_model;
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));
+
+ std::stringstream export_stream;
+ compiled_model.export_model(export_stream);
+
+ configuration[ov::intel_npu::profiling_type.name()] = ov::intel_npu::ProfilingType::MODEL;
+ ov::CompiledModel imported_model;
+ OV_ASSERT_NO_THROW(imported_model = core->import_model(export_stream, target_device, configuration));
+
+ ov::InferRequest inferReq;
+ OV_ASSERT_NO_THROW(inferReq = imported_model.create_infer_request());
+ ASSERT_ANY_THROW(inferReq.infer());
+
+ ov::InferRequest inferProfilingReq;
+ OV_ASSERT_NO_THROW(inferProfilingReq = compiled_model.create_infer_request());
+ OV_ASSERT_NO_THROW(inferProfilingReq.infer());
+ EXPECT_FALSE(inferProfilingReq.get_profiling_info().empty());
+}
+
+TEST_P(ProfilingBlobInferOnly, CacheDirDoesNotReuseBlobAcrossProfilingTypes) {
+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();
+ if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {
+ GTEST_SKIP() << "Skip since driver extension version is lower than expected";
+ }
+
+ m_cache_dir = generateCacheDirName(GetTestName());
+ core->set_property({ov::cache_dir(m_cache_dir)});
+
+ // warm cache with layer profiling blob
+ configuration[ov::enable_profiling.name()] = true;
+ configuration[ov::intel_npu::profiling_type.name()] = ov::intel_npu::ProfilingType::MODEL;
+ ov::CompiledModel model_profiled;
+ OV_ASSERT_NO_THROW(model_profiled = core->compile_model(ov_model, target_device, configuration));
+ EXPECT_FALSE(model_profiled.get_property(ov::loaded_from_cache));
+
+ // same PERF_COUNT, only PROFILING_TYPE differs: must be a cache miss
+ configuration[ov::intel_npu::profiling_type.name()] = ov::intel_npu::ProfilingType::INFER;
+ ov::CompiledModel infer_profiled;
+ OV_ASSERT_NO_THROW(infer_profiled = core->compile_model(ov_model, target_device, configuration));
+ EXPECT_FALSE(infer_profiled.get_property(ov::loaded_from_cache));
+}
+
TEST_P(InferRequestRunTests, MultipleExecutorTestsSyncInfers) {
SKIP_IF_CURRENT_TEST_IS_DISABLED();
ov::CompiledModel compiled_model;
@@ -3386,6 +3439,15 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
::testing::ValuesIn(profilingConfigs)),
InferRequestRunTests::getTestCaseName);
+const std::vector<ov::AnyMap> inferProfilingOnlyConfig{
+ {ov::intel_npu::profiling_type(ov::intel_npu::ProfilingType::INFER)}};
+
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
+ ProfilingBlobInferOnly,
+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::ValuesIn(inferProfilingOnlyConfig)),
+ InferRequestRunTests::getTestCaseName);
+
INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
RandomTensorOverZeroTensorRunTests,
::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),