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] Add support for runtime_requirements and compatibility_check (#35478)
Patrik Stepan9f7b20e48a9a
diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cppindex 5e6c79aaf2f..38aa50d7f6c 100644--- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp+++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp@@ -28,8 +28,7 @@ void regmodule_properties(py::module m) {py::enum_<ov::CompatibilityCheck>(m_properties, "CompatibilityCheck", py::arithmetic()).value("NOT_APPLICABLE", ov::CompatibilityCheck::NOT_APPLICABLE)- .value("OPTIMAL", ov::CompatibilityCheck::OPTIMAL)- .value("PREFER_RECOMPILATION", ov::CompatibilityCheck::PREFER_RECOMPILATION)+ .value("SUPPORTED", ov::CompatibilityCheck::SUPPORTED).value("UNSUPPORTED", ov::CompatibilityCheck::UNSUPPORTED);// Submodule properties - propertiesdiff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.pyindex d504d166068..1ae6bcb78b3 100644--- a/src/bindings/python/tests/test_runtime/test_properties.py+++ b/src/bindings/python/tests/test_runtime/test_properties.py@@ -58,13 +58,8 @@ def test_properties_rw_base():props.CompatibilityCheck,((props.CompatibilityCheck.NOT_APPLICABLE, "CompatibilityCheck.NOT_APPLICABLE", 0),- (props.CompatibilityCheck.OPTIMAL, "CompatibilityCheck.OPTIMAL", 1),- (- props.CompatibilityCheck.PREFER_RECOMPILATION,- "CompatibilityCheck.PREFER_RECOMPILATION",- 2,- ),- (props.CompatibilityCheck.UNSUPPORTED, "CompatibilityCheck.UNSUPPORTED", 3),+ (props.CompatibilityCheck.SUPPORTED, "CompatibilityCheck.SUPPORTED", 1),+ (props.CompatibilityCheck.UNSUPPORTED, "CompatibilityCheck.UNSUPPORTED", 2),),),(diff --git a/src/inference/include/openvino/runtime/properties.hpp b/src/inference/include/openvino/runtime/properties.hppindex 17aad60c225..7467e350ff3 100644--- a/src/inference/include/openvino/runtime/properties.hpp+++ b/src/inference/include/openvino/runtime/properties.hpp@@ -1446,11 +1446,9 @@ static constexpr Property<uint64_t, PropertyMutability::RW> value_cache_group_si* Returned by ov::compatibility_check when queried with an ov::runtime_requirements string argument.*/enum class CompatibilityCheck {- NOT_APPLICABLE = 0, //!< The device does not support this check, or no requirements string was provided.- OPTIMAL = 1, //!< Requirements are fully met; import is expected to succeed with optimal performance.- PREFER_RECOMPILATION = 2, //!< Requirements are loosely compatible; import may succeed but recompilation- //!< is preferred for best performance.- UNSUPPORTED = 3, //!< Requirements are not met; import will fail.+ NOT_APPLICABLE = 0, //!< The device does not support this check, or no requirements string was provided.+ SUPPORTED = 1, //!< Requirements are met; import is expected to succeed with optimal performance.+ UNSUPPORTED = 2, //!< Requirements are not met; import will fail.};/** @cond INTERNAL */@@ -1458,10 +1456,8 @@ inline std::ostream& operator<<(std::ostream& os, const CompatibilityCheck& compswitch (compatibility) {case CompatibilityCheck::NOT_APPLICABLE:return os << "NOT_APPLICABLE";- case CompatibilityCheck::OPTIMAL:- return os << "OPTIMAL";- case CompatibilityCheck::PREFER_RECOMPILATION:- return os << "PREFER_RECOMPILATION";+ case CompatibilityCheck::SUPPORTED:+ return os << "SUPPORTED";case CompatibilityCheck::UNSUPPORTED:return os << "UNSUPPORTED";default:@@ -1474,10 +1470,8 @@ inline std::istream& operator>>(std::istream& is, CompatibilityCheck& compatibilis >> str;if (str == "NOT_APPLICABLE") {compatibility = CompatibilityCheck::NOT_APPLICABLE;- } else if (str == "OPTIMAL") {- compatibility = CompatibilityCheck::OPTIMAL;- } else if (str == "PREFER_RECOMPILATION") {- compatibility = CompatibilityCheck::PREFER_RECOMPILATION;+ } else if (str == "SUPPORTED") {+ compatibility = CompatibilityCheck::SUPPORTED;} else if (str == "UNSUPPORTED") {compatibility = CompatibilityCheck::UNSUPPORTED;} else {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.hppindex 375e453d373..9f00b2cdb1f 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@@ -1569,4 +1569,67 @@ struct CACHE_ENCRYPTION_CALLBACKS final : OptionBase<CACHE_ENCRYPTION_CALLBACKS,}};+struct RUNTIME_REQUIREMENTS final : OptionBase<RUNTIME_REQUIREMENTS, std::string> {+ static std::string_view key() {+ return ov::runtime_requirements.name();+ }++ static std::string defaultValue() {+ return {};+ }++ static OptionMode mode() {+ return OptionMode::RunTime;+ }++ static bool isPublic() {+ return true;+ }++ static ov::PropertyMutability mutability() {+ return ov::PropertyMutability::RO;+ }+};++struct COMPATIBILITY_CHECK final : OptionBase<COMPATIBILITY_CHECK, ov::CompatibilityCheck> {+ static std::string_view key() {+ return ov::compatibility_check.name();+ }++ static constexpr std::string_view getTypeName() {+ return "ov::CompatibilityCheck";+ }++ static ov::CompatibilityCheck defaultValue() {+ return ov::CompatibilityCheck::NOT_APPLICABLE;+ }++ static OptionMode mode() {+ return OptionMode::RunTime;+ }++ static ov::CompatibilityCheck parse(std::string_view val) {+ std::istringstream stringStream = std::istringstream(std::string(val));+ ov::CompatibilityCheck check_result;+ stringStream >> check_result;++ return check_result;+ }++ static std::string toString(const ov::CompatibilityCheck& val) {+ std::ostringstream stringStream;+ stringStream << val;++ return stringStream.str();+ }++ static bool isPublic() {+ return true;+ }++ static ov::PropertyMutability mutability() {+ return ov::PropertyMutability::RO;+ }+};+} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hppindex 8830ebf6174..588681b2d9c 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp@@ -37,6 +37,8 @@ public:virtual std::optional<std::vector<std::string>> get_supported_options() const = 0;virtual bool is_option_supported(std::string optName, std::optional<std::string> optValue = std::nullopt) const = 0;+ virtual bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const = 0;+virtual ~ICompilerAdapter() = default;};diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hppindex f323dec4bcc..0714ca5bce1 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp@@ -75,6 +75,8 @@ public:virtual std::optional<bool> is_profiling_blob() const = 0;+ virtual std::optional<std::string_view> get_compatibility_descriptor() const;+protected:virtual void initialize_impl(const FilteredConfig& config);diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hppindex 62bb850d220..da98dc0c290 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp@@ -28,7 +28,8 @@ public:const ov::Tensor& mainBlob,const FilteredConfig& config,const std::optional<std::vector<ov::Tensor>>& initBlobs = std::nullopt,- std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt) const = 0;+ std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt,+ const std::optional<std::string>& compatibilityDescriptor = std::nullopt) const = 0;virtual ~IParser() = default;};diff --git a/src/plugins/intel_npu/src/common/src/igraph.cpp b/src/plugins/intel_npu/src/common/src/igraph.cppindex 7009720d4f0..513890005df 100644--- a/src/plugins/intel_npu/src/common/src/igraph.cpp+++ b/src/plugins/intel_npu/src/common/src/igraph.cpp@@ -24,6 +24,10 @@ void IGraph::set_argument_value_with_strides(uint32_t, const void*, const std::vOPENVINO_THROW("set_argument_value_with_strides not implemented");}+std::optional<std::string_view> IGraph::get_compatibility_descriptor() const {+ OPENVINO_THROW("get_compatibility_descriptor not implemented");+}+void IGraph::initialize(const FilteredConfig& config) {std::lock_guard<std::mutex> lock(_initialize_mutex);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 bf377bc382c..8c05c7a2cd1 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@@ -29,9 +29,11 @@ public:* @param model a shared pointer to the OpenVINO model to be compiled* @param config a reference to NPUConfig containing plugin config options* including config options related to compilation- * @return an ov::Tensor object containing the blob of the compiled model+ * @return a pair containing an ov::Tensor object with the compiled model (blob) and an optional+ * string with runtime requirements for the blob*/- ov::Tensor compile(const std::shared_ptr<const ov::Model>& model, const FilteredConfig& config) const;+ std::pair<ov::Tensor, std::optional<std::string>> compile(const std::shared_ptr<const ov::Model>& model,+ const FilteredConfig& config) const;/*** @brief Compiles the model, weights separation enabled. All init schedules along with the main one are compiled in@@ -88,15 +90,27 @@ public:std::shared_ptr<void> getLinkedLibrary() const;+ /**+ * @brief Validates the compatibility descriptor against the current device information.+ * This function is used as a fallback check when the driver on the system does not support the required API+ * @param compatibilityDescriptor The compatibility descriptor (string) to be validated+ * @param in_device_desc Pointer to a device descriptor containing the device ID, number of+ * tiles and stepping information+ * @return false if the platform does not meet the requirements specified in the compatibility descriptor,+ * true if the platform is compatible+ */+ bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor,+ vcl_device_desc_t* in_device_desc) const;+private:/**- * @brief Compiles the given model according to the given configuration. During the model serialization step, the- * "WeightlessCacheAttribute" may be stored within the serialized model if requested.+ * @brief Compiles the given model according to the given configuration. During the model serialization step,+ * the "WeightlessCacheAttribute" may be stored within the serialized model if requested.* @note Storing the "WeightlessCacheAttribute" is necessary if the "weights separation" flow is being used.*/- ov::Tensor compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config,- const bool storeWeightlessCacheAttributeFlag) const;+ std::pair<ov::Tensor, std::optional<std::string>> compile(const std::shared_ptr<const ov::Model>& model,+ const FilteredConfig& config,+ const bool storeWeightlessCacheAttributeFlag) const;vcl_log_handle_t _logHandle = nullptr;vcl_compiler_handle_t _compilerHandle = nullptr;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hppindex 8603cd0b913..432d85a1303 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp@@ -32,6 +32,8 @@ public:uint32_t get_version() const override;+ bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const override;+private:bool isCompilerOptionSupported(const FilteredConfig& config,const ze_graph_compiler_version_info_t& compilerVersion,diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hppindex b827d196810..871316ab5c1 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp@@ -196,6 +196,8 @@ public:std::optional<bool> is_profiling_blob() const override;+ std::optional<std::string_view> get_compatibility_descriptor() const override;+private:void initialize_impl(const FilteredConfig& config) override;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hppindex c74177a1ee5..4484fa36f7b 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp@@ -25,6 +25,7 @@ public:NetworkMetadata metadata,std::optional<ov::Tensor> blob,const FilteredConfig& config,+ const std::optional<std::string>& compatibilityDescriptor = std::nullopt,const bool blobIsPersistent = false,const bool calledFromWeightlessGraph = false);@@ -61,6 +62,8 @@ public:void evict_memory() override;+ std::optional<std::string_view> get_compatibility_descriptor() const override;+~Graph() override;protected:@@ -81,6 +84,7 @@ protected:std::vector<std::shared_ptr<Event>> _lastSubmittedEvent;std::optional<ov::Tensor> _blob;+ std::optional<std::string> _compatibilityDescriptor;// In the case of the import path, the blob is released after graph initialization so it can not be any longer// exporteddiff --git a/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/parser.hppindex 1097d29ced5..4d96c46dfca 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp@@ -22,7 +22,8 @@ public:const ov::Tensor& mainBlob,const FilteredConfig& config,const std::optional<std::vector<ov::Tensor>>& initBlobs = std::nullopt,- std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt) const override;+ std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt,+ const std::optional<std::string>& compatibilityDescriptor = std::nullopt) const override;private:std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hppindex 77208296b31..2e402cee30d 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp@@ -33,6 +33,8 @@ public:uint32_t get_version() const override;+ bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const override;+private:std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cppindex d25699973e5..539ea6ac99e 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp@@ -60,7 +60,7 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(const ov::// It is required to check if the device is compatible with the provided platform, as the driver compiler// will be used.auto deviceName = engineBackend->getDevice()->getName();- if (deviceName != platform && deviceName != "AUTO_DETECT") {+ if (!platform.empty() && deviceName != platform && deviceName != "AUTO_DETECT") {OPENVINO_THROW("Could not find a valid NPU device for the provided configuration.");}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 76dd94241f6..fcb2820e55e 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@@ -208,10 +208,6 @@ VCLCompilerImpl::VCLCompilerImpl() : _logHandle(nullptr), _logger("VCLCompilerIm// info will be processed in compile phase if passed by user._logger.info("Device description is not provided, using default values");uint32_t defaultTileCount = std::numeric_limits<uint32_t>::max();- if (_vclVersion.major == 7 && _vclVersion.minor < 6) {- // For vcl <= 7.5, need to use smaller value to pass check- defaultTileCount = std::numeric_limits<uint16_t>::max();- }vcl_device_desc_t device_desc = {sizeof(vcl_device_desc_t),0x00,std::numeric_limits<uint16_t>::max(),@@ -251,13 +247,16 @@ std::shared_ptr<void> VCLCompilerImpl::getLinkedLibrary() const {return VCLApi::getInstance()->getLibrary();}-ov::Tensor VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model, const FilteredConfig& config) const {+std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(+ const std::shared_ptr<const ov::Model>& model,+ const FilteredConfig& config) const {return compile(model, config, false);}-ov::Tensor VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config,- const bool storeWeightlessCacheAttributeFlag) const {+std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(+ const std::shared_ptr<const ov::Model>& model,+ const FilteredConfig& config,+ const bool storeWeightlessCacheAttributeFlag) const {_logger.debug("compile start");/// Check the linked vcl version whether supported in plugin@@ -306,38 +305,71 @@ ov::Tensor VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& modebuildFlags.c_str(),buildFlags.size()};- if (usedVersion.Major >= 7 && usedVersion.Minor >= 4) {- // support the lastest vcl api- // For VCL 7.4 and later, we can use vclAllocatedExecutableCreate2- _logger.debug("Using vclAllocatedExecutableCreate2 for 7.4 <= VCL");- vcl_allocator allocator;+ if (usedVersion.Major > 7 || (usedVersion.Major == 7 && usedVersion.Minor >= 7)) {+ // Support only the lastest VCL api+ vcl_allocator_2 allocator;uint8_t* blob = nullptr;- size_t size = 0;-- auto result = vclAllocatedExecutableCreate2(_compilerHandle, exeDesc, &allocator, &blob, &size);+ size_t blobSize = 0;+ uint8_t* compatibilityStringBuffer = nullptr;+ size_t compatibilityStringSize = 0;++ auto result = vclAllocatedExecutableCreate3(_compilerHandle,+ exeDesc,+ &allocator,+ &blob,+ &blobSize,+ &compatibilityStringBuffer,+ &compatibilityStringSize);if (result != VCL_RESULT_SUCCESS) {- OPENVINO_THROW("Compilation failed. vclAllocatedExecutableCreate2 result: 0x",+ // Check if allocations were performed before throwing exception+ for (const auto& [buffer, size] : allocator.m_info) {+ allocator.deallocate(&allocator, buffer);+ }+ OPENVINO_THROW("Compilation failed. vclAllocatedExecutableCreate3 result: 0x",std::hex,uint64_t(result)," - ",getLatestVCLLog(_logHandle));}- if (size == 0 || blob == nullptr) {- OPENVINO_THROW("Failed to create VCL executable, size is zero or blob is null");+ OPENVINO_ASSERT(blobSize != 0 && blob != nullptr,+ "Failed to create VCL executable, the blob size is zero or the blob is null");++ // Retrieve the real allocated size for the blob from the allocator+ size_t alignedBlobSize = 0;+ for (auto [buffer, size] : allocator.m_info) {+ if (buffer == blob) {+ alignedBlobSize = size;+ break;+ }}+// The allocated size from VCL will be equal or smaller than the allocated size in allocator- _logger.debug("Blob size from VCL: %zu ptr %p", size, static_cast<void*>(blob));- _logger.debug("Allocated vector size: %zu ptr: %p",- allocator.m_size,- static_cast<void*>(allocator.m_allocated));+ _logger.debug("Blob size from VCL: %zu ptr %p", blobSize, static_cast<void*>(blob));+ _logger.debug("Allocated vector size: %zu ptr: %p", alignedBlobSize, static_cast<void*>(blob));++ ov::Tensor alignedBlob = make_tensor_from_aligned_addr(blob, alignedBlobSize);+ std::optional<std::string> compatibilityString;++ // Populate compatibility string only when VCL provides a buffer.+ if (compatibilityStringBuffer != nullptr) {+ OPENVINO_ASSERT(compatibilityStringSize != 0,+ "Failed to create VCL executable, the compatibility descriptor size is zero");+ compatibilityString =+ std::string(reinterpret_cast<char*>(compatibilityStringBuffer), compatibilityStringSize);+ _logger.debug("Compatibility string from VCL: %s", compatibilityString->c_str());- _logger.debug("compile end, blob size:%d", allocator.m_size);- return make_tensor_from_aligned_addr(allocator.m_allocated, allocator.m_size);+ allocator.deallocate(&allocator, compatibilityStringBuffer);+ }++ return std::make_pair<ov::Tensor, std::optional<std::string>>(std::move(alignedBlob),+ std::move(compatibilityString));} else {- OPENVINO_THROW("Not supported VCL version: %d.%d, please use VCL 6.1 or later",+ OPENVINO_THROW("Unsupported VCL version: ",_vclVersion.major,- _vclVersion.minor);+ ".",+ _vclVersion.minor,+ ", please use VCL 7.7 or later");}}@@ -415,7 +447,8 @@ ov::Tensor VCLCompilerImpl::compileWsIterative(const std::shared_ptr<ov::Model>&_logger.debug("compileWsIterative start");FilteredConfig updatedConfig = config;updatedConfig.update({{ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber)}});- return compile(model, updatedConfig, true);+ // The compatibility descriptor is not supported in this case+ return compile(model, updatedConfig, true).first;}std::vector<ov::ProfilingInfo> VCLCompilerImpl::process_profiling_output(const std::vector<uint8_t>& profData,@@ -579,4 +612,39 @@ bool VCLCompilerImpl::is_option_supported(std::string option, std::optional<std:return false;}+bool VCLCompilerImpl::validate_compatibility_descriptor(const std::string& compatibilityDescriptor,+ vcl_device_desc_t* in_device_desc) const {+ vcl_compiler_desc_t compilerDesc;+ compilerDesc.version = _vclVersion;+ compilerDesc.debugLevel = static_cast<vcl_log_level_t>(static_cast<int>(Logger::global().level()) + 1);++ // Create a temporary compiler instance for the query to pass the correct device description.+ // The private compiler instance used by this class was created with default device description.+ vcl_log_handle_t logHandle = nullptr;+ vcl_compiler_handle_t compilerHandle = nullptr;+ try {+ THROW_ON_FAIL_FOR_VCL("vclCompilerCreate",+ vclCompilerCreate(&compilerDesc, in_device_desc, &compilerHandle, &logHandle),+ nullptr);++ const char* optname_ch = ov::compatibility_check.name();+ const char* optvalue_ch = compatibilityDescriptor.c_str();+ _logger.debug("is_option_supported start for option: %s, value: %s", optname_ch, optvalue_ch);+ THROW_ON_FAIL_FOR_VCL("vclGetCompilerIsOptionSupported",+ vclGetCompilerIsOptionSupported(compilerHandle, optname_ch, optvalue_ch),+ logHandle);+ if (compilerHandle) {+ vclCompilerDestroy(compilerHandle);+ }+ return true;+ } catch (const std::exception& e) {+ _logger.debug("Exception in is_option_supported: %s", e.what());+ if (compilerHandle) {+ vclCompilerDestroy(compilerHandle);+ }+ }++ return false;+}+} // namespace intel_npudiff --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 f00aabaf86a..9b9c36da2b0 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@@ -97,7 +97,8 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<congraphDesc,std::move(networkMeta),/* blob = */ std::nullopt,- updatedConfig);+ updatedConfig,+ /* compatibilityDescriptor = */ std::nullopt);}std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Model>&& model,@@ -290,6 +291,29 @@ std::optional<std::vector<std::string>> DriverCompilerAdapter::get_supported_opt}bool DriverCompilerAdapter::is_option_supported(std::string optName, std::optional<std::string> optValue) const {+ // This is a special case, as RUNTIME_REQUIREMENTS is a read-only runtime property+ // used to signal that compiler can provide a compatibility string through a dedicated+ // VCL compiler method. It is not a regular settable option.+ // Therefore, we cannot rely on the compiler's usual option support checking method alone.+ if (optName == RUNTIME_REQUIREMENTS::key()) {+ if (optValue.has_value())+ OPENVINO_THROW("The option '",+ RUNTIME_REQUIREMENTS::key(),+ "' is a read-only property and does not accept any value.");++ // Compatibility string generation is not yet supported through the L0 API, even if compiler supports it+ return false;+ }+ // The COMPATIBILITY_CHECK option is used to signal if compiler adapter supports+ // the validateCompatibilityDescriptor method+ if (optName == COMPATIBILITY_CHECK::key()) {+ if (optValue.has_value())+ OPENVINO_THROW("Compatibility string should be verified with validate_compatibility_descriptor()");++ // Compatibility string validation is not yet supported through the L0 API+ return false;+ }+auto isOptionSupported = _zeGraphExt->isOptionSupported(std::move(optName), std::move(optValue));return isOptionSupported.value_or(false);}@@ -314,4 +338,8 @@ bool DriverCompilerAdapter::isCompilerOptionSupported(const FilteredConfig& conf(compilerVersion.minor >= minorCompilerOptSupportValue));}+bool DriverCompilerAdapter::validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const {+ OPENVINO_THROW_NOT_IMPLEMENTED("Compatibility descriptor validation is not yet supported through the L0 API");+}+} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cppindex 04f67116e6f..5dd5fca726a 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp@@ -754,4 +754,9 @@ std::optional<bool> DynamicGraph::is_profiling_blob() const {return std::nullopt;}+std::optional<std::string_view> DynamicGraph::get_compatibility_descriptor() const {+ _logger.warning("Compatibility descriptor is not supported for DynamicGraph");+ return std::nullopt;+}+} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cppindex 198d019fcdc..50c3b2988ff 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp@@ -22,6 +22,7 @@ Graph::Graph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,NetworkMetadata metadata,std::optional<ov::Tensor> blob,const FilteredConfig& config,+ const std::optional<std::string>& compatibilityDescriptor,const bool blobIsPersistent,const bool calledFromWeightlessGraph): IGraph(),@@ -30,6 +31,7 @@ Graph::Graph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,_graphDesc(graphDesc),_metadata(std::move(metadata)),_blob(std::move(blob)),+ _compatibilityDescriptor(compatibilityDescriptor),_blobIsPersistent(blobIsPersistent),_logger("Graph", config.get<LOG_LEVEL>()) {if (!config.get<CREATE_EXECUTOR>() || config.get<DEFER_WEIGHTS_LOAD>()) {@@ -266,6 +268,10 @@ uint32_t Graph::get_last_submitted_id() const {return _lastSubmittedId;}+std::optional<std::string_view> Graph::get_compatibility_descriptor() const {+ return _compatibilityDescriptor;+}+std::optional<bool> Graph::is_profiling_blob() const {if (_zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {_logger.debug("Cannot determine if the blob was compiled for profiling");diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cppindex 2493cdd3f52..f580f8cd0d3 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp@@ -26,7 +26,8 @@ Parser::Parser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct)std::shared_ptr<IGraph> Parser::parse(const ov::Tensor& mainBlob,const FilteredConfig& config,const std::optional<std::vector<ov::Tensor>>& initBlobs,- std::optional<std::shared_ptr<const ov::Model>>&& model) const {+ std::optional<std::shared_ptr<const ov::Model>>&& model,+ const std::optional<std::string>& compatibilityDescriptor) const {OV_ITT_TASK_CHAIN(PARSE_BLOB, itt::domains::NPUPlugin, "Parser", "parse");// Detect blob format@@ -72,6 +73,7 @@ std::shared_ptr<IGraph> Parser::parse(const ov::Tensor& mainBlob,std::move(mainNetworkMetadata),mainBlob,config,+ compatibilityDescriptor,blobIsPersistent);}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 1578ee10e1b..cae93fb4890 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@@ -64,7 +64,7 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<conOV_ITT_TASK_CHAIN(COMPILE_BLOB, itt::domains::NPUPlugin, "PluginCompilerAdapter", "compile");_logger.debug("compile start");- auto tensor = _compiler->compile(model, config);+ auto [tensor, compatibilityDescriptor] = _compiler->compile(model, config);_logger.debug("compile end");if (config.get<COMPILATION_MODE>() == "HostCompile") {@@ -99,6 +99,7 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<constd::move(networkMeta),std::move(tensor),config,+ compatibilityDescriptor,/* persistentBlob = */ true); // exporting the blob shall be available in such a scenario}@@ -294,4 +295,27 @@ bool PluginCompilerAdapter::is_option_supported(std::string optname, std::option}}+bool PluginCompilerAdapter::validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const {+ if (_zeroInitStruct && _zeroInitStruct->getDevice()) {+ ze_device_properties_t device_properties = {};+ device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;+ auto result = zeDeviceGetProperties(_zeroInitStruct->getDevice(), &device_properties);++ if (result == ZE_RESULT_SUCCESS) {+ vcl_device_desc_t vcl_desc = {sizeof(vcl_device_desc_t),+ device_properties.deviceId,+ static_cast<uint16_t>(device_properties.subdeviceId),+ device_properties.numSlices};++ _logger.info("Validating compatibility logic using deviceID: 0x%X, maxTiles: %u",+ vcl_desc.deviceID,+ vcl_desc.tileCount);++ return _compiler->validate_compatibility_descriptor(compatibilityDescriptor, &vcl_desc);+ }+ }++ return false;+}+} // namespace intel_npudiff --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 0f8f6e6e119..1ede7e134e1 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@@ -177,8 +177,9 @@ WeightlessGraph::WeightlessGraph(const std::shared_ptr<ZeGraphExtWrappers>& zeGrstd::move(mainMetadata),std::move(mainBlob),config,+ /* compatibilityDescriptor = */ std::nullopt,blobIsPersistent,- true),+ /* calledFromWeightlessGraph = */ true),_initsGraphDesc(initGraphDesc),_initBlobs(std::move(initBlobs)),_initsMetadata(std::move(initMetadata)),diff --git a/src/plugins/intel_npu/src/plugin/include/metadata.hpp b/src/plugins/intel_npu/src/plugin/include/metadata.hppindex 626be644068..6b21959ae86 100644--- a/src/plugins/intel_npu/src/plugin/include/metadata.hpp+++ b/src/plugins/intel_npu/src/plugin/include/metadata.hpp@@ -81,6 +81,8 @@ public:virtual std::optional<bool> is_encrypted_blob() const;+ virtual std::optional<std::string_view> get_compatibility_descriptor() const;+virtual ~MetadataBase() = default;static std::streampos getFileSize(std::istream& stream);@@ -164,6 +166,7 @@ constexpr std::string_view META = "meta";constexpr std::string_view OV = "ov";constexpr std::string_view WS_INITS = "ws_inits";constexpr std::string_view BATCH = "batch";+constexpr std::string_view COMPAT_DESC = "desc";} // namespace MetadataTextKeys/**@@ -172,7 +175,8 @@ constexpr std::string_view BATCH = "batch";inline constexpr std::array metadataTextAttributes = {MetadataTextKeys::META,MetadataTextKeys::OV,MetadataTextKeys::WS_INITS,- MetadataTextKeys::BATCH};+ MetadataTextKeys::BATCH,+ MetadataTextKeys::COMPAT_DESC};/*** @brief List of supported version formats.@@ -183,11 +187,12 @@ constexpr uint32_t METADATA_VERSION_2_2{MetadataBase::make_version(2, 2)};constexpr uint32_t METADATA_VERSION_2_3{MetadataBase::make_version(2, 3)};constexpr uint32_t METADATA_VERSION_2_4{MetadataBase::make_version(2, 4)};constexpr uint32_t METADATA_VERSION_2_5{MetadataBase::make_version(2, 5)};+constexpr uint32_t METADATA_VERSION_2_6{MetadataBase::make_version(2, 6)};/*** @brief Current metadata version.*/-constexpr uint32_t CURRENT_METADATA_VERSION{METADATA_VERSION_2_5};+constexpr uint32_t CURRENT_METADATA_VERSION{METADATA_VERSION_2_6};constexpr uint16_t CURRENT_METADATA_MAJOR_VERSION{MetadataBase::get_major(CURRENT_METADATA_VERSION)};constexpr uint16_t CURRENT_METADATA_MINOR_VERSION{MetadataBase::get_minor(CURRENT_METADATA_VERSION)};@@ -418,6 +423,36 @@ private:std::optional<bool> _isEncryptedBlob;};+/**+ * @brief Stores the compiler requirements string.+ */+template <>+class Metadata<METADATA_VERSION_2_6> : public Metadata<METADATA_VERSION_2_5> {+public:+ Metadata(uint64_t blobSize,+ const std::optional<OpenvinoVersion>& ovVersion = std::nullopt,+ const std::optional<std::vector<uint64_t>>& initSizes = std::nullopt,+ const std::optional<int64_t> batchSize = std::nullopt,+ const std::optional<std::vector<ov::Layout>>& inputLayouts = std::nullopt,+ const std::optional<std::vector<ov::Layout>>& outputLayouts = std::nullopt,+ const std::optional<uint32_t> compilerVersion = std::nullopt,+ const std::optional<uint64_t>& blobSizeAfterEncryption = std::nullopt,+ const std::optional<std::string_view> compatibilityDescriptor = std::nullopt);++ void read() override;++ void read_as_text() override;++ void write(std::ostream& stream) override;++ void write_as_text(std::ostream& stream) override;++ std::optional<std::string_view> get_compatibility_descriptor() const override;++private:+ std::optional<std::string> _compatibilityDescriptor;+};+/*** @brief Creates a Metadata object.*diff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hppindex a960232186f..07eb6ba26a2 100644--- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp+++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp@@ -80,6 +80,9 @@ private:std::unique_ptr<MetadataBase> metadata,const ov::AnyMap& properties) const;+ ov::CompatibilityCheck validate_compatibility_descriptor(ov::intel_npu::CompilerType compilerType,+ const ov::AnyMap& arguments) const;+std::unique_ptr<BackendsRegistry> _backendsRegistry;// _backend might not be set by the plugin; certain actions, such as offline compilation, might be supported.diff --git a/src/plugins/intel_npu/src/plugin/include/properties.hpp b/src/plugins/intel_npu/src/plugin/include/properties.hppindex 90f015f5f5a..500e90a10a9 100644--- a/src/plugins/intel_npu/src/plugin/include/properties.hpp+++ b/src/plugins/intel_npu/src/plugin/include/properties.hpp@@ -73,6 +73,7 @@ public:std::string determinePlatform(const ov::AnyMap& properties) const;std::string determineDeviceId(const ov::AnyMap& properties) const;ov::intel_npu::CompilerType determineCompilerType(const ov::AnyMap& properties) const;+ ov::intel_npu::CompilerType determineCompilerTypeForCompatibilityCheck() const;private:struct CopyState {@@ -84,6 +85,7 @@ private:ov::intel_npu::CompilerType currentlyUsedCompiler;std::string currentlyUsedPlatform;bool compilerConfigsFilteredByCompiler;+ bool compatibilityCheckFiltered;std::map<std::string, std::tuple<bool, ov::PropertyMutability, std::function<ov::Any(const Config&)>>>properties;std::vector<ov::PropertyName> supportedProperties;@@ -98,15 +100,23 @@ private:Logger _logger;ov::intel_npu::CompilerType _currentlyUsedCompiler = ov::intel_npu::CompilerType::PREFER_PLUGIN;+ ov::intel_npu::CompilerType _compilerForCompatibilityCheck = ov::intel_npu::CompilerType::DRIVER;std::string _currentlyUsedPlatform;- bool _compilerConfigsFilteredByCompiler =- false; ///< Boolean to check whether properties was filtered with compiler supported properties+ // Boolean to check whether properties were filtered with compiler supported properties+ bool _compilerConfigsFilteredByCompiler = false;+ // Boolean to signal that compatibility check was already filtered by compiler support+ bool _compatibilityCheckFiltered = false;// properties map: {name -> [supported, mutable, eval function]}std::map<std::string, std::tuple<bool, ov::PropertyMutability, std::function<ov::Any(const Config&)>>> _properties;std::vector<ov::PropertyName> _supportedProperties;+ // The compatibility_check property is supported only in case at least one of the compilers (CID or CIP) supports it+ // To avoid loading the compiler library and check the support when the property is registered, the check can+ // be performed at a later stage, when the property is actually queried.+ bool disable_compatibility_check_if_needed();+/*** @brief Checks whether a property was registered by its name*/diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model.cppindex ecf4b7b9168..a7ec17d07f7 100644--- a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp@@ -37,8 +37,16 @@ CompiledModel::CompiledModel(const std::shared_ptr<const ov::Model>& model,_batchSize(batchSize) {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "CompiledModel::CompiledModel");+ // Support for specific properties might depend on the characteristics of the compiled model.+ // Adjust lower level config availability to influence the supported properties list if needed+ FilteredConfig localConfig = config;+ if (!_graph->get_compatibility_descriptor().has_value()) {+ _logger.debug("Graph's compatibility descriptor has no value. Disabling RUNTIME_REQUIREMENTS property.");+ localConfig.enable(ov::runtime_requirements.name(), false);+ }+OV_ITT_TASK_CHAIN(COMPILED_MODEL, itt::domains::NPUPlugin, "CompiledModel::CompiledModel", "initialize_properties");- _propertiesManager = std::make_unique<Properties>(PropertiesType::COMPILED_MODEL, config);+ _propertiesManager = std::make_unique<Properties>(PropertiesType::COMPILED_MODEL, localConfig);configure_stream_executors();@@ -141,7 +149,8 @@ void CompiledModel::export_model(std::ostream& stream) const {inputLayouts,outputLayouts,compilerVersion,- blobSizeAfterEncryption)+ blobSizeAfterEncryption,+ _graph->get_compatibility_descriptor()).write(stream);}}@@ -216,10 +225,35 @@ ov::Any CompiledModel::get_property(const std::string& name) const {if (name == ov::model_name.name()) {OPENVINO_ASSERT(_graph != nullptr, "Missing graph");return _graph->get_metadata().name;- } else {- // default behaviour- return _propertiesManager->getProperty(name);+ } else if (name == ov::runtime_requirements.name()) {+ // Reading the (dummy) property content to check if it is supported+ _propertiesManager->getProperty(name);++ _logger.debug("Runtime requirements from the graph %s length: %zu",+ _graph->get_compatibility_descriptor().value(),+ _graph->get_compatibility_descriptor().value().size());++ std::ostringstream requirementsString;+ Metadata<CURRENT_METADATA_VERSION>(+ 0, // no real blob+ CURRENT_OPENVINO_VERSION,+ std::nullopt, // weightless blobs are not supported+ _batchSize,+ std::nullopt, // input_layouts are not relevant for the compatibility check+ std::nullopt, // output_layouts are not relevant for the compatibility check+ std::nullopt, // skip compiler version as well since it is already included in runtime requirements string+ std::nullopt, // skip encrypted blob size since it is not relevant for the compatibility check+ _graph->get_compatibility_descriptor())+ .write_as_text(requirementsString);+ _logger.debug("Runtime requirements string: %s length: %zu",+ requirementsString.str().c_str(),+ requirementsString.str().length());++ return requirementsString.str();}++ // default behaviour+ return _propertiesManager->getProperty(name);}const std::shared_ptr<IGraph>& CompiledModel::get_graph() const {diff --git a/src/plugins/intel_npu/src/plugin/src/metadata.cpp b/src/plugins/intel_npu/src/plugin/src/metadata.cppindex 06341ebb50b..d7472df7a13 100644--- a/src/plugins/intel_npu/src/plugin/src/metadata.cpp+++ b/src/plugins/intel_npu/src/plugin/src/metadata.cpp@@ -169,6 +169,27 @@ Metadata<METADATA_VERSION_2_5>::Metadata(uint64_t blobSize,_version = METADATA_VERSION_2_5;}+Metadata<METADATA_VERSION_2_6>::Metadata(uint64_t blobSize,+ const std::optional<OpenvinoVersion>& ovVersion,+ const std::optional<std::vector<uint64_t>>& initSizes,+ const std::optional<int64_t> batchSize,+ const std::optional<std::vector<ov::Layout>>& inputLayouts,+ const std::optional<std::vector<ov::Layout>>& outputLayouts,+ const std::optional<uint32_t> compilerVersion,+ const std::optional<uint64_t>& blobSizeAfterEncryption,+ const std::optional<std::string_view> compatibilityDescriptor)+ : Metadata<METADATA_VERSION_2_5>{blobSize,+ ovVersion,+ initSizes,+ batchSize,+ inputLayouts,+ outputLayouts,+ compilerVersion,+ blobSizeAfterEncryption},+ _compatibilityDescriptor{compatibilityDescriptor} {+ _version = METADATA_VERSION_2_6;+}+void MetadataBase::read(std::istream& tensor) {_source = Source(tensor);read();@@ -307,6 +328,18 @@ void Metadata<METADATA_VERSION_2_5>::read() {_isEncryptedBlob = isEncryptedBlob;}+void Metadata<METADATA_VERSION_2_6>::read() {+ Metadata<METADATA_VERSION_2_5>::read();++ uint64_t reqs_len;+ read_data_from_source(reinterpret_cast<char*>(&reqs_len), sizeof(reqs_len));+ if (reqs_len > 0) {+ std::string reqs(reqs_len, '\0');+ read_data_from_source(reqs.data(), reqs_len);+ _compatibilityDescriptor = std::move(reqs);+ }+}+void Metadata<METADATA_VERSION_2_0>::read_as_text() {const auto it = _textAttrs.find(MetadataTextKeys::OV);if (it == _textAttrs.end()) {@@ -345,6 +378,22 @@ void Metadata<METADATA_VERSION_2_2>::read_as_text() {_batchSize = batchValue != 0 ? std::optional<int64_t>(batchValue) : std::nullopt;}+void Metadata<METADATA_VERSION_2_6>::read_as_text() {+ Metadata<METADATA_VERSION_2_5>::read_as_text();++ const auto it = _textAttrs.find(MetadataTextKeys::COMPAT_DESC);+ if (it == _textAttrs.end() || it->second.empty()) {+ return;+ }++ const std::string& v = it->second;+ if (v.size() >= 2 && v.front() == '[' && v.back() == ']') {+ _compatibilityDescriptor = v.substr(1, v.size() - 2);+ } else {+ OPENVINO_THROW("Human-readable metadata: 'desc' value is not bracket-enclosed: ", v);+ }+}+void Metadata<METADATA_VERSION_2_0>::write(std::ostream& stream) {stream.write(reinterpret_cast<const char*>(&_version), sizeof(_version));_ovVersion.write(stream);@@ -405,6 +454,17 @@ void Metadata<METADATA_VERSION_2_5>::write(std::ostream& stream) {const uint8_t isEncryptedBlob = _isEncryptedBlob.value_or(false);stream.write(reinterpret_cast<const char*>(&isEncryptedBlob), sizeof(isEncryptedBlob));+}++void Metadata<METADATA_VERSION_2_6>::write(std::ostream& stream) {+ Metadata<METADATA_VERSION_2_5>::write(stream);++ const std::string& compatDesc = _compatibilityDescriptor.value_or("");+ const uint64_t compatDesc_len = compatDesc.size();+ stream.write(reinterpret_cast<const char*>(&compatDesc_len), sizeof(compatDesc_len));+ if (compatDesc_len > 0) {+ stream.write(compatDesc.data(), static_cast<std::streamsize>(compatDesc_len));+ }append_blob_size_and_magic(stream);}@@ -435,6 +495,18 @@ void Metadata<METADATA_VERSION_2_2>::write_as_text(std::ostream& stream) {}}+void Metadata<METADATA_VERSION_2_6>::write_as_text(std::ostream& stream) {+ Metadata<METADATA_VERSION_2_5>::write_as_text(stream);++ if (_compatibilityDescriptor.has_value() && !_compatibilityDescriptor->empty()) {+ std::string desc = _compatibilityDescriptor.value();+ if (!desc.empty() && desc.back() == '\0') {+ desc.pop_back();+ }+ write_text_field(stream, MetadataTextKeys::COMPAT_DESC, '[' + desc + ']');+ }+}+std::unique_ptr<MetadataBase> create_metadata(uint32_t version, uint64_t blobSize) {uint16_t major = MetadataBase::get_major(version), minor = MetadataBase::get_minor(version);if (major != CURRENT_METADATA_MAJOR_VERSION || minor > CURRENT_METADATA_MINOR_VERSION) {@@ -461,6 +533,8 @@ std::unique_ptr<MetadataBase> create_metadata(uint32_t version, uint64_t blobSizreturn std::make_unique<Metadata<METADATA_VERSION_2_4>>(blobSize);case METADATA_VERSION_2_5:return std::make_unique<Metadata<METADATA_VERSION_2_5>>(blobSize);+ case METADATA_VERSION_2_6:+ return std::make_unique<Metadata<METADATA_VERSION_2_6>>(blobSize);default:return nullptr;}@@ -618,6 +692,10 @@ std::optional<bool> MetadataBase::is_encrypted_blob() const {return std::nullopt;}+std::optional<std::string_view> MetadataBase::get_compatibility_descriptor() const {+ return std::nullopt;+}+std::optional<std::vector<uint64_t>> Metadata<METADATA_VERSION_2_1>::get_init_sizes() const {return _initSizes;}@@ -642,4 +720,8 @@ std::optional<bool> Metadata<METADATA_VERSION_2_5>::is_encrypted_blob() const {return _isEncryptedBlob;}+std::optional<std::string_view> Metadata<METADATA_VERSION_2_6>::get_compatibility_descriptor() const {+ return _compatibilityDescriptor;+}+} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cppindex d939accff0c..c11b00d1ad8 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp@@ -257,6 +257,9 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCoREGISTER_OPTION(ENABLE_STRIDES_FOR);REGISTER_OPTION(SHARED_COMMON_QUEUE);REGISTER_OPTION(CACHE_ENCRYPTION_CALLBACKS);+ REGISTER_OPTION(RUNTIME_REQUIREMENTS);+ REGISTER_OPTION(COMPATIBILITY_CHECK);+if (backend) {// Options registered only if drivers is present and supports the corresponding extension@@ -360,7 +363,72 @@ void Plugin::set_property(const ov::AnyMap& properties) {_propertiesManager->setProperty(properties);}++ov::CompatibilityCheck Plugin::validate_compatibility_descriptor(ov::intel_npu::CompilerType compilerType, const ov::AnyMap& arguments) const {+ if (arguments.empty() || arguments.find(ov::runtime_requirements.name()) == arguments.end()) {+ return ov::CompatibilityCheck::NOT_APPLICABLE;+ }++ const auto& runtimeRequirements = arguments.at(ov::runtime_requirements.name()).as<const std::string&>();+ _logger.debug("Received runtime_requirements: %s length: %zu", runtimeRequirements.c_str(), runtimeRequirements.length());++ // NPU Plugin's runtime requirements are captured in its metadata.+ // For now plugin's requirements are met if metadata can be retrieved from the tensor+ std::unique_ptr<MetadataBase> metadata = nullptr;+ try {+ // The plugin cares only about the string size and the metadata version check for now. Additional checks based+ // on other metadata fields can be done following this line.+ metadata = read_as_text(runtimeRequirements);+ } catch (const std::exception& ex) {+ // Unsupported version, could not read the metadata or an unknown error has occured. Report that the+ // requirements are not met.+ _logger.debug("Failed to read metadata from the runtime requirements. The requirements are not met. %s", ex.what());+ return ov::CompatibilityCheck::UNSUPPORTED;+ }++ const auto descriptorView = metadata->get_compatibility_descriptor();+ std::string compatibilityDescriptor = descriptorView.has_value() ? std::string(descriptorView.value()) : "";+ _logger.debug("Retrieved compatibility descriptor from metadata: %s length: %zu",+ compatibilityDescriptor.c_str(),+ compatibilityDescriptor.length());++ // Implement only the fallback path for now through the PLUGIN compiler type+ std::unique_ptr<ICompilerAdapter> compiler = nullptr;+ CompilerAdapterFactory factory;+ try {+ compiler = factory.getCompiler(_backend, compilerType, std::string_view{});++ // Compiler can validate only if the string describes a blob compatible with the current platform+ auto result = compiler->validate_compatibility_descriptor(compatibilityDescriptor);+ _logger.debug("Compatibility check result: %s", result ? "met" : "not met");+ if (result) {+ return ov::CompatibilityCheck::SUPPORTED;+ } else {+ return ov::CompatibilityCheck::UNSUPPORTED;+ }+ } catch (const std::exception&) {+ _logger.error("Failed to create the recommended compiler type for the compatibility check %d. The requirements are not met.",+ static_cast<int>(compilerType));+ return ov::CompatibilityCheck::NOT_APPLICABLE;+ }+}+ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& arguments) const {+ // Special cases that need to be treated outside of the property manager.+ // Checking runtime requirements requires access to plugin's metadata+ if (name == ov::compatibility_check.name()) {+ // Reading the (dummy) property content to check if it is supported+ // Expected to throw if the property is not supported+ _propertiesManager->getProperty(name);++ // The property was enabled based on the support of the compatibility check in the compiler adapters+ // Use the compiler type determined for compatibility check to validate the requirements and return the result+ auto compilerType = _propertiesManager->determineCompilerTypeForCompatibilityCheck();++ // Validates both local (plugin's) requirements and device requirements+ return validate_compatibility_descriptor(compilerType, arguments);+ }+if (!arguments.empty()) {auto npuPluginArguments = arguments;exclude_model_ptr_from_map(npuPluginArguments);@@ -976,10 +1044,20 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,ParserFactory parserFactory;auto parser = parserFactory.getParser(_backend->getInitStructs());++ // Convert descriptor to an owning string before metadata is potentially destroyed.+ std::optional<std::string> compatibilityDescriptor = std::nullopt;+ if (metadata) {+ if (const auto descriptorView = metadata->get_compatibility_descriptor(); descriptorView.has_value()) {+ compatibilityDescriptor = std::string(descriptorView.value());+ }+ }+auto graph = parser->parse(tensorMain,localConfig,initBlobs,- weightsSeparationEnabled ? std::make_optional(std::move(originalModel)) : std::nullopt);+ weightsSeparationEnabled ? std::make_optional(std::move(originalModel)) : std::nullopt,+ compatibilityDescriptor);graph->update_network_name("net" + std::to_string(_compiledModelLoadCounter++));const std::shared_ptr<ov::Model> modelDummy =diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cppindex 9bcc32974e3..66acba2aaae 100644--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp@@ -455,6 +455,7 @@ Properties::Properties(const Properties& other)other._currentlyUsedCompiler,other._currentlyUsedPlatform,other._compilerConfigsFilteredByCompiler,+ other._compatibilityCheckFiltered,other._properties,other._supportedProperties};}()) {}@@ -468,6 +469,7 @@ Properties::Properties(CopyState&& state)_currentlyUsedCompiler(state.currentlyUsedCompiler),_currentlyUsedPlatform(std::move(state.currentlyUsedPlatform)),_compilerConfigsFilteredByCompiler(state.compilerConfigsFilteredByCompiler),+ _compatibilityCheckFiltered(state.compatibilityCheckFiltered),_properties(std::move(state.properties)),_supportedProperties(std::move(state.supportedProperties)) {}@@ -585,6 +587,15 @@ void Properties::registerPluginProperties() {}return false;}());+ TRY_REGISTER_CUSTOM_PROPERTY(ov::compatibility_check,+ COMPATIBILITY_CHECK,+ true,+ ov::PropertyMutability::RO,+ [](const Config& /* unusedConfig */) {+ // This property is implemented in the plugin directly+ // This implementation here serves only to publish it in supported_properties+ return false;+ });TRY_REGISTER_SIMPLE_PROPERTY(ov::hint::enable_cpu_pinning, ENABLE_CPU_PINNING);FORCE_REGISTER_CUSTOM_PROPERTY(ov::hint::model,@@ -795,6 +806,15 @@ void Properties::registerCompiledModelProperties() {[](const Config& /* unusedConfig */) {return std::shared_ptr<const ov::Model>(nullptr);});+ TRY_REGISTER_CUSTOM_PROPERTY(ov::runtime_requirements,+ RUNTIME_REQUIREMENTS,+ true,+ ov::PropertyMutability::RO,+ [](const Config& /* unusedConfig */) {+ // This property is implemented in compiled model directly+ // This implementation here serves only to publish it in supported_properties+ return std::string("");+ });FORCE_REGISTER_CUSTOM_PROPERTY(ov::cache_encryption_callbacks,@@ -816,7 +836,7 @@ void Properties::registerCompiledModelProperties() {REGISTER_CUSTOM_METRIC(ov::model_name, true, [](const Config&) {// TODO: log an error here as the code shouldn't have gotten here// this property is implemented in compiled model directly- // this implementation here servers only to publish it in supported_properties+ // this implementation here serves only to publish it in supported_propertiesreturn std::string("invalid");});REGISTER_SIMPLE_METRIC(ov::optimal_number_of_infer_requests,@@ -825,7 +845,7 @@ void Properties::registerCompiledModelProperties() {REGISTER_CUSTOM_METRIC(ov::execution_devices, true, [](const Config&) {// TODO: log an error here as the code shouldn't have gotten here// this property is implemented in compiled model directly- // this implementation here servers only to publish it in supported_properties+ // this implementation here serves only to publish it in supported_propertiesreturn std::string("NPU");});}@@ -849,6 +869,11 @@ ov::Any Properties::getProperty(const std::string& name) {}}+ bool needToResetProperties = false;+ if (name == ov::compatibility_check.name() || name == ov::supported_properties.name()) {+ // Mark that properties need to be registered again if the internal config is updated+ needToResetProperties = disable_compatibility_check_if_needed();+ }// Special case for Supported Properties and Caching Properties as they are compiler dependent. So we need to// check compiler support for those properties on each getProperty call as well.if (propertyIsCompilerConfig || !propertyIsRegistered || name == ov::supported_properties.name() ||@@ -884,13 +909,17 @@ ov::Any Properties::getProperty(const std::string& name) {// filter out options againfilterPropertiesByCompilerSupport(_config, compiler.get(), _backend, _logger);- // reset properties for the new options- registerProperties();_compilerConfigsFilteredByCompiler = true;_currentlyUsedCompiler = compilerType;_currentlyUsedPlatform = std::move(compilationPlatform);+ needToResetProperties = true;}}++ if (needToResetProperties) {+ // reset properties for the new options+ registerProperties();+ }}auto&& configIterator = _properties.find(name);@@ -1014,6 +1043,14 @@ bool Properties::isPropertySupported(const std::string& name) {return false;}+ if (name == ov::compatibility_check.name()) {+ bool disabled = disable_compatibility_check_if_needed();+ if (disabled) {+ registerProperties();+ return false;+ }+ }+if (isRegistered) {// Registered and not a config option: always supported. Or it is a special both property which is always// supported.@@ -1212,4 +1249,68 @@ std::string Properties::determineDeviceId(const ov::AnyMap& properties) const {return _config.get<DEVICE_ID>();}+bool Properties::disable_compatibility_check_if_needed() {+ // COMPATIBILITY_CHECK is a RunTime option, thus enabled by default+ // The property should be supported only if at least one of the compiler adapters support it.+ // No need to check again if it was enabled already+ // Plugin will prefer the validation to be performed through CID, but it will fallback+ // to the CIP validation otherwise.++ if (_compatibilityCheckFiltered) {+ // The property was already filtered by compiler support, no need to check again+ return false;+ }++ // Mark that the property has been filtered by compiler support, regardless of the result+ _compatibilityCheckFiltered = true;++ CompilerAdapterFactory factory;+ auto compilerType = ov::intel_npu::CompilerType::DRIVER;+ try {+ auto tempCompiler = factory.getCompiler(_backend, compilerType, std::string_view{});+ // If CID is present but does not support the query, fallback to CIP+ if (!tempCompiler->is_option_supported(ov::compatibility_check.name())) {+ compilerType = ov::intel_npu::CompilerType::PLUGIN;+ try {+ tempCompiler = factory.getCompiler(_backend, compilerType, std::string_view{});+ if (!tempCompiler->is_option_supported(ov::compatibility_check.name())) {+ // Neither of the compiler adapters support the option, it should be disabled+ _logger.debug("Neither CID nor CIP support the compatibility check! Disabling the property.");+ _config.enable(ov::compatibility_check.name(), false);+ return true; // config was updated+ } else {+ // CIP is present and supports the option, COMPATIBILITY_CHECK remains enabled+ _compilerForCompatibilityCheck = ov::intel_npu::CompilerType::PLUGIN;+ }+ } catch (const std::exception&) {+ // CIP is not present either, the property is not supported+ _logger.debug("CIP is not present! Disabling the compatibility check property.");+ _config.enable(ov::compatibility_check.name(), false);+ return true; // config was updated+ }+ } else {+ // COMPATIBILITY_CHECK remains enabled+ _compilerForCompatibilityCheck = ov::intel_npu::CompilerType::DRIVER;+ }+ } catch (const std::exception&) {+ // If CID is not present (driver is not present either) plugin will not be able to retrieve+ // the device information required for the CIP check, thus the property should not be supported.+ // No need to check the CIP support anymore in this case+ _logger.debug("Driver is not present! Disabling the compatibility check property.");+ _config.enable(ov::compatibility_check.name(), false);+ return true; // config was updated+ }++ return false; // config was not updated+}++ov::intel_npu::CompilerType Properties::determineCompilerTypeForCompatibilityCheck() const {+ // The compiler type used for compatibility check is determined based on the support of+ // the COMPATIBILITY_CHECK option in the compiler adapters. If the option is supported+ // in CID, it will be preferred for compatibility check, otherwise CIP will be used+ // if it supports the option.++ return _compilerForCompatibilityCheck;+}+} // namespace intel_npudiff --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 bcad1282c28..47e53d4c8a3 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@@ -262,14 +262,19 @@ DEPRECATED VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate(vuint8_t** blobBuffer,uint64_t* blobSize);-VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate2(vcl_compiler_handle_t compiler,- vcl_executable_desc_t desc,- vcl_allocator2_t* allocator, uint8_t** blobBuffer,- uint64_t* blobSize);+DEPRECATED VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate2(vcl_compiler_handle_t compiler,+ vcl_executable_desc_t desc,+ vcl_allocator2_t* allocator,+ uint8_t** blobBuffer,+ uint64_t* blobSize);-VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate3(- vcl_compiler_handle_t compiler, vcl_executable_desc_t desc, vcl_allocator2_t* allocator, uint8_t** blobBuffer,- uint64_t* blobSize, uint8_t** compatibilityReqBuffer, uint64_t* compatibilityReqSize);+VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate3(vcl_compiler_handle_t compiler,+ vcl_executable_desc_t desc,+ vcl_allocator2_t* allocator,+ uint8_t** blobBuffer,+ uint64_t* blobSize,+ uint8_t** compatibilityStringBuffer,+ uint64_t* compatibilityStringSize);VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreateWSOneShot(vcl_compiler_handle_t compiler,vcl_executable_desc_t desc,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 8e22dbab091..20f81cb0fe6 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@@ -6,9 +6,9 @@#include <memory>-#include "vcl.h"#include "intel_npu/utils/logger/logger.hpp"#include "openvino/core/except.hpp"+#include "vcl.h"namespace intel_npu {// clang-format off@@ -28,7 +28,7 @@ namespace intel_npu {vcl_symbol_statement(vclProfilingDestroy) \vcl_symbol_statement(vclProfilingGetProperties) \vcl_symbol_statement(vclLogHandleGetString) \- vcl_symbol_statement(vclAllocatedExecutableCreate2) \+ vcl_symbol_statement(vclAllocatedExecutableCreate3) \vcl_symbol_statement(vclGetCompilerSupportedOptions) \vcl_symbol_statement(vclGetCompilerIsOptionSupported) \@@ -36,6 +36,7 @@ namespace intel_npu {// symbols that may not be supported in older versions of vcl#define vcl_weak_symbols_list() \vcl_symbol_statement(vclAllocatedExecutableCreate) \+ vcl_symbol_statement(vclAllocatedExecutableCreate2) \vcl_symbol_statement(vclAllocatedExecutableCreateWSOneShot)// clang-format ondiff --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.cppnew file mode 100644index 00000000000..f3781431e0f--- /dev/null+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp@@ -0,0 +1,16 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "common/npu_test_env_cfg.hpp"+#include "compatibility_string.hpp"++using namespace ov::test::behavior;++namespace {++INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests,+ ClassCompatibilityStringTestSuite,+ ::testing::Values(ov::test::utils::DEVICE_NPU),+ ClassCompatibilityStringTestSuite::getTestCaseName);+} // namespacediff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.hppnew file mode 100644index 00000000000..61910165692--- /dev/null+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.hpp@@ -0,0 +1,190 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>++#include <openvino/runtime/intel_npu/properties.hpp>++#include "behavior/compiled_model/properties.hpp"+#include "common/npu_test_env_cfg.hpp"+#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"+#include "openvino/pass/serialize.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"+++using namespace ov::test::behavior;++namespace {++// Tests specific for RUNTIME_REQUIREMENTS and COMPATIBILITY_CHECK properties+class ClassCompatibilityStringTestNPU+ : public OVCompiledModelPropertiesBase,+ public ::testing::WithParamInterface<std::string> {+protected:+ std::string deviceName;+ ov::Core core;++public:+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ OVCompiledModelPropertiesBase::SetUp();+ deviceName = GetParam();+ }+ static std::string getTestCaseName(testing::TestParamInfo<std::string> obj) {+ auto targetDevice = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ std::ostringstream result;+ static uint8_t testCounter = 0;+ result << "_testCounter="+ << std::to_string(testCounter++) + "_"; // used to avoid same names for different tests+ result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";+ result << "_targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);+ return result.str();+ }+};++using ClassCompatibilityStringTestSuite = ClassCompatibilityStringTestNPU;++TEST_P(ClassCompatibilityStringTestSuite, CompatibilityCheckIsSupported) {+ std::vector<ov::PropertyName> properties;++ // Forcing CIP as the current compiler type+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN));++ {+ OV_ASSERT_NO_THROW(properties = core.get_property(deviceName, ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::compatibility_check);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_FALSE(it->is_mutable());+ }++ // Forcing CID as the current compiler type+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER));++ // Test that COMPATIBILITY_CHECK is still present in supported properties when CID is used as the current compiler type+ // Even if CID does not support the option, the property should be marked as supported since the plugin will fallback to CIP+ {+ OV_ASSERT_NO_THROW(properties = core.get_property(deviceName, ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::compatibility_check);+ ASSERT_TRUE(it != properties.cend());+ }+}++TEST_P(ClassCompatibilityStringTestSuite, CompatibilityCheckInvalidArgument) {+ // Forcing CIP as the current compiler type+ ov::CompatibilityCheck result = ov::CompatibilityCheck::NOT_APPLICABLE;+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName, ov::compatibility_check));+ ASSERT_TRUE(result == ov::CompatibilityCheck::NOT_APPLICABLE);++ // Provide an argument without runtime_requirements+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName, ov::compatibility_check, ov::log::level(ov::log::Level::ERR)));+ ASSERT_TRUE(result == ov::CompatibilityCheck::NOT_APPLICABLE);++ // An incorrect runtime_requirements argument should return UNSUPPORTED+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName, ov::compatibility_check, std::make_pair(ov::runtime_requirements.name(), "invalid_string")));+ ASSERT_TRUE(result == ov::CompatibilityCheck::UNSUPPORTED);+}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsSupported) {+ // Forcing CIP as the current compiler type+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));++ std::vector<ov::PropertyName> properties;+ // Test that RUNTIME_REQUIREMENTS is supported for a model compiled with CIP+ 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());+ }+ OV_ASSERT_NO_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements));++ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));+ // Test that RUNTIME_REQUIREMENTS is not supported for a model compiled with CID+ // This check should be conditioned by the compiler/driver version once support is added in L0+ 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());+ }+ OV_EXPECT_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements), ov::Exception, testing::HasSubstr("Unsupported configuration key: RUNTIME_REQUIREMENTS"));++}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsNotSupportedForWS) {+ // 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::enable_weightless(true) }));++ 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 not in the list of supported properties either+ 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_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsExportImport) {+ // Forcing CIP as the current compiler type+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));+ std::string reference_requirements;+ OV_ASSERT_NO_THROW(reference_requirements = compiledModel.get_property(ov::runtime_requirements));++ std::stringstream compiled_blob;+ OV_ASSERT_NO_THROW(compiledModel.export_model(compiled_blob));++ OV_ASSERT_NO_THROW(compiledModel = {});+ OV_ASSERT_NO_THROW(compiledModel = core.import_model(compiled_blob, deviceName));++ std::vector<ov::PropertyName> properties;+ // Test that RUNTIME_REQUIREMENTS is supported for an imported model as well+ 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());+ std::string imported_requirements;+ OV_ASSERT_NO_THROW(imported_requirements = compiledModel.get_property(ov::runtime_requirements));++ // 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 type+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));++ std::string requirements;+ OV_ASSERT_NO_THROW(requirements = compiledModel.get_property(ov::runtime_requirements));+ ov::CompatibilityCheck result = ov::CompatibilityCheck::NOT_APPLICABLE;+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName, ov::compatibility_check, std::make_pair(ov::runtime_requirements.name(), requirements)));+ ASSERT_TRUE(result == ov::CompatibilityCheck::SUPPORTED);+}++} // namespacediff --git a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.cpp b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.cppindex fac295f660e..0ff480b41d1 100644--- a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.cpp+++ b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.cpp@@ -67,6 +67,11 @@ const std::vector<MetadataTextTest::ParamType> inputs = {make_key_value_field(MetadataTextKeys::OV, "2026.1.0") + ";" +make_key_value_field(MetadataTextKeys::WS_INITS, "0"),false},+ // compatibility descriptor value is not bracket-enclosed+ {make_key_value_field(MetadataTextKeys::META, "2.6") + ";" ++ make_key_value_field(MetadataTextKeys::OV, "2026.1.0") + ";" ++ make_key_value_field(MetadataTextKeys::COMPAT_DESC, "platform=NPU3720"),+ false},// unmatched closing bracket in value{make_key_value_field(MetadataTextKeys::META, "2.0") + ";" +make_key_value_field(MetadataTextKeys::OV, "2026.1.0") + ";bad=]VALUE",diff --git a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.hpp b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.hppindex 62ec9884b54..e861ee8c1a6 100644--- a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.hpp+++ b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_text.hpp@@ -96,6 +96,26 @@ TEST_F(MetadataHumanReadableTests, noLayouts) {ASSERT_FALSE(storedMeta->get_output_layouts().has_value());}+TEST_F(MetadataHumanReadableTests, compatibilityDescriptor) {+ const std::string compatDesc = "platform=NPU3720;tiles=2;something=ELSE";+ auto meta = Metadata<METADATA_VERSION_2_6>(0,+ CURRENT_OPENVINO_VERSION,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ compatDesc);+ const auto text = make_text_string(meta);++ std::unique_ptr<MetadataBase> storedMeta;+ OV_ASSERT_NO_THROW(storedMeta = read_as_text(text));++ ASSERT_TRUE(storedMeta->get_compatibility_descriptor().has_value());+ EXPECT_EQ(storedMeta->get_compatibility_descriptor().value(), compatDesc);+}+TEST_F(MetadataHumanReadableTests, compilerVersion) {const uint32_t compilerVersion = 0xCAFECAFE;auto meta = Metadata<METADATA_VERSION_2_4>(0,@@ -113,6 +133,35 @@ TEST_F(MetadataHumanReadableTests, compilerVersion) {ASSERT_FALSE(storedMeta->get_compiler_version().has_value());}+TEST_F(MetadataHumanReadableTests, allTextFields) {+ const std::vector<uint64_t> initSizes{10, 20, 30};+ const int64_t batchSize = 8;+ const uint32_t compilerVersion = 0xDEADBEEF;+ const std::string compatDesc = "platform=NPU3720;tiles=2;something=ELSE";+ auto meta = Metadata<METADATA_VERSION_2_6>(0,+ CURRENT_OPENVINO_VERSION,+ initSizes,+ batchSize,+ std::nullopt,+ std::nullopt,+ compilerVersion,+ std::nullopt,+ compatDesc);+ const auto text = make_text_string(meta);++ std::unique_ptr<MetadataBase> storedMeta;+ OV_ASSERT_NO_THROW(storedMeta = read_as_text(text));++ ASSERT_TRUE(storedMeta->get_init_sizes().has_value());+ ASSERT_TRUE(storedMeta->get_batch_size().has_value());+ EXPECT_EQ(storedMeta->get_batch_size().value(), batchSize);+ ASSERT_FALSE(storedMeta->get_input_layouts().has_value());+ ASSERT_FALSE(storedMeta->get_output_layouts().has_value());+ ASSERT_FALSE(storedMeta->get_compiler_version().has_value());+ ASSERT_TRUE(storedMeta->get_compatibility_descriptor().has_value());+ EXPECT_EQ(storedMeta->get_compatibility_descriptor().value(), compatDesc);+}+TEST_P(MetadataTextTest, Format) {std::unique_ptr<MetadataBase> meta;if (isValid) {diff --git a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_version.cpp b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_version.cppindex e59ef128fd6..34d26d1380d 100644--- a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_version.cpp+++ b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_version.cpp@@ -140,6 +140,91 @@ TEST_F(MetadataUnitTests, writeAndReadCurrentMetadataFromBlobWithContentAllAttri}}+TEST_F(MetadataUnitTests, writeAndReadCurrentMetadataFromBlobWithCompatibilityDesc) {+ uint64_t blobSize = 64;+ const std::string compatDesc = "platform=NPU3720;tiles=2;etc=...";+ std::stringstream stream;+ std::vector<uint8_t> content(blobSize, 0);+ stream.write(reinterpret_cast<const char*>(content.data()), static_cast<std::streamsize>(blobSize));++ auto meta = MetadataTest(blobSize,+ CURRENT_OPENVINO_VERSION,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ compatDesc);+ OV_ASSERT_NO_THROW(meta.write(stream));++ std::unique_ptr<MetadataBase> storedMeta;+ OV_ASSERT_NO_THROW(storedMeta = read_metadata_from(stream));+ ASSERT_TRUE(storedMeta->get_blob_size() == blobSize);+ ASSERT_TRUE(storedMeta->get_compatibility_descriptor().has_value());+ ASSERT_EQ(storedMeta->get_compatibility_descriptor().value(), compatDesc);++ stream.seekg(0, std::ios::beg);+ size_t streamSize = MetadataBase::getFileSize(stream);+ auto tensor = ov::Tensor(ov::element::u8, ov::Shape{streamSize});+ stream.read(tensor.data<char>(), tensor.get_byte_size());+ OV_ASSERT_NO_THROW(storedMeta = read_metadata_from(tensor));+ ASSERT_TRUE(storedMeta->get_blob_size() == blobSize);+ ASSERT_TRUE(storedMeta->get_compatibility_descriptor().has_value());+ ASSERT_EQ(storedMeta->get_compatibility_descriptor().value(), compatDesc);+}++TEST_F(MetadataUnitTests, writeAndReadCurrentMetadataFromBlobWithEmptyCompatibilityDescriptor) {+ uint64_t blobSize = 0;+ std::stringstream stream;++ auto meta = MetadataTest(blobSize,+ CURRENT_OPENVINO_VERSION,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::string{});+ OV_ASSERT_NO_THROW(meta.write(stream));++ std::unique_ptr<MetadataBase> storedMeta;+ OV_ASSERT_NO_THROW(storedMeta = read_metadata_from(stream));+ ASSERT_FALSE(storedMeta->get_compatibility_descriptor().has_value());++ stream.seekg(0, std::ios::beg);+ size_t streamSize = MetadataBase::getFileSize(stream);+ auto tensor = ov::Tensor(ov::element::u8, ov::Shape{streamSize});+ stream.read(tensor.data<char>(), tensor.get_byte_size());+ OV_ASSERT_NO_THROW(storedMeta = read_metadata_from(tensor));+ ASSERT_FALSE(storedMeta->get_compatibility_descriptor().has_value());+}++TEST_F(MetadataUnitTests, compatibilityDescriptorLenExceedsTensorBounds) {+ std::stringstream stream;+ const std::string compatDesc = "platform=NPU3720;tiles=2;etc=...";+ auto meta = Metadata<METADATA_VERSION_2_6>(0,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ std::nullopt,+ compatDesc);+ meta.write(stream);+ std::string blob = stream.str();++ const size_t compatDescLenOffset = blob.size() - MAGIC_BYTES.size() - sizeof(uint64_t) - compatDesc.size() - sizeof(uint64_t);+ const uint64_t badLen = compatDesc.size() + 0xFF;+ std::memcpy(&blob[compatDescLenOffset], &badLen, sizeof(badLen));++ auto tensor = ov::Tensor(ov::element::u8, ov::Shape{blob.size()});+ std::memcpy(tensor.data<char>(), blob.data(), blob.size());+ ASSERT_ANY_THROW(read_metadata_from(tensor));+}+TEST_F(MetadataUnitTests, writeAndReadInvalidMetadataVersion) {uint64_t blobSize = 0;std::stringstream stream;diff --git a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_wrappers.hpp b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_wrappers.hppindex 651ec108a8e..f29e3672c4f 100644--- a/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_wrappers.hpp+++ b/src/plugins/intel_npu/tests/unit/npu/metadata/metadata_wrappers.hpp@@ -18,7 +18,8 @@ struct MetadataTest : Metadata<CURRENT_METADATA_VERSION> {const std::optional<std::vector<ov::Layout>>& inputLayouts = std::nullopt,const std::optional<std::vector<ov::Layout>>& outputLayouts = std::nullopt,const std::optional<uint32_t>& compilerVersion = std::nullopt,- const std::optional<uint64_t>& blobSizeAfterEncryption = std::nullopt)+ const std::optional<uint64_t>& blobSizeAfterEncryption = std::nullopt,+ const std::optional<std::string>& compatibilityDescriptor = std::nullopt): Metadata<CURRENT_METADATA_VERSION>(blobSize,ovVersion,initSizes,@@ -26,7 +27,8 @@ struct MetadataTest : Metadata<CURRENT_METADATA_VERSION> {inputLayouts,outputLayouts,compilerVersion,- blobSizeAfterEncryption) {}+ blobSizeAfterEncryption,+ compatibilityDescriptor) {}void set_version(uint32_t newVersion) {_version = newVersion;diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cppindex a5912fd9df2..454e47f3479 100644--- a/src/plugins/template/src/plugin.cpp+++ b/src/plugins/template/src/plugin.cpp@@ -451,9 +451,7 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, constconst auto& requirements = it->second.as<std::string>();if (!requirements.empty()) {if (const auto pos = requirements.find(get_runtime_requirements()); pos == 0) {- return ov::CompatibilityCheck::OPTIMAL;- } else if (pos != std::string::npos) {- return ov::CompatibilityCheck::PREFER_RECOMPILATION;+ return ov::CompatibilityCheck::SUPPORTED;} else {return ov::CompatibilityCheck::UNSUPPORTED;}diff --git a/src/plugins/template/tests/functional/specific_properties_test.cpp b/src/plugins/template/tests/functional/specific_properties_test.cppindex ee1ce389f8c..88732cb7415 100644--- a/src/plugins/template/tests/functional/specific_properties_test.cpp+++ b/src/plugins/template/tests/functional/specific_properties_test.cpp@@ -40,7 +40,7 @@ TEST(PropertyTest, PluginReportsRequirementsMetForValidRequirements) {const auto compat =core->get_property("TEMPLATE", ov::compatibility_check, std::make_pair(ov::runtime_requirements.name(), reqs));- EXPECT_EQ(compat, ov::CompatibilityCheck::OPTIMAL);+ EXPECT_EQ(compat, ov::CompatibilityCheck::SUPPORTED);}TEST(PropertyTest, PluginRejectsModifiedRequirements) {@@ -66,7 +66,7 @@ TEST(PropertyTest, PluginAcceptModifiedRequirements) {std::string tampered = "tampered_" + reqs;EXPECT_EQ(core->get_property("TEMPLATE", ov::compatibility_check, {{ov::runtime_requirements.name(), tampered}}),- ov::CompatibilityCheck::PREFER_RECOMPILATION);+ ov::CompatibilityCheck::UNSUPPORTED);}TEST(PropertyTest, PluginRejectsEmptyRequirements) {