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] Migrate to vclAllocatedExecutableCreateWSOneShot2 (#37254)
Wenjing Kang2f48ef39e60e
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hppindex 141f3be2eb6..7d2865db129 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp@@ -39,11 +39,12 @@ public:/*** @brief Compiles the model, weights separation enabled. All init schedules along with the main one are compiled in* the same scope.- * @return An ov::Tensor object for each init schedule, followed by another one corresponding to the main- * part.+ * @return A pair containing one ov::Tensor for each init schedule, followed by another one corresponding to the+ * main part, and an optional compatibility string for the compiled blobs.*/- std::vector<ov::Tensor> compileWsOneShot(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config) const;+ std::pair<std::vector<ov::Tensor>, std::optional<std::string>> compileWsOneShot(+ const std::shared_ptr<ov::Model>& model,+ const FilteredConfig& config) const;/*** @brief Sequential compilation of Init(s) and Main*@@ -58,9 +59,9 @@ public:* Compiler should somehow understand which Init (or Main) to return* Plugin does not know total numbers of Init schedules*/- ov::Tensor compileWsIterative(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config,- size_t callNumber) const;+ std::pair<ov::Tensor, std::optional<std::string>> compileWsIterative(const std::shared_ptr<ov::Model>& model,+ const FilteredConfig& config,+ size_t callNumber) const;/*** @brief Returns information about supported layers of the network passed* @param model The model to be querieddiff --git a/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hppindex 820997ae90b..c5f05a695e2 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp@@ -41,7 +41,8 @@ public:std::shared_ptr<const ov::Model>,std::pair<std::string, std::shared_ptr<ov::ICore>>>&& weightsSource,const FilteredConfig& config,- const bool blobIsPersistent = false);+ const bool blobIsPersistent = false,+ const std::optional<std::string>& compatibilityDescriptor = std::nullopt);/*** @brief The main schedule along with the weights initialization ones are exported.@@ -59,8 +60,6 @@ public:*/void initialize_impl(const FilteredConfig& config) override;- std::optional<std::string_view> get_compatibility_descriptor() const override;-// TODO: public for multi-threaded executionstruct InputData {std::vector<std::shared_ptr<ov::ITensor>> tensors;diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cppindex 04a774e4d92..e50afb0c5a1 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp@@ -40,6 +40,21 @@ UsedVersion getUsedVclVersion(uint16_t pluginMajor, uint16_t pluginMinor, constreturn {usedMajor, usedMinor};}+void checkVclVersion(const UsedVersion& usedVersion, const vcl_version_info_t& loadedVersion) {+ if (usedVersion.Major < VCL_COMPILER_VERSION_MAJOR ||+ (usedVersion.Major == VCL_COMPILER_VERSION_MAJOR && usedVersion.Minor < VCL_COMPILER_VERSION_MINOR)) {+ OPENVINO_THROW("Unsupported VCL version: ",+ loadedVersion.major,+ ".",+ loadedVersion.minor,+ ", please use VCL ",+ VCL_COMPILER_VERSION_MAJOR,+ ".",+ VCL_COMPILER_VERSION_MINOR,+ " or later");+ }+}+} // namespacenamespace intel_npu {@@ -80,6 +95,45 @@ static inline std::string getLatestVCLLog(vcl_log_handle_t logHandle) {return logContent;}+static std::optional<std::string> getVCLCompatibilityString(vcl_executable_handle_t executable,+ vcl_log_handle_t logHandle) {+ uint64_t compatibilityStringSize = 0;+ auto result = vclExecutableGetCompatibilityString(executable, nullptr, &compatibilityStringSize);+ if (result == VCL_RESULT_ERROR_UNSUPPORTED_FEATURE) {+ return std::nullopt;+ }+ if (result != VCL_RESULT_SUCCESS || compatibilityStringSize == 0) {+ OPENVINO_THROW("Failed to get compatibility string size. vclExecutableGetCompatibilityString result: 0x",+ std::hex,+ uint64_t(result),+ " - ",+ getLatestVCLLog(logHandle));+ }++ if (compatibilityStringSize > std::numeric_limits<size_t>::max()) {+ OPENVINO_THROW("Compatibility string size is too large to allocate a local buffer");+ }+ std::string compatibilityString(static_cast<size_t>(compatibilityStringSize), '\0');+ result = vclExecutableGetCompatibilityString(executable, compatibilityString.data(), &compatibilityStringSize);+ if (result != VCL_RESULT_SUCCESS) {+ OPENVINO_THROW("Failed to get compatibility string. vclExecutableGetCompatibilityString result: 0x",+ std::hex,+ uint64_t(result),+ " - ",+ getLatestVCLLog(logHandle));+ }+ if (compatibilityStringSize > compatibilityString.size()) {+ OPENVINO_THROW("Returned compatibility string size exceeds the allocated buffer size");+ }++ const size_t outSize = static_cast<size_t>(compatibilityStringSize);+ compatibilityString.resize(outSize);+ if (outSize > 0 && compatibilityString[outSize - 1] == '\0') {+ compatibilityString.resize(outSize - 1);+ }+ return compatibilityString;+}+#define THROW_ON_FAIL_FOR_VCL(step, ret, logHandle) \{ \vcl_result_t result = ret; \@@ -202,18 +256,7 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(/// Check the linked vcl version whether supported in pluginUsedVersion usedVersion = getUsedVclVersion(VCL_COMPILER_VERSION_MAJOR, VCL_COMPILER_VERSION_MINOR, _vclVersion);_logger.debug("the finally used compiler vcl version is %d.%d", usedVersion.Major, usedVersion.Minor);- if (usedVersion.Major < VCL_COMPILER_VERSION_MAJOR ||- (usedVersion.Major == VCL_COMPILER_VERSION_MAJOR && usedVersion.Minor < VCL_COMPILER_VERSION_MINOR)) {- OPENVINO_THROW("Unsupported VCL version: ",- _vclVersion.major,- ".",- _vclVersion.minor,- ", please use VCL ",- VCL_COMPILER_VERSION_MAJOR,- ".",- VCL_COMPILER_VERSION_MINOR,- " or later");- }+ checkVclVersion(usedVersion, _vclVersion);const auto maxOpsetVersion = _compilerProperties.supportedOpsets;_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);@@ -301,44 +344,18 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(allocator->m_info.erase(it);std::optional<std::string> compatibilityString;- uint64_t compatibilityStringSize = 0;- result = vclExecutableGetCompatibilityString(executable, nullptr, &compatibilityStringSize);- if (result == VCL_RESULT_ERROR_UNSUPPORTED_FEATURE) {+ try {+ compatibilityString = getVCLCompatibilityString(executable, _logHandle);+ } catch (...) {+ vclExecutableDestroy(executable);+ throw;+ }+ if (!compatibilityString.has_value()) {// Some compilation modes (e.g. HostCompile_Interpreter) do not produce a compatibility descriptor._logger.info("vclExecutableGetCompatibilityString is not supported for this executable (0x%x); ""compatibility string will be absent",- uint32_t(result));- } else if (result != VCL_RESULT_SUCCESS || compatibilityStringSize == 0) {- if (executable != nullptr) {- vclExecutableDestroy(executable);- }- OPENVINO_THROW("Failed to get compatibility string size. vclExecutableGetCompatibilityString result: 0x",- std::hex,- uint64_t(result),- " - ",- getLatestVCLLog(_logHandle));+ uint32_t(VCL_RESULT_ERROR_UNSUPPORTED_FEATURE));} else {- OPENVINO_ASSERT(compatibilityStringSize <= std::numeric_limits<size_t>::max(),- "Compatibility string size is too large to allocate a local buffer");- compatibilityString.emplace(static_cast<size_t>(compatibilityStringSize), '\0');- result = vclExecutableGetCompatibilityString(executable, compatibilityString->data(), &compatibilityStringSize);- if (result != VCL_RESULT_SUCCESS) {- if (executable != nullptr) {- vclExecutableDestroy(executable);- }- OPENVINO_THROW("Failed to get compatibility string. vclExecutableGetCompatibilityString result: 0x",- std::hex,- uint64_t(result),- " - ",- getLatestVCLLog(_logHandle));- }- OPENVINO_ASSERT(compatibilityStringSize <= compatibilityString->size(),- "Returned compatibility string size exceeds the allocated buffer size");- size_t outSize = static_cast<size_t>(compatibilityStringSize);- if (outSize > 0 && (*compatibilityString)[outSize - 1] == '\0') {- --outSize;- }- compatibilityString->resize(outSize);_logger.debug("Compatibility string from VCL: %s", compatibilityString->c_str());}@@ -355,13 +372,15 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(std::move(compatibilityString));}-std::vector<ov::Tensor> VCLCompilerImpl::compileWsOneShot(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config) const {+std::pair<std::vector<ov::Tensor>, std::optional<std::string>> VCLCompilerImpl::compileWsOneShot(+ const std::shared_ptr<ov::Model>& model,+ const FilteredConfig& config) const {_logger.debug("compileWsOneShot start");/// Check the linked vcl version whether supported in pluginUsedVersion usedVersion = getUsedVclVersion(VCL_COMPILER_VERSION_MAJOR, VCL_COMPILER_VERSION_MINOR, _vclVersion);_logger.debug("the finally used compiler vcl version is %d.%d", usedVersion.Major, usedVersion.Minor);+ checkVclVersion(usedVersion, _vclVersion);const auto maxOpsetVersion = _compilerProperties.supportedOpsets;_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);@@ -405,14 +424,27 @@ std::vector<ov::Tensor> VCLCompilerImpl::compileWsOneShot(const std::shared_ptr<buildFlags.size()};_logger.debug("compiler vcl version: %d.%d", _vclVersion.major, _vclVersion.minor);- _logger.debug("Using vclAllocatedExecutableCreateWSOneShot");+ _logger.debug("Using vclAllocatedExecutableCreateWSOneShot2");auto allocator = std::make_shared<vcl_allocator_2>();+ vcl_executable_handle_t executable = nullptr;- THROW_ON_FAIL_FOR_VCL("vclAllocatedExecutableCreateWSOneShot",- vclAllocatedExecutableCreateWSOneShot(_compilerHandle, exeDesc, allocator.get()),- _logHandle);+ auto result = vclAllocatedExecutableCreateWSOneShot2(_compilerHandle, exeDesc, allocator.get(), &executable);+ if (result != VCL_RESULT_SUCCESS) {+ if (executable != nullptr) {+ vclExecutableDestroy(executable);+ }+ OPENVINO_THROW("Compilation failed. vclAllocatedExecutableCreateWSOneShot2 result: 0x",+ std::hex,+ uint64_t(result),+ " - ",+ getLatestVCLLog(_logHandle));+ }+ if (executable == nullptr) {+ OPENVINO_THROW("Failed to create VCL executable, executable handle is null");+ }if (allocator->m_info.size() == 0) {+ vclExecutableDestroy(executable);OPENVINO_THROW("Failed to create VCL executable, blobCount is zero");}@@ -423,17 +455,42 @@ std::vector<ov::Tensor> VCLCompilerImpl::compileWsOneShot(const std::shared_ptr<// Clean up m_info, delegating actual physical frees strictly to the Tensor/Deleter from now on.allocator->m_info.clear();- return initMainTensors;+ std::optional<std::string> compatibilityString;+ try {+ compatibilityString = getVCLCompatibilityString(executable, _logHandle);+ } catch (...) {+ vclExecutableDestroy(executable);+ throw;+ }+ if (!compatibilityString.has_value()) {+ _logger.info("vclExecutableGetCompatibilityString is not supported for this executable (0x%x); "+ "compatibility string will be absent",+ uint32_t(VCL_RESULT_ERROR_UNSUPPORTED_FEATURE));+ } else {+ _logger.debug("Compatibility string from VCL: %s", compatibilityString->c_str());+ }++ result = vclExecutableDestroy(executable);+ if (result != VCL_RESULT_SUCCESS) {+ OPENVINO_THROW("Failed to destroy executable. vclExecutableDestroy result: 0x",+ std::hex,+ uint64_t(result),+ " - ",+ getLatestVCLLog(_logHandle));+ }++ return std::make_pair(std::move(initMainTensors), std::move(compatibilityString));}-ov::Tensor VCLCompilerImpl::compileWsIterative(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config,- size_t callNumber) const {+std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compileWsIterative(+ const std::shared_ptr<ov::Model>& model,+ const FilteredConfig& config,+ size_t callNumber) const {_logger.debug("compileWsIterative start");FilteredConfig updatedConfig = config;updatedConfig.update({{ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber)}});- // The compatibility descriptor is not supported in this case- return compile(model, updatedConfig, true).first;+ // Return the compatibility descriptor together with the compiled blob.+ return compile(model, updatedConfig, true);}std::vector<ov::ProfilingInfo> VCLCompilerImpl::process_profiling_output(const std::vector<uint8_t>& profData,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 7ff65d7d8f4..311736dd12d 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@@ -259,7 +259,9 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Modstd::move(initNetworkMetadata),/* initBlobs = */ std::nullopt,std::move(model),- updatedConfig);+ updatedConfig,+ /* persistentBlob = */ false,+ get_compatibility_descriptor(mainGraphHandle._handle));}ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov::Model>& model,diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cppindex a7464c775a5..3650b686cc0 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp@@ -98,7 +98,8 @@ std::shared_ptr<IGraph> Parser::parse(initBlobs,std::move(weightsSource),config,- blobIsPersistent);+ blobIsPersistent,+ compatibilityDescriptor);}} // namespace intel_npudiff --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 0a2053251e9..b95f419bbc5 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@@ -147,10 +147,13 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::Modov::Tensor tensorMain;GraphDescriptor mainGraphDesc;NetworkMetadata mainNetworkMetadata;+ std::optional<std::string> compatibilityDescriptor;switch (localConfig.get<SEPARATE_WEIGHTS_VERSION>()) {case ov::intel_npu::WSVersion::ONE_SHOT: {- std::vector<ov::Tensor> initMainTensors = _compiler->compileWsOneShot(model, localConfig);+ auto oneShotResult = _compiler->compileWsOneShot(model, localConfig);+ auto initMainTensors = std::move(oneShotResult.first);+ compatibilityDescriptor = std::move(oneShotResult.second);tensorMain = initMainTensors.back();initMainTensors.pop_back();@@ -212,7 +215,15 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::Modstd::shared_ptr<ov::Model> targetModel = model;size_t i = 0;- while (auto tensor = _compiler->compileWsIterative(targetModel, localConfig, i++)) {+ while (true) {+ auto iterativeResult = _compiler->compileWsIterative(targetModel, localConfig, i++);+ auto tensor = std::move(iterativeResult.first);+ if (iterativeResult.second.has_value()) {+ compatibilityDescriptor = std::move(iterativeResult.second);+ }+ if (!tensor) {+ break;+ }GraphDescriptor graphDesc = _zeGraphExt->getGraphDescriptor(tensor.data(), tensor.get_byte_size());NetworkMetadata networkMetadata = _zeGraphExt->getNetworkMeta(graphDesc);@@ -259,7 +270,8 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::ModtensorsInits,std::move(model),localConfig,- /* persistentBlob = */ true); // exporting the blob shall be available in such a scenario+ /* persistentBlob = */ true,+ compatibilityDescriptor); // exporting the blob shall be available in such a scenario}ov::SupportedOpsMap PluginCompilerAdapter::query(const std::shared_ptr<const ov::Model>& model,diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cppindex f7b3b67d65d..b56d95b5f2c 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp@@ -264,14 +264,15 @@ WeightlessGraph::WeightlessGraph(std::variant<std::monostate, std::shared_ptr<const ov::Model>, std::pair<std::string, std::shared_ptr<ov::ICore>>>&&weightsSource,const FilteredConfig& config,- const bool blobIsPersistent)+ const bool blobIsPersistent,+ const std::optional<std::string>& compatibilityDescriptor): Graph(zeGraphExt,zeroInitStruct,mainGraphDesc,std::move(mainMetadata),std::move(mainBlob),config,- /* compatibilityDescriptor = */ std::nullopt,+ compatibilityDescriptor,blobIsPersistent),_initsGraphDesc(initGraphDesc),_initBlobs(std::move(initBlobs)),@@ -429,11 +430,6 @@ void WeightlessGraph::initialize_impl(const FilteredConfig& config) {set_weights_inputs();}-std::optional<std::string_view> WeightlessGraph::get_compatibility_descriptor() const {- _logger.warning("Compatibility descriptor is not supported for WeightlessGraph");- return std::nullopt;-}-WeightlessGraph::InputData WeightlessGraph::allocate_inputs(const size_t initIndex,std::unordered_map<size_t, std::shared_ptr<ov::op::v0::Constant>>& constants) {diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.h b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.hindex 580a7ababcf..4ec74aa8806 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.h+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.h@@ -22,7 +22,7 @@ extern "C" {#endif#define VCL_COMPILER_VERSION_MAJOR 7-#define VCL_COMPILER_VERSION_MINOR 8+#define VCL_COMPILER_VERSION_MINOR 10#define VCL_PROFILING_VERSION_MAJOR 2#define VCL_PROFILING_VERSION_MINOR 0@@ -297,6 +297,13 @@ VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreateWSOneShot(vclvcl_executable_desc_t desc,vcl_allocator2_t* allocator);+/// @brief Creates weight-separated blobs and returns an executable handle for compatibility-string queries.+/// @details The returned handle must be released with \b vclExecutableDestroy.+VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreateWSOneShot2(vcl_compiler_handle_t compiler,+ vcl_executable_desc_t desc,+ vcl_allocator2_t* allocator,+ vcl_executable_handle_t* executable);+////////////////////////////////////////////////////////////////////////////////// @brief Destroys the executable and releases the cached blob.VCL_APIEXPORT vcl_result_t VCL_APICALL vclExecutableDestroy(vcl_executable_handle_t executable);diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hppindex 406e33a0138..fccd84ca522 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp@@ -38,8 +38,7 @@ namespace intel_npu {#define vcl_weak_symbols_list() \vcl_symbol_statement(vclAllocatedExecutableCreate) \vcl_symbol_statement(vclAllocatedExecutableCreate2) \- vcl_symbol_statement(vclAllocatedExecutableCreateWSOneShot)-// clang-format on+ vcl_symbol_statement(vclAllocatedExecutableCreateWSOneShot2) // clang-format onclass VCLApi {public:diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cppindex c28affaab6a..dffb64a507f 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp@@ -5,6 +5,7 @@#include <gmock/gmock-matchers.h>#include <gmock/gmock.h>#include <gtest/gtest.h>+#include <memory>#include <mutex>#include <openvino/runtime/intel_npu/properties.hpp>@@ -183,7 +184,7 @@ TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsValueIsReadableWhencompiledModel = {};}-TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsNotSupportedForWS) {+TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsSupportedForWS) {// Preparing the model for the teststd::stringstream model_xml, model_bin;{@@ -205,18 +206,108 @@ TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsNotSupportedForWS{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),ov::intel_npu::platform(ov::intel_npu::Platform::standardize(ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU))),- ov::enable_weightless(true)}));+ ov::enable_weightless(true),+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT)}));std::vector<ov::PropertyName> properties;- // Test that RUNTIME_REQUIREMENTS is not supported for a weightless model- OV_EXPECT_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements),- ov::Exception,- testing::HasSubstr("Unsupported configuration key: RUNTIME_REQUIREMENTS"));+ // Test that RUNTIME_REQUIREMENTS is supported for a weightless model+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_FALSE(it->is_mutable());++ std::string requirements;+ OV_ASSERT_NO_THROW(requirements = compiledModel.get_property(ov::runtime_requirements));+ ASSERT_FALSE(requirements.empty());+}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsSupportedForWSIterative) {+ // Preparing the model for the test+ std::stringstream model_xml, model_bin;+ {+ // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime+ // information of constant nodes+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::pass::Serialize serializer(model_xml, model_bin);+ serializer.run_on_model(model);+ }+ auto model_bin_str = model_bin.str();+ ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});+ std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());+ auto model = core.read_model(model_xml.str(), model_weights);++ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU))),+ ov::enable_weightless(true),+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE)}));++ std::vector<ov::PropertyName> properties;+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it != properties.cend());- // Test that RUNTIME_REQUIREMENTS is not in the list of supported properties either+ std::string requirements;+ OV_ASSERT_NO_THROW(requirements = compiledModel.get_property(ov::runtime_requirements));+ ASSERT_FALSE(requirements.empty());+}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsExportImportForWSIterative) {+ // Preparing the model for the test+ std::stringstream model_xml, model_bin;+ {+ // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime+ // information of constant nodes+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::pass::Serialize serializer(model_xml, model_bin);+ serializer.run_on_model(model);+ }+ auto model_bin_str = model_bin.str();+ ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});+ std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());+ auto model = core.read_model(model_xml.str(), model_weights);++ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU))),+ ov::enable_weightless(true),+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE)}));++ std::vector<ov::PropertyName> properties;OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);- ASSERT_TRUE(it == properties.cend());+ ASSERT_TRUE(it != properties.cend());++ std::string reference_requirements;+ OV_ASSERT_NO_THROW(reference_requirements = compiledModel.get_property(ov::runtime_requirements));+ ASSERT_FALSE(reference_requirements.empty());++ std::stringstream compiled_blob;+ OV_ASSERT_NO_THROW(compiledModel.export_model(compiled_blob));++ OV_ASSERT_NO_THROW(compiledModel = {});+ // A weightless blob does not embed the weights, so the original model must be provided on import+ OV_ASSERT_NO_THROW(compiledModel = core.import_model(compiled_blob, deviceName, {ov::hint::model(model)}));++ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it != properties.cend());++ std::string imported_requirements;+ OV_ASSERT_NO_THROW(imported_requirements = compiledModel.get_property(ov::runtime_requirements));+ ASSERT_FALSE(imported_requirements.empty());++ // The equality must be guaranteed for a given openvino version+ // If the blob was exported with a different OV version, requirements might differ+ ASSERT_EQ(reference_requirements, imported_requirements);}TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsExportImport) {@@ -251,6 +342,81 @@ TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsExportImport) {ASSERT_EQ(reference_requirements, imported_requirements);}+TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsExportImportForWSIterativeCID) {+ // The compatibility descriptor on the compiler-in-driver path is only available when the driver+ // graph API version is high enough. On older drivers it is expected to be absent.+ const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ const bool driverHandlesCompatibilityCheck =+ initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);++ // Preparing the model for the test+ std::stringstream model_xml, model_bin;+ {+ // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime+ // information of constant nodes+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::pass::Serialize serializer(model_xml, model_bin);+ serializer.run_on_model(model);+ }+ auto model_bin_str = model_bin.str();+ ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});+ std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());+ auto model = core.read_model(model_xml.str(), model_weights);++ // Forcing CID as the current compiler type+ // Check for the property in the supported properties list, since the driver may not support it.+ std::vector<ov::PropertyName> supportedProperties;+ OV_ASSERT_NO_THROW(supportedProperties =+ core.get_property(deviceName,+ ov::supported_properties,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));+ if (find(supportedProperties.cbegin(), supportedProperties.cend(), ov::enable_weightless.name()) ==+ supportedProperties.cend()) {+ GTEST_SKIP() << "current driver does not support ENABLE_WEIGHTLESS";+ }++ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::bypass_umd_caching(true),+ ov::enable_weightless(true),+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE)}));++ std::vector<ov::PropertyName> properties;+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ if (!driverHandlesCompatibilityCheck) {+ ASSERT_TRUE(it == properties.cend());+ return;+ }+ ASSERT_TRUE(it != properties.cend());++ std::string reference_requirements;+ OV_ASSERT_NO_THROW(reference_requirements = compiledModel.get_property(ov::runtime_requirements));+ ASSERT_FALSE(reference_requirements.empty());++ std::stringstream compiled_blob;+ OV_ASSERT_NO_THROW(compiledModel.export_model(compiled_blob));++ OV_ASSERT_NO_THROW(compiledModel = {});+ // A weightless blob does not embed the weights, so the original model must be provided on import+ OV_ASSERT_NO_THROW(compiledModel = core.import_model(compiled_blob, deviceName, {ov::hint::model(model)}));++ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it != properties.cend());++ std::string imported_requirements;+ OV_ASSERT_NO_THROW(imported_requirements = compiledModel.get_property(ov::runtime_requirements));+ ASSERT_FALSE(imported_requirements.empty());++ // The equality must be guaranteed for a given openvino version+ // If the blob was exported with a different OV version, requirements might differ+ ASSERT_EQ(reference_requirements, imported_requirements);+}+TEST_P(ClassCompatibilityStringTestSuite, CompatibilityStringGenerateAndCheck) {// Forcing CIP as the current compiler typeauto model = ov::test::utils::make_conv_pool_relu();