OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPU] Run inferences seq from different compiled models if RUN_INFERENCES_SEQUENTIALLY and SHARED_COMMON_QUEUE are set (#38132)
Bogdan Pereanu0537c38ec367
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cppindex 437120149af..16314e9cabd 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp@@ -332,19 +332,20 @@ void DynamicGraph::initialize_impl(const FilteredConfig& config) {_logger.debug("Graph initialize without graph handle");uint32_t commandQueueOptions = 0;- if (config.has<TURBO>() && config.get<TURBO>()) {+ if (config.get<TURBO>()) {OPENVINO_ASSERT(_zeroInitStruct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 0),"Turbo is not supported by the current driver");_logger.debug("Set ZE_NPU_COMMAND_QUEUE_OPTION_TURBO in command queue options");commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;}- if (config.has<RUN_INFERENCES_SEQUENTIALLY>() && config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (config.get<RUN_INFERENCES_SEQUENTIALLY>()) {OPENVINO_ASSERT(_zeroInitStruct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1),"Running inferences sequentially is not supported by the current driver");_logger.debug("Set ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC in command queue options");commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC;}+ bool sharedCommonQueue = config.get<SHARED_COMMON_QUEUE>();{std::lock_guard<std::mutex> lock(_commandQueueDescMutex);_commandQueueDesc = CommandQueueDesc{@@ -352,9 +353,9 @@ void DynamicGraph::initialize_impl(const FilteredConfig& config) {config.has<WORKLOAD_TYPE>() ? zeroUtils::toZeQueueWorkloadType(config.get<WORKLOAD_TYPE>()) : std::nullopt,commandQueueOptions,this,- config.get<SHARED_COMMON_QUEUE>()};+ sharedCommonQueue};- if (config.get<SHARED_COMMON_QUEUE>() == false) {+ if (sharedCommonQueue == false) {// Keep it alive per compiled model when the shared common queue feature is disabled._commandQueue = ZeroCmdQueuePool::getInstance().getCommandQueue(_zeroInitStruct, _commandQueueDesc);}diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cppindex e851abe6eb4..6330ff40b16 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp@@ -186,17 +186,21 @@ void Graph::initialize_impl(const FilteredConfig& config) {return;}+ bool sharedCommonQueue = config.get<SHARED_COMMON_QUEUE>();uint32_t commandQueueOptions = 0;- if (config.has<TURBO>() && config.get<TURBO>()) {- if (_zeroInitStruct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 0)) {- _logger.debug("Set ZE_NPU_COMMAND_QUEUE_OPTION_TURBO in command queue options");- commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;- }+ if (config.get<TURBO>() && _zeroInitStruct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 0)) {+ _logger.debug("Set ZE_NPU_COMMAND_QUEUE_OPTION_TURBO in command queue options");+ commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;}- if (_zeroInitStruct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1) &&- config.has<RUN_INFERENCES_SEQUENTIALLY>() && config.get<RUN_INFERENCES_SEQUENTIALLY>()) {- _logger.debug("Set ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC in command queue options");- commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC;+ if (config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (_zeroInitStruct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1)) {+ _logger.debug("Set ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC in command queue options");+ commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC;+ } else {+ OPENVINO_ASSERT(!sharedCommonQueue,+ "RUN_INFERENCES_SEQUENTIALLY requires a command queue with device-sync support when "+ "SHARED_COMMON_QUEUE is enabled");+ }}{@@ -206,10 +210,10 @@ void Graph::initialize_impl(const FilteredConfig& config) {config.has<WORKLOAD_TYPE>() ? zeroUtils::toZeQueueWorkloadType(config.get<WORKLOAD_TYPE>()) : std::nullopt,commandQueueOptions,this,- config.get<SHARED_COMMON_QUEUE>(),+ sharedCommonQueue,};- if (config.get<SHARED_COMMON_QUEUE>() == false) {+ if (sharedCommonQueue == false) {// Keep it alive per compiled model when the shared common queue feature is disabled._commandQueue = ZeroCmdQueuePool::getInstance().getCommandQueue(_zeroInitStruct, _commandQueueDesc);}@@ -227,8 +231,8 @@ void Graph::initialize_impl(const FilteredConfig& config) {_batchSize = determine_batch_size();}- if (_zeroInitStruct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1) &&- config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (config.get<RUN_INFERENCES_SEQUENTIALLY>() &&+ _zeroInitStruct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1)) {auto numberOfCommandLists = _batchSize.has_value() ? *_batchSize : 1;_lastSubmittedEvent.resize(numberOfCommandLists);diff --git a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp b/src/plugins/intel_npu/src/plugin/include/compiled_model.hppindex fa324d8f125..84eb2082260 100644--- a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp+++ b/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp@@ -62,7 +62,10 @@ public:private:// For special config, stream executors must be set accordingly to ensure correct behavior.- void configure_stream_executors(ov::streams::Num numStreams, bool runInferencesSequentially);+ void configure_stream_executors(ov::streams::Num numStreams,+ bool runInferencesSequentially,+ bool useSharedExecutors,+ uint64_t sharedExecutorsId);Logger _logger;diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model.cppindex 78916c5c1a7..23a147d1a60 100644--- a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp@@ -69,8 +69,11 @@ std::shared_ptr<ov::IAsyncInferRequest> CompiledModel::create_infer_request() coconst std::shared_ptr<InferRequest>& inferRequest = _device->createInferRequest(shared_from_this(), localConfig);std::call_once(_streamExecutorsInitFlag, [this, &localConfig] {- const_cast<CompiledModel*>(this)->configure_stream_executors(localConfig.get<NUM_STREAMS>(),- localConfig.get<RUN_INFERENCES_SEQUENTIALLY>());+ const_cast<CompiledModel*>(this)->configure_stream_executors(+ localConfig.get<NUM_STREAMS>(),+ localConfig.get<RUN_INFERENCES_SEQUENTIALLY>(),+ localConfig.get<SHARED_COMMON_QUEUE>(),+ localConfig.get<SHARED_COMMON_QUEUE>() ? _graph->get_command_queue_desc().key() : 0);});return std::make_shared<AsyncInferRequest>(inferRequest,@@ -218,10 +221,25 @@ void CompiledModel::release_memory() {}}-void CompiledModel::configure_stream_executors(ov::streams::Num numStreams, bool runInferencesSequentially) {+void CompiledModel::configure_stream_executors(ov::streams::Num numStreams,+ bool runInferencesSequentially,+ bool useSharedExecutors,+ uint64_t sharedExecutorsId) {// In case of sequential execution of async requests for the same compiled model, the compiled model must use// dedicated executors with a single thread to ensure sequential execution of its async requests.if (runInferencesSequentially) {+ if (useSharedExecutors) {+ // In case of sequential execution with shared executors, use the global single-threaded executors+ // provided by the executor manager, so that async requests of all compiled models belonging to the same+ // shared group are also executed sequentially relative to each other.+ set_task_executor(ov::threading::executor_manager()->get_executor(+ std::string("Intel NPU plugin start inferences executor") + " " + std::to_string(sharedExecutorsId)));+ _resultExecutor = ov::threading::executor_manager()->get_executor(+ std::string("Intel NPU plugin wait inferences executor") + " " + std::to_string(sharedExecutorsId));++ return;+ }+set_task_executor(make_executor("Intel NPU plugin start inferences executor", 1));_resultExecutor = make_executor("Intel NPU plugin wait inferences executor", 1);diff --git a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cppindex 886613d5a48..3a0050eae85 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp@@ -153,11 +153,10 @@ void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {_config.get<COMPILER_TYPE>(),_config.get<DEVICE_ID>(),_config.get<PLATFORM>());- ov::AnyMap supportCheckArguments = {- {ov::intel_npu::compiler_type.name(), normalizedArguments.compilerType},- {ov::device::id.name(), normalizedArguments.deviceId},- {ov::intel_npu::platform.name(), normalizedArguments.platform},- };+ ov::AnyMap supportCheckArguments = properties;+ supportCheckArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;+ supportCheckArguments[ov::device::id.name()] = normalizedArguments.deviceId;+ supportCheckArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;for (auto&& value : properties) {const auto propertyDescriptorIt = _properties.find(value.first);@@ -585,18 +584,6 @@ void PluginPropertyManager::registerProperties() {registerConfigProperty(IMPORT_RAW_BLOB{}, false);registerConfigProperty(ALLOW_BYTECODE{}, false);registerConfigProperty(PROFILING_TYPE{}, false);- registerConfigProperty(SHARED_COMMON_QUEUE{}, false);-- // Special case: this property is always registered because it's supported by the implementation,- // but it's not visible in supported_properties if the driver doesn't support it.- registerConfigProperty(RUN_INFERENCES_SEQUENTIALLY{}, [this] {- if (_backend && _backend->getInitStructs()) {- if (_backend->getInitStructs()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1)) {- return true;- }- }- return false;- }());OPENVINO_SUPPRESS_DEPRECATED_STARTregisterConfigProperty(ENABLE_CPU_PINNING{}, false);@@ -770,6 +757,86 @@ void PluginPropertyManager::registerProperties() {});+ const auto hasRequiredCommandQueueVersion = [this] {+ return _backend && _backend->getInitStructs() &&+ _backend->getInitStructs()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1);+ };+ // Returns the value a property would have once the request is applied: the requested value when the caller+ // supplied one, otherwise the value currently stored in the config.+ const auto resolveRequestedBool = [](const ov::AnyMap& arguments,+ const std::string& propertyName,+ bool currentValue) {+ const auto argumentIt = arguments.find(propertyName);+ return argumentIt != arguments.end() ? argumentIt->second.as<bool>() : currentValue;+ };+ // Special case: this property is always registered because it's supported by the implementation, but it's not visible in supported_properties if the driver doesn't support it.+ register_property(ov::intel_npu::run_inferences_sequentially.name(), hasRequiredCommandQueueVersion(), ov::PropertyMutability::RW,+ [this, hasRequiredCommandQueueVersion, resolveRequestedBool](const ov::AnyMap& arguments) {+ if (!_config.hasOpt(ov::intel_npu::run_inferences_sequentially.name())) {+ return false;+ }+ // If SHARED_COMMON_QUEUE is not registered, RUN_INFERENCES_SEQUENTIALLY is considered supported.+ if (!_config.hasOpt(ov::intel_npu::shared_common_queue.name())) {+ return true;+ }++ // Disabling RUN_INFERENCES_SEQUENTIALLY is always allowed, whatever the SHARED_COMMON_QUEUE value is.+ if (!resolveRequestedBool(arguments,+ ov::intel_npu::run_inferences_sequentially.name(),+ _config.get<RUN_INFERENCES_SEQUENTIALLY>())) {+ return true;+ }++ const bool sharedCommonQueue = resolveRequestedBool(arguments,+ ov::intel_npu::shared_common_queue.name(),+ _config.get<SHARED_COMMON_QUEUE>());++ // Only the combination of both properties enabled needs the required command queue version.+ if (!sharedCommonQueue || hasRequiredCommandQueueVersion()) {+ return true;+ }+ return false;+ },+ [this](const ov::AnyMap&) {+ return _config.get<RUN_INFERENCES_SEQUENTIALLY>();+ },+ [this](const ov::Any& value) {+ _config.updateAny(ov::intel_npu::run_inferences_sequentially.name(), value);+ }+ );++ register_property(ov::intel_npu::shared_common_queue.name(), false, ov::PropertyMutability::RW,+ [this, resolveRequestedBool](const ov::AnyMap& arguments) {+ if (!_config.hasOpt(ov::intel_npu::shared_common_queue.name())) {+ return false;+ }+ // If RUN_INFERENCES_SEQUENTIALLY is not registered, SHARED_COMMON_QUEUE is considered supported.+ if (!_config.hasOpt(ov::intel_npu::run_inferences_sequentially.name())) {+ return true;+ }++ // Disabling SHARED_COMMON_QUEUE is always allowed, whatever the RUN_INFERENCES_SEQUENTIALLY value is.+ if (!resolveRequestedBool(arguments,+ ov::intel_npu::shared_common_queue.name(),+ _config.get<SHARED_COMMON_QUEUE>())) {+ return true;+ }++ const bool runInferencesSequentially = resolveRequestedBool(arguments,+ ov::intel_npu::run_inferences_sequentially.name(),+ _config.get<RUN_INFERENCES_SEQUENTIALLY>());++ // SHARED_COMMON_QUEUE is unsupported only when RUN_INFERENCES_SEQUENTIALLY is also enabled and that property is not public.+ return !runInferencesSequentially ||+ _properties.at(ov::intel_npu::run_inferences_sequentially.name()).isPublic;+ },+ [this](const ov::AnyMap&) {+ return _config.get<SHARED_COMMON_QUEUE>();+ },+ [this](const ov::Any& value) {+ _config.updateAny(ov::intel_npu::shared_common_queue.name(), value);+ }+ );register_property(ov::intel_npu::stepping.name(), false, ov::PropertyMutability::RW,[this](const ov::AnyMap&) {return _config.hasOpt(ov::intel_npu::stepping.name());diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cppindex dd8f441c31b..4752b32c498 100644--- a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp@@ -51,7 +51,7 @@ bool CommandQueueDesc::operator==(const CommandQueueDesc& other) const {return true;}bool CommandQueueDesc::owner_tag_required() const {- return (_options & ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC) != 0 || !_shared_common_queue;+ return !_shared_common_queue;}void CommandQueueDesc::update_key() {uint64_t hash = zero_hashing::kFnvOffsetBasis64;@@ -67,9 +67,7 @@ void CommandQueueDesc::update_key() {const bool use_owner_tag = owner_tag_required();if (use_owner_tag) {- OPENVINO_ASSERT(_owner_tag != nullptr,- "owner_tag must not be null when ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC is set or "- "shared_common_queue is disabled");+ OPENVINO_ASSERT(_owner_tag != nullptr, "owner_tag must not be null when shared_common_queue is disabled");hash = zero_hashing::hash_combine64(hash, std::hash<const void*>{}(_owner_tag));}diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cppindex 1ed6786ec00..b0a4518cef4 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp@@ -2,14 +2,16 @@// SPDX-License-Identifier: Apache-2.0//-#include <array>-#include <cstddef>-#include <exception>#include <gmock/gmock-matchers.h>#include <gmock/gmock.h>#include <gtest/gtest.h>++#include <array>+#include <cstddef>+#include <exception>#include <memory>#include <thread>+#include <vector>#include "behavior/ov_infer_request/inference.hpp"#include "common/npu_test_env_cfg.hpp"@@ -26,6 +28,7 @@#include "openvino/runtime/compiled_model.hpp"#include "openvino/runtime/core.hpp"#include "openvino/runtime/intel_npu/properties.hpp"+#include "openvino/runtime/threading/executor_manager.hpp"#include "shared_test_classes/base/ov_behavior_test_utils.hpp"using CompilationParams = std::tuple<std::string, // Device name@@ -123,6 +126,125 @@ public:return std::make_shared<Model>(res, params);}++ void setTilesIfSupported() {+ const auto supportedProperties =+ core->get_property(target_device, supported_properties.name()).as<std::vector<PropertyName>>();+ const bool tilesSupported =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::tiles.name();+ });++ if (tilesSupported) {+ configuration[ov::intel_npu::tiles.name()] = 2;+ }+ }++ bool isTurboSupported() {+ const auto supportedProperties =+ core->get_property(target_device, supported_properties.name()).as<std::vector<PropertyName>>();+ const bool turboSupported =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::turbo.name();+ });++ return turboSupported;+ }++ bool isRunInferencesSequentiallySupported() {+ const auto supportedProperties =+ core->get_property(target_device, supported_properties.name()).as<std::vector<PropertyName>>();+ const bool runInferencesSequentiallySupported =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::run_inferences_sequentially.name();+ });++ return runInferencesSequentiallySupported;+ }++ // Global executors are registered by the executor manager only when the compiled models are configured to share+ // their start/wait inference executors. Clearing them before the actual check makes the expected count independent+ // of the executors registered by the previously executed tests.+ static void resetGlobalExecutors() {+ ov::threading::executor_manager()->clear();+ }++ static size_t getGlobalExecutorsNumber() {+ return ov::threading::executor_manager()->get_executors_number();+ }++ // Builds one pipeline of chained compiled models for each given model priority. Since the model priority is part+ // of the command queue configuration, each pipeline ends up using its own command queue, thus its own pair of+ // global start/wait inference executors. Models belonging to the same pipeline share both the command queue and+ // the executors, so their inferences are executed sequentially relative to each other.+ void runSharedCommonQueuePipelines(const std::vector<ov::hint::Priority>& pipelinePriorities) {+ constexpr size_t modelsPerPipeline = 4;+ const auto shape = Shape{1, 64, 64, 256};+ const auto shapeSize = ov::shape_size(shape);+ const auto model = createModel(element::f32, shape, "N...");+ auto context = core->get_default_context(target_device);+ const size_t pipelineCount = pipelinePriorities.size();++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::shared_common_queue.name()] = true;++ std::vector<std::vector<ov::CompiledModel>> compiledModels(pipelineCount);+ std::vector<std::vector<ov::InferRequest>> inferenceRequests(pipelineCount);+ std::vector<std::vector<ov::Tensor>> outputTensors(pipelineCount);+ ov::Tensor inputTensor = context.create_host_tensor(ov::element::f32, shape);++ resetGlobalExecutors();++ for (size_t pipeline = 0; pipeline < pipelineCount; ++pipeline) {+ ov::AnyMap pipelineConfiguration = configuration;+ pipelineConfiguration[ov::hint::model_priority.name()] = pipelinePriorities[pipeline];++ for (size_t modelIndex = 0; modelIndex < modelsPerPipeline; ++modelIndex) {+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, pipelineConfiguration));+ compiledModels[pipeline].push_back(compiledModel);+ inferenceRequests[pipeline].push_back(compiledModel.create_infer_request());+ outputTensors[pipeline].push_back(context.create_host_tensor(ov::element::f32, shape));+ }+ }++ EXPECT_EQ(getGlobalExecutorsNumber(), 2 * pipelineCount)+ << "Each command queue configuration shall get its own pair of global start/wait inference executors";++ for (size_t run = 0; run < 10; ++run) {+ auto* inputData = reinterpret_cast<float*>(inputTensor.data());+ std::fill(inputData, inputData + shapeSize, static_cast<float>(run));++ for (size_t pipeline = 0; pipeline < pipelineCount; ++pipeline) {+ inferenceRequests[pipeline][0].set_input_tensor(inputTensor);+ inferenceRequests[pipeline][0].set_output_tensor(outputTensors[pipeline][0]);+ inferenceRequests[pipeline][0].start_async();++ for (size_t modelIndex = 1; modelIndex < modelsPerPipeline; ++modelIndex) {+ inferenceRequests[pipeline][modelIndex].set_input_tensor(outputTensors[pipeline][modelIndex - 1]);+ inferenceRequests[pipeline][modelIndex].set_output_tensor(outputTensors[pipeline][modelIndex]);+ inferenceRequests[pipeline][modelIndex].start_async();+ }+ }++ for (size_t pipeline = 0; pipeline < pipelineCount; ++pipeline) {+ inferenceRequests[pipeline][modelsPerPipeline - 1].wait();+ }++ for (size_t pipeline = 0; pipeline < pipelineCount; ++pipeline) {+ for (size_t modelIndex = 0; modelIndex < modelsPerPipeline; ++modelIndex) {+ const auto* outputData = reinterpret_cast<const float*>(outputTensors[pipeline][modelIndex].data());+ const auto expectedValue = static_cast<float>(run + modelIndex + 1);+ for (size_t elementIndex = 0; elementIndex < shapeSize; ++elementIndex) {+ ASSERT_NEAR(outputData[elementIndex], expectedValue, 1e-5)+ << "Run=" << run << " Pipeline=" << pipeline << " Model=" << modelIndex+ << " Expected=" << expectedValue << ", actual=" << outputData[elementIndex] << " for index "+ << elementIndex;+ }+ }+ }+ }+ }};using BooleanPrecisionCompilationParams = std::tuple<std::string, // Device name@@ -904,6 +1026,12 @@ TEST_P(BatchingRunTests, CheckTwoRunsInfer) {using RunSeqTests = InferRequestRunTests;TEST_P(RunSeqTests, CheckMultipleRunsSeq0) {+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }+ setTilesIfSupported();+auto shape = Shape{1, 64, 64, 256};auto shape_size = ov::shape_size(shape);auto model = createModel(element::f32, shape, "N...");@@ -913,7 +1041,8 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq0) {auto context = core->get_default_context(target_device);configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;++ resetGlobalExecutors();compiled_model = core->compile_model(model, target_device, configuration);const uint32_t inferences = 32;@@ -927,6 +1056,9 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq0) {output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);}+ EXPECT_EQ(getGlobalExecutorsNumber(), 0)+ << "The compiled model shall use dedicated executors when SHARED_COMMON_QUEUE is disabled";+inference_request[0].set_input_tensor(input_tensor);inference_request[0].set_output_tensor(output_tensor[0]);@@ -963,6 +1095,12 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq0) {}TEST_P(RunSeqTests, CheckMultipleRunsSeq1) {+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }+ setTilesIfSupported();+auto shape = Shape{1, 64, 64, 256};auto shape_size = ov::shape_size(shape);auto model = createModel(element::f32, shape, "N...");@@ -972,7 +1110,8 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq1) {auto context = core->get_default_context(target_device);configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;++ resetGlobalExecutors();compiled_model = core->compile_model(model, target_device, configuration);const int inferences = 32;@@ -987,6 +1126,9 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq1) {output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);}+ EXPECT_EQ(getGlobalExecutorsNumber(), 0)+ << "The compiled model shall use dedicated executors when SHARED_COMMON_QUEUE is disabled";+inference_request[inferences - 1].set_input_tensor(input_tensor);inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);@@ -1023,6 +1165,12 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq1) {}TEST_P(RunSeqTests, CheckMultipleRunsSeq2) {+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }+ setTilesIfSupported();+auto shape = Shape{1, 64, 64, 256};auto shape_size = ov::shape_size(shape);auto model = createModel(element::f32, shape, "N...");@@ -1032,7 +1180,8 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq2) {auto context = core->get_default_context(target_device);configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;++ resetGlobalExecutors();compiled_model = core->compile_model(model, target_device, configuration);const int inferences = 32;@@ -1047,6 +1196,9 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq2) {output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);}+ EXPECT_EQ(getGlobalExecutorsNumber(), 0)+ << "The compiled model shall use dedicated executors when SHARED_COMMON_QUEUE is disabled";+inference_request[inferences - 1].set_input_tensor(input_tensor);inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);@@ -1100,115 +1252,129 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq3) {ov::CompiledModel compiled_model;configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;++ resetGlobalExecutors();compiled_model = core->compile_model(model, target_device, configuration);ov::InferRequest inference_request;inference_request = compiled_model.create_infer_request();+ EXPECT_EQ(getGlobalExecutorsNumber(), 0)+ << "The compiled model shall use dedicated executors when SHARED_COMMON_QUEUE is disabled";+OV_EXPECT_THROW(inference_request.infer(),ov::Exception,HasSubstr("Only start async is supported when RUN_INFERENCES_SEQUENTIALLY is enabled!"));}TEST_P(RunSeqTests, CheckMultipleRunsSeq4) {- auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }+ setTilesIfSupported();ov::CompiledModel compiled_model;- bool isRunInferencesSequentially =- std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {- return property == intel_npu::run_inferences_sequentially.name();- });+ auto shape = Shape{1, 64, 64, 256};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");- if (isRunInferencesSequentially) {- auto shape = Shape{1, 64, 64, 256};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");+ auto context = core->get_default_context(target_device);- auto context = core->get_default_context(target_device);+ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);+ resetGlobalExecutors();+ compiled_model = core->compile_model(model, target_device, configuration);- const int inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;+ const int inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;- input_tensor = context.create_host_tensor(ov::element::f32, shape);+ input_tensor = context.create_host_tensor(ov::element::f32, shape);- for (int i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }+ for (int i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }- const int runs = 10;- for (int z = 0; z < runs; z++) {- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(z);- }+ EXPECT_EQ(getGlobalExecutorsNumber(), 0)+ << "The compiled model shall use dedicated executors when SHARED_COMMON_QUEUE is disabled";++ const int runs = 10;+ for (int z = 0; z < runs; z++) {+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(z);+ }- if (runs % 2) {- inference_request[inferences - 1].set_input_tensor(input_tensor);- inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);+ if (z % 2) {+ inference_request[inferences - 1].set_input_tensor(input_tensor);+ inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);- inference_request[inferences - 1].start_async(); // Adds '1' to each element+ inference_request[inferences - 1].start_async(); // Adds '1' to each element- for (int i = inferences - 2; i >= 0; i--) {- inference_request[i].set_input_tensor(output_tensor[i + 1]);- inference_request[i].set_output_tensor(output_tensor[i]);+ for (int i = inferences - 2; i >= 0; i--) {+ inference_request[i].set_input_tensor(output_tensor[i + 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);- inference_request[i].start_async(); // Adds '1' to each element- }+ inference_request[i].start_async(); // Adds '1' to each element+ }- inference_request[0].wait();+ inference_request[0].wait();- float expected_result = static_cast<float>(z) + 1.f;+ float expected_result = static_cast<float>(z) + 1.f;- for (int i = inferences - 1; i >= 0; i--) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;+ for (int i = inferences - 1; i >= 0; i--) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;}- } else {- inference_request[0].set_input_tensor(input_tensor);- inference_request[0].set_output_tensor(output_tensor[0]);+ expected_result++;+ }+ } else {+ inference_request[0].set_input_tensor(input_tensor);+ inference_request[0].set_output_tensor(output_tensor[0]);- inference_request[0].start_async(); // Adds '1' to each element+ inference_request[0].start_async(); // Adds '1' to each element- for (uint32_t i = 1; i < inferences; i++) {- inference_request[i].set_input_tensor(output_tensor[i - 1]);- inference_request[i].set_output_tensor(output_tensor[i]);+ for (uint32_t i = 1; i < inferences; i++) {+ inference_request[i].set_input_tensor(output_tensor[i - 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);- inference_request[i].start_async(); // Adds '1' to each element- }+ inference_request[i].start_async(); // Adds '1' to each element+ }- inference_request[inferences - 1].wait();+ inference_request[inferences - 1].wait();- float expected_result = static_cast<float>(z) + 1.f;+ float expected_result = static_cast<float>(z) + 1.f;- for (uint32_t i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;+ for (uint32_t i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;}+ expected_result++;}}}}TEST_P(RunSeqTests, CheckTurboWithMultipleRunsSeq) {- auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();+ bool turboSupported = isTurboSupported();+ if (!turboSupported) {+ GTEST_SKIP() << "Turbo is not supported by the current backend/driver.";+ }++ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }+ setTilesIfSupported();auto shape = Shape{1, 64, 64, 256};auto shape_size = ov::shape_size(shape);@@ -1220,7 +1386,8 @@ TEST_P(RunSeqTests, CheckTurboWithMultipleRunsSeq) {configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;configuration[intel_npu::turbo.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;++ resetGlobalExecutors();compiled_model = core->compile_model(model, target_device, configuration);const int inferences = 32;@@ -1235,6 +1402,9 @@ TEST_P(RunSeqTests, CheckTurboWithMultipleRunsSeq) {output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);}+ EXPECT_EQ(getGlobalExecutorsNumber(), 0)+ << "The compiled model shall use dedicated executors when SHARED_COMMON_QUEUE is disabled";+const int runs = 10;for (int z = 0; z < runs; z++) {auto* input_data = reinterpret_cast<float*>(input_tensor.data());@@ -1270,6 +1440,300 @@ TEST_P(RunSeqTests, CheckTurboWithMultipleRunsSeq) {}}+TEST_P(RunSeqTests, CheckMultipleCompiledModelsWithSharedCommonQueue) {+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }++ setTilesIfSupported();++ constexpr size_t modelCount = 8;+ const auto shape = Shape{1, 64, 64, 256};+ const auto shapeSize = ov::shape_size(shape);+ const auto model = createModel(element::f32, shape, "N...");+ auto context = core->get_default_context(target_device);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::shared_common_queue.name()] = true;++ std::array<ov::CompiledModel, modelCount> compiledModels;+ std::array<ov::InferRequest, modelCount> inferenceRequests;+ std::array<ov::Tensor, modelCount> outputTensors;+ ov::Tensor inputTensor = context.create_host_tensor(ov::element::f32, shape);++ resetGlobalExecutors();+ for (size_t modelIndex = 0; modelIndex < modelCount; ++modelIndex) {+ OV_ASSERT_NO_THROW(compiledModels[modelIndex] = core->compile_model(model, target_device, configuration));+ inferenceRequests[modelIndex] = compiledModels[modelIndex].create_infer_request();+ outputTensors[modelIndex] = context.create_host_tensor(ov::element::f32, shape);+ }++ // All compiled models use the same command queue configuration, therefore they shall share a single pair of+ // start/wait inference executors.+ EXPECT_EQ(getGlobalExecutorsNumber(), 2)+ << "All compiled models shall share the same pair of global start/wait inference executors";++ for (size_t run = 0; run < 10; ++run) {+ auto* inputData = reinterpret_cast<float*>(inputTensor.data());+ const auto inputValue = static_cast<float>(run);+ std::fill(inputData, inputData + shapeSize, inputValue);++ inferenceRequests[0].set_input_tensor(inputTensor);+ inferenceRequests[0].set_output_tensor(outputTensors[0]);+ inferenceRequests[0].start_async();++ for (size_t modelIndex = 1; modelIndex < modelCount; ++modelIndex) {+ inferenceRequests[modelIndex].set_input_tensor(outputTensors[modelIndex - 1]);+ inferenceRequests[modelIndex].set_output_tensor(outputTensors[modelIndex]);+ inferenceRequests[modelIndex].start_async();+ }++ inferenceRequests[modelCount - 1].wait();++ for (size_t modelIndex = 0; modelIndex < modelCount; ++modelIndex) {+ const auto* outputData = reinterpret_cast<const float*>(outputTensors[modelIndex].data());+ const auto expectedValue = static_cast<float>(run + modelIndex + 1);+ for (size_t elementIndex = 0; elementIndex < shapeSize; ++elementIndex) {+ ASSERT_NEAR(outputData[elementIndex], expectedValue, 1e-5)+ << "Run=" << run << " Model=" << modelIndex << " Expected=" << expectedValue+ << ", actual=" << outputData[elementIndex] << " for index " << elementIndex;+ }+ }+ }+}++TEST_P(RunSeqTests, CheckMultipleCompiledModelsWithSharedCommonQueueSetProperty) {+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }++ setTilesIfSupported();++ constexpr size_t modelCount = 8;+ const auto shape = Shape{1, 64, 64, 256};+ const auto shapeSize = ov::shape_size(shape);+ const auto model = createModel(element::f32, shape, "N...");+ auto context = core->get_default_context(target_device);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::shared_common_queue.name()] = true;++ core->set_property("NPU", configuration);++ std::array<ov::CompiledModel, modelCount> compiledModels;+ std::array<ov::InferRequest, modelCount> inferenceRequests;+ std::array<ov::Tensor, modelCount> outputTensors;+ ov::Tensor inputTensor = context.create_host_tensor(ov::element::f32, shape);++ resetGlobalExecutors();+ for (size_t modelIndex = 0; modelIndex < modelCount; ++modelIndex) {+ OV_ASSERT_NO_THROW(compiledModels[modelIndex] = core->compile_model(model, target_device));+ inferenceRequests[modelIndex] = compiledModels[modelIndex].create_infer_request();+ outputTensors[modelIndex] = context.create_host_tensor(ov::element::f32, shape);+ }++ // All compiled models use the same command queue configuration, therefore they shall share a single pair of+ // start/wait inference executors.+ EXPECT_EQ(getGlobalExecutorsNumber(), 2)+ << "All compiled models shall share the same pair of global start/wait inference executors";++ for (size_t run = 0; run < 10; ++run) {+ auto* inputData = reinterpret_cast<float*>(inputTensor.data());+ const auto inputValue = static_cast<float>(run);+ std::fill(inputData, inputData + shapeSize, inputValue);++ inferenceRequests[0].set_input_tensor(inputTensor);+ inferenceRequests[0].set_output_tensor(outputTensors[0]);+ inferenceRequests[0].start_async();++ for (size_t modelIndex = 1; modelIndex < modelCount; ++modelIndex) {+ inferenceRequests[modelIndex].set_input_tensor(outputTensors[modelIndex - 1]);+ inferenceRequests[modelIndex].set_output_tensor(outputTensors[modelIndex]);+ inferenceRequests[modelIndex].start_async();+ }++ inferenceRequests[modelCount - 1].wait();++ for (size_t modelIndex = 0; modelIndex < modelCount; ++modelIndex) {+ const auto* outputData = reinterpret_cast<const float*>(outputTensors[modelIndex].data());+ const auto expectedValue = static_cast<float>(run + modelIndex + 1);+ for (size_t elementIndex = 0; elementIndex < shapeSize; ++elementIndex) {+ ASSERT_NEAR(outputData[elementIndex], expectedValue, 1e-5)+ << "Run=" << run << " Model=" << modelIndex << " Expected=" << expectedValue+ << ", actual=" << outputData[elementIndex] << " for index " << elementIndex;+ }+ }+ }+}++TEST_P(RunSeqTests, CheckTwoPipelinesWithSharedCommonQueue) {+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }++ setTilesIfSupported();++ // Two different command queue configurations shall lead to four global executors.+ runSharedCommonQueuePipelines({ov::hint::Priority::LOW, ov::hint::Priority::HIGH});+}++TEST_P(RunSeqTests, CheckThreePipelinesWithSharedCommonQueue) {+ bool run_inferences_sequentially_supported = isRunInferencesSequentiallySupported();+ if (!run_inferences_sequentially_supported) {+ GTEST_SKIP() << "Run inferences sequentially is not supported on this device.";+ }++ setTilesIfSupported();++ // Three different command queue configurations shall lead to six global executors.+ runSharedCommonQueuePipelines({ov::hint::Priority::LOW, ov::hint::Priority::MEDIUM, ov::hint::Priority::HIGH});+}++TEST_P(RunSeqTests, CheckRunSeqWithSharedCommonQueue) {+ const ov::AnyMap configurationWithSharedQueue = {+ {ov::intel_npu::run_inferences_sequentially.name(), true},+ {ov::intel_npu::shared_common_queue.name(), true},+ };+ const bool commandQueueSupported =+ ::intel_npu::ZeroInitStructsHolder::getInstance()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1);++ {+ ov::Core testCore;+ static_cast<void>(testCore.get_property(target_device, ov::supported_properties)); // Initialize NPU plugin+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, configurationWithSharedQueue));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(testCore.set_property(target_device, configurationWithSharedQueue),+ ov::Exception,+ "Unsupported configuration key: NPU_RUN_INFERENCES_SEQUENTIALLY");+ }+ }++ {+ ov::Core testCore;+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.compile_model(ov_model, target_device, configurationWithSharedQueue));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(+ testCore.compile_model(ov_model, target_device, configurationWithSharedQueue),+ ov::Exception,+ "[ NOT_FOUND ] Option 'NPU_RUN_INFERENCES_SEQUENTIALLY' is not supported for current configuration");+ }+ }++ {+ ov::Core testCore;+ std::stringstream exportedModel;+ OV_ASSERT_NO_THROW(testCore.compile_model(ov_model, target_device).export_model(exportedModel));++ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.import_model(exportedModel, target_device, configurationWithSharedQueue));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(+ testCore.import_model(exportedModel, target_device, configurationWithSharedQueue),+ ov::Exception,+ "[ NOT_FOUND ] Option 'NPU_RUN_INFERENCES_SEQUENTIALLY' is not supported for current configuration");+ }+ }+}++TEST_P(RunSeqTests, CheckSharedCommonQueueAfterRunSeqSetProperty) {+ const ov::AnyMap runSeqConfiguration = {{ov::intel_npu::run_inferences_sequentially.name(), true}};+ const ov::AnyMap sharedQueueConfiguration = {{ov::intel_npu::shared_common_queue.name(), true}};+ const bool commandQueueSupported =+ ::intel_npu::ZeroInitStructsHolder::getInstance()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1);++ {+ ov::Core testCore;+ static_cast<void>(testCore.get_property(target_device, ov::supported_properties)); // Initialize NPU plugin+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, runSeqConfiguration));+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, sharedQueueConfiguration));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(testCore.set_property(target_device, sharedQueueConfiguration),+ ov::Exception,+ ov::intel_npu::shared_common_queue.name());+ }+ }++ {+ ov::Core testCore;+ static_cast<void>(testCore.get_property(target_device, ov::supported_properties)); // Initialize NPU plugin+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, runSeqConfiguration));+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.compile_model(ov_model, target_device, sharedQueueConfiguration));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(testCore.compile_model(ov_model, target_device, sharedQueueConfiguration),+ ov::Exception,+ ov::intel_npu::shared_common_queue.name());+ }+ }++ {+ ov::Core testCore;+ std::stringstream exportedModel;+ OV_ASSERT_NO_THROW(testCore.compile_model(ov_model, target_device).export_model(exportedModel));+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, runSeqConfiguration));+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.import_model(exportedModel, target_device, sharedQueueConfiguration));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(testCore.import_model(exportedModel, target_device, sharedQueueConfiguration),+ ov::Exception,+ ov::intel_npu::shared_common_queue.name());+ }+ }+}++TEST_P(RunSeqTests, CheckRunSeqAfterSharedCommonQueueSetProperty) {+ const ov::AnyMap sharedQueueConfiguration = {{ov::intel_npu::shared_common_queue.name(), true}};+ const ov::AnyMap runSeqConfiguration = {{ov::intel_npu::run_inferences_sequentially.name(), true}};+ const bool commandQueueSupported =+ ::intel_npu::ZeroInitStructsHolder::getInstance()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1);++ {+ ov::Core testCore;+ static_cast<void>(testCore.get_property(target_device, ov::supported_properties)); // Initialize NPU plugin+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, sharedQueueConfiguration));+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, runSeqConfiguration));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(testCore.set_property(target_device, runSeqConfiguration),+ ov::Exception,+ ov::intel_npu::run_inferences_sequentially.name());+ }+ }++ {+ ov::Core testCore;+ static_cast<void>(testCore.get_property(target_device, ov::supported_properties)); // Initialize NPU plugin+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, sharedQueueConfiguration));+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.compile_model(ov_model, target_device, runSeqConfiguration));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(testCore.compile_model(ov_model, target_device, runSeqConfiguration),+ ov::Exception,+ ov::intel_npu::run_inferences_sequentially.name());+ }+ }++ {+ ov::Core testCore;+ std::stringstream exportedModel;+ OV_ASSERT_NO_THROW(testCore.compile_model(ov_model, target_device).export_model(exportedModel));+ OV_ASSERT_NO_THROW(testCore.set_property(target_device, sharedQueueConfiguration));+ if (commandQueueSupported) {+ OV_ASSERT_NO_THROW(testCore.import_model(exportedModel, target_device, runSeqConfiguration));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(testCore.import_model(exportedModel, target_device, runSeqConfiguration),+ ov::Exception,+ ov::intel_npu::run_inferences_sequentially.name());+ }+ }+}+using BatchingRunSeqTests = InferRequestRunTests;TEST_P(BatchingRunSeqTests, CheckMultipleBatchingRunsSeq) {@@ -1283,6 +1747,8 @@ TEST_P(BatchingRunSeqTests, CheckMultipleBatchingRunsSeq) {configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;configuration[ov::intel_npu::tiles.name()] = 2;++ resetGlobalExecutors();compiled_model = core->compile_model(model, target_device, configuration);const uint32_t inferences = 32;@@ -1296,6 +1762,9 @@ TEST_P(BatchingRunSeqTests, CheckMultipleBatchingRunsSeq) {output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);}+ EXPECT_EQ(getGlobalExecutorsNumber(), 0)+ << "The compiled model shall use dedicated executors when SHARED_COMMON_QUEUE is disabled";+inference_request[0].set_input_tensor(input_tensor);inference_request[0].set_output_tensor(output_tensor[0]);@@ -2923,7 +3392,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,::testing::ValuesIn(configsInferRequestRunTests)),InferRequestRunTests::getTestCaseName);-INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,+INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,RunSeqTests,::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),::testing::ValuesIn(configsInferRequestRunTests)),diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cppindex ec058e11117..bece3cc5ae8 100644--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp@@ -837,6 +837,60 @@ TEST_P(ExpectLoadingCompilerPropertySupported, ExpectCompilerPropertyIsSupportedASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);}+using SharedCommonQueueCompatibilityTests = PropertiesManagerTests;++TEST_P(SharedCommonQueueCompatibilityTests, BothDisabledIsAlwaysSupported) {+ OV_ASSERT_NO_THROW(propertiesManager->setProperty(+ {{ov::intel_npu::run_inferences_sequentially(false)}, {ov::intel_npu::shared_common_queue(false)}}));++ ASSERT_FALSE(propertiesManager->getProperty(ov::intel_npu::run_inferences_sequentially.name()).as<bool>());+ ASSERT_FALSE(propertiesManager->getProperty(ov::intel_npu::shared_common_queue.name()).as<bool>());+}++TEST_P(SharedCommonQueueCompatibilityTests, SharedCommonQueueEnabledWithSequentialInferencesDisabledIsSupported) {+ OV_ASSERT_NO_THROW(propertiesManager->setProperty(+ {{ov::intel_npu::run_inferences_sequentially(false)}, {ov::intel_npu::shared_common_queue(true)}}));++ ASSERT_FALSE(propertiesManager->getProperty(ov::intel_npu::run_inferences_sequentially.name()).as<bool>());+ ASSERT_TRUE(propertiesManager->getProperty(ov::intel_npu::shared_common_queue.name()).as<bool>());+}++TEST_P(SharedCommonQueueCompatibilityTests, SequentialInferencesEnabledWithSharedCommonQueueDisabledIsSupported) {+ OV_ASSERT_NO_THROW(propertiesManager->setProperty(+ {{ov::intel_npu::run_inferences_sequentially(true)}, {ov::intel_npu::shared_common_queue(false)}}));++ ASSERT_TRUE(propertiesManager->getProperty(ov::intel_npu::run_inferences_sequentially.name()).as<bool>());+ ASSERT_FALSE(propertiesManager->getProperty(ov::intel_npu::shared_common_queue.name()).as<bool>());+}++TEST_P(SharedCommonQueueCompatibilityTests, BothEnabledDependsOnCommandQueueVersion) {+ const ov::AnyMap bothEnabled = {{ov::intel_npu::run_inferences_sequentially(true)},+ {ov::intel_npu::shared_common_queue(true)}};++ // Ask the properties manager instead of re-deriving the driver requirement here: RUN_INFERENCES_SEQUENTIALLY is+ // reported as supported only when the driver provides the required command queue version.+ if (propertiesManager->isPropertySupported(ov::intel_npu::run_inferences_sequentially.name())) {+ OV_ASSERT_NO_THROW(propertiesManager->setProperty(bothEnabled));+ ASSERT_TRUE(propertiesManager->getProperty(ov::intel_npu::run_inferences_sequentially.name()).as<bool>());+ ASSERT_TRUE(propertiesManager->getProperty(ov::intel_npu::shared_common_queue.name()).as<bool>());+ } else {+ OV_EXPECT_THROW(propertiesManager->setProperty(bothEnabled),+ ov::Exception,+ HasSubstr("Unsupported configuration key"));+ }+}++// A single-property update must be judged on its own requested value: disabling one of them while the other one is+// already enabled in the config is a no-op with respect to the driver requirement.+TEST_P(SharedCommonQueueCompatibilityTests, DisablingOnePropertyWhileTheOtherIsEnabledIsSupported) {+ OV_ASSERT_NO_THROW(propertiesManager->setProperty({{ov::intel_npu::shared_common_queue(true)}}));+ OV_ASSERT_NO_THROW(propertiesManager->setProperty({{ov::intel_npu::run_inferences_sequentially(false)}}));++ OV_ASSERT_NO_THROW(propertiesManager->setProperty({{ov::intel_npu::shared_common_queue(false)}}));+ OV_ASSERT_NO_THROW(propertiesManager->setProperty({{ov::intel_npu::run_inferences_sequentially(true)}}));+ OV_ASSERT_NO_THROW(propertiesManager->setProperty({{ov::intel_npu::shared_common_queue(false)}}));+}+} // namespace behavior} // namespace test} // namespace ov@@ -866,6 +920,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,::testing::ValuesIn(supported_compiler_configs)),PropertiesManagerTests::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,+ SharedCommonQueueCompatibilityTests,+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),+ ::testing::Values(std::string{})),+ PropertiesManagerTests::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,CompileLogLevelPropertyTests,::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),diff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cppindex d8bf8bee25c..3e9f5484a7f 100644--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp@@ -295,7 +295,7 @@ TEST_P(ZeroCmdQueuePoolTests, AllCommandQueueOptionsCombinations) {<< "The test must cover and create all command queue combinations exactly once";}-TEST_P(ZeroCmdQueuePoolTests, CreateDifferentCommandQueueForEachDeviceSyncOption) {+TEST_P(ZeroCmdQueuePoolTests, OwnerTagAffectsPoolingOnlyWhenSharedCommonQueueIsDisabled) {if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1)) {GTEST_SKIP()<< "ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC command queue option is not supported by the current driver.\n";@@ -304,7 +304,8 @@ TEST_P(ZeroCmdQueuePoolTests, CreateDifferentCommandQueueForEachDeviceSyncOptionint owner_a = 1;int owner_b = 2;- // With DEVICE_SYNC enabled, owner_tag participates in the pool key.+ // With shared_common_queue enabled, owner_tag does not participate in the pool key,+ // including when DEVICE_SYNC is enabled.::intel_npu::CommandQueueDesc device_sync_desc_a{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,ZE_WORKLOAD_TYPE_DEFAULT,ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,@@ -328,8 +329,8 @@ TEST_P(ZeroCmdQueuePoolTests, CreateDifferentCommandQueueForEachDeviceSyncOption::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, device_sync_desc_b);EXPECT_NE(queue_device_sync_b, nullptr);- EXPECT_NE(queue_device_sync_a_1.get(), queue_device_sync_b.get())- << "Different DEVICE_SYNC owner_tag pointers should create different pooled queues";+ EXPECT_EQ(queue_device_sync_a_1.get(), queue_device_sync_b.get())+ << "owner_tag should be ignored when shared_common_queue is enabled";// Without DEVICE_SYNC, owner_tag must not affect pooling.::intel_npu::CommandQueueDesc no_device_sync_desc_a{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,@@ -350,6 +351,27 @@ TEST_P(ZeroCmdQueuePoolTests, CreateDifferentCommandQueueForEachDeviceSyncOptionEXPECT_NE(queue_no_device_sync_a, nullptr);EXPECT_EQ(queue_no_device_sync_a.get(), queue_no_device_sync_b.get())<< "owner_tag should be ignored when DEVICE_SYNC option is not set";++ // With shared_common_queue disabled, owner_tag differentiates pooled queues.+ ::intel_npu::CommandQueueDesc non_shared_desc_a{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_DEFAULT,+ 0,+ &owner_a,+ false};+ ::intel_npu::CommandQueueDesc non_shared_desc_b{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_DEFAULT,+ 0,+ &owner_b,+ false};+ auto queue_non_shared_a =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, non_shared_desc_a);+ auto queue_non_shared_b =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, non_shared_desc_b);++ EXPECT_NE(queue_non_shared_a, nullptr);+ EXPECT_NE(queue_non_shared_b, nullptr);+ EXPECT_NE(queue_non_shared_a.get(), queue_non_shared_b.get())+ << "Different owner_tag pointers should create different queues when shared_common_queue is disabled";}TEST_P(ZeroCmdQueuePoolTests, MultiThreadingTest) {