Skip to content

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

Add enable_weightless property (#32345)

Oleg Pipikin5a87a6db3210
diff --git a/src/bindings/python/src/openvino/runtime/properties/__init__.py b/src/bindings/python/src/openvino/runtime/properties/__init__.py
index c04bebbc350..fc4d42ad88a 100644
--- a/src/bindings/python/src/openvino/runtime/properties/__init__.py
+++ b/src/bindings/python/src/openvino/runtime/properties/__init__.py
@@ -32,6 +32,7 @@ from openvino._pyopenvino.properties import key_cache_precision
from openvino._pyopenvino.properties import value_cache_precision
from openvino._pyopenvino.properties import key_cache_group_size
from openvino._pyopenvino.properties import value_cache_group_size
+from openvino._pyopenvino.properties import enable_weightless
# Submodules
from openvino.runtime.properties import hint
diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
index 5d194946bde..e36c044c518 100644
--- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
+++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
@@ -42,6 +42,7 @@ void regmodule_properties(py::module m) {
wrap_property_RW(m_properties, ov::value_cache_precision, "value_cache_precision");
wrap_property_RW(m_properties, ov::key_cache_group_size, "key_cache_group_size");
wrap_property_RW(m_properties, ov::value_cache_group_size, "value_cache_group_size");
+ wrap_property_RW(m_properties, ov::enable_weightless, "enable_weightless");
wrap_property_RO(m_properties, ov::supported_properties, "supported_properties");
wrap_property_RO(m_properties, ov::available_devices, "available_devices");
diff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.py
index 266c8690b78..3c1d3b85e57 100644
--- a/src/bindings/python/tests/test_runtime/test_properties.py
+++ b/src/bindings/python/tests/test_runtime/test_properties.py
@@ -314,9 +314,7 @@ def test_properties_ro(ov_property_ro, expected_value):
(
hints.model_distribution_policy,
"MODEL_DISTRIBUTION_POLICY",
- (
- ({hints.ModelDistributionPolicy.TENSOR_PARALLEL}, {hints.ModelDistributionPolicy.TENSOR_PARALLEL}),
- ),
+ (({hints.ModelDistributionPolicy.TENSOR_PARALLEL}, {hints.ModelDistributionPolicy.TENSOR_PARALLEL}),),
),
(
hints.enable_hyper_threading,
@@ -483,6 +481,7 @@ def test_properties_ro(ov_property_ro, expected_value):
"NPU_QDQ_OPTIMIZATION_AGGRESSIVE",
((True, True),),
),
+ (props.enable_weightless, "ENABLE_WEIGHTLESS", ((True, True), (False, False))),
],
)
def test_properties_rw(ov_property_rw, expected_value, test_values):
diff --git a/src/inference/dev_api/openvino/runtime/weightless_properties_utils.hpp b/src/inference/dev_api/openvino/runtime/weightless_properties_utils.hpp
new file mode 100644
index 00000000000..c01feedc18f
--- /dev/null
+++ b/src/inference/dev_api/openvino/runtime/weightless_properties_utils.hpp
@@ -0,0 +1,52 @@
+// Copyright (C) 2018-2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <filesystem>
+#include <optional>
+#include <variant>
+
+#include "openvino/runtime/properties.hpp"
+
+namespace ov::util {
+/**
+ * @brief Checks if configuration has properties which enables weightless blob.
+ *
+ * @param config Input configuration to examine.
+ * @return std::nullopt If input configuration doesn't define to enable/disable weightless blob.
+ * @return true If ENABLE_WEIGHTLESS:true
+ * @return true If no ENABLE_WEIGHTLESS and CACHE_MODE:OPTIMIZE_SIZE
+ * @return false If ENABLE_WEIGHTLESS:false
+ * @return false If no ENABLE_WEIGHTLESS and CACHE_MODE:OPTIMIZE_SPEED
+ */
+inline std::optional<bool> is_weightless_enabled(const ov::AnyMap& config) {
+ if (auto it = config.find(ov::enable_weightless.name()); it != config.end()) {
+ return std::make_optional(it->second.as<bool>());
+ } else if (auto cache_mode_it = config.find(ov::cache_mode.name()); cache_mode_it != config.end()) {
+ return std::make_optional(cache_mode_it->second.as<ov::CacheMode>() == ov::CacheMode::OPTIMIZE_SIZE);
+ }
+ return std::nullopt;
+}
+
+using WeightlessHint = std::variant<std::filesystem::path, std::shared_ptr<const ov::Model>, ov::Tensor>;
+
+/**
+ * @brief Get the weightless hint from configuration.
+ *
+ * @param config input config to find and get weightless hint
+ * @return WeightlessHint variant if exist or empty path if not found.
+ */
+inline WeightlessHint get_weightless_hint(const ov::AnyMap& config) {
+ WeightlessHint hint;
+ if (auto it = config.find(ov::weights_path.name()); it != config.end()) {
+ hint = std::filesystem::path(it->second.as<std::string>());
+ } else if (auto it = config.find(ov::hint::model.name()); it != config.end()) {
+ hint = it->second.as<std::shared_ptr<const ov::Model>>();
+ } else if (auto it = config.find(ov::hint::compiled_blob.name()); it != config.end()) {
+ hint = it->second.as<Tensor>();
+ }
+ return hint;
+}
+} // namespace ov::util
diff --git a/src/inference/include/openvino/runtime/properties.hpp b/src/inference/include/openvino/runtime/properties.hpp
index 9fff55e0f78..67071ddc1d7 100644
--- a/src/inference/include/openvino/runtime/properties.hpp
+++ b/src/inference/include/openvino/runtime/properties.hpp
@@ -820,10 +820,10 @@ inline std::istream& operator>>(std::istream& is, CacheMode& mode) {
/** @endcond */
/**
- * @brief Read-write property to select the cache mode between optimize_size and optimize_speed.
- * If optimize_speed is selected (default), loading time will decrease but the cache file size will increase.
- * If optimize_size is selected, smaller cache files will be created.
- * Only the GPU and NPU plugins support this for now.
+ * @brief Read-write property to select the cache mode between OPTIMIZE_SIZE and OPTIMIZE_SPEED.
+ * If OPTIMIZE_SPEED is selected (default), loading time will decrease but the cache file size will increase.
+ * If OPTIMIZE_SIZE is selected, smaller cache files will be created.
+ * The cache model default behaviour can be overridden by ENABLE_WEIGHTLESS property.
* @ingroup ov_runtime_cpp_prop_api
*/
static constexpr Property<CacheMode, PropertyMutability::RW> cache_mode{"CACHE_MODE"};
@@ -833,6 +833,12 @@ struct EncryptionCallbacks {
std::function<std::string(const std::string&)> decrypt;
};
+/**
+ * @brief Read-write property to enable/disable weightless cache.
+ * @ingroup ov_runtime_cpp_prop_api
+ */
+static constexpr Property<bool, PropertyMutability::RW> enable_weightless{"ENABLE_WEIGHTLESS"};
+
/**
* @brief Write-only property to set encryption/decryption function for saving/loading model cache.
* If cache_encryption_callbacks is set, the model topology will be encrypted when saving to the cache and decrypted
diff --git a/src/plugins/intel_cpu/src/config.cpp b/src/plugins/intel_cpu/src/config.cpp
index dce25d5f24f..5c1d547d039 100644
--- a/src/plugins/intel_cpu/src/config.cpp
+++ b/src/plugins/intel_cpu/src/config.cpp
@@ -21,6 +21,7 @@
#include "openvino/runtime/intel_cpu/properties.hpp"
#include "openvino/runtime/internal_properties.hpp"
#include "openvino/runtime/properties.hpp"
+#include "openvino/runtime/weightless_properties_utils.hpp"
#include "utils/debug_capabilities.h"
#include "utils/general_utils.h"
#include "utils/precision_support.h"
@@ -449,17 +450,27 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
} else if (key == ov::cache_mode.name()) {
try {
m_cache_mode = val.as<ov::CacheMode>();
+ if (const auto enable_weightless = ov::util::is_weightless_enabled(prop); enable_weightless) {
+ enableWeightless = *enable_weightless;
+ }
} catch (...) {
OPENVINO_THROW("Wrong value for property key ", ov::cache_mode.name());
}
} else if (key == ov::hint::model.name() || key == ov::internal::caching_with_mmap.name() ||
key == ov::weights_path.name()) {
+ // do nothing
} else if (key == ov::intel_cpu::enable_sage_attn.name()) {
try {
enableSageAttn = val.as<bool>();
} catch (ov::Exception&) {
OPENVINO_THROW("Wrong value for property key ", ov::intel_cpu::enable_sage_attn.name());
}
+ } else if (key == ov::enable_weightless.name()) {
+ try {
+ enableWeightless = val.as<bool>();
+ } catch (...) {
+ OPENVINO_THROW("Wrong value for property key ", ov::enable_weightless.name());
+ }
} else {
OPENVINO_THROW("NotFound: Unsupported property ", key, " by CPU plugin.");
}
diff --git a/src/plugins/intel_cpu/src/config.h b/src/plugins/intel_cpu/src/config.h
index 68ea781a204..06c3041cfe3 100644
--- a/src/plugins/intel_cpu/src/config.h
+++ b/src/plugins/intel_cpu/src/config.h
@@ -139,6 +139,7 @@ struct Config {
std::function<std::string(const std::string&)> cacheDecrypt;
ov::CacheMode m_cache_mode = ov::CacheMode::OPTIMIZE_SPEED;
+ bool enableWeightless = false;
#ifdef CPU_DEBUG_CAPS
DebugCapsConfig debugCaps;
diff --git a/src/plugins/intel_cpu/src/plugin.cpp b/src/plugins/intel_cpu/src/plugin.cpp
index e867f84fef1..8941f868642 100644
--- a/src/plugins/intel_cpu/src/plugin.cpp
+++ b/src/plugins/intel_cpu/src/plugin.cpp
@@ -49,6 +49,7 @@
#include "openvino/runtime/threading/cpu_message.hpp"
#include "openvino/runtime/threading/executor_manager.hpp"
#include "openvino/runtime/threading/istreams_executor.hpp"
+#include "openvino/runtime/weightless_properties_utils.hpp"
#include "openvino/util/xml_parse_utils.hpp"
#include "sigstack_manager.h"
#include "transformations/transformation_pipeline.h"
@@ -517,6 +518,10 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& options)
return decltype(ov::weights_path)::value_type(std::string(""));
}
+ if (name == ov::enable_weightless) {
+ return decltype(ov::enable_weightless)::value_type{engConfig.enableWeightless};
+ }
+
return get_ro_property(name, options);
}
@@ -566,7 +571,8 @@ ov::Any Plugin::get_ro_property(const std::string& name, [[maybe_unused]] const
RW_property(ov::key_cache_precision.name()),
RW_property(ov::value_cache_precision.name()),
RW_property(ov::key_cache_group_size.name()),
- RW_property(ov::value_cache_group_size.name())};
+ RW_property(ov::value_cache_group_size.name()),
+ RW_property(ov::enable_weightless.name())};
std::vector<ov::PropertyName> wo_properties{WO_property(ov::weights_path.name())};
@@ -702,17 +708,12 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
}
static std::string get_origin_weights_path(const ov::AnyMap& config) {
- ov::CacheMode cache_mode = ov::CacheMode::OPTIMIZE_SPEED;
std::string origin_weights_path;
- auto cm_it = config.find(ov::cache_mode.name());
- if (cm_it != config.end()) {
- cache_mode = cm_it->second.as<ov::CacheMode>();
- if (cache_mode == ov::CacheMode::OPTIMIZE_SIZE) {
- auto wp_it = config.find(ov::weights_path.name());
- if (wp_it != config.end()) {
- origin_weights_path = wp_it->second.as<std::string>();
- }
+ if (ov::util::is_weightless_enabled(config).value_or(false)) {
+ auto wp_it = config.find(ov::weights_path.name());
+ if (wp_it != config.end()) {
+ origin_weights_path = wp_it->second.as<std::string>();
}
}
diff --git a/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_plugin/properties.cpp b/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_plugin/properties.cpp
index bb786f3828b..2069ad0562e 100644
--- a/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_plugin/properties.cpp
+++ b/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_plugin/properties.cpp
@@ -67,6 +67,7 @@ TEST_F(OVClassConfigTestCPU, smoke_PluginAllSupportedPropertiesAreAvailable) {
RW_property(ov::value_cache_precision.name()),
RW_property(ov::key_cache_group_size.name()),
RW_property(ov::value_cache_group_size.name()),
+ RW_property(ov::enable_weightless.name()),
};
ov::Core ie;
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/compiled_model/model_cache.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/compiled_model/model_cache.cpp
index 7ce2c284851..97eae32b315 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/compiled_model/model_cache.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/compiled_model/model_cache.cpp
@@ -4,6 +4,7 @@
#include "behavior/compiled_model/model_cache.hpp"
#include "common_test_utils/test_constants.hpp"
+#include "openvino/runtime/properties.hpp"
using namespace ov::test::behavior;
@@ -13,6 +14,10 @@ INSTANTIATE_TEST_SUITE_P(smoke_,
::testing::Bool(),
::testing::ValuesIn(inference_modes),
::testing::ValuesIn(model_dtypes),
+ ::testing::Values(ov::AnyMap{ov::enable_weightless("ON"),
+ ov::cache_mode("OPTIMIZE_SPEED")},
+ ov::AnyMap{ov::cache_mode("OPTIMIZE_SIZE")},
+ ov::AnyMap{ov::enable_weightless("OFF")}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
WeightlessCacheAccuracy::get_test_case_name);
@@ -22,5 +27,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_,
::testing::Bool(),
::testing::ValuesIn(inference_modes),
::testing::ValuesIn(low_precision_dtypes),
+ ::testing::Values(ov::AnyMap{ov::enable_weightless("ON"),
+ ov::cache_mode("OPTIMIZE_SPEED")},
+ ov::AnyMap{ov::cache_mode("OPTIMIZE_SIZE")}),
::testing::Values(ov::test::utils::DEVICE_CPU)),
WeightlessCacheAccuracy::get_test_case_name);
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
index 4f0bfe77b83..f3c17cb0d28 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
@@ -39,6 +39,7 @@ OV_CONFIG_RELEASE_OPTION(ov::hint, model, nullptr, "Shared pointer to the ov::Mo
OV_CONFIG_RELEASE_OPTION(ov::internal, key_cache_quant_mode, ov::internal::CacheQuantMode::BY_CHANNEL, "AUTO or BY_CHANNEL or BY_TOKEN")
OV_CONFIG_RELEASE_OPTION(ov::internal, value_cache_quant_mode, ov::internal::CacheQuantMode::BY_TOKEN, "AUTO or BY_CHANNEL or BY_TOKEN")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu, mem_pool_util_threshold, 0.5, "Minimum utilization threshold (0.0~1.0) for reusable memory in the pool")
+OV_CONFIG_RELEASE_OPTION(ov, enable_weightless, false, "Enable/Disable weightless blob")
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, shape_predictor_settings, {10, 16 * 1024, 2, 1.1f}, "Preallocation settings")
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, queue_type, QueueTypes::out_of_order, "Type of the queue that must be used for model execution. May be in-order or out-of-order")
diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cpp
index 151da9aae1a..d80f077db24 100644
--- a/src/plugins/intel_gpu/src/graph/program.cpp
+++ b/src/plugins/intel_gpu/src/graph/program.cpp
@@ -1876,7 +1876,7 @@ void program::load(cldnn::BinaryInputBuffer& ib,
std::shared_ptr<WeightsMemory> weights_memory = nullptr;
std::string weights_path = _config.get_weights_path();
- if (_config.get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE) {
+ if (_config.get_enable_weightless()) {
if (model_ptr) {
if (cache_attr_map) {
weights_memory = std::make_shared<WeightsMemory>(model_ptr, cache_attr_map);
diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cpp
index d0b9f82ed12..cc7a9e3c1aa 100644
--- a/src/plugins/intel_gpu/src/plugin/plugin.cpp
+++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp
@@ -27,6 +27,7 @@
#include "intel_gpu/runtime/itt.hpp"
#include "openvino/core/any.hpp"
#include "openvino/core/deprecated.hpp"
+#include "openvino/op/util/op_types.hpp"
#include "openvino/pass/manager.hpp"
#include "openvino/pass/visualize_tree.hpp"
#include "openvino/runtime/device_id_parser.hpp"
@@ -37,13 +38,12 @@
#include "openvino/runtime/plugin_config.hpp"
#include "openvino/runtime/properties.hpp"
#include "openvino/runtime/shared_buffer.hpp"
+#include "openvino/runtime/weightless_properties_utils.hpp"
#include "openvino/util/weights_path.hpp"
#include "transformations/common_optimizations/dimension_tracking.hpp"
#include "transformations/init_node_info.hpp"
#include "transformations/rt_info/fused_names_attribute.hpp"
#include "transformations/utils/utils.hpp"
-#include "openvino/op/util/op_types.hpp"
-
// Undef DEVICE_TYPE macro which can be defined somewhere in windows headers as DWORD and conflict with our metric
#ifdef DEVICE_TYPE
@@ -168,11 +168,9 @@ std::shared_ptr<ov::Model> Plugin::clone_and_transform_model(const std::shared_p
ov::pass::VisualizeTree(path_base + ".svg").run_on_model(cloned_model);
}
- ov::CacheMode cache_mode = config.get_cache_mode();
-
- // Set weighless cache attribute only for non IR (e.g. onnxruntime) models
+ // Set weightless cache attribute only for non IR (e.g. onnxruntime) models
// This is a temporary solution. A common way of handling weightless caching will be defined later.
- if (cache_mode == ov::CacheMode::OPTIMIZE_SIZE) {
+ if (config_copy.get_enable_weightless()) {
const std::string& weights_path = config.get_weights_path();
if (!ov::util::validate_weights_path(weights_path) && !is_weightless_cache_attributes_set(cloned_model))
@@ -414,7 +412,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
return nullptr;
}
- if (config.get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE) {
+ if (ov::util::is_weightless_enabled(config.get_user_properties()).value_or(false)) {
const std::string& weights_path = config.get_weights_path();
if (!ov::util::validate_weights_path(weights_path)) {
@@ -464,7 +462,7 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& options)
return decltype(ov::internal::supported_properties)::value_type{get_supported_internal_properties()};
} else if (name == ov::available_devices) {
std::vector<std::string> available_devices = { };
- for (auto const& dev : m_device_map)
+ for (const auto& dev : m_device_map)
available_devices.push_back(dev.first);
return decltype(ov::available_devices)::value_type {available_devices};
} else if (name == ov::internal::caching_properties) {
diff --git a/src/plugins/intel_gpu/src/plugin/program_builder.cpp b/src/plugins/intel_gpu/src/plugin/program_builder.cpp
index 11175f1427b..39e31abedf7 100644
--- a/src/plugins/intel_gpu/src/plugin/program_builder.cpp
+++ b/src/plugins/intel_gpu/src/plugin/program_builder.cpp
@@ -281,7 +281,7 @@ void ProgramBuilder::add_primitive(const ov::Node& op, std::shared_ptr<cldnn::pr
prim->origin_op_name = op.get_friendly_name();
prim->origin_op_type_name = op.get_type_name();
- if (this->m_config.get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE) {
+ if (this->m_config.get_enable_weightless()) {
if (auto data_prim = dynamic_cast<cldnn::data*>(prim.get())) {
auto rt_info = op.get_rt_info();
diff --git a/src/plugins/intel_gpu/src/runtime/execution_config.cpp b/src/plugins/intel_gpu/src/runtime/execution_config.cpp
index 15cb99193e8..be09b3444ef 100644
--- a/src/plugins/intel_gpu/src/runtime/execution_config.cpp
+++ b/src/plugins/intel_gpu/src/runtime/execution_config.cpp
@@ -2,31 +2,31 @@
// SPDX-License-Identifier: Apache-2.0
//
+#include "intel_gpu/op/indirect_sdpa.hpp"
+#include "intel_gpu/op/kv_cache.hpp"
+#include "intel_gpu/op/sdpa.hpp"
+#include "intel_gpu/plugin/remote_context.hpp"
#include "intel_gpu/primitives/paged_attention.hpp"
#include "intel_gpu/runtime/execution_config.hpp"
-#include "intel_gpu/plugin/remote_context.hpp"
+#include "intel_gpu/runtime/internal_properties.hpp"
#include "openvino/core/any.hpp"
#include "openvino/core/model.hpp"
+#include "openvino/op/gru_sequence.hpp"
+#include "openvino/op/istft.hpp"
#include "openvino/op/loop.hpp"
#include "openvino/op/lstm_sequence.hpp"
-#include "openvino/op/gru_sequence.hpp"
#include "openvino/op/paged_attention.hpp"
#include "openvino/op/scaled_dot_product_attention.hpp"
-#include "intel_gpu/op/sdpa.hpp"
-#include "intel_gpu/op/indirect_sdpa.hpp"
#include "openvino/op/search_sorted.hpp"
#include "openvino/op/sparse_fill_empty_rows.hpp"
#include "openvino/op/stft.hpp"
-#include "openvino/op/istft.hpp"
-#include "ov_ops/dynamic_quantize.hpp"
-#include "ov_ops/rms.hpp"
#include "openvino/runtime/internal_properties.hpp"
-#include "intel_gpu/runtime/internal_properties.hpp"
#include "openvino/runtime/plugin_config.hpp"
#include "openvino/runtime/properties.hpp"
+#include "openvino/runtime/weightless_properties_utils.hpp"
+#include "ov_ops/dynamic_quantize.hpp"
+#include "ov_ops/rms.hpp"
#include "transformations/utils/utils.hpp"
-#include "intel_gpu/op/kv_cache.hpp"
-
namespace ov::intel_gpu {
@@ -162,10 +162,13 @@ void ExecutionConfig::apply_rt_info(const IRemoteContext* context, const ov::RTM
apply_rt_info_property(ov::hint::dynamic_quantization_group_size, rt_info);
apply_rt_info_property(ov::intel_gpu::hint::dynamic_quantization_group_size_max, rt_info);
- // WEIGHTS_PATH is used for the weightless cache mechanism which is used only with
- // ov::CacheMode::OPTIMIZE_SIZE setting. Not setting WEIGHTS_PATH will result in not
+ // WEIGHTS_PATH is used for the weightless cache mechanism which is used only as defined by
+ // ov::util::is_weightless_enabled. Not setting WEIGHTS_PATH will result in not
// using that mechanism.
- if (get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE) {
+ if (const auto enable_weightless = ov::util::is_weightless_enabled(get_user_properties()); enable_weightless) {
+ set_property({ov::enable_weightless(*enable_weightless)});
+ }
+ if (get_enable_weightless()) {
apply_rt_info_property(ov::weights_path, rt_info);
}
}
diff --git a/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp b/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp
index e6a0498b4c9..33f03274361 100644
--- a/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp
+++ b/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp
@@ -7,7 +7,6 @@
#include <cstdio>
-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
#include "common_test_utils/common_utils.hpp"
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
@@ -17,13 +16,15 @@
#include "common_test_utils/test_common.hpp"
#include "openvino/core/rt_info/weightless_caching_attributes.hpp"
#include "openvino/op/convert.hpp"
+#include "openvino/op/matmul.hpp"
#include "openvino/op/util/op_types.hpp"
#include "openvino/pass/constant_folding.hpp"
#include "openvino/pass/manager.hpp"
#include "openvino/pass/serialize.hpp"
+#include "openvino/runtime/weightless_properties_utils.hpp"
#include "openvino/util/codec_xor.hpp"
+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
#include "shared_test_classes/subgraph/weights_decompression_builders.hpp"
-#include "openvino/op/matmul.hpp"
#ifndef WIN32
# include <unistd.h>
#endif
@@ -56,12 +57,12 @@ std::string import_api_to_string(Import_API api) {
}
}
-typedef std::tuple<Import_API, bool, ov::element::Type, ov::element::Type> testParams;
+typedef std::tuple<Import_API, bool, ov::element::Type, ov::element::Type, ov::AnyMap> testParams;
class CheckWeightlessCacheAccuracy : public ::testing::Test, public ::testing::WithParamInterface<testParams> {
public:
static std::string get_test_case_name(::testing::TestParamInfo<testParams> obj) {
- const auto& [import_api_, do_encryption_, inference_mode_, model_dtype_] = obj.param;
+ const auto& [import_api_, do_encryption_, inference_mode_, model_dtype_, config_] = obj.param;
std::ostringstream result;
const char separator = '_';
@@ -69,6 +70,10 @@ public:
result << "do_encryption=" << do_encryption_ << separator;
result << "inference_mode=" << inference_mode_ << separator;
result << "model_dtype=" << model_dtype_;
+ result << "_config=";
+ for (const auto& [name, value] : config_) {
+ result << name << "[" << value.as<std::string>() << "]|";
+ }
return result.str();
}
@@ -95,7 +100,7 @@ void CheckWeightlessCacheAccuracy::SetUp() {
cache_path = filePrefix + ".blob";
cache_dir = filePrefix + "_cache_dir";
- std::tie(import_api, do_encryption, inference_mode, model_dtype) = GetParam();
+ std::tie(import_api, do_encryption, inference_mode, model_dtype, std::ignore) = GetParam();
}
void CheckWeightlessCacheAccuracy::TearDown() {
@@ -109,12 +114,16 @@ void CheckWeightlessCacheAccuracy::TearDown() {
}
void CheckWeightlessCacheAccuracy::run() {
- ov::AnyMap config = {ov::cache_dir(cache_dir),
- ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
- ov::hint::inference_precision(inference_mode)};
- ov::AnyMap config_with_weights_path = {ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
- ov::weights_path(bin_path),
- ov::hint::inference_precision(inference_mode)};
+ ov::AnyMap config = {ov::cache_dir(cache_dir), ov::hint::inference_precision(inference_mode)};
+ for (const auto& property : std::get<4>(GetParam())) {
+ config.insert(property);
+ }
+
+ auto config_with_weights_path = config;
+ if (ov::util::is_weightless_enabled(config).value_or(false)) {
+ config_with_weights_path.insert(ov::weights_path(bin_path));
+ }
+ config_with_weights_path.erase(ov::cache_dir.name());
if (do_encryption) {
ov::EncryptionCallbacks encryption_callbacks;
@@ -295,7 +304,10 @@ INSTANTIATE_TEST_SUITE_P(smoke_CheckWeightlessCacheAccuracy,
::testing::Combine(::testing::ValuesIn(import_api_types),
::testing::Bool(),
::testing::ValuesIn(inference_modes),
- ::testing::ValuesIn(model_dtypes)),
+ ::testing::ValuesIn(model_dtypes),
+ ::testing::Values(ov::AnyMap{ov::enable_weightless("ON"), ov::cache_mode("OPTIMIZE_SPEED")},
+ ov::AnyMap{ov::cache_mode("OPTIMIZE_SIZE")},
+ ov::AnyMap{ov::enable_weightless("OFF"), ov::cache_mode("OPTIMIZE_SIZE")})),
CheckWeightlessCacheAccuracy::get_test_case_name);
INSTANTIATE_TEST_SUITE_P(smoke_CheckWeightlessCacheAccuracyLowPrecision,
@@ -303,7 +315,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_CheckWeightlessCacheAccuracyLowPrecision,
::testing::Combine(::testing::ValuesIn(import_api_types),
::testing::Bool(),
::testing::ValuesIn(inference_modes),
- ::testing::ValuesIn(low_precision_dtypes)),
+ ::testing::ValuesIn(low_precision_dtypes),
+ ::testing::Values(ov::AnyMap{ov::cache_mode("OPTIMIZE_SIZE")},
+ ov::AnyMap{ov::enable_weightless("OFF"), ov::cache_mode("OPTIMIZE_SIZE")})),
CheckWeightlessCacheAccuracy::get_test_case_name);
TEST(smoke_CheckWeightlessCacheAccuracy, ConstantFoldingAttrPropagation) {
diff --git a/src/tests/functional/plugin/shared/include/behavior/compiled_model/model_cache.hpp b/src/tests/functional/plugin/shared/include/behavior/compiled_model/model_cache.hpp
index 750393b8ef8..220b3f3550d 100644
--- a/src/tests/functional/plugin/shared/include/behavior/compiled_model/model_cache.hpp
+++ b/src/tests/functional/plugin/shared/include/behavior/compiled_model/model_cache.hpp
@@ -9,7 +9,8 @@ namespace ov {
namespace test {
namespace behavior {
-typedef std::tuple<bool, bool, ov::element::Type, ov::element::Type, const char*> WeightlessCacheAccuracyTestParams;
+typedef std::tuple<bool, bool, ov::element::Type, ov::element::Type, ov::AnyMap, const char*>
+ WeightlessCacheAccuracyTestParams;
class WeightlessCacheAccuracy : public ::testing::Test, public ::testing::WithParamInterface<WeightlessCacheAccuracyTestParams> {
public:
diff --git a/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp b/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp
index e8c8ba06de4..e2fbc03cc9e 100644
--- a/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp
+++ b/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp
@@ -3,13 +3,13 @@
//
#include "behavior/compiled_model/model_cache.hpp"
-
+#include "common_test_utils/ov_tensor_utils.hpp"
#include "common_test_utils/subgraph_builders/read_concat_split_assign.hpp"
#include "common_test_utils/subgraph_builders/single_concat_with_constant.hpp"
#include "common_test_utils/subgraph_builders/ti_with_lstm_cell.hpp"
#include "common_test_utils/test_assertions.hpp"
-#include "common_test_utils/ov_tensor_utils.hpp"
#include "openvino/op/matmul.hpp"
+#include "openvino/runtime/weightless_properties_utils.hpp"
#include "openvino/util/codec_xor.hpp"
#include "shared_test_classes/subgraph/weights_decompression_builders.hpp"
@@ -24,7 +24,11 @@ std::string WeightlessCacheAccuracy::get_test_case_name(const ::testing::TestPar
result << "_do_encryption=" << utils::bool2str(std::get<1>(obj.param));
result << "_inference_mode=" << std::get<2>(obj.param);
result << "_model_dtype=" << std::get<3>(obj.param);
- result << "_device=" << std::get<4>(obj.param);
+ result << "_config=";
+ for (const auto& [name, value] : std::get<4>(obj.param)) {
+ result << name << "[" << value.as<std::string>() << "]|";
+ }
+ result << "_device=" << std::get<5>(obj.param);
return result.str();
}
@@ -36,7 +40,8 @@ void WeightlessCacheAccuracy::SetUp() {
m_cache_path = filePrefix + ".blob";
m_cache_dir = filePrefix + "_cache_dir";
- std::tie(m_use_compile_model_api, m_do_encryption, m_inference_mode, m_model_dtype, m_target_device) = GetParam();
+ std::tie(m_use_compile_model_api, m_do_encryption, m_inference_mode, m_model_dtype, std::ignore, m_target_device) =
+ GetParam();
}
void WeightlessCacheAccuracy::TearDown() {
@@ -50,12 +55,16 @@ void WeightlessCacheAccuracy::TearDown() {
}
void WeightlessCacheAccuracy::run() {
- ov::AnyMap config = {ov::cache_dir(m_cache_dir),
- ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
- ov::hint::inference_precision(m_inference_mode)};
- ov::AnyMap config_with_weights_path = {ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
- ov::weights_path(m_bin_path),
- ov::hint::inference_precision(m_inference_mode)};
+ ov::AnyMap config = {ov::cache_dir(m_cache_dir), ov::hint::inference_precision(m_inference_mode)};
+ for (const auto& property : std::get<4>(GetParam())) {
+ config.insert(property);
+ }
+
+ auto config_with_weights_path = config;
+ if (ov::util::is_weightless_enabled(config).value_or(false)) {
+ config_with_weights_path.insert(ov::weights_path(m_bin_path));
+ }
+ config_with_weights_path.erase(ov::cache_dir.name());
if (m_do_encryption) {
ov::EncryptionCallbacks encryption_callbacks;