Skip to content

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

[core] Add property RUNTIME_REQUIREMENTS (#34118)

Pawel Raasz7200b26ab9a9
diff --git a/src/bindings/python/src/openvino/properties/__init__.py b/src/bindings/python/src/openvino/properties/__init__.py
index 93dddb99f92..4f48de30a30 100644
--- a/src/bindings/python/src/openvino/properties/__init__.py
+++ b/src/bindings/python/src/openvino/properties/__init__.py
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Enums
+from openvino._pyopenvino.properties import CompatibilityCheck
from openvino._pyopenvino.properties import CacheMode
from openvino._pyopenvino.properties import WorkloadType
diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
index 11a06e70a6f..5e6c79aaf2f 100644
--- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
+++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
@@ -26,6 +26,12 @@ void regmodule_properties(py::module m) {
.value("OPTIMIZE_SIZE", ov::CacheMode::OPTIMIZE_SIZE)
.value("OPTIMIZE_SPEED", ov::CacheMode::OPTIMIZE_SPEED);
+ 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("UNSUPPORTED", ov::CompatibilityCheck::UNSUPPORTED);
+
// Submodule properties - properties
wrap_property_RW(m_properties, ov::enable_profiling, "enable_profiling");
wrap_property_RW(m_properties, ov::cache_dir, "cache_dir");
@@ -54,6 +60,8 @@ void regmodule_properties(py::module m) {
wrap_property_RO(m_properties, ov::range_for_async_infer_requests, "range_for_async_infer_requests");
wrap_property_RO(m_properties, ov::execution_devices, "execution_devices");
wrap_property_RO(m_properties, ov::loaded_from_cache, "loaded_from_cache");
+ wrap_property_RO(m_properties, ov::compatibility_check, "compatibility_check");
+ wrap_property_RO(m_properties, ov::runtime_requirements, "runtime_requirements");
wrap_property_WO(m_properties, ov::cache_encryption_callbacks, "cache_encryption_callbacks");
diff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.py
index 98c1231c54f..d504d166068 100644
--- a/src/bindings/python/tests/test_runtime/test_properties.py
+++ b/src/bindings/python/tests/test_runtime/test_properties.py
@@ -54,6 +54,19 @@ def test_properties_rw_base():
(props.CacheMode.OPTIMIZE_SPEED, "CacheMode.OPTIMIZE_SPEED", 1),
),
),
+ (
+ 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.WorkloadType,
(
@@ -88,9 +101,7 @@ def test_properties_rw_base():
),
(
hints.ModelDistributionPolicy,
- (
- (hints.ModelDistributionPolicy.TENSOR_PARALLEL, "ModelDistributionPolicy.TENSOR_PARALLEL", 0),
- ),
+ ((hints.ModelDistributionPolicy.TENSOR_PARALLEL, "ModelDistributionPolicy.TENSOR_PARALLEL", 0),),
),
(
hints.ExecutionMode,
@@ -187,6 +198,8 @@ def test_conflicting_enum(proxy_enums, expected_values):
(props.range_for_async_infer_requests, "RANGE_FOR_ASYNC_INFER_REQUESTS"),
(props.execution_devices, "EXECUTION_DEVICES"),
(props.loaded_from_cache, "LOADED_FROM_CACHE"),
+ (props.runtime_requirements, "RUNTIME_REQUIREMENTS"),
+ (props.compatibility_check, "COMPATIBILITY_CHECK"),
(device.full_name, "FULL_DEVICE_NAME"),
(device.architecture, "DEVICE_ARCHITECTURE"),
(device.type, "DEVICE_TYPE"),
diff --git a/src/inference/include/openvino/runtime/properties.hpp b/src/inference/include/openvino/runtime/properties.hpp
index 7f7587ce624..17aad60c225 100644
--- a/src/inference/include/openvino/runtime/properties.hpp
+++ b/src/inference/include/openvino/runtime/properties.hpp
@@ -1438,4 +1438,99 @@ static constexpr Property<uint64_t, PropertyMutability::RW> key_cache_group_size
* @ingroup ov_runtime_cpp_prop_api
*/
static constexpr Property<uint64_t, PropertyMutability::RW> value_cache_group_size{"VALUE_CACHE_GROUP_SIZE"};
+
+/**
+ * @brief Enum to describe the compatibility of a compiled model blob with the current device environment.
+ * @ingroup ov_runtime_cpp_prop_api
+ *
+ * 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.
+};
+
+/** @cond INTERNAL */
+inline std::ostream& operator<<(std::ostream& os, const CompatibilityCheck& compatibility) {
+ switch (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::UNSUPPORTED:
+ return os << "UNSUPPORTED";
+ default:
+ OPENVINO_THROW("Unsupported CompatibilityCheck value");
+ }
+}
+
+inline std::istream& operator>>(std::istream& is, CompatibilityCheck& compatibility) {
+ std::string str;
+ is >> 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 == "UNSUPPORTED") {
+ compatibility = CompatibilityCheck::UNSUPPORTED;
+ } else {
+ OPENVINO_THROW("Unsupported CompatibilityCheck value: ", str);
+ }
+ return is;
+}
+/** @endcond */
+
+/**
+ * @brief Read-only property carrying plugin-specific runtime requirements of a compiled model blob.
+ * @ingroup ov_runtime_cpp_prop_api
+ *
+ * The property value is a std::string encoding the device environment requirements at the time
+ * a model was compiled. The format and content are plugin-dependent and may encode information such as
+ * plugin version, required hardware capabilities, or driver version.
+ *
+ * **Reading** — query on a compiled model to obtain requirements to persist alongside the blob:
+ * @code
+ * ov::Core core;
+ * auto compiled_model = core.compile_model(model, "NPU");
+ * std::string requirements = compiled_model.get_property(ov::runtime_requirements);
+ * @endcode
+ *
+ * **Passing as a hint** — use the property name to construct a hint pair when querying ov::compatibility_check:
+ * @code
+ * auto compat = core.get_property("NPU", ov::compatibility_check, {{ov::runtime_requirements.name(), requirements}});
+ * @endcode
+ */
+inline constexpr Property<std::string, PropertyMutability::RO> runtime_requirements{"RUNTIME_REQUIREMENTS"};
+
+/**
+ * @brief Read-only property to check whether a device satisfies the runtime requirements of a compiled model blob.
+ * @ingroup ov_runtime_cpp_prop_api
+ *
+ * Returns an ov::CompatibilityCheck value describing whether the current device environment is compatible
+ * with the requirements string passed as an argument via ov::runtime_requirements.
+ * The requirements string is obtained from a previously compiled model via ov::CompiledModel::get_property().
+ *
+ * @note The property must be queried with an ov::runtime_requirements argument.
+ * Querying without arguments returns ov::CompatibilityCheck::NOT_APPLICABLE.
+ *
+ * **Check requirements before import**
+ *
+ * @code
+ * auto compiled_model = core.compile_model(model, "NPU");
+ * auto requirements = compiled_model.get_property(ov::runtime_requirements);
+ * auto compat = core.get_property("NPU", ov::compatibility_check, {{ov::runtime_requirements.name(), requirements}});
+ * if (compat == ov::CompatibilityCheck::OPTIMAL ||
+ * compat == ov::CompatibilityCheck::PREFER_RECOMPILATION) {
+ * auto imported = core.import_model(blob_stream, "NPU");
+ * }
+ * @endcode
+ */
+static constexpr Property<CompatibilityCheck, PropertyMutability::RO> compatibility_check{"COMPATIBILITY_CHECK"};
} // namespace ov
diff --git a/src/plugins/template/src/compiled_model.cpp b/src/plugins/template/src/compiled_model.cpp
index 0f101015651..af798b21868 100644
--- a/src/plugins/template/src/compiled_model.cpp
+++ b/src/plugins/template/src/compiled_model.cpp
@@ -132,7 +132,8 @@ ov::Any ov::template_plugin::CompiledModel::get_property(const std::string& name
ov::supported_properties,
ov::execution_devices,
ov::loaded_from_cache,
- ov::optimal_number_of_infer_requests};
+ ov::optimal_number_of_infer_requests,
+ ov::runtime_requirements};
return ro_properties;
};
const auto& default_rw_properties = []() {
@@ -150,6 +151,9 @@ ov::Any ov::template_plugin::CompiledModel::get_property(const std::string& name
} else if (ov::optimal_number_of_infer_requests == name) {
unsigned int value = m_cfg.streams;
return decltype(ov::optimal_number_of_infer_requests)::value_type(value);
+ } else if (ov::runtime_requirements == name) {
+ // A real plugin would encode compilation capabilities.
+ return std::string(get_template_plugin()->get_runtime_requirements());
} else if (ov::supported_properties == name) {
auto ro_properties = default_ro_properties();
auto rw_properties = default_rw_properties();
diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp
index 3838e0697e2..928441ab8d6 100644
--- a/src/plugins/template/src/plugin.cpp
+++ b/src/plugins/template/src/plugin.cpp
@@ -353,7 +353,8 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const
ov::device::capabilities,
ov::device::type,
ov::range_for_async_infer_requests,
- ov::execution_devices};
+ ov::execution_devices,
+ ov::compatibility_check};
return ro_properties;
};
const auto& default_rw_properties = []() {
@@ -416,6 +417,20 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const
return decltype(ov::execution_devices)::value_type{get_device_name()};
} else if (ov::range_for_async_infer_requests == name) {
return decltype(ov::range_for_async_infer_requests)::value_type{1, 1, 1};
+ } else if (ov::compatibility_check == name) {
+ if (auto it = arguments.find(ov::runtime_requirements.name()); it != arguments.end()) {
+ const 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;
+ } else {
+ return ov::CompatibilityCheck::UNSUPPORTED;
+ }
+ }
+ }
+ return ov::CompatibilityCheck::NOT_APPLICABLE;
} else {
return m_cfg.Get(name);
}
@@ -426,3 +441,9 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const
static const ov::Version version = {CI_BUILD_NUMBER, "openvino_template_plugin"};
OV_DEFINE_PLUGIN_CREATE_FUNCTION(ov::template_plugin::Plugin, version)
// ! [plugin:create_plugin_engine]
+
+// ! [plugin:get_runtime_requirements]
+std::string_view ov::template_plugin::Plugin::get_runtime_requirements() const {
+ return "TEMPLATE_PLUGIN_CAPABILITIES_v1";
+}
+// ! [plugin:get_runtime_requirements]
diff --git a/src/plugins/template/src/plugin.hpp b/src/plugins/template/src/plugin.hpp
index 9c797794e92..f9c90d6e454 100644
--- a/src/plugins/template/src/plugin.hpp
+++ b/src/plugins/template/src/plugin.hpp
@@ -4,6 +4,8 @@
#pragma once
+#include <string_view>
+
#include "backend.hpp"
#include "compiled_model.hpp"
#include "config.hpp"
@@ -54,6 +56,7 @@ public:
private:
friend class CompiledModel;
friend class InferRequest;
+ std::string_view get_runtime_requirements() const;
std::shared_ptr<ov::runtime::Backend> m_backend;
Configuration m_cfg;
diff --git a/src/plugins/template/tests/functional/specific_properties_test.cpp b/src/plugins/template/tests/functional/specific_properties_test.cpp
new file mode 100644
index 00000000000..ee1ce389f8c
--- /dev/null
+++ b/src/plugins/template/tests/functional/specific_properties_test.cpp
@@ -0,0 +1,91 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include "common_test_utils/ov_plugin_cache.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/relu.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/runtime/properties.hpp"
+#include "openvino/util/common_util.hpp"
+
+namespace ov::test {
+
+std::shared_ptr<ov::Model> make_simple_model() {
+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 3});
+ auto relu = std::make_shared<ov::op::v0::Relu>(data);
+ auto result = std::make_shared<ov::op::v0::Result>(relu);
+ return std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{data});
+}
+
+TEST(PropertyTest, CompiledModelExposesRuntimeRequirements) {
+ auto core = ov::test::utils::PluginCache::get().core("TEMPLATE");
+ auto compiled = core->compile_model(make_simple_model(), "TEMPLATE");
+
+ const auto supported = compiled.get_property(ov::supported_properties);
+ ASSERT_TRUE(ov::util::contains(supported, ov::runtime_requirements.name()));
+
+ const auto reqs = compiled.get_property(ov::runtime_requirements);
+ EXPECT_FALSE(reqs.empty());
+}
+
+TEST(PropertyTest, PluginReportsRequirementsMetForValidRequirements) {
+ auto core = ov::test::utils::PluginCache::get().core("TEMPLATE");
+ auto compiled = core->compile_model(make_simple_model(), "TEMPLATE");
+
+ const auto reqs = compiled.get_property(ov::runtime_requirements);
+ ASSERT_FALSE(reqs.empty());
+
+ const auto compat =
+ core->get_property("TEMPLATE", ov::compatibility_check, std::make_pair(ov::runtime_requirements.name(), reqs));
+ EXPECT_EQ(compat, ov::CompatibilityCheck::OPTIMAL);
+}
+
+TEST(PropertyTest, PluginRejectsModifiedRequirements) {
+ auto core = ov::test::utils::PluginCache::get().core("TEMPLATE");
+ auto compiled = core->compile_model(make_simple_model(), "TEMPLATE");
+
+ const auto reqs = compiled.get_property(ov::runtime_requirements);
+ ASSERT_FALSE(reqs.empty());
+
+ EXPECT_EQ(core->get_property("TEMPLATE",
+ ov::compatibility_check,
+ ov::AnyMap{{ov::runtime_requirements.name(), "_tampered"}}),
+ ov::CompatibilityCheck::UNSUPPORTED);
+}
+
+TEST(PropertyTest, PluginAcceptModifiedRequirements) {
+ auto core = ov::test::utils::PluginCache::get().core("TEMPLATE");
+ auto compiled = core->compile_model(make_simple_model(), "TEMPLATE");
+
+ const auto reqs = compiled.get_property(ov::runtime_requirements);
+ ASSERT_FALSE(reqs.empty());
+
+ std::string tampered = "tampered_" + reqs;
+
+ EXPECT_EQ(core->get_property("TEMPLATE", ov::compatibility_check, {{ov::runtime_requirements.name(), tampered}}),
+ ov::CompatibilityCheck::PREFER_RECOMPILATION);
+}
+
+TEST(PropertyTest, PluginRejectsEmptyRequirements) {
+ auto core = ov::test::utils::PluginCache::get().core("TEMPLATE");
+
+ const std::string empty_reqs;
+ EXPECT_EQ(core->get_property("TEMPLATE", ov::compatibility_check, {{ov::runtime_requirements.name(), empty_reqs}}),
+ ov::CompatibilityCheck::NOT_APPLICABLE);
+}
+
+TEST(PropertyTest, PluginReturnsNotApplicableWithoutArguments) {
+ auto core = ov::test::utils::PluginCache::get().core("TEMPLATE");
+ const auto compat = core->get_property("TEMPLATE", ov::compatibility_check);
+ EXPECT_EQ(compat, ov::CompatibilityCheck::NOT_APPLICABLE);
+}
+
+TEST(PropertyTest, CompatibilityCheckListedInSupportedProperties) {
+ auto core = ov::test::utils::PluginCache::get().core("TEMPLATE");
+ const auto supported = core->get_property("TEMPLATE", ov::supported_properties);
+ EXPECT_TRUE(ov::util::contains(supported, ov::compatibility_check.name()));
+}
+} // namespace ov::test