Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Split configuration for device and others in compile model #26977

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e10f512
Split configuration for device and others
praasz Oct 9, 2024
32750d6
Fix call compile model with weights
praasz Oct 9, 2024
cdc5655
Remove modify core state in compile_model
praasz Oct 13, 2024
f9a2362
Remove not used variable
praasz Oct 13, 2024
b1387b2
Fix MSVC build error
praasz Oct 13, 2024
4f33336
Auto-Batch remove prop validation to meta device
praasz Oct 14, 2024
a6ad92e
Add missing supported properties in Template
praasz Oct 14, 2024
ce4a5a0
Add parse only properties in auto-batch
praasz Oct 14, 2024
d9e02b9
Merge remote-tracking branch 'origin/master' into split-config-in-com…
praasz Oct 14, 2024
945aab2
Template plugin sync supported properties
praasz Oct 14, 2024
a89eed8
CPU plugin sync supported properties
praasz Oct 14, 2024
0426bda
Hetero plugin sync supported properties
praasz Oct 14, 2024
8ae4d36
Make `parse_only_meta_device` member private
praasz Oct 14, 2024
1220a36
Merge branch 'master' into split-config-in-compile-model
praasz Oct 16, 2024
2a9b1e6
Merge branch 'master' into split-config-in-compile-model
praasz Oct 21, 2024
327c93a
Remove not used parameter in function
praasz Oct 22, 2024
82e337f
Merge branch 'master' into split-config-in-compile-model
praasz Oct 22, 2024
45e270d
Merge branch 'master' into split-config-in-compile-model
praasz Oct 23, 2024
ec5b0cf
Merge branch 'master' into split-config-in-compile-model
praasz Oct 25, 2024
837f633
Merge branch 'master' into split-config-in-compile-model
praasz Oct 28, 2024
cd5516b
Merge branch 'master' into split-config-in-compile-model
praasz Nov 12, 2024
803b5c3
Merge branch 'master' into split-config-in-compile-model
praasz Nov 14, 2024
b7e1ea7
Merge branch 'master' into split-config-in-compile-model
praasz Nov 15, 2024
d9dfae2
Merge branch 'master' into split-config-in-compile-model
praasz Nov 18, 2024
fabdba5
Merge branch 'master' into split-config-in-compile-model
praasz Nov 18, 2024
82b6c5c
Add kv_cache_precision as supported property by GPU
praasz Nov 20, 2024
982b9e8
Merge branch 'master' into split-config-in-compile-model
praasz Nov 21, 2024
c1ffd36
Merge branch 'master' into split-config-in-compile-model
praasz Nov 29, 2024
ce822f7
Merge branch 'master' into split-config-in-compile-model
praasz Dec 2, 2024
2772f3d
Filter core properties by using local core config
praasz Dec 10, 2024
46c05ba
Revert changes
praasz Dec 10, 2024
434b67f
Update `parseDeviceNameIntoConfig` to provide local core configuration
praasz Dec 11, 2024
78b5226
Merge remote-tracking branch 'origin/master' into split-config-in-com…
praasz Dec 11, 2024
c0b700b
Fix issues after merge
praasz Dec 11, 2024
7dc7b73
Clean core properties for HW devices in parseDeviceNameIntoConfig
praasz Dec 11, 2024
9c7f13a
Add comment about cache_dir removal from compile config
praasz Dec 11, 2024
511bb88
Re order code in core_impl.cpp
praasz Dec 11, 2024
ca0ba63
Merge branch 'master' into split-config-in-compile-model
praasz Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 128 additions & 77 deletions src/inference/src/dev/core_impl.cpp

Large diffs are not rendered by default.

120 changes: 84 additions & 36 deletions src/inference/src/dev/core_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,90 @@ using CreatePluginEngineFunc = void(std::shared_ptr<::ov::IPlugin>&);

const std::string DEFAULT_DEVICE_NAME = "DEFAULT_DEVICE";

class CoreConfig final {
public:
CoreConfig() = default;
CoreConfig(const CoreConfig& other);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be operator= either defined or deleted.


struct CacheConfig {
std::string _cacheDir;
std::shared_ptr<ov::ICacheManager> _cacheManager;

static CacheConfig create(const std::string& dir);
};

void set(const ov::AnyMap& config);

/**
* @brief Removes core-level properties from config and triggers new state for core config
* @param config - config to be updated
*/
void set_and_update(ov::AnyMap& config);

OPENVINO_DEPRECATED("Don't use this method, it will be removed soon")
void set_cache_dir_for_device(const std::string& dir, const std::string& name);

std::string get_cache_dir() const;

bool get_enable_mmap() const;

CacheConfig get_cache_config_for_device(const ov::Plugin& plugin, ov::AnyMap& parsedConfig) const;

// Creating thread-safe copy of global config including shared_ptr to ICacheManager
CacheConfig get_cache_config_for_device(const ov::Plugin& plugin) const;

private:
mutable std::mutex _cacheConfigMutex;
CacheConfig _cacheConfig;
std::map<std::string, CacheConfig> _cacheConfigPerDevice;
bool _flag_enable_mmap = true;
};

struct Parsed {
std::string _deviceName;
AnyMap _config;
CoreConfig _core_config;
};

/**
* @brief Provides Parsed device name and configuration.
*
* Uses default core configuration updated with user properties from config.
* The core properties are removed from user configuration for HW devices only.
* @note The `CACHE_DIR` is not removed from compiled configuration.
*
* @param deviceName Device name to be parsed
* @param config User configuration to be parsed.
* @param keep_auto_batch_property If set keep auto batch properties in compile properties.
* @return Parsed:
* - device name
* - compile properties
* - core configuration
*/
Parsed parseDeviceNameIntoConfig(const std::string& deviceName,
const AnyMap& config = {},
const bool keep_auto_batch_property = false);

/**
* @brief Provides Parsed device name and configuration.
*
* Uses user core configuration which is updated with user properties from config.
* The core properties are removed from user configuration for HW devices only.
* @note The `CACHE_DIR` is not removed from compiled configuration.
*
* @param deviceName Device name to be parsed
* @param coreConfig Core configuration used as base for parsed output.
* @param config User configuration to be parsed.
* @param keep_auto_batch_property If set keep auto batch properties in compile properties.
* @return Parsed:
* - device name
* - compile properties
* - core configuration
*/
Parsed parseDeviceNameIntoConfig(const std::string& deviceName,
const CoreConfig& coreConfig,
const AnyMap& config = {},
const bool keep_core_property = false);
const bool keep_auto_batch_property = false);

/**
* @brief Checks whether config is applicable for device with 'device_name'
Expand Down Expand Up @@ -61,47 +137,17 @@ class CoreImpl : public ov::ICore, public std::enable_shared_from_this<ov::ICore
bool is_proxy_device(const ov::Plugin& plugin) const;
bool is_proxy_device(const std::string& dev_name) const;

class CoreConfig final {
public:
struct CacheConfig {
std::string _cacheDir;
std::shared_ptr<ov::ICacheManager> _cacheManager;

static CacheConfig create(const std::string& dir);
};

/**
* @brief Removes core-level properties from config and triggers new state for core config
* @param config - config to be updated
*/
void set_and_update(ov::AnyMap& config);

OPENVINO_DEPRECATED("Don't use this method, it will be removed soon")
void set_cache_dir_for_device(const std::string& dir, const std::string& name);

std::string get_cache_dir() const;

bool get_enable_mmap() const;

// Creating thread-safe copy of config including shared_ptr to ICacheManager
// Passing empty or not-existing name will return global cache config
CacheConfig get_cache_config_for_device(const ov::Plugin& plugin, ov::AnyMap& parsedConfig) const;

private:
mutable std::mutex _cacheConfigMutex;
CacheConfig _cacheConfig;
std::map<std::string, CacheConfig> _cacheConfigPerDevice;
bool _flag_enable_mmap = true;
};

struct CacheContent {
explicit CacheContent(const std::shared_ptr<ov::ICacheManager>& cache_manager,
bool mmap_enabled = false,
const std::string model_path = {})
: cacheManager(cache_manager),
modelPath(model_path) {}
modelPath(model_path),
mmap_enabled{mmap_enabled} {}
std::shared_ptr<ov::ICacheManager> cacheManager;
std::string blobId = {};
std::string modelPath = {};
bool mmap_enabled = false;
};

// Core settings (cache config, etc)
Expand Down Expand Up @@ -291,7 +337,9 @@ class CoreImpl : public ov::ICore, public std::enable_shared_from_this<ov::ICore

ov::SoPtr<ov::IRemoteContext> create_context(const std::string& device_name, const AnyMap& args) const override;

ov::AnyMap get_supported_property(const std::string& device_name, const ov::AnyMap& config, const bool keep_core_property = true) const override;
ov::AnyMap get_supported_property(const std::string& device_name,
const ov::AnyMap& config,
const bool keep_core_property = true) const override;

ov::SoPtr<ov::IRemoteContext> get_default_context(const std::string& device_name) const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ TEST_F(AutoFuncTests, compiled_with_cache_enabled_batch_enabled) {
ASSERT_EQ(ov::test::utils::listFilesWithExt(cache_path, "blob").size(), 5);
core.set_property(ov::cache_dir(""));
#endif
}
}
2 changes: 1 addition & 1 deletion src/plugins/auto_batch/src/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ class Plugin : public ov::IPlugin {
mutable ov::AnyMap m_plugin_config;
};
} // namespace autobatch_plugin
} // namespace ov
} // namespace ov
1 change: 1 addition & 0 deletions src/plugins/intel_gpu/src/plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ std::vector<ov::PropertyName> Plugin::get_supported_properties() const {
ov::PropertyName{ov::hint::dynamic_quantization_group_size.name(), PropertyMutability::RW},
ov::PropertyName{ov::hint::activations_scale_factor.name(), PropertyMutability::RW},
ov::PropertyName{ov::weights_path.name(), PropertyMutability::RW},
ov::PropertyName{ov::hint::kv_cache_precision.name(), PropertyMutability::RW},
};

return supported_properties;
Expand Down
25 changes: 15 additions & 10 deletions src/plugins/template/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,18 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const
return ro_properties;
};
const auto& default_rw_properties = []() {
std::vector<ov::PropertyName> rw_properties{ov::device::id,
ov::enable_profiling,
ov::hint::performance_mode,
ov::hint::num_requests,
ov::hint::inference_precision,
ov::hint::execution_mode,
ov::num_streams,
ov::template_plugin::disable_transformations,
ov::log::level};
std::vector<ov::PropertyName> rw_properties{
ov::device::id,
ov::enable_profiling,
ov::hint::performance_mode,
ov::hint::num_requests,
ov::hint::inference_precision,
ov::hint::execution_mode,
ov::num_streams,
ov::template_plugin::disable_transformations,
ov::log::level,
ov::hint::model_priority,
};
return rw_properties;
};
if (ov::supported_properties == name) {
Expand All @@ -280,7 +283,9 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const
} else if (ov::internal::supported_properties == name) {
return decltype(ov::internal::supported_properties)::value_type{
ov::PropertyName{ov::internal::caching_properties.name(), ov::PropertyMutability::RO},
ov::PropertyName{ov::internal::exclusive_async_requests.name(), ov::PropertyMutability::RW}};
ov::PropertyName{ov::internal::exclusive_async_requests.name(), ov::PropertyMutability::RW},
ov::PropertyName{ov::inference_num_threads.name(), ov::PropertyMutability::RW},
ov::PropertyName{ov::internal::threads_per_stream.name(), ov::PropertyMutability::RW}};
} else if (ov::available_devices == name) {
// TODO: fill list of available devices
return decltype(ov::available_devices)::value_type{{""}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ TEST_P(InferRequestPropertiesTest, ReusableCPUStreamsExecutor) {
}
}
}

TEST_P(InferRequestPropertiesTest, ConfigHasUnsupportedPluginProperty) {
configuration.insert({ov::enable_mmap(false)});
if (target_device.find(ov::test::utils::DEVICE_AUTO) == std::string::npos &&
target_device.find(ov::test::utils::DEVICE_MULTI) == std::string::npos &&
target_device.find(ov::test::utils::DEVICE_HETERO) == std::string::npos &&
target_device.find(ov::test::utils::DEVICE_BATCH) == std::string::npos) {
OV_ASSERT_NO_THROW(core->set_property(target_device, configuration));
}
// Compile model to target plugins
execNet = core->compile_model(function, target_device, configuration);
OV_ASSERT_NO_THROW(execNet.create_infer_request());
}
} // namespace behavior
} // namespace test
} // namespace ov
Loading