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] Adding support for in-order execution (#30333)
Bogdan Pereanu4e5ac62f51f1
diff --git a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rstindex 823f6987af7..2ef2b323699 100644--- a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst+++ b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst@@ -150,6 +150,7 @@ offer a limited set of supported OpenVINO features.ov::intel_npu::max_tilesov::intel_npu::bypass_umd_cachingov::intel_npu::defer_weights_load+ ov::intel_npu::run_inferences_sequentially.. tab-item:: Read-only propertiesdiff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cppindex c8a63e92597..b1dc44d6610 100644--- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp+++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp@@ -340,4 +340,5 @@ void regmodule_properties(py::module m) {wrap_property_RW(m_intel_npu, ov::intel_npu::defer_weights_load, "defer_weights_load");wrap_property_RW(m_intel_npu, ov::intel_npu::compiler_dynamic_quantization, "compiler_dynamic_quantization");wrap_property_RW(m_intel_npu, ov::intel_npu::qdq_optimization, "qdq_optimization");+ wrap_property_RW(m_intel_npu, ov::intel_npu::run_inferences_sequentially, "run_inferences_sequentially");}diff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.pyindex fa9b99dc0ca..29341b0ac9e 100644--- a/src/bindings/python/tests/test_runtime/test_properties.py+++ b/src/bindings/python/tests/test_runtime/test_properties.py@@ -457,6 +457,11 @@ def test_properties_ro(ov_property_ro, expected_value):"NPU_COMPILER_DYNAMIC_QUANTIZATION",((True, True),),),+ (+ intel_npu.run_inferences_sequentially,+ "NPU_RUN_INFERENCES_SEQUENTIALLY",+ ((True, True),),+ ),],)def test_properties_rw(ov_property_rw, expected_value, test_values):diff --git a/src/inference/include/openvino/runtime/intel_npu/properties.hpp b/src/inference/include/openvino/runtime/intel_npu/properties.hppindex 4ecdc9644d6..5deabd6ba61 100644--- a/src/inference/include/openvino/runtime/intel_npu/properties.hpp+++ b/src/inference/include/openvino/runtime/intel_npu/properties.hpp@@ -127,5 +127,14 @@ static constexpr ov::Property<bool> bypass_umd_caching{"NPU_BYPASS_UMD_CACHING"}*/static constexpr ov::Property<bool> defer_weights_load{"NPU_DEFER_WEIGHTS_LOAD"};+/**+ * @brief [Only for NPU Plugin]+ * Type: boolean, default is false.+ * This option allows running inferences in async mode sequentially in the order in which they are started to optimize+ * host scheduling.+ * @ingroup ov_runtime_npu_prop_cpp_api+ */+static constexpr ov::Property<bool> run_inferences_sequentially{"NPU_RUN_INFERENCES_SEQUENTIALLY"};+} // namespace intel_npu} // namespace ovdiff --git a/src/plugins/intel_npu/README.md b/src/plugins/intel_npu/README.mdindex a7c636c12cf..86f95c63abf 100644--- a/src/plugins/intel_npu/README.md+++ b/src/plugins/intel_npu/README.md@@ -180,6 +180,7 @@ The following properties are supported:| `ov::intel_npu::max_tiles`/</br>`NPU_MAX_TILES` | RW | Maximum number of tiles supported by the device we compile for. Can be set for offline compilation. If not set, it will be populated by driver.| `[0-]` | `[1-6] depends on npu platform` || `ov::intel_npu::bypass_umd_caching`/</br>`NPU_BYPASS_UMD_CACHING` | RW | Bypass the caching of compiled models in UMD. | `YES`/ `NO`| `NO` || `ov::intel_npu::defer_weights_load`/</br>`NPU_DEFER_WEIGHTS_LOAD` | RW | Delay loading the weights until inference is created. | `YES`/ `NO`| `NO` |+| `ov::intel_npu::run_inferences_sequentially`/</br>`NPU_RUN_INFERENCES_SEQUENTIALLY` | RW | Run inferences in async mode sequentially in the order in which they are started to optimize host scheduling. | `YES`/ `NO`| `NO` | ### Performance Hint: Default Number of DPU Groups / DMA Enginesdiff --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.hppindex 878042925ca..835f73c9558 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@@ -354,15 +354,6 @@ static constexpr ov::Property<std::string, ov::PropertyMutability::RO> backend_n*/static constexpr ov::Property<std::string> backend_compilation_params{"NPU_BACKEND_COMPILATION_PARAMS"};-/**- * @brief [Only for NPU Plugin]- * Type: boolean, default is false.- * This option allows to run inferences sequentially, in the order in which they were created- * @note Experimental property, for now it only works in very specific scenarios. We need driver updates before we can- * implement a robust solution for in-order execution- */-static constexpr ov::Property<bool> run_inferences_sequentially{"NPU_RUN_INFERENCES_SEQUENTIALLY"};-/*** @brief [Only for NPU Plugin]* Type: boolean, default is false.diff --git a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hppindex 4a53dcc96cf..21769b691f7 100644--- a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp@@ -35,6 +35,7 @@ public:std::vector<ov::ProfilingInfo> get_profiling_info() const;protected:+ std::shared_ptr<ZeroInitStructsHolder> _init_structs;std::shared_ptr<IGraph> _graph;const Config _config;const uint32_t _id;diff --git a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cppindex 5b6dde6a87a..bbd1c844e25 100644--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp@@ -22,7 +22,8 @@ Pipeline::Pipeline(const Config& config,const std::shared_ptr<IGraph>& graph,const std::vector<std::vector<std::shared_ptr<ov::ITensor>>>& input_tensors,const std::vector<std::shared_ptr<ov::ITensor>>& output_tensors)- : _graph(graph),+ : _init_structs(init_structs),+ _graph(graph),_config(config),_id(_graph->get_unique_id()),_number_of_command_lists(_graph->get_batch_size().has_value() ? *_graph->get_batch_size() : 1),@@ -30,13 +31,14 @@ Pipeline::Pipeline(const Config& config,OV_ITT_SCOPED_TASK(itt::domains::LevelZeroBackend, "Zero_infer_request::Pipeline::Pipeline");_logger.debug("Pipeline - initialize started");- OPENVINO_ASSERT(_sync_output_with_fences || !_config.get<RUN_INFERENCES_SEQUENTIALLY>(),+ OPENVINO_ASSERT(_sync_output_with_fences || !_config.get<RUN_INFERENCES_SEQUENTIALLY>() ||+ _init_structs->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1),"In-order execution doesn't work in case synchronization of the inferences is done using events");if (_config.has<PERF_COUNT>() && _config.get<PERF_COUNT>()) {auto profiling_pool =- std::make_shared<zeroProfiling::ProfilingPool>(init_structs, _graph, zeroProfiling::POOL_SIZE);- _profiling_query = std::make_unique<zeroProfiling::ProfilingQuery>(init_structs, 0);+ std::make_shared<zeroProfiling::ProfilingPool>(_init_structs, _graph, zeroProfiling::POOL_SIZE);+ _profiling_query = std::make_unique<zeroProfiling::ProfilingQuery>(_init_structs, 0);if (profiling_pool->create()) {_profiling_query->create(profiling_pool);@@ -44,14 +46,16 @@ Pipeline::Pipeline(const Config& config,if (_config.get<PROFILING_TYPE>() == ov::intel_npu::ProfilingType::INFER) {_logger.debug("ZeroInferRequest::ZeroInferRequest - profiling type == ov::intel_npu::ProfilingType::INFER");- _npu_profiling = std::make_shared<zeroProfiling::NpuInferProfiling>(init_structs, _config.get<LOG_LEVEL>());+ _npu_profiling =+ std::make_shared<zeroProfiling::NpuInferProfiling>(_init_structs, _config.get<LOG_LEVEL>());}}- if (!_sync_output_with_fences || _config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (!_sync_output_with_fences || (_init_structs->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1) &&+ _config.get<RUN_INFERENCES_SEQUENTIALLY>())) {_event_pool =- std::make_shared<EventPool>(init_structs->getDevice(),- init_structs->getContext(),+ std::make_shared<EventPool>(_init_structs->getDevice(),+ _init_structs->getContext(),_number_of_command_lists ? static_cast<uint32_t>(_number_of_command_lists) : 1);_events.reserve(_number_of_command_lists);@@ -63,7 +67,7 @@ Pipeline::Pipeline(const Config& config,_command_lists.reserve(_number_of_command_lists);for (size_t i = 0; i < _number_of_command_lists; i++) {_command_lists.emplace_back(- std::make_unique<CommandList>(init_structs, _graph->get_command_queue_group_ordinal()));+ std::make_unique<CommandList>(_init_structs, _graph->get_command_queue_group_ordinal()));}if (_sync_output_with_fences) {@@ -125,7 +129,8 @@ Pipeline::Pipeline(const Config& config,++io_index;}- if (_config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (_init_structs->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1) &&+ _config.get<RUN_INFERENCES_SEQUENTIALLY>()) {if (_graph->get_last_submitted_event(i)) {_graph->get_last_submitted_event(i)->AppendWaitOnEvent(*_command_lists.at(i));}@@ -146,7 +151,8 @@ Pipeline::Pipeline(const Config& config,_command_lists.at(i)->appendNpuTimestamp(reinterpret_cast<uint64_t*>(_npu_profiling->npu_ts_infer_end));}- if (_config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (_init_structs->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1) &&+ _config.get<RUN_INFERENCES_SEQUENTIALLY>()) {if (_graph->get_last_submitted_event(i)) {_graph->get_last_submitted_event(i)->AppendEventReset(*_command_lists.at(i));}@@ -167,7 +173,8 @@ Pipeline::Pipeline(const Config& config,void Pipeline::push() {_logger.debug("Pipeline - push() started");- if (_config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (_init_structs->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1) &&+ _config.get<RUN_INFERENCES_SEQUENTIALLY>()) {if (_id) {auto previousIndex = _graph->get_last_submitted_id();diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cppindex 630f0b5cb9e..fc2fe028af8 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp@@ -102,15 +102,24 @@ void DriverGraph::initialize(const Config& config) {zeroUtils::findCommandQueueGroupOrdinal(_zeroInitStruct->getDevice(),ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);- bool turbo = false;- if (config.has<TURBO>()) {- turbo = config.get<TURBO>();+ uint32_t command_queue_options = 0;++ if (config.has<TURBO>() && config.get<TURBO>()) {+ if (_zeroInitStruct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {+ OPENVINO_THROW("Turbo is not supported by the current driver");+ }+ command_queue_options = command_queue_options | 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>()) {+ command_queue_options = command_queue_options | ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC;}_command_queue = std::make_shared<CommandQueue>(_zeroInitStruct,zeroUtils::toZeQueuePriority(config.get<MODEL_PRIORITY>()),_command_queue_group_ordinal,- turbo);+ command_queue_options);if (config.has<WORKLOAD_TYPE>()) {set_workload_type(config.get<WORKLOAD_TYPE>());@@ -127,7 +136,8 @@ void DriverGraph::initialize(const Config& config) {_batch_size = get_batch_size(_metadata);- if (config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (_zeroInitStruct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1) &&+ config.get<RUN_INFERENCES_SEQUENTIALLY>()) {auto number_of_command_lists = _batch_size.has_value() ? *_batch_size : 1;_last_submitted_event.resize(number_of_command_lists);diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cppindex a997e4e03e7..56139f6a4c6 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp@@ -102,15 +102,24 @@ void PluginGraph::initialize(const Config& config) {zeroUtils::findCommandQueueGroupOrdinal(_zeroInitStruct->getDevice(),ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);- bool turbo = false;- if (config.has<TURBO>()) {- turbo = config.get<TURBO>();+ uint32_t command_queue_options = 0;++ if (config.has<TURBO>() && config.get<TURBO>()) {+ if (_zeroInitStruct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {+ OPENVINO_THROW("Turbo is not supported by the current driver");+ }+ command_queue_options = command_queue_options | 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>()) {+ command_queue_options = command_queue_options | ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC;}_command_queue = std::make_shared<CommandQueue>(_zeroInitStruct,zeroUtils::toZeQueuePriority(config.get<MODEL_PRIORITY>()),_command_queue_group_ordinal,- turbo);+ command_queue_options);if (config.has<WORKLOAD_TYPE>()) {set_workload_type(config.get<WORKLOAD_TYPE>());@@ -120,7 +129,8 @@ void PluginGraph::initialize(const Config& config) {_batch_size = get_batch_size(_metadata);- if (config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (_zeroInitStruct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1) &&+ config.get<RUN_INFERENCES_SEQUENTIALLY>()) {auto number_of_command_lists = _batch_size.has_value() ? *_batch_size : 1;_last_submitted_event.resize(number_of_command_lists);diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cppindex 60925b405ba..a1229f209af 100644--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp@@ -297,7 +297,6 @@ void Properties::registerProperties() {TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::turbo, TURBO);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::bypass_umd_caching, BYPASS_UMD_CACHING);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::defer_weights_load, DEFER_WEIGHTS_LOAD);- TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::compiler_dynamic_quantization, COMPILER_DYNAMIC_QUANTIZATION);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::qdq_optimization, QDQ_OPTIMIZATION);TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::disable_version_check, DISABLE_VERSION_CHECK);@@ -327,6 +326,15 @@ void Properties::registerProperties() {return config.get<MAX_TILES>();}});++ TRY_REGISTER_VARPUB_PROPERTY(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY, [&] {+ if (_backend && _backend->getInitStructs()) {+ if (_backend->getInitStructs()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1)) {+ return true;+ }+ }+ return false;+ }());} else if (_pType == PropertiesType::COMPILED_MODEL) {// These properties require different handling in plugin vs compiled_modelTRY_REGISTER_CUSTOM_PROPERTY(ov::workload_type,@@ -337,6 +345,7 @@ void Properties::registerProperties() {return config.get<WORKLOAD_TYPE>();});// compiled-model only+ TRY_REGISTER_VARPUB_PROPERTY(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY, true);TRY_REGISTER_SIMPLE_PROPERTY(ov::loaded_from_cache, LOADED_FROM_CACHE);}diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hppindex a9a5efc1cf6..d01c24a42fa 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hpp@@ -14,7 +14,7 @@/*** @brief Last version of the Command Queue functions used within plugin*/-using ze_command_queue_npu_dditable_ext_last_t = ze_command_queue_npu_dditable_ext_1_0_t;+using ze_command_queue_npu_dditable_ext_last_t = ze_command_queue_npu_dditable_ext_t;/*** @brief Last version of the Graph Profiling functions used within plugin*/diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hppindex 0faa5c24a17..0a51287c241 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp@@ -120,8 +120,8 @@ public:CommandQueue() = delete;CommandQueue(const std::shared_ptr<ZeroInitStructsHolder>& init_structs,const ze_command_queue_priority_t& priority,- const uint32_t& group_ordinal,- bool turbo = false);+ const uint32_t group_ordinal,+ const uint32_t command_queue_options = 0);CommandQueue(const CommandQueue&) = delete;CommandQueue(CommandQueue&&) = delete;CommandQueue& operator=(const CommandQueue&) = delete;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 cb3d83a4147..786cc5a07ca 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@@ -149,23 +149,36 @@ void CommandList::updateMutableCommandList(uint32_t arg_index, const void* arg_vCommandQueue::CommandQueue(const std::shared_ptr<ZeroInitStructsHolder>& init_structs,const ze_command_queue_priority_t& priority,- const uint32_t& group_ordinal,- bool turbo)+ const uint32_t group_ordinal,+ const uint32_t command_queue_options): _init_structs(init_structs),_log("CommandQueue", Logger::global().level()) {ze_command_queue_desc_t queue_desc ={ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC, nullptr, group_ordinal, 0, 0, ZE_COMMAND_QUEUE_MODE_DEFAULT, priority};- ze_command_queue_desc_npu_ext_t turbo_cfg = {};+ if (command_queue_options) {+ if (_init_structs->getCommandQueueDdiTable().version() == ZE_MAKE_VERSION(1, 0)) {+ ze_command_queue_desc_npu_ext_t turbo_cfg = {};- if (turbo) {- if (_init_structs->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 0)) {turbo_cfg.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC_NPU_EXT;- turbo_cfg.turbo = turbo;+ turbo_cfg.turbo = command_queue_options & ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;queue_desc.pNext = &turbo_cfg;- } else {- OPENVINO_THROW("Turbo is not supported by the current driver");++ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeCommandQueueCreate",+ zeCommandQueueCreate(_init_structs->getContext(), _init_structs->getDevice(), &queue_desc, &_handle));+ } else if (_init_structs->getCommandQueueDdiTable().version() > ZE_MAKE_VERSION(1, 0)) {+ ze_command_queue_desc_npu_ext_2_t command_queue_desc = {};++ command_queue_desc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC_NPU_EXT_2;+ command_queue_desc.options = command_queue_options;++ queue_desc.pNext = &command_queue_desc;++ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeCommandQueueCreate",+ zeCommandQueueCreate(_init_structs->getContext(), _init_structs->getDevice(), &queue_desc, &_handle));}}diff --git a/src/plugins/intel_npu/tests/functional/behavior/infer_request_run.hpp b/src/plugins/intel_npu/tests/functional/behavior/infer_request_run.hppindex ab53a442c16..7cbb5f297de 100644--- a/src/plugins/intel_npu/tests/functional/behavior/infer_request_run.hpp+++ b/src/plugins/intel_npu/tests/functional/behavior/infer_request_run.hpp@@ -19,6 +19,7 @@#include "common/utils.hpp"#include "functional_test_utils/ov_plugin_cache.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"#include "openvino/core/any.hpp"#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"@@ -793,15 +794,31 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq2) {inference_request[0].wait();- try {+ auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();++ bool isRunInferencesSequentially =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::run_inferences_sequentially.name();+ });++ if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getCommandQueueDdiTable().version() >=+ ZE_MAKE_VERSION(1, 1)) {+ ASSERT_TRUE(isRunInferencesSequentially);+inference_request[5].start_async();inference_request[5].wait();- } catch (const std::exception& ex) {- ASSERT_FALSE(false) << ex.what();- return;- }+ } else {+ ASSERT_TRUE(!isRunInferencesSequentially);+ try {+ inference_request[5].start_async();+ inference_request[5].wait();+ } catch (const std::exception& ex) {+ ASSERT_FALSE(false) << ex.what();+ return;+ }- ASSERT_FALSE(true) << "Exception is expected but it didn't throw any exception!";+ ASSERT_FALSE(true) << "Exception is expected but it didn't throw any exception!";+ }}TEST_P(RunSeqTests, CheckMultipleRunsSeq3) {@@ -819,6 +836,162 @@ TEST_P(RunSeqTests, CheckMultipleRunsSeq3) {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 isRunInferencesSequentially =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::run_inferences_sequentially.name();+ });++ 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);++ 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);++ 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);++ 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);+ }++ if (runs % 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++ 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[0].wait();++ 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) {+ EXPECT_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++;+ }+ } 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++ 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[inferences - 1].wait();++ 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) {+ EXPECT_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>>();++ 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);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[intel_npu::turbo.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ 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;++ 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);+ }++ 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);+ }++ 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++ 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[0].wait();++ 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) {+ EXPECT_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++;+ }+ }+}+using BatchingRunSeqTests = InferRequestRunTests;TEST_P(BatchingRunSeqTests, CheckMultipleBatchingRunsSeq) {diff --git a/src/plugins/intel_npu/thirdparty/level-zero-ext b/src/plugins/intel_npu/thirdparty/level-zero-extindex 24108f3d688..965e6f46980 160000--- a/src/plugins/intel_npu/thirdparty/level-zero-ext+++ b/src/plugins/intel_npu/thirdparty/level-zero-ext@@ -1 +1 @@-Subproject commit 24108f3d6889b2d878896f0f97ec793d36fe800f+Subproject commit 965e6f469809bed2f6a2f9066a2529b491cb11d9