Skip to content

Commit 3d614db

Browse files
[NPU] Refactor NPU property handling into owner-specific property managers (#36166)
### Details: Refactor NPU property handling to remove the shared Properties container and move ownership into dedicated plugin and compiled model property managers. - Introduce owner-specific PluginPropertyManager and CompiledModelPropertyManager - Remove the legacy shared properties.hpp/.cpp layer - Keep shared property registration utilities in property_registration.hpp - Update plugin and compiled-model property registration to use the shared descriptor/registration helpers - Update NPU functional test object sources to reflect the new file layout This makes property ownership explicit, keeps plugin and compiled-model behavior separate, and reduces special-case logic leaking outside the owning manager while preserving existing property behavior. The deadlock fix also restores correct handling of property queries and updates with extra config. ### Tickets: - *CVS-187127* ### AI Assistance: - *AI assistance used: yes* - *Splitting the current version of the property file into the 2 different files: plugin and compiled model property manager* - *Update documentation* - *Review* --------- Signed-off-by: Bogdan Pereanu <bogdan.pereanu@intel.com> Co-authored-by: Bogdan Pereanu <bogdan.pereanu@intel.com>
1 parent fadc486 commit 3d614db

31 files changed

Lines changed: 2100 additions & 1923 deletions

src/plugins/intel_npu/docs/npu-properties-howto.md

Lines changed: 113 additions & 78 deletions
Large diffs are not rendered by default.

src/plugins/intel_npu/src/backend/include/zero_device.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class ZeroDevice : public IDevice {
3737

3838
void updateInfo(const ov::AnyMap& properties) override;
3939

40+
bool validateCompatibilityDescriptor(const std::string& compatibilityDescriptor) const override;
41+
4042
ZeroDevice& operator=(const ZeroDevice&) = delete;
4143
ZeroDevice(const ZeroDevice&) = delete;
4244

src/plugins/intel_npu/src/backend/src/zero_device.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,27 @@ void ZeroDevice::updateInfo(const ov::AnyMap& properties) {
196196
_log.setLevel(properties.at(ov::log::level.name()).as<ov::log::Level>());
197197
}
198198
}
199+
200+
bool ZeroDevice::validateCompatibilityDescriptor(const std::string& compatibilityDescriptor) const {
201+
if (_initStructs->getZeDrvApiVersion() < ZE_MAKE_VERSION(1, 16)) {
202+
OPENVINO_THROW("Compatibility descriptor validation is not supported by this driver");
203+
}
204+
205+
ze_validate_runtime_requirements_output_t output = {};
206+
output.stype = ZE_STRUCTURE_TYPE_RUNTIME_REQUIREMENTS_OUTPUT;
207+
output.pNext = nullptr;
208+
209+
const ze_result_t result =
210+
zeDeviceValidateRuntimeRequirements(_initStructs->getDevice(), compatibilityDescriptor.c_str(), &output);
211+
212+
if (result != ZE_RESULT_SUCCESS) {
213+
_log.warning("zeDeviceValidateRuntimeRequirements returned error: 0x%x", static_cast<uint32_t>(result));
214+
return false;
215+
}
216+
217+
// Only REQUIREMENTS_MET and MET_RECOMPILATION_ADVISABLE are treated as compatible.
218+
// NOT_APPLICABLE (the descriptor does not apply to this device) and REQUIREMENTS_NOT_MET are
219+
// intentionally treated as incompatible, since neither guarantees the blob runs correctly here
220+
return output.result == ZE_VALIDATE_RUNTIME_REQUIREMENTS_RESULT_REQUIREMENTS_MET ||
221+
output.result == ZE_VALIDATE_RUNTIME_REQUIREMENTS_RESULT_REQUIREMENTS_MET_RECOMPILATION_ADVISABLE;
222+
}

src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ class ICompilerAdapter {
3535
const FilteredConfig& config) const = 0;
3636
virtual uint32_t get_version() const = 0;
3737
virtual std::optional<std::vector<std::string>> get_supported_options() const = 0;
38-
virtual bool is_option_supported(std::string optName, std::optional<std::string> optValue = std::nullopt) const = 0;
39-
40-
virtual bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const = 0;
38+
virtual bool is_option_supported(const std::string& optName,
39+
const std::optional<std::string>& optValue = std::nullopt) const = 0;
4140

4241
virtual ~ICompilerAdapter() = default;
4342
};

src/plugins/intel_npu/src/common/include/intel_npu/common/npu.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class IDevice : public std::enable_shared_from_this<IDevice> {
8585
const Config& config) = 0;
8686

8787
virtual void updateInfo(const ov::AnyMap& properties) = 0;
88+
virtual bool validateCompatibilityDescriptor(const std::string& compatibilityDescriptor) const = 0;
8889

8990
protected:
9091
virtual ~IDevice() = default;

src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,23 @@ class VCLCompilerImpl final : public std::enable_shared_from_this<VCLCompilerImp
8585
*/
8686
bool get_supported_options(std::vector<char>& options) const;
8787

88-
bool is_option_supported(std::string option, std::optional<std::string> optValue = std::nullopt) const;
89-
90-
std::shared_ptr<void> getLinkedLibrary() const;
88+
bool is_option_supported(const std::string& option,
89+
const std::optional<std::string>& optValue = std::nullopt) const;
9190

9291
/**
93-
* @brief Validates the compatibility descriptor against the current device information.
94-
* This function is used as a fallback check when the driver on the system does not support the required API
95-
* @param compatibilityDescriptor The compatibility descriptor (string) to be validated
92+
* @brief Checks whether the given option and value are supported by the compiler for the specified device.
93+
* This overload is used when a device descriptor is available, allowing device-specific validation.
9694
* @param in_device_desc Pointer to a device descriptor containing the device ID, number of
97-
* tiles and stepping information
98-
* @return false if the platform does not meet the requirements specified in the compatibility descriptor,
99-
* true if the platform is compatible
95+
* tiles and stepping information used for device-specific checks
96+
* @param option The option name to check
97+
* @param optValue The option value to validate
98+
* @return true if the option and value are supported for the given device, false otherwise
10099
*/
101-
bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor,
102-
vcl_device_desc_t* in_device_desc) const;
100+
bool is_option_supported(vcl_device_desc_t* in_device_desc,
101+
const std::string& option,
102+
const std::optional<std::string>& optValue = std::nullopt) const;
103+
104+
std::shared_ptr<void> getLinkedLibrary() const;
103105

104106
private:
105107
/**

src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ class DriverCompilerAdapter final : public ICompilerAdapter {
2828

2929
std::optional<std::vector<std::string>> get_supported_options() const override;
3030

31-
bool is_option_supported(std::string optName, std::optional<std::string> optValue = std::nullopt) const override;
31+
bool is_option_supported(const std::string& optName,
32+
const std::optional<std::string>& optValue = std::nullopt) const override;
3233

3334
uint32_t get_version() const override;
3435

35-
bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const override;
36-
3736
private:
3837
bool isCompilerOptionSupported(const FilteredConfig& config,
3938
const ze_graph_compiler_version_info_t& compilerVersion,

src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ class PluginCompilerAdapter final : public ICompilerAdapter {
2929

3030
std::optional<std::vector<std::string>> get_supported_options() const override;
3131

32-
bool is_option_supported(std::string optName, std::optional<std::string> optValue = std::nullopt) const override;
32+
bool is_option_supported(const std::string& optName,
33+
const std::optional<std::string>& optValue = std::nullopt) const override;
3334

3435
uint32_t get_version() const override;
3536

36-
bool validate_compatibility_descriptor(const std::string& compatibilityDescriptor) const override;
37-
3837
private:
3938
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
4039

src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class ZeGraphExtWrappers {
6363
* @return `true` if the option is supported, `false` if it is not supported,
6464
* and `std::nullopt` if the option-support query itself is not supported.
6565
*/
66-
std::optional<bool> isOptionSupported(std::string optName,
67-
std::optional<std::string> optValue = std::nullopt) const;
66+
std::optional<bool> isOptionSupported(const std::string& optName,
67+
const std::optional<std::string>& optValue = std::nullopt) const;
6868

6969
/**
7070
* @brief Tells us whether or not the driver is able to receive and take into account a hash of the model instead of

src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,13 @@ bool VCLCompilerImpl::get_supported_options(std::vector<char>& options) const {
521521
return false;
522522
}
523523

524-
bool VCLCompilerImpl::is_option_supported(std::string option, std::optional<std::string> optValue) const {
524+
bool VCLCompilerImpl::is_option_supported(const std::string& option, const std::optional<std::string>& optValue) const {
525525
try {
526526
const char* optname_ch = option.c_str();
527527
const char* optvalue_ch = optValue.has_value() ? optValue.value().c_str() : nullptr;
528528
_logger.debug("is_option_supported start for option: %s, value: %s",
529529
optname_ch,
530-
optValue ? optvalue_ch : "null");
530+
optvalue_ch ? optvalue_ch : "null");
531531
THROW_ON_FAIL_FOR_VCL("vclGetCompilerIsOptionSupported",
532532
vclGetCompilerIsOptionSupported(_compilerHandle, optname_ch, optvalue_ch),
533533
_logHandle);
@@ -540,8 +540,9 @@ bool VCLCompilerImpl::is_option_supported(std::string option, std::optional<std:
540540
return false;
541541
}
542542

543-
bool VCLCompilerImpl::validate_compatibility_descriptor(const std::string& compatibilityDescriptor,
544-
vcl_device_desc_t* in_device_desc) const {
543+
bool VCLCompilerImpl::is_option_supported(vcl_device_desc_t* in_device_desc,
544+
const std::string& option,
545+
const std::optional<std::string>& optValue) const {
545546
vcl_compiler_desc_t compilerDesc;
546547
compilerDesc.version = _vclVersion;
547548
compilerDesc.debugLevel = static_cast<vcl_log_level_t>(static_cast<int>(Logger::global().level()) + 1);
@@ -555,9 +556,11 @@ bool VCLCompilerImpl::validate_compatibility_descriptor(const std::string& compa
555556
vclCompilerCreate(&compilerDesc, in_device_desc, &compilerHandle, &logHandle),
556557
nullptr);
557558

558-
const char* optname_ch = ov::compatibility_check.name();
559-
const char* optvalue_ch = compatibilityDescriptor.c_str();
560-
_logger.debug("is_option_supported start for option: %s, value: %s", optname_ch, optvalue_ch);
559+
const char* optname_ch = option.c_str();
560+
const char* optvalue_ch = optValue.has_value() ? optValue.value().c_str() : nullptr;
561+
_logger.debug("is_option_supported start for option: %s, value: %s",
562+
optname_ch,
563+
optvalue_ch ? optvalue_ch : "null");
561564
THROW_ON_FAIL_FOR_VCL("vclGetCompilerIsOptionSupported",
562565
vclGetCompilerIsOptionSupported(compilerHandle, optname_ch, optvalue_ch),
563566
logHandle);

0 commit comments

Comments
 (0)