OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPU] Remove WS_COMPILE_CALL_NUMBER from private properties (#38181)
Bogdan Pereanu57cc7902d1f1
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.hppindex 209aaf52293..987c28d4df0 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@@ -365,11 +365,14 @@ static constexpr ov::Property<WSVersion> separate_weights_version{"NPU_SEPARATE_static constexpr ov::Property<ModelSerializerVersion> model_serializer_version{"NPU_MODEL_SERIALIZER_VERSION"};/**- * @brief [Experimental, only for NPU Plugin]+ * @brief [Only for NPU Plugin]* Type: integer.** Used for communicating a state to the compiler when compiling a model using the compiler-in-driver interfaces. This* takes effect only when weights separation is enabled and "NPU_SEPARATE_WEIGHTS_VERSION" is set to "ITERATIVE".+ *+ * Note: This property is internal, it is used strictly for plugin -> compiler synchronization and is not meant to be+ * used by the application. Setting or getting it from user code will throw.*/static constexpr ov::Property<uint32_t> ws_compile_call_number{"WS_COMPILE_CALL_NUMBER"};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.cppindex c3d27f028b7..86ba221e831 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@@ -210,6 +210,11 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Modreturn is_option_supported(optionName);};+ OPENVINO_ASSERT(is_option_supported(ov::intel_npu::ws_compile_call_number.name()),+ "WS_COMPILE_CALL_NUMBER is a compiler option and must be supported by the compiler.");+ OPENVINO_ASSERT(!updatedConfig.has(ov::intel_npu::ws_compile_call_number.name()),+ "WS_COMPILE_CALL_NUMBER is an internal option owned by the weights separation compilation "+ "loop and must not be set by the user.");while (true) {_logger.debug("compileWS iteration %d", callNumber);updatedConfig.update(ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber++));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.cppindex 69ee9c1c6e0..48d0122ca10 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@@ -221,6 +221,11 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::Modstd::shared_ptr<ov::Model> targetModel = model;size_t i = 0;+ OPENVINO_ASSERT(is_option_supported(ov::intel_npu::ws_compile_call_number.name()),+ "WS_COMPILE_CALL_NUMBER is a compiler option and must be supported by the compiler.");+ OPENVINO_ASSERT(!localConfig.has(ov::intel_npu::ws_compile_call_number.name()),+ "WS_COMPILE_CALL_NUMBER is an internal option owned by the weights separation compilation "+ "loop and must not be set by the user.");while (true) {auto iterativeResult = _compiler->compileWsIterative(targetModel, localConfig, i++);auto tensor = std::move(iterativeResult.first);diff --git a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cppindex 3a0050eae85..95c598b79f6 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@@ -866,6 +866,17 @@ void PluginPropertyManager::registerProperties() {_config.update(ov::intel_npu::compile_log_level.name(), value.as<std::string>());});+ register_property(ov::intel_npu::ws_compile_call_number.name(), false, ov::PropertyMutability::RO, //The RO isn't true here, it will throw even if trying to read it+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::intel_npu::ws_compile_call_number.name());+ },+ [](const ov::AnyMap&) -> ov::Any {+ OPENVINO_THROW("Property '", ov::intel_npu::ws_compile_call_number.name(), "' cannot be accessed.");+ },+ [](const ov::Any&) {+ OPENVINO_THROW("Property '", ov::intel_npu::ws_compile_call_number.name(), "' cannot be accessed.");+ }+ );const auto alwaysSupported = [](const ov::AnyMap&) {return true;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.cppindex bece3cc5ae8..598c3fd8622 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@@ -738,77 +738,64 @@ TEST_P(CompatibilityCheckTests, CheckCacheEncryptionCallbacksWithGetMergedConfigASSERT_TRUE(unknownProperties.empty());}-TEST_P(CompatibilityCheckTests, CheckInternalCompilerOptionWithGetMergedConfigAndUnknownPropertiesOnCompile) {- auto [filteredConfig, unknownProperties] = [&]() {- return propertiesManager->getMergedConfigAndUnknownProperties(- {{{"WS_COMPILE_CALL_NUMBER", ov::Any(1)},- ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},- ::intel_npu::ConfigMergeMode::Compile);- }();-- ASSERT_TRUE(filteredConfig.hasInternal("WS_COMPILE_CALL_NUMBER"));- ASSERT_TRUE(unknownProperties.empty());+using WSCompileCallNumberPropertyTests = PropertiesManagerTests;++TEST_P(WSCompileCallNumberPropertyTests, IsNotExposedToTheUser) {+ ASSERT_FALSE(propertiesManager->isPropertySupported(ov::intel_npu::ws_compile_call_number.name()));++ std::vector<ov::PropertyName> supportedProperties;+ OV_ASSERT_NO_THROW(supportedProperties =+ propertiesManager->getProperty(ov::supported_properties.name())+ .as<std::vector<ov::PropertyName>>());+ ASSERT_EQ(std::find(supportedProperties.cbegin(),+ supportedProperties.cend(),+ ov::intel_npu::ws_compile_call_number.name()),+ supportedProperties.cend());}-TEST_P(CompatibilityCheckTests,- CheckInternalCompilerOptionWithGetMergedConfigAndUnknownPropertiesOnImportLoadedFromCache) {- std::string logs;- std::mutex logs_mutex;-- 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');- };+TEST_P(WSCompileCallNumberPropertyTests, CannotBeReadThroughGetProperty) {+ OV_EXPECT_THROW(propertiesManager->getProperty(ov::intel_npu::ws_compile_call_number.name()),+ ov::Exception,+ HasSubstr("Property 'WS_COMPILE_CALL_NUMBER' cannot be accessed."));+}- auto [filteredConfig, unknownProperties] = [&]() {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);- return propertiesManager->getMergedConfigAndUnknownProperties(- {{{"WS_COMPILE_CALL_NUMBER", ov::Any(1)},- ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),- {ov::loaded_from_cache.name(), ov::Any(true)}}},- ::intel_npu::ConfigMergeMode::Import);- }();+TEST_P(WSCompileCallNumberPropertyTests, CannotBeWrittenThroughSetProperty) {+ OV_EXPECT_THROW(propertiesManager->setProperty({{ov::intel_npu::ws_compile_call_number(5)}}),+ ov::Exception,+ HasSubstr("READ-ONLY configuration key: WS_COMPILE_CALL_NUMBER"));- ASSERT_FALSE(filteredConfig.hasInternal("WS_COMPILE_CALL_NUMBER"));- ASSERT_TRUE(unknownProperties.empty());- ASSERT_NE(logs.find("Property 'WS_COMPILE_CALL_NUMBER' is recognized as a compiler option, will not be used for "- "current configuration."),- std::string::npos);+ // The rejected value must not have been stored as an internal compiler option either.+ OV_EXPECT_THROW(propertiesManager->getProperty(ov::intel_npu::ws_compile_call_number.name()),+ ov::Exception,+ HasSubstr("Property 'WS_COMPILE_CALL_NUMBER' cannot be accessed."));}-TEST_P(CompatibilityCheckTests, CheckInternalCompilerOptionWithGetMergedConfigAndUnknownPropertiesOnImport) {- auto [filteredConfig, unknownProperties] = [&]() {- return propertiesManager->getMergedConfigAndUnknownProperties(- {{{"WS_COMPILE_CALL_NUMBER", ov::Any(1)},- ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},- ::intel_npu::ConfigMergeMode::Import);- }();-- ASSERT_FALSE(filteredConfig.hasInternal("WS_COMPILE_CALL_NUMBER"));- ASSERT_EQ(unknownProperties.size(), 1);- ASSERT_TRUE(unknownProperties.count("WS_COMPILE_CALL_NUMBER"));+TEST_P(WSCompileCallNumberPropertyTests, IsRejectedByGetMergedConfigAndUnknownProperties) {+ for (const auto mergeMode :+ {::intel_npu::ConfigMergeMode::Compile, ::intel_npu::ConfigMergeMode::Import,+ ::intel_npu::ConfigMergeMode::Query}) {+ OV_EXPECT_THROW(propertiesManager->getMergedConfigAndUnknownProperties(+ {{ov::intel_npu::ws_compile_call_number(1),+ ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ mergeMode),+ ov::Exception,+ HasSubstr("READ-ONLY configuration key: WS_COMPILE_CALL_NUMBER"));+ }}-TEST_P(CompatibilityCheckTests, CheckInternalCompilerOptionWithSetPropertyAndGetProperty) {- OV_ASSERT_NO_THROW(- propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}}));- ov::intel_npu::CompilerType compilerType = ov::intel_npu::CompilerType::DRIVER;- OV_ASSERT_NO_THROW(- compilerType =- propertiesManager->getProperty(ov::intel_npu::compiler_type.name()).as<ov::intel_npu::CompilerType>());- ASSERT_EQ(compilerType, ov::intel_npu::CompilerType::PLUGIN); // make sure plugin compiler is set+TEST_P(WSCompileCallNumberPropertyTests, RemainsAvailableAsInternalCompilerOption) {+ // The option itself stays registered so that the compiler adapters can still set it internally, it is only the+ // user-facing property which is unusable.+ auto [filteredConfig, unknownProperties] = propertiesManager->getMergedConfigAndUnknownProperties(+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Compile);- OV_EXPECT_THROW(propertiesManager->getProperty("WS_COMPILE_CALL_NUMBER"),- ov::Exception,- testing::HasSubstr("Unsupported configuration key: WS_COMPILE_CALL_NUMBER"));+ ASSERT_TRUE(filteredConfig.hasOpt(ov::intel_npu::ws_compile_call_number.name()));+ ASSERT_FALSE(filteredConfig.hasInternal(ov::intel_npu::ws_compile_call_number.name()));+ ASSERT_TRUE(unknownProperties.empty());- OV_ASSERT_NO_THROW(propertiesManager->setProperty({{"WS_COMPILE_CALL_NUMBER", ov::Any(5)}}));- uint32_t ws_compile_call_number = 0;- OV_ASSERT_NO_THROW(ws_compile_call_number =- propertiesManager->getProperty("WS_COMPILE_CALL_NUMBER").as<uint32_t>());- ASSERT_EQ(ws_compile_call_number, 5);+ OV_ASSERT_NO_THROW(filteredConfig.update(ov::intel_npu::ws_compile_call_number.name(), "3"));+ ASSERT_EQ(filteredConfig.get<::intel_npu::WS_COMPILE_CALL_NUMBER>(), 3);}using ExpectLoadingCompilerPropertySupported = PropertiesManagerTests;@@ -914,6 +901,12 @@ INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,::testing::Values(std::string{})),PropertiesManagerTests::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,+ WSCompileCallNumberPropertyTests,+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),+ ::testing::Values(std::string{})),+ PropertiesManagerTests::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,ExpectLoadingCompilerPropertySupported,::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),