Skip to content

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

[NPU] Remove the legacy "use_base_model_serializer" config option and enable the "no-weights-copy" model marshalling algorithm on the CiD path (#34625)

Razvan Apetroaie79b55219ba4b
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.hpp
index 3592e69a97d..9238765aa9a 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
@@ -1450,20 +1450,6 @@ struct WS_COMPILE_CALL_NUMBER final : OptionBase<WS_COMPILE_CALL_NUMBER, uint32_
}
};
-struct USE_BASE_MODEL_SERIALIZER final : OptionBase<USE_BASE_MODEL_SERIALIZER, bool> {
- static std::string_view key() {
- return ov::intel_npu::use_base_model_serializer.name();
- }
-
- static bool defaultValue() {
- return true;
- }
-
- static OptionMode mode() {
- return OptionMode::CompileTime;
- }
-};
-
struct MODEL_SERIALIZER_VERSION final : OptionBase<MODEL_SERIALIZER_VERSION, ov::intel_npu::ModelSerializerVersion> {
static std::string_view key() {
return ov::intel_npu::model_serializer_version.name();
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
index d8d515a720b..1253691fda4 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
@@ -348,20 +348,6 @@ static constexpr ov::Property<WSVersion> separate_weights_version{"NPU_SEPARATE_
*/
static constexpr ov::Property<bool> weightless_blob{"NPU_WEIGHTLESS_BLOB"};
-/**
- * @brief [Only for NPU Plugin]
- * Type: bool. Default is "true".
- *
- * This config option concerns the algorithm used for serializing the "ov::Model" at compilation time in order to be
- * passed through the driver.
- *
- * The base serializer is the OV implementation of the "XmlSerializer" without any extensions. All weights are copied in
- * a separate buffer. By turning this off, the NPU extension of the serializer is enabled. This allows optimizing the
- * process by storing metadata (memory location & bytes size) instead of weights values. However, this solution may be
- * less reliable.
- */
-static constexpr ov::Property<bool> use_base_model_serializer{"NPU_USE_BASE_MODEL_SERIALIZER"};
-
/**
* @brief [Only for NPU Plugin]
* Type: enum. Default is "AUTO".
@@ -372,8 +358,6 @@ static constexpr ov::Property<bool> use_base_model_serializer{"NPU_USE_BASE_MODE
* The value chosen for this option will impact memory usage, since some versions clone the values of the weights in a
* separate buffer. If this option is set to "AUTO", the plugin will use the latest version that is compatible with the
* current compiler.
- *
- * @note This feature is a work-in-progress and may not yet work as intended.
*/
static constexpr ov::Property<ModelSerializerVersion> model_serializer_version{"NPU_MODEL_SERIALIZER_VERSION"};
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.hpp
index abf2117ce0b..e4242dc0177 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
@@ -92,7 +92,7 @@ public:
*/
bool get_supported_options(std::vector<char>& options) const;
- bool is_option_supported(const std::string& option, std::optional<std::string> optValue = std::nullopt) const;
+ bool is_option_supported(std::string option, std::optional<std::string> optValue = std::nullopt) const;
std::shared_ptr<void> getLinkedLibrary() const;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp
index cfced7b6532..146ad3057a5 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp
@@ -10,6 +10,8 @@
#include <string>
#include "intel_npu/common/filtered_config.hpp"
+#include "intel_npu/config/options.hpp"
+#include "intel_npu/npu_private_properties.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "openvino/core/model.hpp"
#include "openvino/pass/manager.hpp"
@@ -19,6 +21,7 @@ namespace intel_npu {
struct SerializedIR {
std::shared_ptr<uint8_t> buffer = nullptr;
size_t size = 0;
+ ov::intel_npu::ModelSerializerVersion serializerVersion = MODEL_SERIALIZER_VERSION::defaultValue();
std::optional<uint64_t> hash = std::nullopt;
};
@@ -33,8 +36,12 @@ namespace compiler_utils {
*
* @param compilerVersion The compiler version reported by the driver.
* @param supportedOpsetVersion The last operators set version supported by the compiler.
- * @param useBaseModelSerializer "true" means the legacy serializer will be used (weights will be copied), "false" means
- * the optimized one is used instead (weights pointers are stored instead).
+ * @param serializerVersion The version of the serialization algorithm that should be applied. If not "AUTO", then only
+ * the given version will be attempted. Otherwise, the NPU plugin will choose the version based on the support offered
+ * by the compiler-adapter and preference.
+ * @param isOptionSupportedByCompiler Function that allows querying the support offered by the compiler-adapter for a
+ * given <config option, value> pair. The serializer will use this function to determine the compatibility of the
+ * algorithm. If "nullptr" is passed, then the compatibility check is skipped.
* @param computeModelHash If true, a hash of the model will also be returned.
* @param storeWeightlessCacheAttribute If true, the returned serialized model will also contain within its runtime
* information the WeightlessCacheAttributes stored using a custom format. This format can be interpreted by the
@@ -44,8 +51,10 @@ namespace compiler_utils {
*/
SerializedIR serializeIR(const std::shared_ptr<const ov::Model>& model,
ze_graph_compiler_version_info_t compilerVersion,
- const uint32_t supportedOpsetVersion = 11,
- const bool useBaseModelSerializer = true,
+ const uint32_t supportedOpsetVersion,
+ const ov::intel_npu::ModelSerializerVersion serializerVersion,
+ const std::function<bool(const std::string&, const std::optional<std::string>&)>&
+ isOptionSupportedByCompiler = nullptr,
const bool computeModelHash = false,
const bool storeWeightlessCacheAttribute = false);
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.cpp
index 482d858ab0a..cc843bc30c5 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
@@ -37,29 +37,6 @@ UsedVersion getUsedVclVersion(uint16_t pluginMajor, uint16_t pluginMinor, const
return {usedMajor, usedMinor};
}
-bool isUseBaseModelSerializer(UsedVersion useVersion, const intel_npu::FilteredConfig& config) {
- // vcl serializer(No copy) is only support for vcl version >= 7.5
- if (useVersion.Major < 7 || (useVersion.Major == 7 && useVersion.Minor < 5)) {
- return true;
- }
-
- // user pass use_base_model_serializer config
- if (config.isAvailable(ov::intel_npu::use_base_model_serializer.name()) &&
- config.has(ov::intel_npu::use_base_model_serializer.name())) {
- return config.get<intel_npu::USE_BASE_MODEL_SERIALIZER>();
- }
-
- // user pass model_serializer_version config
- if (config.isAvailable(ov::intel_npu::model_serializer_version.name()) &&
- config.has(ov::intel_npu::model_serializer_version.name())) {
- return (config.get<intel_npu::MODEL_SERIALIZER_VERSION>() ==
- ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY);
- }
-
- // No VCL serializer was chosen explicitly, will default to the "no weights copy" implementation
- return false;
-}
-
struct vcl_allocator : vcl_allocator2_t {
vcl_allocator() : vcl_allocator2_t{allocate, deallocate} {}
@@ -405,16 +382,22 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
compilerVersion.major = _compilerProperties.version.major;
compilerVersion.minor = _compilerProperties.version.minor;
- bool useBaseModelSerializer = true;
- useBaseModelSerializer = isUseBaseModelSerializer(usedVersion, config);
- _logger.debug("serialize IR method is %s",
- useBaseModelSerializer ? "base vcl serializer" : "vcl serializer (not copy weights)");
+ const auto isOptionValueSupportedByCompiler = [this](const std::string& optionName,
+ const std::optional<std::string>& optionValue) {
+ return is_option_supported(optionName, optionValue);
+ };
auto serializedIR = compiler_utils::serializeIR(model,
compilerVersion,
maxOpsetVersion,
- useBaseModelSerializer,
+ config.get<MODEL_SERIALIZER_VERSION>(),
+ isOptionValueSupportedByCompiler,
false,
storeWeightlessCacheAttributeFlag);
+ FilteredConfig updatedConfig = config;
+ if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {
+ updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),
+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});
+ }
std::string buildFlags;
const auto isOptionSupportedByCompiler = [this](const std::string& optionName) {
@@ -424,7 +407,7 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
_logger.debug("create build flags");
buildFlags += compiler_utils::serializeIOInfo(model, true);
buildFlags += " ";
- buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
+ buildFlags += compiler_utils::serializeConfig(updatedConfig, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("final build flags to compiler: %s", buildFlags.c_str());
@@ -489,12 +472,22 @@ std::vector<std::shared_ptr<NetworkDescription>> VCLCompilerImpl::compileWsOneSh
compilerVersion.major = _compilerProperties.version.major;
compilerVersion.minor = _compilerProperties.version.minor;
- bool useBaseModelSerializer = true;
- useBaseModelSerializer = isUseBaseModelSerializer(usedVersion, config);
- _logger.debug("serialize IR method is %s",
- useBaseModelSerializer ? "base vcl serializer" : "vcl serializer (not copy weights)");
- auto serializedIR =
- compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer, false, true);
+ const auto isOptionValueSupportedByCompiler = [this](const std::string& optionName,
+ const std::optional<std::string>& optionValue) {
+ return is_option_supported(optionName, optionValue);
+ };
+ auto serializedIR = compiler_utils::serializeIR(model,
+ compilerVersion,
+ maxOpsetVersion,
+ config.get<MODEL_SERIALIZER_VERSION>(),
+ isOptionValueSupportedByCompiler,
+ false,
+ true);
+ FilteredConfig updatedConfig = config;
+ if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {
+ updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),
+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});
+ }
std::string buildFlags;
const auto isOptionSupportedByCompiler = [this](const std::string& optionName) {
@@ -504,7 +497,7 @@ std::vector<std::shared_ptr<NetworkDescription>> VCLCompilerImpl::compileWsOneSh
_logger.debug("create build flags");
buildFlags += compiler_utils::serializeIOInfo(model, true);
buildFlags += " ";
- buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
+ buildFlags += compiler_utils::serializeConfig(updatedConfig, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("final build flags to compiler: %s", buildFlags.c_str());
vcl_executable_desc_t exeDesc = {serializedIR.buffer.get(),
@@ -613,17 +606,26 @@ ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model
ze_graph_compiler_version_info_t compilerVersion;
compilerVersion.major = _compilerProperties.version.major;
compilerVersion.minor = _compilerProperties.version.minor;
- bool useBaseModelSerializer = true;
- useBaseModelSerializer = isUseBaseModelSerializer(usedVersion, config);
- _logger.debug("serialize IR method is %s",
- useBaseModelSerializer ? "base vcl serializer" : "vcl serializer (not copy weights)");
- auto serializedIR = compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer);
+ FilteredConfig updatedConfig = config;
+ const auto isOptionValueSupportedByCompiler = [this](const std::string& optionName,
+ const std::optional<std::string>& optionValue) {
+ return is_option_supported(optionName, optionValue);
+ };
+ auto serializedIR = compiler_utils::serializeIR(model,
+ compilerVersion,
+ maxOpsetVersion,
+ config.get<MODEL_SERIALIZER_VERSION>(),
+ isOptionValueSupportedByCompiler);
+ if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {
+ updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),
+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});
+ }
std::string buildFlags;
const auto isOptionSupportedByCompiler = [this](const std::string& optionName) {
return is_option_supported(optionName);
};
- buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
+ buildFlags += compiler_utils::serializeConfig(updatedConfig, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("queryImpl build flags : %s", buildFlags.c_str());
vcl_query_handle_t queryHandle;
@@ -683,7 +685,7 @@ bool VCLCompilerImpl::get_supported_options(std::vector<char>& options) const {
return false;
}
-bool VCLCompilerImpl::is_option_supported(const std::string& option, std::optional<std::string> optValue) const {
+bool VCLCompilerImpl::is_option_supported(std::string option, std::optional<std::string> optValue) const {
try {
const char* optname_ch = option.c_str();
const char* optvalue_ch = optValue.has_value() ? optValue.value().c_str() : nullptr;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp
index 2bcec32283d..a606bdb6bf9 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
@@ -18,25 +18,6 @@
#include "weightless_graph.hpp"
#include "weightless_utils.hpp"
-namespace {
-
-/**
- * @brief On-going migration from "use_base_model_serializer" to "model_serializer_version". So we have to check both,
- * depending on which one is supported by the compiler.
- */
-bool useBaseModelSerializer(const intel_npu::FilteredConfig& config) {
- if (config.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
- return config.get<intel_npu::USE_BASE_MODEL_SERIALIZER>();
- }
- if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {
- return (config.get<intel_npu::MODEL_SERIALIZER_VERSION>() !=
- ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY);
- }
- return true;
-}
-
-} // namespace
-
namespace intel_npu {
DriverCompilerAdapter::DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct)
@@ -67,30 +48,40 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<con
_logger.debug("serialize IR");
+ const auto isOptionValueSupportedByCompiler = [this](const std::string& optionName,
+ const std::optional<std::string>& optionValue) {
+ return is_option_supported(optionName, optionValue);
+ };
auto serializedIR = compiler_utils::serializeIR(model,
compilerVersion,
maxOpsetVersion,
- useBaseModelSerializer(config),
+ config.get<MODEL_SERIALIZER_VERSION>(),
+ isOptionValueSupportedByCompiler,
_zeGraphExt->isPluginModelHashSupported());
+ FilteredConfig updatedConfig = config;
+ if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {
+ updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),
+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});
+ }
std::string buildFlags;
const bool useIndices = !((compilerVersion.major < 5) || (compilerVersion.major == 5 && compilerVersion.minor < 9));
const auto isOptionSupportedByCompiler = std::bind(&DriverCompilerAdapter::isCompilerOptionSupported,
this,
- std::cref(config),
+ std::cref(updatedConfig),
std::cref(compilerVersion),
std::placeholders::_1);
_logger.debug("build flags");
buildFlags += compiler_utils::serializeIOInfo(model, useIndices);
buildFlags += " ";
- buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
+ buildFlags += compiler_utils::serializeConfig(updatedConfig, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("compileIR Build flags : %s", buildFlags.c_str());
_logger.debug("compile start");
// If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching
- const bool bypassCache = !config.get<CACHE_DIR>().empty() || config.get<BYPASS_UMD_CACHING>();
+ const bool bypassCache = !updatedConfig.get<CACHE_DIR>().empty() || updatedConfig.get<BYPASS_UMD_CACHING>();
auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, bypassCache);
_logger.debug("compile end");
@@ -103,7 +94,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<con
graphDesc,
std::move(networkMeta),
/* blob = */ std::nullopt,
- config);
+ updatedConfig);
}
std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Model>&& model,
@@ -118,8 +109,6 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
compilerVersion.minor);
}
- FilteredConfig updatedConfig = config;
-
const auto maxOpsetVersion = _compilerProperties.maxOVOpsetVersionSupported;
_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);
@@ -130,12 +119,22 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
}
_logger.debug("serialize IR");
+ const auto isOptionValueSupportedByCompiler = [this](const std::string& optionName,
+ const std::optional<std::string>& optionValue) {
+ return is_option_supported(optionName, optionValue);
+ };
auto serializedIR = compiler_utils::serializeIR(model,
compilerVersion,
maxOpsetVersion,
- useBaseModelSerializer(updatedConfig),
+ config.get<MODEL_SERIALIZER_VERSION>(),
+ isOptionValueSupportedByCompiler,
_zeGraphExt->isPluginModelHashSupported(),
true);
+ FilteredConfig updatedConfig = config;
+ if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {
+ updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),
+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});
+ }
std::string buildFlags;
const bool useIndices = !((compilerVersion.major < 5) || (compilerVersion.major == 5 && compilerVersion.minor < 9));
@@ -173,7 +172,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
_logger.debug("compile start");
// If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching
- const bool bypassCache = !config.get<CACHE_DIR>().empty() || config.get<BYPASS_UMD_CACHING>();
+ const bool bypassCache = !updatedConfig.get<CACHE_DIR>().empty() || updatedConfig.get<BYPASS_UMD_CACHING>();
auto graphDesc = _zeGraphExt->getGraphDescriptor(serializedIR, buildFlags, bypassCache);
_logger.debug("compile end");
@@ -211,7 +210,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
std::move(initNetworkMetadata),
/* initBlobs = */ std::nullopt,
std::move(model),
- config);
+ updatedConfig);
}
ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov::Model>& model,
@@ -223,16 +222,29 @@ ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov:
_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);
_logger.debug("serialize IR");
- auto serializedIR =
- compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer(config));
+ const auto isOptionValueSupportedByCompiler = [this](const std::string& optionName,
+ const std::optional<std::string>& optionValue) {
+ return is_option_supported(optionName, optionValue);
+ };
+ auto serializedIR = compiler_utils::serializeIR(model,
+ compilerVersion,
+ maxOpsetVersion,
+ config.get<MODEL_SERIALIZER_VERSION>(),
+ isOptionValueSupportedByCompiler);
+
+ FilteredConfig updatedConfig = config;
+ if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {
+ updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),
+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});
+ }
const auto isOptionSupportedByCompiler = std::bind(&DriverCompilerAdapter::isCompilerOptionSupported,
this,
- std::cref(config),
+ std::cref(updatedConfig),
std::cref(compilerVersion),
std::placeholders::_1);
std::string buildFlags;
- buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
+ buildFlags += compiler_utils::serializeConfig(updatedConfig, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("queryImpl build flags : %s", buildFlags.c_str());
ov::SupportedOpsMap result;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
index af62b8a0211..603dbff5d87 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
@@ -215,6 +215,77 @@ void storeWeightlessCacheAttribute(const std::shared_ptr<ov::Model>& model) {
}
}
+int get_ir_version(const std::shared_ptr<const ov::Model>& model, const intel_npu::Logger& logger) {
+ const auto& rtInfo = model->get_rt_info();
+ const auto it = rtInfo.find("version");
+ if (it != rtInfo.end()) {
+ return static_cast<int>(it->second.as<int64_t>());
+ }
+
+ logger.warning("The IR version was not found within the runtime information attributes. The NPU plugin will "
+ "continue execution assuming the version is 11. If wrong, compilation issues may occur.");
+ return 11;
+}
+
+/**
+ * @brief Find out which model serializer version should be used by the model serializer.
+ * @details This result depends on the support offered by the compiler adapter and the IR version of the model. IR
+ * versions < 11 support only "ALL_WEIGHTS_COPY". If the provided "serializerVersion" is not "AUTO", then the same
+ * version will be returned only if it is supported by the compiler adapter. Otherwise, the plugin will decide the
+ * version based on compatibility and preference.
+ *
+ * @param serializerVersion The requested serializer version, can be "AUTO"
+ * @param isOptionValueSupportedByCompiler Function used to query the support offered by the compiler-adapter. If
+ * "nullptr", then the support is not checked.
+ * @return ov::intel_npu::ModelSerializerVersion
+ */
+ov::intel_npu::ModelSerializerVersion determineModelSerializerVersion(
+ const ov::intel_npu::ModelSerializerVersion serializerVersion,
+ const std::function<bool(const std::string&, const std::optional<std::string>&)>& isOptionValueSupportedByCompiler,
+ const std::shared_ptr<ov::Model>& model,
+ const intel_npu::Logger& logger) {
+ if (get_ir_version(model, logger) < 11) {
+ // Models that use a version < 11 cannot be marshalled using the "no_weights_copy" algorithm. See C#179944.
+ return ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY;
+ }
+ if (isOptionValueSupportedByCompiler == nullptr) {
+ // Can't query the support offered by the compiler. This is considered a test scenario, therefore the version
+ // given as argument will be used.
+ logger.warning(
+ "No function has been provided to the model serializer that allows querying the options supported by the "
+ "compiler. The provided model serializer version will be used without checking the compiler support. This "
+ "is acceptable to happen only if the current run is a test.");
+ return serializerVersion != ov::intel_npu::ModelSerializerVersion::AUTO
+ ? serializerVersion
+ : ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY;
+ }
+
+ switch (serializerVersion) {
+ case ov::intel_npu::ModelSerializerVersion::AUTO:
+ // The "AUTO" value allows the plugin to pick the option it considers best. Try the more performant version
+ // first
+ if (isOptionValueSupportedByCompiler(ov::intel_npu::model_serializer_version.name(),
+ intel_npu::MODEL_SERIALIZER_VERSION::toString(
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY))) {
+ return ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY;
+ }
+ return ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY;
+ case ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY:
+ // We assume this version is always supported
+ return serializerVersion;
+ default:
+ // The user has chosen one explicit version, other than "all-weights-copy". Attempt to use it, and throw if not
+ // successful
+ if (!isOptionValueSupportedByCompiler(ov::intel_npu::model_serializer_version.name(),
+ intel_npu::MODEL_SERIALIZER_VERSION::toString(serializerVersion))) {
+ OPENVINO_THROW("The NPU plugin was requested to use the model serializer version \"",
+ intel_npu::MODEL_SERIALIZER_VERSION::toString(serializerVersion),
+ "\", but the compiler adapter does not support this version");
+ }
+ return serializerVersion;
+ }
+}
+
} // namespace
namespace intel_npu::compiler_utils {
@@ -241,7 +312,7 @@ protected:
/**
* @brief Model preprocessing steps common to all serializers.
* @details These steps should include operator conversions and the storage of additional runtime information that
- * the driver-compiler adapter may use.
+ * the compiler adapter may use.
*
* @param storeWeightlessCacheAttributeFlag If true, the WeightlessCacheAttributes will also be stored as runtime
* information using a custom format. This is necessary if the "weights separation" flow is used.
@@ -275,7 +346,7 @@ protected:
// has been removed.
model->set_rt_info(true, "is_new_api");
// Flag used to indicate an NPU plugin version that switched the I/O identification convention from
- // names to indices. The flag is needed to inform the driver-compiler adapter to expect indices
+ // names to indices. The flag is needed to inform the compiler adapter to expect indices
// when attempting to deserialize the I/O metadata.
model->set_rt_info(true, "use_indices_for_io_metadata");
}
@@ -374,7 +445,7 @@ public:
OPENVINO_ASSERT(offset == sizeOfSerializedIR);
- return {buffer, sizeOfSerializedIR, hash};
+ return {buffer, sizeOfSerializedIR, ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY, hash};
}
private:
@@ -456,7 +527,7 @@ public:
std::optional<uint64_t> hash = computeModelHash ? std::make_optional<uint64_t>(0) : std::nullopt;
serialize_model_to_buffer(model, buffer.get(), hash);
- return {buffer, serializedModelSize, hash};
+ return {buffer, serializedModelSize, ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY, hash};
}
private:
@@ -499,20 +570,34 @@ private:
}
};
-SerializedIR serializeIR(const std::shared_ptr<const ov::Model>& model,
- const ze_graph_compiler_version_info_t compilerVersion,
- const uint32_t supportedOpsetVersion,
- const bool useBaseModelSerializer,
- const bool computeModelHash,
- const bool storeWeightlessCacheAttributeFlag) {
+SerializedIR serializeIR(
+ const std::shared_ptr<const ov::Model>& model,
+ const ze_graph_compiler_version_info_t compilerVersion,
+ const uint32_t supportedOpsetVersion,
+ const ov::intel_npu::ModelSerializerVersion serializerVersion,
+ const std::function<bool(const std::string&, const std::optional<std::string>&)>& isOptionValueSupportedByCompiler,
+ const bool computeModelHash,
+ const bool storeWeightlessCacheAttributeFlag) {
// The current instance is already a clone (or should be one), we are not modifying the original model
const std::shared_ptr<ov::Model> nonConstantModel = std::const_pointer_cast<ov::Model>(model);
- if (!useBaseModelSerializer) {
+ const Logger& logger = Logger("serializeIR", Logger::global().level());
+ const ov::intel_npu::ModelSerializerVersion version =
+ determineModelSerializerVersion(serializerVersion, isOptionValueSupportedByCompiler, nonConstantModel, logger);
+
+ logger.info("Model serializer version chosen by the NPU plugin: %s",
+ MODEL_SERIALIZER_VERSION::toString(version).c_str());
+
+ switch (version) {
+ case ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY:
return VCLSerializerWithoutWeightsCopy(compilerVersion, supportedOpsetVersion)
.serialize(nonConstantModel, computeModelHash, storeWeightlessCacheAttributeFlag);
+ case ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY:
+ return VCLSerializerWithWeightsCopy(compilerVersion, supportedOpsetVersion)
+ .serialize(nonConstantModel, computeModelHash, storeWeightlessCacheAttributeFlag);
+ default:
+ OPENVINO_THROW("Invalid version of model serializer determined by the utility function. Obtained the version: ",
+ MODEL_SERIALIZER_VERSION::toString(version));
}
- return VCLSerializerWithWeightsCopy(compilerVersion, supportedOpsetVersion)
- .serialize(nonConstantModel, computeModelHash, storeWeightlessCacheAttributeFlag);
}
std::string serializeIOInfo(const std::shared_ptr<const ov::Model>& model, const bool useIndices) {
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index ed3257c524a..1bd382b1a11 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -197,18 +197,6 @@ std::shared_ptr<const ov::Model> exclude_model_ptr_from_map(ov::AnyMap& properti
return modelPtr;
}
-int get_ir_version(const std::shared_ptr<const ov::Model>& model, const intel_npu::Logger& logger) {
- const auto& rtInfo = model->get_rt_info();
- const auto it = rtInfo.find("version");
- if (it != rtInfo.end()) {
- return static_cast<int>(it->second.as<int64_t>());
- }
-
- logger.warning("The IR version was not found within the runtime information attributes. The NPU plugin will "
- "continue execution assuming the version is 11. If wrong, compilation issues may occur.");
- return 11;
-}
-
void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredConfig& config) {
// Initialize (note: it will reset registered options)
options.reset();
@@ -268,7 +256,6 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCo
REGISTER_OPTION(WEIGHTLESS_BLOB);
REGISTER_OPTION(SEPARATE_WEIGHTS_VERSION);
REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);
- REGISTER_OPTION(USE_BASE_MODEL_SERIALIZER);
REGISTER_OPTION(MODEL_SERIALIZER_VERSION);
REGISTER_OPTION(ENABLE_STRIDES_FOR);
@@ -499,33 +486,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
_logger.warning("Model received in config will be ignored as it was already provided by parameter.");
}
- // There is an on-going migration from "USE_BASE_MODEL_SERIALIZER" to "MODEL_SERIALIZER_VERSION". Until done, make
- // sure only the option supported by the compiler is registered in the config.
- bool useBaseModelSerializer = true;
- bool modelSerializerChosenExplicitly = false;
-
- if (get_ir_version(model, _logger) > 10) {
- const std::string useBaseModelSerializerKey = ov::intel_npu::use_base_model_serializer.name();
- const std::string modelSerializerVersionKey = ov::intel_npu::model_serializer_version.name();
- if (localProperties.count(useBaseModelSerializerKey)) {
- modelSerializerChosenExplicitly = true;
- useBaseModelSerializer = localProperties.at(useBaseModelSerializerKey).as<bool>();
- localProperties.erase(useBaseModelSerializerKey);
- localProperties.erase(modelSerializerVersionKey);
- } else if (localProperties.count(modelSerializerVersionKey)) {
- modelSerializerChosenExplicitly = true;
- const auto modelSerializerVersion =
- localProperties.at(modelSerializerVersionKey).as<ov::intel_npu::ModelSerializerVersion>();
- useBaseModelSerializer =
- !(modelSerializerVersion == ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY);
- localProperties.erase(modelSerializerVersionKey);
- }
- } else {
- // Models that use a version < 11 cannot be marshalled using the "no_weights_copy" algorithm. See C#179944.
- // This is a hack that should be cleaned up after the config option migration is complete.
- modelSerializerChosenExplicitly = true;
- }
-
if (_backend != nullptr) {
_backend->updateInfo(localProperties);
}
@@ -647,35 +607,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
localConfig.update({{ov::intel_npu::weightless_blob.name(), cacheModeOptimizeSize ? "YES" : "NO"}});
}
- if (modelSerializerChosenExplicitly) {
- if (localConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
- localConfig.update(
- {{ov::intel_npu::use_base_model_serializer.name(), useBaseModelSerializer ? "YES" : "NO"}});
- } else if (localConfig.isAvailable(ov::intel_npu::model_serializer_version.name())) {
- localConfig.update({{ov::intel_npu::model_serializer_version.name(),
- useBaseModelSerializer ? "ALL_WEIGHTS_COPY" : "NO_WEIGHTS_COPY"}});
- }
- } else {
- const auto compilerType = localConfig.get<COMPILER_TYPE>();
- if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
- if (localConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
- localConfig.update({{ov::intel_npu::use_base_model_serializer.name(), "NO"}});
- } else if (localConfig.isAvailable(ov::intel_npu::model_serializer_version.name())) {
- localConfig.update({{ov::intel_npu::model_serializer_version.name(), "NO_WEIGHTS_COPY"}});
- }
- } else if (compilerType == ov::intel_npu::CompilerType::DRIVER) {
- if (localConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
- localConfig.update({{ov::intel_npu::use_base_model_serializer.name(), "YES"}});
- } else if (localConfig.isAvailable(ov::intel_npu::model_serializer_version.name())) {
- localConfig.update({{ov::intel_npu::model_serializer_version.name(), "ALL_WEIGHTS_COPY"}});
- }
- }
- }
-
std::shared_ptr<intel_npu::IGraph> graph;
auto compileWithConfig = [&](auto&& modelToCompile, const auto& config) {
- if (!localConfig.get<WEIGHTLESS_BLOB>() && !localConfig.get<ENABLE_WEIGHTLESS>() ) {
+ if (!localConfig.get<WEIGHTLESS_BLOB>() && !localConfig.get<ENABLE_WEIGHTLESS>()) {
return compiler->compile(modelToCompile, config);
} else {
check_weightless_cache_attribute_occurrence(model);
@@ -886,31 +821,6 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
update_log_level(properties);
auto localProperties = properties;
- // There is an on-going migration from "USE_BASE_MODEL_SERIALIZER" to "MODEL_SERIALIZER_VERSION". Until done, make
- // sure only the option supported by the compiler is registered in the config.
- bool useBaseModelSerializer = true;
- bool modelSerializerChosenExplicitly = false;
- if (get_ir_version(model, _logger) > 10) {
- const std::string useBaseModelSerializerKey = ov::intel_npu::use_base_model_serializer.name();
- const std::string modelSerializerVersionKey = ov::intel_npu::model_serializer_version.name();
- if (localProperties.count(useBaseModelSerializerKey)) {
- modelSerializerChosenExplicitly = true;
- useBaseModelSerializer = localProperties.at(useBaseModelSerializerKey).as<bool>();
- localProperties.erase(useBaseModelSerializerKey);
- localProperties.erase(modelSerializerVersionKey);
- } else if (localProperties.count(modelSerializerVersionKey)) {
- modelSerializerChosenExplicitly = true;
- const auto modelSerializerVersion =
- localProperties.at(modelSerializerVersionKey).as<ov::intel_npu::ModelSerializerVersion>();
- useBaseModelSerializer =
- !(modelSerializerVersion == ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY);
- localProperties.erase(modelSerializerVersionKey);
- }
- } else {
- // Models that use a version < 11 cannot be marshalled using the "no_weights_copy" algorithm. See C#179944.
- // This is a hack that should be cleaned up after the config option migration is complete.
- modelSerializerChosenExplicitly = true;
- }
exclude_model_ptr_from_map(localProperties);
if (_backend != nullptr) {
@@ -936,32 +846,6 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
}
FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties, compiler.get());
-
- if (modelSerializerChosenExplicitly) {
- if (localConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
- localConfig.update(
- {{ov::intel_npu::use_base_model_serializer.name(), useBaseModelSerializer ? "YES" : "NO"}});
- } else if (localConfig.isAvailable(ov::intel_npu::model_serializer_version.name())) {
- localConfig.update({{ov::intel_npu::model_serializer_version.name(),
- useBaseModelSerializer ? "ALL_WEIGHTS_COPY" : "NO_WEIGHTS_COPY"}});
- }
- } else {
- const auto compilerType = localConfig.get<COMPILER_TYPE>();
- if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
- if (localConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
- localConfig.update({{ov::intel_npu::use_base_model_serializer.name(), "NO"}});
- } else if (localConfig.isAvailable(ov::intel_npu::model_serializer_version.name())) {
- localConfig.update({{ov::intel_npu::model_serializer_version.name(), "NO_WEIGHTS_COPY"}});
- }
- } else if (compilerType == ov::intel_npu::CompilerType::DRIVER) {
- if (localConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())) {
- localConfig.update({{ov::intel_npu::use_base_model_serializer.name(), "YES"}});
- } else if (localConfig.isAvailable(ov::intel_npu::model_serializer_version.name())) {
- localConfig.update({{ov::intel_npu::model_serializer_version.name(), "ALL_WEIGHTS_COPY"}});
- }
- }
- }
-
ov::SupportedOpsMap supportedOpsMap;
try {
supportedOpsMap = compiler->query(model->clone(), localConfig);
diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp
index 63f7f005bb4..b14bac4ba65 100644
--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp
@@ -539,7 +539,6 @@ void Properties::registerPluginProperties() {
TRY_REGISTER_SIMPLE_PROPERTY(ov::enable_weightless, ENABLE_WEIGHTLESS);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::weightless_blob, WEIGHTLESS_BLOB);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::separate_weights_version, SEPARATE_WEIGHTS_VERSION);
- TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::use_base_model_serializer, USE_BASE_MODEL_SERIALIZER);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::model_serializer_version, MODEL_SERIALIZER_VERSION);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::enable_strides_for, ENABLE_STRIDES_FOR);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::disable_idle_memory_prunning, DISABLE_IDLE_MEMORY_PRUNING);
diff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp
index cec4e77f354..9bf08cc02bd 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp
@@ -121,9 +121,14 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, TestLargeModelWeightsCopy) {
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, true));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(
+ model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY));
// If the size changes significantly, then investigation may be required
ASSERT_TRUE(serializedModel.size > SERIALIZED_MODEL_THRESHOLD_ALL_WEIGHTS_COPY);
+ ASSERT_TRUE(serializedModel.serializerVersion == ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY);
}
TEST_P(DriverCompilerAdapterCustomStreamTestNPU, TestLargeModelNoWeightsCopy) {
@@ -131,25 +136,53 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, TestLargeModelNoWeightsCopy) {
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(
+ model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY));
// If the size changes significantly, then investigation may be required
ASSERT_TRUE(serializedModel.size < SERIALIZED_MODEL_THRESHOLD_NO_WEIGHTS_COPY);
+ ASSERT_TRUE(serializedModel.serializerVersion == ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY);
ov::pass::StreamSerialize::DataHeader dataHeader;
memcpy(&dataHeader, serializedModel.buffer.get(), sizeof(dataHeader));
ASSERT_TRUE(dataHeader.consts_size == 0);
}
+TEST_P(DriverCompilerAdapterCustomStreamTestNPU, TestLargeModelAutoSerializerVersion) {
+ auto model = createModelWithLargeWeights();
+ const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
+
+ ::intel_npu::SerializedIR serializedModel;
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::AUTO));
+ // The serializer should decide which version to use. This value should not be "auto".
+ ASSERT_TRUE(serializedModel.serializerVersion != ov::intel_npu::ModelSerializerVersion::AUTO);
+}
+
TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckHashPresence) {
auto model = createModelWithLargeWeights();
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(
+ model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY));
ASSERT_FALSE(serializedModel.hash.has_value());
EXPECT_NO_THROW(serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true));
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true));
ASSERT_TRUE(serializedModel.hash.has_value());
}
@@ -162,12 +195,21 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckWeightlessCacheAttributePr
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model->clone(), dummyCompilerVersion, 11, false));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(
+ model->clone(),
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY));
ASSERT_FALSE(model->has_rt_info("ws_bin_offset_1"));
EXPECT_NO_THROW(serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, false, true));
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ false,
+ true));
// Follows the contract established with the driver-compiler adapter. Predefined prefix + a topological ID of the
// Constant node
ASSERT_TRUE(model->has_rt_info("ws_bin_offset_1"));
@@ -182,13 +224,25 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckWeightlessCacheAttributeCh
::intel_npu::SerializedIR serializedModel;
EXPECT_NO_THROW(serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, true));
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true,
+ true));
ASSERT_TRUE(serializedModel.hash.has_value());
const uint64_t hashNoWCA = serializedModel.hash.value();
model = createModelWithLargeWeights(true);
EXPECT_NO_THROW(serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, true));
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true,
+ true));
ASSERT_FALSE(hashNoWCA == serializedModel.hash.value());
}
@@ -201,23 +255,39 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckPluginHashIgnoresOnlyNonde
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model->clone(), dummyCompilerVersion, 11, false, true, false));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model->clone(),
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true,
+ false));
ASSERT_TRUE(serializedModel.hash.has_value());
const uint64_t hashNoAttribute = serializedModel.hash.value();
model->input().get_node()->get_rt_info()[TestNonDeterministicAttribute::get_type_info_static()] =
TestNonDeterministicAttribute();
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model->clone(), dummyCompilerVersion, 11, false, true, false));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model->clone(),
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true,
+ false));
ASSERT_TRUE(hashNoAttribute == serializedModel.hash.value());
model->input().get_node()->get_rt_info()[TestDeterministicAttribute::get_type_info_static()] =
TestDeterministicAttribute();
EXPECT_NO_THROW(serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, false));
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 11,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true,
+ false));
ASSERT_FALSE(hashNoAttribute == serializedModel.hash.value());
}
@@ -229,18 +299,26 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckSameModelDifferentInstance
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model,
- dummyCompilerVersion,
- 10, // Triggers an additional pass
- false,
- true,
- false));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 10, // Triggers an additional pass
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true,
+ false));
ASSERT_TRUE(serializedModel.hash.has_value());
const uint64_t hashFirstInstance = serializedModel.hash.value();
model = createModelWithLargeWeights();
EXPECT_NO_THROW(serializedModel =
- ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 10, false, true, false));
+ ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 10,
+ ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY,
+ nullptr,
+ true,
+ false));
ASSERT_TRUE(hashFirstInstance == serializedModel.hash.value());
}
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cpp
index 1f91dfd4064..2834cc491dd 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cpp
@@ -30,13 +30,16 @@ INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests,
{ov::intel_npu::defer_weights_load(false)}})),
ov::test::utils::appendPlatformTypeTestName<OVCompileAndInferRequestTurbo>);
-INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests,
- OVCompileAndInferRequestSerializers,
- ::testing::Combine(::testing::Values(createModelContainingSubgraph()),
- ::testing::Values(ov::test::utils::DEVICE_NPU),
- ::testing::ValuesIn(std::vector<ov::AnyMap>{
- {ov::intel_npu::use_base_model_serializer(true)},
- {ov::intel_npu::use_base_model_serializer(false)}})),
- ov::test::utils::appendPlatformTypeTestName<OVCompileAndInferRequestSerializers>);
+INSTANTIATE_TEST_SUITE_P(
+ compatibility_smoke_BehaviorTests,
+ OVCompileAndInferRequestSerializers,
+ ::testing::Combine(
+ ::testing::Values(createModelContainingSubgraph()),
+ ::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::ValuesIn(std::vector<ov::AnyMap>{
+ {ov::intel_npu::model_serializer_version(ov::intel_npu::ModelSerializerVersion::AUTO)},
+ {ov::intel_npu::model_serializer_version(ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY)},
+ {ov::intel_npu::model_serializer_version(ov::intel_npu::ModelSerializerVersion::NO_WEIGHTS_COPY)}})),
+ ov::test::utils::appendPlatformTypeTestName<OVCompileAndInferRequestSerializers>);
} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.hpp
index 57208e2fd30..2dfbb95760f 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.hpp
@@ -295,7 +295,7 @@ TEST_P(OVCompileAndInferRequestSerializers, AccurateResults) {
} catch (const ov::Exception& exception) {
ASSERT_STR_CONTAINS(
exception.what(),
- "[ NOT_FOUND ] Option 'NPU_USE_BASE_MODEL_SERIALIZER' is not supported for current configuration");
+ "[ NOT_FOUND ] Option 'NPU_MODEL_SERIALIZER_VERSION' is not supported for current configuration");
}
}
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
index a7e0814082c..33b7e6e7e65 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
@@ -102,8 +102,13 @@ protected:
void serializeIR() {
auto compilerProperties = zeroInitStruct->getCompilerProperties();
const auto maxOpsetVersion = compilerProperties.maxOVOpsetVersionSupported;
+ // The test is not concerned with validating the serialization algorithm. Choose the "all-weights-copy" as the
+ // safest version.
serializedIR =
- ::intel_npu::compiler_utils::serializeIR(model, compilerProperties.compilerVersion, maxOpsetVersion, true);
+ ::intel_npu::compiler_utils::serializeIR(model,
+ compilerProperties.compilerVersion,
+ maxOpsetVersion,
+ ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY);
}
bool bypassUmdCache() {
diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp
index e3522c19fa2..399b092712b 100644
--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp
@@ -168,7 +168,6 @@ public:
REGISTER_OPTION(WEIGHTLESS_BLOB);
REGISTER_OPTION(SEPARATE_WEIGHTS_VERSION);
REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);
- REGISTER_OPTION(USE_BASE_MODEL_SERIALIZER);
REGISTER_OPTION(MODEL_SERIALIZER_VERSION);
REGISTER_OPTION(ENABLE_STRIDES_FOR);