Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU]fix by-channel key cache layout check (#30203)

Zhang Yi1ee4259567f5
diff --git a/src/plugins/intel_cpu/src/nodes/paged_attn.cpp b/src/plugins/intel_cpu/src/nodes/paged_attn.cpp
index 5fee93d7198..e7cb5b32ff5 100644
--- a/src/plugins/intel_cpu/src/nodes/paged_attn.cpp
+++ b/src/plugins/intel_cpu/src/nodes/paged_attn.cpp
@@ -150,10 +150,10 @@ void PagedAttention::initSupportedPrimitiveDescriptors() {
supportedPrimitiveDescriptors.emplace_back(config, impl_desc_type::ref_any);
}
-bool PagedAttention::isQuantByChannel(const Config::CacheQuantMode mode) noexcept {
+bool PagedAttention::isQuantByChannel(const Config::CacheQuantMode mode, const ov::element::Type precision) noexcept {
// AUTO means select by primitive
// for non-x86 platform, by-channel quantization is disabled
- bool byChannel = true;
+ bool byChannel = precision.is_integral();
if (mode == Config::CacheQuantMode::BY_HIDDEN) {
byChannel = false;
}
@@ -176,7 +176,7 @@ void PagedAttention::createPrimitive() {
auto vCachePrecision = getOriginalInputPrecisionAtPort(PagedAttentionExecutor::ID_VCACHE);
const auto& cpuConfig = context->getConfig();
- bool byChannel = isQuantByChannel(cpuConfig.keyCacheQuantMode);
+ bool byChannel = isQuantByChannel(cpuConfig.keyCacheQuantMode, kCachePrecision);
return make_pa_executor(rtPrecision,
kCachePrecision,
vCachePrecision,
diff --git a/src/plugins/intel_cpu/src/nodes/paged_attn.h b/src/plugins/intel_cpu/src/nodes/paged_attn.h
index 2948fd082b8..1b65a5195af 100644
--- a/src/plugins/intel_cpu/src/nodes/paged_attn.h
+++ b/src/plugins/intel_cpu/src/nodes/paged_attn.h
@@ -46,7 +46,7 @@ public:
void createPrimitive() override;
static bool isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept;
- static bool isQuantByChannel(const Config::CacheQuantMode mode) noexcept;
+ static bool isQuantByChannel(const Config::CacheQuantMode mode, const ov::element::Type precision) noexcept;
private:
ov::element::Type getRuntimePrecision() const override;
diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
index 1ce362647b6..1b8e1724ffe 100644
--- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
+++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
@@ -469,7 +469,7 @@ void Transformations::PreLpt(const std::vector<ov::element::Type>& defaultPrecis
cacheConfig.keyCacheBlockSize = 32;
cacheConfig.valueCacheBlockSize = 32;
- bool byChannel = node::PagedAttention::isQuantByChannel(config.keyCacheQuantMode);
+ bool byChannel = node::PagedAttention::isQuantByChannel(config.keyCacheQuantMode, cacheConfig.keyCachePrecision);
cacheConfig.keyCacheQuantBychannel = byChannel;
cacheConfig.valueCacheQuantBychannel = false;
cacheConfig.keyCacheDimOrder = {0, 1, 2, 3};