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][WS] Use "ov::enable_weightless" instead of the "weightless_blob" NPU specific config option (#35063)
Stefania Herganef488845c8b8b
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cppindex 52945e0fc64..e5d4647c045 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp@@ -250,9 +250,6 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCoREGISTER_OPTION(BATCH_COMPILER_MODE_SETTINGS);REGISTER_OPTION(TURBO);REGISTER_OPTION(ENABLE_WEIGHTLESS);- // WEIGHTLESS_BLOB can be removed once- // NPU Compilers support ENABLE_WEIGHTLESS- REGISTER_OPTION(WEIGHTLESS_BLOB);REGISTER_OPTION(SEPARATE_WEIGHTS_VERSION);REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);REGISTER_OPTION(MODEL_SERIALIZER_VERSION);@@ -531,25 +528,27 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<OV_ITT_TASK_NEXT(PLUGIN_COMPILE_MODEL, "compile");- if (localConfig.isAvailable(ov::intel_npu::weightless_blob.name()) && !localConfig.get<CACHE_DIR>().empty()) {+ if (localConfig.isAvailable(ov::enable_weightless.name()) && !localConfig.get<CACHE_DIR>().empty()) {// If OV caching is enabled, then weights separation is performed only if the user opted for optimizing the// size of the binary objectconst bool cacheModeOptimizeSize = (localConfig.get<CACHE_MODE>() == ov::CacheMode::OPTIMIZE_SIZE);- if (localConfig.get<WEIGHTLESS_BLOB>() && !cacheModeOptimizeSize) {- _logger.warning("The cache mode was not set to \"optimize size\" but the \"WEIGHTLESS_BLOB\" configuration "- "option was set to true. Weights separation WILL NOT be performed in this case.");- } else if (!localConfig.get<WEIGHTLESS_BLOB>() && cacheModeOptimizeSize) {- _logger.warning("The cache mode was set to \"optimize size\" but the \"WEIGHTLESS_BLOB\" configuration "- "option was set to false. Weights separation WILL be performed in this case.");+ if (localConfig.get<ENABLE_WEIGHTLESS>() && !cacheModeOptimizeSize) {+ _logger.warning(+ "The cache mode was not set to \"optimize size\" but the \"ENABLE_WEIGHTLESS\" configuration option"+ "was set to true. Weights separation WILL NOT be performed in this case.");+ } else if (!localConfig.get<ENABLE_WEIGHTLESS>() && cacheModeOptimizeSize) {+ _logger.warning(+ "The cache mode was set to \"optimize size\" but the \"ENABLE_WEIGHTLESS\" configuration option"+ "was set to false. Weights separation WILL be performed in this case.");}- localConfig.update({{ov::intel_npu::weightless_blob.name(), cacheModeOptimizeSize ? "YES" : "NO"}});+ localConfig.update({{ov::enable_weightless.name(), cacheModeOptimizeSize ? "YES" : "NO"}});}std::shared_ptr<intel_npu::IGraph> graph;auto compileWithConfig = [&](auto&& modelToCompile, const auto& config) {- if (!localConfig.get<WEIGHTLESS_BLOB>() && !localConfig.get<ENABLE_WEIGHTLESS>()) {+ if (!localConfig.get<ENABLE_WEIGHTLESS>()) {return compiler->compile(modelToCompile, config);} else {check_weightless_cache_attribute_occurrence(model);diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cppindex cf7f0e34386..557088633c9 100644--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp@@ -552,7 +552,6 @@ void Properties::registerPluginProperties() {TRY_REGISTER_SIMPLE_PROPERTY(ov::hint::enable_cpu_pinning, ENABLE_CPU_PINNING);TRY_REGISTER_SIMPLE_PROPERTY(ov::workload_type, WORKLOAD_TYPE);TRY_REGISTER_SIMPLE_PROPERTY(ov::enable_weightless, ENABLE_WEIGHTLESS);- TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::weightless_blob, WEIGHTLESS_BLOB);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::separate_weights_version, SEPARATE_WEIGHTS_VERSION);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::model_serializer_version, MODEL_SERIALIZER_VERSION);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::enable_strides_for, ENABLE_STRIDES_FOR);@@ -754,7 +753,6 @@ void Properties::registerCompiledModelProperties() {BATCH_COMPILER_MODE_SETTINGS);TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY);TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::enable_weightless, ENABLE_WEIGHTLESS);- TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::weightless_blob, WEIGHTLESS_BLOB);TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::separate_weights_version, SEPARATE_WEIGHTS_VERSION);TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::enable_strides_for, ENABLE_STRIDES_FOR);diff --git a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp b/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hppindex 71190a3ddd6..ecbc3c570be 100644--- a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp+++ b/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp@@ -265,7 +265,7 @@ protected:TEST_P(WeightsSeparationTests, CheckOneShotVersionThrows) {model = createTestModel();configuration[ov::intel_npu::compiler_type.name()] = ov::intel_npu::CompilerType::DRIVER;- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));OV_EXPECT_THROW(compiled_model = core->compile_model(model, target_device, configuration), ov::Exception, _);}@@ -276,7 +276,7 @@ TEST_P(WeightsSeparationTests, CheckOneShotVersionThrows) {*/TEST_P(WeightsSeparationTests, CheckForFailureNoWeightlessCacheAttribute) {model = createTestModel(false);- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_EXPECT_THROW(compiled_model = core->compile_model(model, target_device, configuration), ov::Exception, _);}@@ -307,7 +307,7 @@ TEST_P(WeightsSeparationTests, CorrectInferenceResultIfCachingUsed) {*/TEST_P(WeightsSeparationTests, CorrectInferenceResultIfModelHintUsed) {model = createTestModel();- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -332,7 +332,7 @@ TEST_P(WeightsSeparationTests, CorrectInferenceResultIfWeightsPathUsed) {model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();ov::serialize(model, model_path + ".xml", model_path + ".bin");- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -356,7 +356,7 @@ TEST_P(WeightsSeparationTests, WrongInferenceResultIfWrongWeightsProvided) {model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();ov::serialize(different_model, model_path + ".xml", model_path + ".bin");- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -385,7 +385,7 @@ TEST_P(WeightsSeparationTests, WrongInferenceResultIfWrongWeightsProvided) {TEST_P(WeightsSeparationTests, CorrectInferenceResultIfTensorImported) {model = createTestModel();- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -406,7 +406,7 @@ TEST_P(WeightsSeparationTests, CorrectInferenceResultIfTensorImported) {TEST_P(WeightsSeparationTests, ImportFailureIfNoWeightsProvided) {model = createTestModel();- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -423,7 +423,7 @@ TEST_P(WeightsSeparationTests, ImportFailureIfNoWeightsProvided) {TEST_P(WeightsSeparationTests, ModelHintHasPriorityOverWeightsPath) {model = createTestModel();- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -504,7 +504,7 @@ TEST_P(WeightsSeparationTests, WeightfulIfCacheDirectoryNotProvided) {/*** @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be- * weightless. Otherwise, ov::intel_npu::weightless_blob is this switch.+ * weightless. Otherwise, ov::enable_weightless is this switch.*/TEST_P(WeightsSeparationTests, CacheModeHasPriorityOverWeightlessBlobIfCachingIsUsed) {m_cache_dir = generateCacheDirName(GetTestName());@@ -512,7 +512,7 @@ TEST_P(WeightsSeparationTests, CacheModeHasPriorityOverWeightlessBlobIfCachingIsmodel = createTestModel();- configuration.emplace(ov::intel_npu::weightless_blob(true));+ configuration.emplace(ov::enable_weightless(true));configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SPEED));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -529,12 +529,12 @@ TEST_P(WeightsSeparationTests, CacheModeHasPriorityOverWeightlessBlobIfCachingIs/*** @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be- * weightless. Otherwise, ov::intel_npu::weightless_blob is this switch.+ * weightless. Otherwise, ov::enable_weightless is this switch.*/TEST_P(WeightsSeparationTests, WeightlessBlobHasPriorityOverCacheModeIfCachingIsNotUsed) {model = createTestModel();- configuration.emplace(ov::intel_npu::weightless_blob(false));+ configuration.emplace(ov::enable_weightless(false));configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -555,14 +555,14 @@ TEST_P(WeightsSeparationTests, WeightlessBlobHasPriorityOverCacheModeIfCachingIsTEST_P(WeightsSeparationTests, WeightlessBlobIsSmaller) {model = createTestModelLightInitSchedule();std::ostringstream weightfullBlobStream;- configuration.insert(ov::intel_npu::weightless_blob(false));+ configuration.insert(ov::enable_weightless(false));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);OV_ASSERT_NO_THROW(compiled_model.export_model(weightfullBlobStream));std::ostringstream weightlessBlobStream;- configuration.at(ov::intel_npu::weightless_blob.name()) = true;+ configuration.at(ov::enable_weightless.name()) = true;OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -579,7 +579,7 @@ void WeightsSeparationTests::runCorrectInferenceResultIfCannotCompileAsWeightlesov::serialize(model, model_path + ".xml", model_path + ".bin");// compilation should succeed- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));ASSERT_TRUE(compiled_model);@@ -609,7 +609,7 @@ void WeightsSeparationTests::runCorrectInferenceResultIfCannotCompileAsWeightlesTEST_P(WeightsSeparationTests, CorrectInferenceResultWeightlessWithDuplicateConstants) {model = createTestModelWeightlessWithDuplicateConstants();- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();ov::serialize(model, model_path + ".xml", model_path + ".bin");@@ -646,7 +646,7 @@ using WeightsSeparationOneShotTests = WeightsSeparationTests;*/TEST_P(WeightsSeparationOneShotTests, CorrectInferenceResultNoImportOneShot) {model = createTestModel();- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));@@ -674,7 +674,7 @@ using WeightsSeparationIterativeTests = WeightsSeparationTests;*/TEST_P(WeightsSeparationIterativeTests, CorrectInferenceResultNoImportIterative) {model = createTestModel();- configuration.insert(ov::intel_npu::weightless_blob(true));+ configuration.insert(ov::enable_weightless(true));configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE));OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));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.hppindex 581fc84fbb7..1be5b8e1f5e 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@@ -164,7 +164,6 @@ public:REGISTER_OPTION(IMPORT_RAW_BLOB);REGISTER_OPTION(BATCH_COMPILER_MODE_SETTINGS);REGISTER_OPTION(TURBO);- REGISTER_OPTION(WEIGHTLESS_BLOB);REGISTER_OPTION(SEPARATE_WEIGHTS_VERSION);REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);REGISTER_OPTION(MODEL_SERIALIZER_VERSION);