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

[CPU] Change kvcache type if user sets INFERENCE_PRECISION_HINT #690

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/cpp/src/continuous_batching_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ContinuousBatchingPipeline::Impl {
// The model can be compiled for GPU as well
std::shared_ptr<ov::Model> model = core.read_model(models_path + "/openvino_model.xml");

DeviceConfig device_config(core, scheduler_config, device);
DeviceConfig device_config(core, scheduler_config, device, plugin_config);

apply_paged_attention_transformations(model, device_config);

Expand Down
16 changes: 15 additions & 1 deletion src/cpp/src/device_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DeviceConfig {
std::string m_device;

public:
DeviceConfig(ov::Core& core, const SchedulerConfig& scheduling_config, const std::string& device) {
DeviceConfig(ov::Core& core, const SchedulerConfig& scheduling_config, const std::string& device, const ov::AnyMap& plugin_config = {}) {
m_device = device;

// keep information about blocsk
Expand All @@ -29,6 +29,20 @@ class DeviceConfig {
if (m_device == "CPU") {
auto inference_precision = core.get_property(device, ov::hint::inference_precision);
m_kv_cache_type = inference_precision == ov::element::bf16 ? ov::element::bf16 : ov::element::f16;
// if user sets precision hint, kv cache type should be changed
if (plugin_config.find(ov::hint::inference_precision.name()) != plugin_config.end()) {
const auto precision = plugin_config.at(ov::hint::inference_precision.name()).as<ov::element::Type>();
if (precision == ov::element::f32) {
m_kv_cache_type = ov::element::f32;
Wovchena marked this conversation as resolved.
Show resolved Hide resolved
} else if (precision == ov::element::f16) {
m_kv_cache_type = ov::element::f16;
} else if (precision == ov::element::bf16) {
m_kv_cache_type = ov::element::bf16;
} else {
// use default f32
m_kv_cache_type = ov::element::f32;
}
}
} else if (m_device == "GPU") {
OPENVINO_ASSERT("GPU is not currently supported. Please, remove this assert and fill configuration");
} else {
Expand Down
Loading