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
[GPU] Enable by_channel mode for key cache compression (#31343)
Taylor Yeonbok Lee0d85ced72e54
diff --git a/src/inference/dev_api/openvino/runtime/internal_properties.hpp b/src/inference/dev_api/openvino/runtime/internal_properties.hppindex 566a82a9790..206c7c72dde 100644--- a/src/inference/dev_api/openvino/runtime/internal_properties.hpp+++ b/src/inference/dev_api/openvino/runtime/internal_properties.hpp@@ -90,5 +90,78 @@ static constexpr Property<float, PropertyMutability::RW> query_model_ratio{"QUER*/static constexpr Property<bool, PropertyMutability::RW> enable_lp_transformations{"LP_TRANSFORMS_MODE"};+/**+ * @brief Enum to define possible cache quant schema hints.+ */+enum class CacheQuantMode { AUTO = 0, BY_CHANNEL = 1, BY_TOKEN = 2 };++/** @cond INTERNAL */+inline std::ostream& operator<<(std::ostream& os, const CacheQuantMode& mode) {+ switch (mode) {+ case CacheQuantMode::AUTO:+ return os << "AUTO";+ case CacheQuantMode::BY_CHANNEL:+ return os << "BY_CHANNEL";+ case CacheQuantMode::BY_TOKEN:+ return os << "BY_TOKEN";+ default:+ OPENVINO_THROW("Unsupported cache quant mode");+ }+}++inline std::istream& operator>>(std::istream& is, CacheQuantMode& mode) {+ std::string str;+ is >> str;+ if (str == "AUTO") {+ mode = CacheQuantMode::AUTO;+ } else if (str == "BY_CHANNEL") {+ mode = CacheQuantMode::BY_CHANNEL;+ } else if (str == "BY_TOKEN") {+ mode = CacheQuantMode::BY_TOKEN;+ } else {+ OPENVINO_THROW("Unsupported cache quant mode: ", str);+ }+ return is;+}+/** @endcond */++/**+ * @brief Define quantization mode for key cache. Group size decision policy may be different per plugin.+ * @param AUTO - Default mode decided by plugin.+ * @param BY_CHANNEL - Quantize key cache by channel dimension.+ * @param BY_TOKEN - Quantize key cache by token dimension.++ By channel: Quantize along with tokens in each channel+ ┌──┬──┬─────────────────────────┐+ │ │ │ │ token[0]+ │ │ │ │ token[1]+ │ │ │ ... │ token[2]+ │ │ │ │ ..+ │ │ │ │ token[seq_len - 1]+ └──┴──┴─────────────────────────┘+ c[0] c[1] ... c[head_size - 1]++ By token: Quantize along with channel dim per each token+ ┌───────────────────────────────┐+ ├───────────────────────────────┤ token[0]+ ├───────────────────────────────┤ token[1]+ │ │ ...+ │ │+ │ │+ │ │ token[seq_len - 1]+ └───────────────────────────────┘+ c[0] c[1] ... c[head_size - 1]+ */++static constexpr Property<CacheQuantMode, PropertyMutability::RW> key_cache_quant_mode{"KEY_CACHE_QUANT_MODE"};++/**+ * @brief Define quantization mode for value cache. Group size decision policy may be different per plugin.+ * @param AUTO - Default mode decided by plugin+ * @param BY_CHANNEL - Quantize value cache by channel dimension.+ * @param BY_TOKEN - Quantize key cache by token dimension.+ */++static constexpr Property<CacheQuantMode, PropertyMutability::RW> value_cache_quant_mode{"VALUE_CACHE_QUANT_MODE"};} // namespace internal} // namespace ovdiff --git a/src/plugins/intel_cpu/src/config.cpp b/src/plugins/intel_cpu/src/config.cppindex bf7236ddaca..8acb8271447 100644--- a/src/plugins/intel_cpu/src/config.cpp+++ b/src/plugins/intel_cpu/src/config.cpp@@ -389,15 +389,15 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {key,". Expected only unsigned integer numbers");}- } else if (key == ov::intel_cpu::key_cache_quant_mode.name()) {+ } else if (key == ov::internal::key_cache_quant_mode.name()) {try {- const auto mode = val.as<ov::intel_cpu::CacheQuantMode>();- if (mode == ov::intel_cpu::CacheQuantMode::AUTO) {+ const auto mode = val.as<ov::internal::CacheQuantMode>();+ if (mode == ov::internal::CacheQuantMode::AUTO) {keyCacheQuantMode = CacheQuantMode::AUTO;- } else if (mode == ov::intel_cpu::CacheQuantMode::BY_CHANNEL) {+ } else if (mode == ov::internal::CacheQuantMode::BY_CHANNEL) {keyCacheQuantMode = CacheQuantMode::BY_CHANNEL;- } else if (mode == ov::intel_cpu::CacheQuantMode::BY_HIDDEN) {- keyCacheQuantMode = CacheQuantMode::BY_HIDDEN;+ } else if (mode == ov::internal::CacheQuantMode::BY_TOKEN) {+ keyCacheQuantMode = CacheQuantMode::BY_TOKEN;} else {OPENVINO_THROW("invalid value");}@@ -405,18 +405,18 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {OPENVINO_THROW("Wrong value ",val.as<std::string>()," for property key ",- ov::intel_cpu::key_cache_quant_mode.name(),- ". Expected AUTO/BY_CHANNEL/BY_HIDDEN");+ ov::internal::key_cache_quant_mode.name(),+ ". Expected AUTO/BY_CHANNEL/BY_TOKEN");}- } else if (key == ov::intel_cpu::value_cache_quant_mode.name()) {+ } else if (key == ov::internal::value_cache_quant_mode.name()) {try {- const auto mode = val.as<ov::intel_cpu::CacheQuantMode>();- if (mode == ov::intel_cpu::CacheQuantMode::AUTO) {+ const auto mode = val.as<ov::internal::CacheQuantMode>();+ if (mode == ov::internal::CacheQuantMode::AUTO) {valueCacheQuantMode = CacheQuantMode::AUTO;- } else if (mode == ov::intel_cpu::CacheQuantMode::BY_CHANNEL) {+ } else if (mode == ov::internal::CacheQuantMode::BY_CHANNEL) {valueCacheQuantMode = CacheQuantMode::BY_CHANNEL;- } else if (mode == ov::intel_cpu::CacheQuantMode::BY_HIDDEN) {- valueCacheQuantMode = CacheQuantMode::BY_HIDDEN;+ } else if (mode == ov::internal::CacheQuantMode::BY_TOKEN) {+ valueCacheQuantMode = CacheQuantMode::BY_TOKEN;} else {OPENVINO_THROW("invalid value");}@@ -424,8 +424,8 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {OPENVINO_THROW("Wrong value ",val.as<std::string>()," for property key ",- ov::intel_cpu::value_cache_quant_mode.name(),- ". Expected AUTO/BY_CHANNEL/BY_HIDDEN");+ ov::internal::value_cache_quant_mode.name(),+ ". Expected AUTO/BY_CHANNEL/BY_TOKEN");}} else if (key == ov::intel_cpu::enable_tensor_parallel.name()) {try {diff --git a/src/plugins/intel_cpu/src/config.h b/src/plugins/intel_cpu/src/config.hindex 23c02b2d255..7cec072e47c 100644--- a/src/plugins/intel_cpu/src/config.h+++ b/src/plugins/intel_cpu/src/config.h@@ -44,7 +44,7 @@ struct Config {enum CacheQuantMode : uint8_t {AUTO,BY_CHANNEL,- BY_HIDDEN,+ BY_TOKEN,};enum class ModelType : uint8_t { CNN, LLM, Unknown };diff --git a/src/plugins/intel_cpu/src/internal_properties.hpp b/src/plugins/intel_cpu/src/internal_properties.hppindex 54590fa3650..2f50164b34c 100644--- a/src/plugins/intel_cpu/src/internal_properties.hpp+++ b/src/plugins/intel_cpu/src/internal_properties.hpp@@ -67,61 +67,6 @@ inline std::istream& operator>>(std::istream& is, SnippetsMode& mode) {*/static constexpr Property<SnippetsMode, PropertyMutability::RW> snippets_mode{"SNIPPETS_MODE"};-/**- * @brief Enum to define possible cache quant schema hints.- */-enum class CacheQuantMode : uint8_t {- AUTO,- BY_CHANNEL,- BY_HIDDEN,-};--/** @cond INTERNAL */-inline std::ostream& operator<<(std::ostream& os, const CacheQuantMode& mode) {- switch (mode) {- case CacheQuantMode::AUTO:- return os << "AUTO";- case CacheQuantMode::BY_CHANNEL:- return os << "BY_CHANNEL";- case CacheQuantMode::BY_HIDDEN:- return os << "BY_HIDDEN";- default:- OPENVINO_THROW("Unsupported snippets mode value");- }-}--inline std::istream& operator>>(std::istream& is, CacheQuantMode& mode) {- std::string str;- is >> str;- if (str == "AUTO") {- mode = CacheQuantMode::AUTO;- } else if (str == "BY_CHANNEL") {- mode = CacheQuantMode::BY_CHANNEL;- } else if (str == "BY_HIDDEN") {- mode = CacheQuantMode::BY_HIDDEN;- } else {- OPENVINO_THROW("Unsupported cache quant mode: ", str);- }- return is;-}-/** @endcond */--/**- * @brief Define cache quant mode.- * @param AUTO - default mode by primitive- * @param BY_CHANNEL - quant by channel- * @param BY_HIDDEN - quant by hidden- */-static constexpr Property<CacheQuantMode, PropertyMutability::RW> key_cache_quant_mode{"KEY_CACHE_QUANT_MODE"};--/**- * @brief Define cache quant mode.- * @param AUTO - default mode by primitive- * @param BY_CHANNEL - quant by channel- * @param BY_HIDDEN - quant by hidden- */-static constexpr Property<CacheQuantMode, PropertyMutability::RW> value_cache_quant_mode{"VALUE_CACHE_QUANT_MODE"};-/*** @brief This property used to test accurcay of setting model_distribution_policy to TENSOR_PARALLEL in functional* tests.diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cppindex f3a8a26111a..327104fb0b1 100644--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cpp+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cpp@@ -3610,7 +3610,7 @@ struct AttentionExecutor : public PagedAttentionExecutor {auto Hk = k_cache.size(1);/* The layout for kv cache:- by-hidden, quantized by S(hidden dims) group_num = N+ by-token, quantized by S(token dims) group_num = NN * f32(scale + zp)|group_0|group_1|...|group_Nadjusted_S = S + N * f32(scale + zp) * sub_byte_multiplier@@ -3634,11 +3634,12 @@ struct AttentionExecutor : public PagedAttentionExecutor {size_t value_group_num =_helper._value_group_size ? v_cache.size(3) / (_helper._value_group_size + value_params_size) : 1;- // check by_hidden_dims parameter of value cache+ // check by_token_dims parameter of value cacheOPENVINO_ASSERT(value_group_num != 0U || !v_cache.get_precision().is_integral(),"PagedAttn value cache gets wrong group_size, ",_helper._value_group_size,- " should be smaller than hidden_dims");+ " should be smaller than token_dims");+size_t S = 0;// check parameter of quantized key cacheif (k_cache.get_precision().is_integral()) {@@ -3648,7 +3649,7 @@ struct AttentionExecutor : public PagedAttentionExecutor {OPENVINO_ASSERT(key_group_num,"PagedAttn key cache gets wrong group_size, ",_helper._key_group_size,- " should be smaller than hidden_dims");+ " should be smaller than token_dims");S = k_cache.size(3) - key_params_size * key_group_num;_helper._key_group_size = _helper._key_group_size ? _helper._key_group_size : S;}@@ -3665,7 +3666,7 @@ struct AttentionExecutor : public PagedAttentionExecutor {OPENVINO_ASSERT(value_group_num,"PagedAttn value cache gets wrong group_size, ",_helper._value_group_size,- " should be smaller than hidden_dims");+ " should be smaller than token_dims");SV = v_cache.size(3) - value_params_size * value_group_num;_helper._value_group_size = _helper._value_group_size ? _helper._value_group_size : SV;}diff --git a/src/plugins/intel_cpu/src/nodes/paged_attn.cpp b/src/plugins/intel_cpu/src/nodes/paged_attn.cppindex 8938809a42a..a27a65810f1 100644--- a/src/plugins/intel_cpu/src/nodes/paged_attn.cpp+++ b/src/plugins/intel_cpu/src/nodes/paged_attn.cpp@@ -173,7 +173,7 @@ bool PagedAttention::isQuantByChannel(const Config::CacheQuantMode mode,// for non-x86 platform, by-channel quantization is disabled// By default, by-channel should only be enabled when precision is integralbool byChannel = precision.is_integral() && isKey;- if (!precision.is_integral() || mode == Config::CacheQuantMode::BY_HIDDEN) {+ if (!precision.is_integral() || mode == Config::CacheQuantMode::BY_TOKEN) {byChannel = false;}#if defined(OPENVINO_ARCH_ARM64)diff --git a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp b/src/plugins/intel_cpu/src/nodes/scaled_attn.cppindex 9b8b7a58fdb..ab9228b4612 100644--- a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp+++ b/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp@@ -1246,7 +1246,7 @@ void ScaledDotProductAttention::createPrimitive() {m_key_quant_param.isByChannel = false;if (cpuConfig.keyCacheQuantMode == ov::intel_cpu::Config::CacheQuantMode::BY_CHANNEL) {m_key_quant_param.isByChannel = true;- } else if (cpuConfig.keyCacheQuantMode == ov::intel_cpu::Config::CacheQuantMode::BY_HIDDEN) {+ } else if (cpuConfig.keyCacheQuantMode == ov::intel_cpu::Config::CacheQuantMode::BY_TOKEN) {m_key_quant_param.isByChannel = false;}m_value_quant_param.groupSize = cpuConfig.valueCacheGroupSize ? cpuConfig.valueCacheGroupSize : valueS;diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/common/concat_transpose_sdp_transpose.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/common/concat_transpose_sdp_transpose.cppindex 306639b63c0..eb0660971b4 100644--- a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/common/concat_transpose_sdp_transpose.cpp+++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/common/concat_transpose_sdp_transpose.cpp@@ -107,8 +107,8 @@ public:configuration[ov::hint::inference_precision.name()] = ov::element::f32;configuration[ov::key_cache_group_size.name()] = keyGroupSize;configuration[ov::value_cache_group_size.name()] = keyGroupSize;- configuration[ov::intel_cpu::key_cache_quant_mode.name()] =- quantKeyByChannel ? ov::intel_cpu::CacheQuantMode::BY_CHANNEL : ov::intel_cpu::CacheQuantMode::BY_HIDDEN;+ configuration[ov::internal::key_cache_quant_mode.name()] =+ quantKeyByChannel ? ov::internal::CacheQuantMode::BY_CHANNEL : ov::internal::CacheQuantMode::BY_TOKEN;// explictly set u8 kv_cache for QuantByChannelif (quantKeyByChannel) {configuration[ov::hint::kv_cache_precision.name()] = ov::element::u8;diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hppindex dcbb0b04de3..1c33dcd27f6 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hpp@@ -84,6 +84,7 @@ struct paged_attention : public primitive_base<paged_attention> {} else {ob << false;}+ ob << is_key_by_channel;}void load(BinaryInputBuffer& ib) override {@@ -107,6 +108,7 @@ struct paged_attention : public primitive_base<paged_attention> {} else {scale_val = std::optional<float>();}+ ib >> is_key_by_channel;}std::optional<float> scale_val{};@@ -118,5 +120,6 @@ struct paged_attention : public primitive_base<paged_attention> {bool has_alibi = false;bool has_rotated_blocks = false;bool has_score_aggregation = false;+ bool is_key_by_channel = false;};} // namespace cldnndiff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inlindex e2eeef0569a..4c5504091c2 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl@@ -35,6 +35,8 @@ OV_CONFIG_RELEASE_OPTION(ov::hint, activations_scale_factor, -1.0f, "Scalar floaOV_CONFIG_RELEASE_OPTION(ov::internal, enable_lp_transformations, false, "Enable/Disable Low precision transformations set")OV_CONFIG_RELEASE_OPTION(ov::intel_gpu, config_file, "", "Path to custom layers config file")OV_CONFIG_RELEASE_OPTION(ov::hint, model, nullptr, "Shared pointer to the ov::Model")+OV_CONFIG_RELEASE_OPTION(ov::internal, key_cache_quant_mode, ov::internal::CacheQuantMode::BY_TOKEN, "AUTO or BY_CHANNEL or BY_TOKEN")+OV_CONFIG_RELEASE_OPTION(ov::internal, value_cache_quant_mode, ov::internal::CacheQuantMode::BY_TOKEN, "AUTO or BY_CHANNEL or BY_TOKEN")OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, shape_predictor_settings, {10, 16 * 1024, 2, 1.1f}, "Preallocation settings")OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, queue_type, QueueTypes::out_of_order, "Type of the queue that must be used for model execution. May be in-order or out-of-order")diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/paged_attention.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/paged_attention.cppindex 7d006c925ff..58e30d044ca 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/paged_attention.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/paged_attention.cpp@@ -740,6 +740,13 @@ struct paged_attention_impl : multi_stage_primitive<paged_attention> {if (data_type_traits::is_i8_u8(impl_param.get_input_layout(PagedAttentionInputIdx::KEY_CACHE).data_type)) {config.is_kv_compressed = true;+ config.is_key_by_channel = desc->is_key_by_channel;+ OPENVINO_ASSERT(+ config.is_key_by_channel == (impl_param.get_program().get_config().get_key_cache_quant_mode() == ov::internal::CacheQuantMode::BY_CHANNEL),+ "[GPU] Paged Attention key cache quantization mode mismatch: prim.key_cache_by_channel : ",+ desc->is_key_by_channel,+ " but exec_config : ",+ impl_param.get_program().get_config().get_key_cache_quant_mode());config.use_asymmetric_quantization = true;}@@ -788,7 +795,7 @@ struct paged_attention_impl : multi_stage_primitive<paged_attention> {const kernel_selector::MultiDataTensor& input_tensors,bool is_dynamic = false) {auto params = get_default_params<kv_cache_update_kernel_params_t>(impl_param, is_dynamic);-+ const auto& desc = impl_param.typed_desc<paged_attention>();const auto& key_tensor = input_tensors[PagedAttentionInputIdx::KEY];const auto& value_tensor = input_tensors[PagedAttentionInputIdx::VALUE];const auto& key_cache_tensor = input_tensors[PagedAttentionInputIdx::KEY_CACHE];@@ -810,7 +817,17 @@ struct paged_attention_impl : multi_stage_primitive<paged_attention> {params.inputs[5] = subsequence_begins_tensor;params.outputs[0] = key_cache_tensor;params.outputs[1] = value_cache_tensor;-+ params.is_key_by_channel = desc->is_key_by_channel;+ OPENVINO_ASSERT(+ params.is_key_by_channel == (impl_param.get_program().get_config().get_key_cache_quant_mode() == ov::internal::CacheQuantMode::BY_CHANNEL),+ "[GPU] Paged Attention key cache quantization mode mismatch: prim.key_cache_by_channel : ",+ params.is_key_by_channel,+ " and exec_config : ",+ impl_param.get_program().get_config().get_key_cache_quant_mode());++ const auto pa_block_size = static_cast<int32_t>(paged_attention::block_size);+ if (params.is_key_by_channel)+ params.key_group_size = pa_block_size;params.conf = get_sdpa_configuration(impl_param, is_dynamic);params.is_prefill = stage == PagedAttentionStage::PREFILL || stage == PagedAttentionStage::MIXED;diff --git a/src/plugins/intel_gpu/src/graph/paged_attention.cpp b/src/plugins/intel_gpu/src/graph/paged_attention.cppindex 94ea3023aef..e4d566b2a87 100644--- a/src/plugins/intel_gpu/src/graph/paged_attention.cpp+++ b/src/plugins/intel_gpu/src/graph/paged_attention.cpp@@ -21,7 +21,7 @@ layout paged_attention_inst::calc_output_layout(const paged_attention_node& /*notemplate<typename ShapeType>std::vector<layout> paged_attention_inst::calc_output_layouts(paged_attention_node const& /*node*/, kernel_impl_params const& impl_param) {- const auto& q_layout = impl_param.get_input_layout(0);+ const auto& q_layout = impl_param.get_input_layout(cldnn::paged_attention::PagedAttentionInputIdx::QUERY);const auto& desc = impl_param.typed_desc<paged_attention>();auto data_layout = q_layout;@@ -34,14 +34,26 @@ std::vector<layout> paged_attention_inst::calc_output_layouts(paged_attention_nodata_layout.data_padding = padding();- const auto& key_cache_ps = impl_param.get_input_layout(3).get_partial_shape();- bool valid_block_size = key_cache_ps[3].is_dynamic() || key_cache_ps[3].get_length() == paged_attention::block_size;- OPENVINO_ASSERT(valid_block_size, "[GPU] Incorrect block size for Paged Attention operation. "- "Expected ", paged_attention::block_size, ", but got ", key_cache_ps[3].get_length());+ const auto& key_cache_idx = cldnn::paged_attention::PagedAttentionInputIdx::KEY_CACHE;+ const auto& key_cache_ps = impl_param.get_input_layout(key_cache_idx).get_partial_shape();+ const auto& key_cache_quant_mode = impl_param.get_program().get_config().get_key_cache_quant_mode();+ bool key_cache_compressed = impl_param.get_input_layout(key_cache_idx).data_type == ov::element::i8 ||+ impl_param.get_input_layout(key_cache_idx).data_type == ov::element::u8;+ auto expected_block_size = paged_attention::block_size;+ if (key_cache_compressed && key_cache_quant_mode == ov::internal::CacheQuantMode::BY_CHANNEL) {+ expected_block_size += 4;+ }+ OPENVINO_ASSERT((key_cache_quant_mode == ov::internal::CacheQuantMode::BY_CHANNEL) == desc->is_key_by_channel,+ "[GPU] Paged Attention key cache quantization mode mismatch: prim.is_key_by_channel : ",+ desc->is_key_by_channel, " but exec_config : ", impl_param.get_program().get_config().get_key_cache_quant_mode());+ bool valid_block_size = key_cache_ps.is_dynamic() ||+ (key_cache_ps[key_cache_idx].get_length() == static_cast<long int>(expected_block_size));+ OPENVINO_ASSERT(valid_block_size, "[GPU] Incorrect block size for Paged Attention operation for key cache quant mode "+ , key_cache_quant_mode, ". Expected ", expected_block_size, ", but got ", key_cache_ps[key_cache_idx].get_length());std::vector<layout> output_layouts{ data_layout };if (desc->has_scores_output()) {- const auto past_lens_idx = 5;+ const auto past_lens_idx = cldnn::paged_attention::PagedAttentionInputIdx::PAST_LENS;const auto output_dt = data_layout.data_type;if (impl_param.get_input_layout(past_lens_idx).is_static()) {const auto& memory_deps = impl_param.memory_deps;@@ -83,9 +95,10 @@ std::string paged_attention_inst::to_string(const paged_attention_node& node) {paged_attention_info.add("has_alibi", desc->has_alibi);paged_attention_info.add("has_score_aggregation", desc->has_score_aggregation);paged_attention_info.add("has_rotated_blocks", desc->has_rotated_blocks);- paged_attention_info.add("key_cache_dt", node.get_input_layout(3).data_type);- paged_attention_info.add("value_cache_dt", node.get_input_layout(4).data_type);+ paged_attention_info.add("key_cache_dt", node.get_input_layout(cldnn::paged_attention::PagedAttentionInputIdx::KEY_CACHE).data_type);+ paged_attention_info.add("value_cache_dt", node.get_input_layout(cldnn::paged_attention::PagedAttentionInputIdx::VALUE_CACHE).data_type);paged_attention_info.add("score_output", desc->has_scores_output());+ paged_attention_info.add("is_key_by_channel", desc->is_key_by_channel);paged_attention_info.add("score_aggregation", desc->has_score_aggregation);node_info->add("paged_attention primitive info", paged_attention_info);node_info->dump(primitive_description);diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_kv_cache_update_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_kv_cache_update_ref.clindex 96dc47c1b6e..f56e24294ae 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_kv_cache_update_ref.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_kv_cache_update_ref.cl@@ -4,7 +4,7 @@#include "include/batch_headers/common.cl"-inline void FUNC(quantize_and_save)(__global const INPUT0_TYPE* in_data,+inline void FUNC(quantize_and_save_per_token)(__global const INPUT0_TYPE* in_data,const uint in_data_offset,__global OUTPUT_TYPE* out_data,const uint out_data_offset,@@ -51,6 +51,129 @@ inline void FUNC(quantize_and_save)(__global const INPUT0_TYPE* in_data,}}+#ifdef IS_KEY_BY_CHANNEL+#define COMP_K_OFFSET PAGED_ATTENTION_BLOCK_SIZE+#define NUM_HEAD_SIZE_GROUPS K_HEAD_SIZE / SUBGROUP_SIZE+inline void FUNC(quantize_and_save_by_channel_block_with_requantize)(__global const INPUT0_TYPE* in_data,+ const uint in_data_offset,+ const uint in_data_pitch,+ __global OUTPUT_TYPE* out_data,+ const uint out_data_offset,+ const uint out_data_pitch,+ const uint token_pos_in_block,+ const uint new_tokens_num,+ const uint sglid) {+ for (int h_sub = 0; h_sub < NUM_HEAD_SIZE_GROUPS; h_sub++) {+ const int hidden_idx = h_sub * SUBGROUP_SIZE + sglid;+ const uint out_offset_per_wi = out_data_offset + hidden_idx * out_data_pitch;+ // Read original scale and zp+ INPUT0_TYPE* comp_ptr = (INPUT0_TYPE*) (&out_data[out_offset_per_wi + COMP_K_OFFSET]);+ const INPUT0_TYPE orig_scale = comp_ptr[0];+ const INPUT0_TYPE orig_zp = comp_ptr[1];+ INPUT0_TYPE max_value = INPUT0_VAL_MIN;+ INPUT0_TYPE min_value = INPUT0_VAL_MAX;+ // Read new input+ #define READ_SIZE 16+ #define OUT_DATA_VEC MAKE_VECTOR_TYPE(OUTPUT_TYPE, READ_SIZE)+ #define IN_DATA_VEC MAKE_VECTOR_TYPE(INPUT0_TYPE, READ_SIZE)+ #define VLOAD CAT(vload, READ_SIZE)+ IN_DATA_VEC cache_data_vec_decompressed;+ for (int j = 0; j < new_tokens_num; ++j) {+ INPUT0_TYPE new_token = BLOCK_READN(INPUT0_TYPE, 1, in_data, in_data_offset + j * K_HEAD_SIZE * KV_HEADS_NUM + h_sub * SUBGROUP_SIZE);+ // Read a hidden dim of the previously quantized cache => decompress+ // TODO : current block size is 16 (same as PA block size),+ // but when the block size becomes different, this part should be updated as well+ cache_data_vec_decompressed[token_pos_in_block + j] = new_token;+ INPUT0_TYPE max_value = fmax(max_value, new_token);+ INPUT0_TYPE min_value = fmin(min_value, new_token);+ }+ OUT_DATA_VEC prev_cache_data_vec = VLOAD(0, out_data + out_offset_per_wi);+ #undef READ_SIZE+ #undef VLOAD+ #undef DATA_VEC+ for (int j = 0; j < token_pos_in_block + new_tokens_num; ++j) {+ if (j < token_pos_in_block) {+ INPUT0_TYPE decompressed_cache_val = ((INPUT0_TYPE)prev_cache_data_vec[j] - orig_zp) * orig_scale;+ cache_data_vec_decompressed[j] = decompressed_cache_val;+ }+ max_value = fmax(max_value, cache_data_vec_decompressed[j]);+ min_value = fmin(min_value, cache_data_vec_decompressed[j]);+ }+ // requantize and store+ {+ #define ACCUMULATOR_TYPE float+ ACCUMULATOR_TYPE range = max_value - min_value;+ const ACCUMULATOR_TYPE min_range = fabs(max_value * 0.1f);+ if (range <= min_range) {+ // When the range is very small, expand the range to avoid zp overflow+ range += fmax(1.0f, min_range);+ }+ ACCUMULATOR_TYPE scale_tmp = (ACCUMULATOR_TYPE)((CHAR_MAX - CHAR_MIN) / range);+ ACCUMULATOR_TYPE zp_tmp = (ACCUMULATOR_TYPE)(-min_value * scale_tmp) + CHAR_MIN;+ INPUT0_TYPE scale = (INPUT1_TYPE)(scale_tmp);+ INPUT0_TYPE zp = (INPUT1_TYPE)(zp_tmp);+ #undef ACCUMULATOR_TYPE++ for (uint token = 0; token < token_pos_in_block + new_tokens_num; ++token) {+ OUTPUT_TYPE quantized = convert_char_rte(cache_data_vec_decompressed[token] * scale + zp);+ out_data[out_offset_per_wi + token] = quantized;+ }+ comp_ptr[0] = 1.0/scale;+ comp_ptr[1] = zp;+ }+ }+}++inline void FUNC(quantize_and_save_by_channel_prefill)(__global const INPUT0_TYPE* in_data,+ const uint in_data_offset,+ const uint in_data_pitch,+ __global OUTPUT_TYPE* out_data,+ const uint out_data_offset,+ const uint tokens_num,+ //const uint token_start_pos_key,+ const uint sglid) {+ uint out_offset = out_data_offset;+ for (uint i = 0; i < NUM_HEAD_SIZE_GROUPS; i++) {+ uint key_in_offset_tmp = in_data_offset + i * SUBGROUP_SIZE;+ INPUT0_TYPE input_data[PAGED_ATTENTION_BLOCK_SIZE];+ INPUT0_TYPE max_value = INPUT0_VAL_MIN;+ INPUT0_TYPE min_value = INPUT0_VAL_MAX;+ // Read 16 tokens x 16 hidden+ unroll_for (uint token_num = 0; token_num < tokens_num; token_num++) {+ input_data[token_num] = BLOCK_READN(INPUT0_TYPE, 1, in_data, key_in_offset_tmp + sglid);+ max_value = fmax(max_value, input_data[token_num]);+ min_value = fmin(min_value, input_data[token_num]);+ key_in_offset_tmp += in_data_pitch;+ }+ #define ACCUMULATOR_TYPE float+ ACCUMULATOR_TYPE range = max_value - min_value;+ const ACCUMULATOR_TYPE min_range = fabs(max_value * 0.1f);+ if (range <= min_range) {+ // When the range is very small, expand the range to avoid zp overflow+ range += fmax(1.0f, min_range);+ }+ ACCUMULATOR_TYPE scale_tmp = (ACCUMULATOR_TYPE)((CHAR_MAX - CHAR_MIN) / range);+ ACCUMULATOR_TYPE zp_tmp = (ACCUMULATOR_TYPE)(-min_value * scale_tmp) + CHAR_MIN;+ INPUT0_TYPE scale = (INPUT1_TYPE)(scale_tmp);+ INPUT0_TYPE zp = (INPUT1_TYPE)(zp_tmp);+ #undef ACCUMULATOR_TYPE+ // Quantize and save each hidden dim+ uint out_offset_per_wi = out_offset + sglid * ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE;+ // store comp_data+ INPUT0_TYPE* comp_ptr = (INPUT0_TYPE*) (&out_data[out_offset_per_wi + COMP_K_OFFSET]);+ comp_ptr[0] = 1.0 / scale;+ comp_ptr[1] = zp;+ // Store quantized key+ for (uint token_num = 0; token_num < tokens_num; token_num++) {+ OUTPUT_TYPE res = convert_char_rte(input_data[token_num] * scale + zp);+ out_data[out_offset_per_wi] = res;+ out_offset_per_wi++;+ }+ out_offset += ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE * SUBGROUP_SIZE;+ }+}+#endif+REQD_SUB_GROUP_SIZE(SUBGROUP_SIZE)__attribute__((reqd_work_group_size(1, 1, SUBGROUP_SIZE)))KERNEL(pa_kv_cache_update)(@@ -70,33 +193,33 @@ KERNEL(pa_kv_cache_update)() {// If the the number of new tokens equals to the number of past_lens elements,// then it's the 2nd+ iteration+ const uint KEY_IN_STRIDE = KV_HEADS_NUM * K_HEAD_SIZE + INPUT0_PAD_AFTER_FEATURE_NUM + INPUT0_PAD_BEFORE_FEATURE_NUM;+ const uint VAL_IN_STRIDE = KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM;+ #ifdef IS_KEY_BY_CHANNEL+ const int k_hidden_stride = ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE;+ #endifif (!is_prefill_stage) {// 2nd+ tokenconst uint seq_idx = (uint)get_global_id(0);const uint head_idx = (uint)get_global_id(1);const uint sglid = (uint)get_global_id(2);- const uint seq_len = past_lens[seq_idx];- const uint current_token_pos_in_block = seq_len % PAGED_ATTENTION_BLOCK_SIZE;- const uint seq_block_idx = block_indices_begins[seq_idx] + seq_len / PAGED_ATTENTION_BLOCK_SIZE;+ const uint past_seq_len = past_lens[seq_idx];+ const uint current_token_pos_in_block = past_seq_len % PAGED_ATTENTION_BLOCK_SIZE;+ const uint seq_block_idx = block_indices_begins[seq_idx] + past_seq_len / PAGED_ATTENTION_BLOCK_SIZE;const uint block_idx = block_indices[seq_block_idx];+ uint key_in_offset = INPUT0_OFFSET + seq_idx * KEY_IN_STRIDE + head_idx * K_HEAD_SIZE;+ uint value_in_offset = INPUT1_OFFSET + seq_idx * VAL_IN_STRIDE + head_idx * V_HEAD_SIZE;- uint key_in_offset = INPUT0_OFFSET +- seq_idx * (KV_HEADS_NUM * K_HEAD_SIZE + INPUT0_PAD_BEFORE_FEATURE_NUM + INPUT0_PAD_AFTER_FEATURE_NUM) +- head_idx * K_HEAD_SIZE;- uint value_in_offset = INPUT1_OFFSET +- seq_idx * (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_BEFORE_FEATURE_NUM + INPUT1_PAD_AFTER_FEATURE_NUM) +- head_idx * V_HEAD_SIZE;-+ #ifdef IS_KEY_BY_CHANNEL+ uint block_k_base_offset = block_idx * KV_HEADS_NUM * ADJUSTED_K_HEAD_SIZE * ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE + head_idx * ADJUSTED_K_HEAD_SIZE * ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE;+ #else // can it be shared?uint block_k_base_offset = block_idx * KV_HEADS_NUM * ADJUSTED_K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE + head_idx * ADJUSTED_K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;+ #endifuint block_v_base_offset = block_idx * KV_HEADS_NUM * ADJUSTED_V_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE + head_idx * ADJUSTED_V_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;uint key_out_offset = block_k_base_offset + current_token_pos_in_block;uint value_out_offset = block_v_base_offset + current_token_pos_in_block * V_HEAD_SIZE;- const uint comp_k_offset = block_k_base_offset + K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;- const uint comp_v_offset = block_v_base_offset + V_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;-#if !IS_KV_COMPRESSED-#define READ_K_BLOCK_SIZE GENERATE_STAGE_K_BLOCK_SIZEfor (uint head_idx_index = 0; head_idx_index < K_HEAD_SIZE; head_idx_index += SUBGROUP_SIZE * READ_K_BLOCK_SIZE) {#define BLOCK_READ(ptr, offset) BLOCK_READN(INPUT0_TYPE, READ_K_BLOCK_SIZE, ptr, offset);@@ -130,28 +253,44 @@ KERNEL(pa_kv_cache_update)(#endif}}-#else // IS_KV_COMPRESSED+ #ifdef IS_KEY_BY_CHANNEL{+ FUNC_CALL(quantize_and_save_by_channel_block_with_requantize)(key_data,+ key_in_offset,+ KEY_IN_STRIDE,+ key_cache_data,+ block_k_base_offset,+ k_hidden_stride,+ current_token_pos_in_block,+ 1,+ sglid);+ }+ #else // Key per token+ {+ const uint comp_k_offset = block_k_base_offset + K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;// key processingINPUT0_TYPE input_data[K_HEAD_SIZE / SUBGROUP_SIZE];- FUNC_CALL(quantize_and_save)(key_data, key_in_offset, key_cache_data, key_out_offset, PAGED_ATTENTION_BLOCK_SIZE, comp_k_offset,+ FUNC_CALL(quantize_and_save_per_token)(key_data, key_in_offset, key_cache_data, key_out_offset, PAGED_ATTENTION_BLOCK_SIZE, comp_k_offset,current_token_pos_in_block, sglid, K_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);}-+ #endif+ // value per token{- // value processing+ const uint comp_v_offset = block_v_base_offset + V_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;INPUT0_TYPE input_data[V_HEAD_SIZE / SUBGROUP_SIZE];- FUNC_CALL(quantize_and_save)(value_data, value_in_offset, value_cache_data, value_out_offset, 1, comp_v_offset,+ FUNC_CALL(quantize_and_save_per_token)(value_data, value_in_offset, value_cache_data, value_out_offset, 1, comp_v_offset,current_token_pos_in_block, sglid, V_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);}#endif // IS_KV_COMPRESSED} else {+// 1st tokenconst uint block_idx = get_global_id(0);const uint head_idx = get_global_id(1);const uint sglid = get_global_id(2);+const uint subsequence_idx = gws_seq_indexes_correspondence[block_idx];const uint subsequence_begin_idx = subsequence_begins[subsequence_idx];@@ -159,37 +298,69 @@ KERNEL(pa_kv_cache_update)(const uint block_end_pos = blocked_indexes_end[block_idx];const uint tokens_num = block_end_pos - block_start_pos;const uint past_len = past_lens[subsequence_idx];+ const uint token_start_pos_key = (past_len + block_start_pos - subsequence_begin_idx) % PAGED_ATTENTION_BLOCK_SIZE;+ const uint token_start_pos_val = (past_len + block_start_pos - subsequence_begin_idx) % PAGED_ATTENTION_BLOCK_SIZE;- const uint token_start_pos = (past_len + block_start_pos - subsequence_begin_idx) % PAGED_ATTENTION_BLOCK_SIZE;-- uint key_in_offset = INPUT0_OFFSET +- block_start_pos * (KV_HEADS_NUM * K_HEAD_SIZE + INPUT0_PAD_AFTER_FEATURE_NUM + INPUT0_PAD_BEFORE_FEATURE_NUM) +- head_idx * K_HEAD_SIZE;+ uint key_in_offset = INPUT0_OFFSET + block_start_pos * KEY_IN_STRIDE + head_idx * K_HEAD_SIZE;- uint value_in_offset = INPUT1_OFFSET +- block_start_pos * (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM) +- head_idx * V_HEAD_SIZE;+ uint value_in_offset = INPUT1_OFFSET + block_start_pos * VAL_IN_STRIDE + head_idx * V_HEAD_SIZE;const uint current_block_idx = (past_len + block_start_pos - subsequence_begin_idx) / PAGED_ATTENTION_BLOCK_SIZE;const uint block_offset = block_indices_begins[subsequence_idx] + current_block_idx;+ #if defined(IS_KV_COMPRESSED) && defined(IS_KEY_BY_CHANNEL)+ uint block_k_base_offset = block_indices[block_offset] * KV_HEADS_NUM * ADJUSTED_K_HEAD_SIZE * ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE ++ head_idx * ADJUSTED_K_HEAD_SIZE * ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE;+ uint key_out_offset = block_k_base_offset;+ #elseuint block_k_base_offset = block_indices[block_offset] * KV_HEADS_NUM * ADJUSTED_K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE +head_idx * ADJUSTED_K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;uint key_out_offset = block_k_base_offset;+ const uint comp_k_offset = block_k_base_offset + K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;+ key_out_offset += token_start_pos_key;+ #endif+uint block_v_base_offset = block_indices[block_offset] * KV_HEADS_NUM * ADJUSTED_V_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE +head_idx * ADJUSTED_V_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;- uint value_out_offset = block_v_base_offset;- const uint comp_k_offset = block_k_base_offset + K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;const uint comp_v_offset = block_v_base_offset + V_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;-- key_out_offset += token_start_pos;- value_out_offset += token_start_pos * V_HEAD_SIZE;-+ uint value_out_offset = block_v_base_offset;+ value_out_offset += token_start_pos_val * V_HEAD_SIZE;if (tokens_num == PAGED_ATTENTION_BLOCK_SIZE) {+ // block is full+ #if defined(IS_KV_COMPRESSED) && defined(IS_KEY_BY_CHANNEL)+ // Key by channel+ if (token_start_pos_key != 0) {+ // mixed mode => need requantize with prev tokens+ FUNC_CALL(quantize_and_save_by_channel_block_with_requantize)(key_data,+ key_in_offset,+ KEY_IN_STRIDE,+ key_cache_data,+ block_k_base_offset,+ k_hidden_stride,+ token_start_pos_key,+ tokens_num,+ sglid);+ } else {+ FUNC_CALL(quantize_and_save_by_channel_prefill)(key_data,+ key_in_offset,+ KEY_IN_STRIDE,+ key_cache_data,+ key_out_offset,+ tokens_num,+ sglid);+ }+ // Value per token+ unroll_for (uint token_num = 0; token_num < tokens_num; token_num++) {+ INPUT0_TYPE input_data[V_HEAD_SIZE / SUBGROUP_SIZE];+ FUNC_CALL(quantize_and_save_per_token)(value_data, value_in_offset, value_cache_data, value_out_offset, 1,+ comp_v_offset, token_num, sglid, V_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);+ value_in_offset += (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM);+ value_out_offset += V_HEAD_SIZE;+ }+ #else // defined(IS_KV_COMPRESSED) && defined(IS_KEY_BY_CHANNEL)unroll_for (uint token_num = 0; token_num < PAGED_ATTENTION_BLOCK_SIZE; token_num++) {--#if !IS_KV_COMPRESSED+ #if !IS_KV_COMPRESSED{uint head_idx_index = 0;@@ -245,7 +416,6 @@ KERNEL(pa_kv_cache_update)(}}}-{uint v_head_idx_index = 0;@@ -303,33 +473,64 @@ KERNEL(pa_kv_cache_update)(}}}--#else // IS_KV_COMPRESSED+ #else // IS_KV_COMPRESSED{- // key processing+ // Key per tokenINPUT0_TYPE input_data[K_HEAD_SIZE / SUBGROUP_SIZE];- FUNC_CALL(quantize_and_save)(key_data, key_in_offset, key_cache_data, key_out_offset, PAGED_ATTENTION_BLOCK_SIZE,+ FUNC_CALL(quantize_and_save_per_token)(key_data, key_in_offset, key_cache_data, key_out_offset, PAGED_ATTENTION_BLOCK_SIZE,comp_k_offset, token_num, sglid, K_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);}-{- // value processing+ // Value per tokenINPUT0_TYPE input_data[V_HEAD_SIZE / SUBGROUP_SIZE];- FUNC_CALL(quantize_and_save)(value_data, value_in_offset, value_cache_data, value_out_offset, 1,+ FUNC_CALL(quantize_and_save_per_token)(value_data, value_in_offset, value_cache_data, value_out_offset, 1,comp_v_offset, token_num, sglid, V_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);}-#endif // IS_KV_COMPRESSED-+ #endif // IS_KV_COMPRESSEDkey_in_offset += (KV_HEADS_NUM * K_HEAD_SIZE + INPUT0_PAD_AFTER_FEATURE_NUM + INPUT0_PAD_BEFORE_FEATURE_NUM);- value_in_offset += (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM);key_out_offset += 1;+ value_in_offset += (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM);value_out_offset += V_HEAD_SIZE;}+ #endif // defined(IS_KV_COMPRESSED) && defined(IS_KEY_BY_CHANNEL)} else {+ // block with leftover tokens+ #if defined(IS_KV_COMPRESSED) && defined(IS_KEY_BY_CHANNEL)+ // key processing by channel+ if (token_start_pos_key != 0) {+ // mixed mode => need requantize with prev tokens+ FUNC_CALL(quantize_and_save_by_channel_block_with_requantize)(key_data,+ key_in_offset,+ KEY_IN_STRIDE,+ key_cache_data,+ block_k_base_offset,+ k_hidden_stride,+ token_start_pos_key,+ tokens_num,+ sglid);+ } else {+ FUNC_CALL(quantize_and_save_by_channel_prefill)(key_data,+ key_in_offset,+ KEY_IN_STRIDE,+ key_cache_data,+ key_out_offset,+ tokens_num,+ sglid);+ }++ // value processing per token+ for (uint token_num = 0; token_num < tokens_num; token_num++) {+ INPUT0_TYPE input_data[V_HEAD_SIZE / SUBGROUP_SIZE];+ FUNC_CALL(quantize_and_save_per_token)(value_data, value_in_offset, value_cache_data, value_out_offset, 1,+ comp_v_offset, token_start_pos_val + token_num, sglid, V_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);+ value_in_offset += (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM);+ value_out_offset += V_HEAD_SIZE;+ }+ #else // defined(IS_KV_COMPRESSED) && defined(IS_KEY_BY_CHANNEL)for (uint token_num = 0; token_num < tokens_num; token_num++) {uint head_idx_index = 0;-#if !IS_KV_COMPRESSED+ #if !IS_KV_COMPRESSED#define READ_BLOCK_SIZE 1#define BLOCK_READ(ptr, offset) BLOCK_READN(INPUT0_TYPE, READ_BLOCK_SIZE, ptr, offset);#define DATA_VEC MAKE_VECTOR_TYPE(INPUT0_TYPE, READ_BLOCK_SIZE)@@ -351,27 +552,26 @@ KERNEL(pa_kv_cache_update)(}}-#else // IS_KV_COMPRESSED+ #else // IS_KV_COMPRESSED{// key processingINPUT0_TYPE input_data[K_HEAD_SIZE / SUBGROUP_SIZE];- FUNC_CALL(quantize_and_save)(key_data, key_in_offset, key_cache_data, key_out_offset, PAGED_ATTENTION_BLOCK_SIZE,- comp_k_offset, token_start_pos + token_num, sglid, K_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);+ FUNC_CALL(quantize_and_save_per_token)(key_data, key_in_offset, key_cache_data, key_out_offset, PAGED_ATTENTION_BLOCK_SIZE,+ comp_k_offset, token_start_pos_key + token_num, sglid, K_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);}-{// value processingINPUT0_TYPE input_data[V_HEAD_SIZE / SUBGROUP_SIZE];- FUNC_CALL(quantize_and_save)(value_data, value_in_offset, value_cache_data, value_out_offset, 1,- comp_v_offset, token_start_pos + token_num, sglid, V_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);+ FUNC_CALL(quantize_and_save_per_token)(value_data, value_in_offset, value_cache_data, value_out_offset, 1,+ comp_v_offset, token_start_pos_val + token_num, sglid, V_HEAD_SIZE / SUBGROUP_SIZE, &input_data[0]);}-#endif // IS_KV_COMPRESSED+ #endif // IS_KV_COMPRESSEDkey_in_offset += (KV_HEADS_NUM * K_HEAD_SIZE + INPUT0_PAD_AFTER_FEATURE_NUM + INPUT0_PAD_BEFORE_FEATURE_NUM);- value_in_offset += (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM);key_out_offset += 1;+ value_in_offset += (KV_HEADS_NUM * V_HEAD_SIZE + INPUT1_PAD_AFTER_FEATURE_NUM + INPUT1_PAD_BEFORE_FEATURE_NUM);value_out_offset += V_HEAD_SIZE;-}+ #endif // defined(IS_KV_COMPRESSED) && defined(IS_KEY_BY_CHANNEL)}}}diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_sdpa_opt.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_sdpa_opt.clindex 331287f5b63..6d0fe3c27ae 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_sdpa_opt.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/pa_sdpa_opt.cl@@ -210,17 +210,29 @@ KERNEL(pa_sdpa_opt)(const uint start_block_idx = block_indices_begins[subsequence_idx] + partition_idx * PAGED_ATTENTION_BLOCKS_PER_PARTITION + sgid;for (uint block_num = 0; block_num < blocks_num; block_num++) {const uint head_idx = head_num_idx / KV_HEADS_GROUP_SIZE;- const uint block_offset = block_indices[start_block_idx + block_num * SUBGROUPS_PER_WG] * ADJUSTED_K_HEAD_SIZE * KV_HEADS_NUM * SUBGROUP_SIZE + head_idx * ADJUSTED_K_HEAD_SIZE * SUBGROUP_SIZE;+ const uint block_indice = block_indices[start_block_idx + block_num * SUBGROUPS_PER_WG];SOFTMAX_ACCUMULATOR_VEC_TYPE qk_acc = SOFTMAX_ACCUMULATOR_VAL_ZERO;#define KEY_VEC_SIZE SUBGROUP_SIZE#define KEY_BLOCK MAKE_VECTOR_TYPE(INPUT1_TYPE, KEY_VEC_SIZE)#if IS_KV_COMPRESSED- const uint key_comp_offset = block_offset + K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;+ #ifdef IS_KEY_BY_CHANNEL+ const uint head_stride = ADJUSTED_K_HEAD_SIZE * ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE;+ const uint block_stride = KV_HEADS_NUM * head_stride;+ const uint key_block_offset = block_indice * block_stride + head_idx * head_stride;+ const uint hidden_stride = ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE;+ #else+ const uint block_offset = block_indice * ADJUSTED_K_HEAD_SIZE * KV_HEADS_NUM * SUBGROUP_SIZE + head_idx * ADJUSTED_K_HEAD_SIZE * SUBGROUP_SIZE;+ const key_block_offset = block_offset;+ const hidden_stride = SUBGROUP_SIZE;+ const uint key_comp_offset = key_block_offset + K_HEAD_SIZE * PAGED_ATTENTION_BLOCK_SIZE;INPUT0_TYPE* key_comp_ptr = key_cache + key_comp_offset;INPUT0_TYPE comp_scale = key_comp_ptr[0 + sglid];INPUT0_TYPE comp_zp = key_comp_ptr[PAGED_ATTENTION_BLOCK_SIZE + sglid];+ #endif+#else+ const uint block_offset = block_indice * ADJUSTED_K_HEAD_SIZE * KV_HEADS_NUM * SUBGROUP_SIZE + head_idx * ADJUSTED_K_HEAD_SIZE * SUBGROUP_SIZE;#endifunroll_for (uint qk_idx = 0; qk_idx < K_HEAD_SIZE / KEY_VEC_SIZE; qk_idx++) {@@ -228,10 +240,23 @@ KERNEL(pa_sdpa_opt)(#define TO_KEY_BLOCK_UNCOMPRESSED_TYPE(val) CAT(convert_, KEY_BLOCK_UNCOMPRESSED)(val)#if IS_KV_COMPRESSED+ #ifdef IS_KEY_BY_CHANNEL+ const uint key_comp_offset = key_block_offset + qk_idx * SUBGROUP_SIZE * hidden_stride + sglid * hidden_stride + PAGED_ATTENTION_BLOCK_SIZE;+ INPUT0_TYPE* key_comp_ptr = key_cache + key_comp_offset;+ INPUT0_TYPE comp_scale = key_comp_ptr[0];+ INPUT0_TYPE comp_zp = key_comp_ptr[1];+ #endif+KEY_BLOCK_UNCOMPRESSED k_vals;unroll_for (uint i = 0; i < KEY_VEC_SIZE; i++) {- k_vals[i] = BLOCK_READN(INPUT1_TYPE, 1, key_cache, block_offset + qk_idx * SUBGROUP_SIZE * KEY_VEC_SIZE + i * SUBGROUP_SIZE);+ k_vals[i] = BLOCK_READN(INPUT1_TYPE, 1, key_cache, key_block_offset + qk_idx * hidden_stride * KEY_VEC_SIZE + i * hidden_stride);+ #ifdef IS_KEY_BY_CHANNEL+ INPUT0_TYPE key_orig = k_vals[i];+ k_vals[i] = (k_vals[i] - _sub_group_shuffle(comp_zp, i)) * _sub_group_shuffle(comp_scale, i);+ #else+ half key_orig = k_vals[i];k_vals[i] = (k_vals[i] - comp_zp) * comp_scale;+ #endif}#elseKEY_BLOCK k_vals = 0;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.cppindex 541ebf018b7..4d470f59a4a 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.cpp@@ -136,10 +136,17 @@ JitConstants KVCacheUpdateKernelRef::GetJitConstants(const kv_cache_update_paramif (params.conf.is_kv_compressed) {auto scales_zp_size = params.inputs[0].ElementSize() * 2; // scale + zp- jit.AddConstant(MakeJitConstant("SCALE_ZP_SIZE_PER_TOKEN", scales_zp_size));- jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size + scales_zp_size));+ if (params.is_key_by_channel) {+ jit.AddConstant(MakeJitConstant("IS_KEY_BY_CHANNEL", 1));+ jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size));+ jit.AddConstant(MakeJitConstant("ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE", paged_attention_block_size + scales_zp_size));+ } else {+ jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size + scales_zp_size));+ jit.AddConstant(MakeJitConstant("ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE", paged_attention_block_size));+ }jit.AddConstant(MakeJitConstant("ADJUSTED_V_HEAD_SIZE", params.conf.v_head_size + scales_zp_size));} else {+ jit.AddConstant(MakeJitConstant("ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE", paged_attention_block_size));jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size));jit.AddConstant(MakeJitConstant("ADJUSTED_V_HEAD_SIZE", params.conf.v_head_size));}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.hindex 020426b0c3b..f90569afdcd 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_kv_cache_update_kernel_ref.h@@ -12,6 +12,8 @@ namespace kernel_selector {struct kv_cache_update_params : base_params {kv_cache_update_params() : base_params(KernelType::PA_KV_CACHE_UPDATE) {}+ bool is_key_by_channel = false;+ int32_t key_group_size = 0;bool is_prefill = false;sdpa_configuration conf;};diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_sdpa_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_sdpa_kernel_opt.cppindex b97d14f654e..35f9d3e4be4 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_sdpa_kernel_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/pa_sdpa_kernel_opt.cpp@@ -262,12 +262,19 @@ JitConstants PagedAttentionSDPAKernelOpt::GetJitConstants(const pa_sdpa_params&if (params.conf.is_kv_compressed) {auto scales_zp_size = params.inputs[0].ElementSize() * 2; // scale + zp- jit.AddConstant(MakeJitConstant("SCALE_ZP_SIZE_PER_TOKEN", scales_zp_size));- jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size + scales_zp_size));+ if (params.conf.is_key_by_channel) {+ jit.AddConstant(MakeJitConstant("IS_KEY_BY_CHANNEL", 1));+ jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size));+ jit.AddConstant(MakeJitConstant("ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE", paged_attention_block_size + scales_zp_size));+ } else {+ jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size + scales_zp_size));+ jit.AddConstant(MakeJitConstant("ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE", paged_attention_block_size));+ }jit.AddConstant(MakeJitConstant("ADJUSTED_V_HEAD_SIZE", params.conf.v_head_size + scales_zp_size));} else {jit.AddConstant(MakeJitConstant("ADJUSTED_K_HEAD_SIZE", params.conf.k_head_size));jit.AddConstant(MakeJitConstant("ADJUSTED_V_HEAD_SIZE", params.conf.v_head_size));+ jit.AddConstant(MakeJitConstant("ADJUSTED_PAGED_ATTENTION_BLOCK_SIZE", paged_attention_block_size));}if (kernel_idx == KernelsTypes::SINGLE_TOKEN_GQA) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/sdpa_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/sdpa_kernel_base.hindex c0408d5ee65..eef169f0b28 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/sdpa_kernel_base.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sdpa/sdpa_kernel_base.h@@ -90,6 +90,7 @@ struct sdpa_configuration {bool is_causal = false;bool has_alibi_input = false;bool is_kv_compressed = false;+ bool is_key_by_channel = false;bool use_asymmetric_quantization = false;bool combine_scales_and_zp = false;bool per_head_quantization = false;diff --git a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp b/src/plugins/intel_gpu/src/plugin/compiled_model.cppindex 27c9a296403..9f1c226f762 100644--- a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp+++ b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp@@ -278,6 +278,8 @@ ov::Any CompiledModel::get_property(const std::string& name) const {ov::PropertyName{ov::hint::dynamic_quantization_group_size.name(), PropertyMutability::RO},ov::PropertyName{ov::hint::activations_scale_factor.name(), PropertyMutability::RO},ov::PropertyName{ov::hint::kv_cache_precision.name(), PropertyMutability::RO},+ ov::PropertyName{ov::internal::key_cache_quant_mode.name(), PropertyMutability::RO},+ ov::PropertyName{ov::internal::value_cache_quant_mode.name(), PropertyMutability::RO},ov::PropertyName{ov::device::id.name(), PropertyMutability::RO},ov::PropertyName{ov::execution_devices.name(), PropertyMutability::RO},};diff --git a/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cpp b/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cppindex 8940ff35229..113238527dd 100644--- a/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cpp@@ -86,7 +86,7 @@ static void CreatePagedAttentionExtensionOp(ProgramBuilder& p, const std::shared}prim.has_rotated_blocks = op->get_input_size() > cldnn::paged_attention::PagedAttentionInputIdx::ROTATION_TRIG_LUT;-+ prim.is_key_by_channel = p.get_config().get_key_cache_quant_mode() == ov::internal::CacheQuantMode::BY_CHANNEL;prim.num_outputs = 1;if (op->get_output_size() > 1) {diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cppindex b1e75602f48..9c806c7673d 100644--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp@@ -16,6 +16,7 @@#include "intel_gpu/runtime/debug_configuration.hpp"#include "intel_gpu/runtime/itt.hpp"+#include "intel_gpu/primitives/paged_attention.hpp"#include "low_precision/add.hpp"#include "low_precision/concat.hpp"#include "low_precision/convolution.hpp"@@ -57,6 +58,7 @@#include "openvino/op/rnn_sequence.hpp"#include "openvino/op/scaled_dot_product_attention.hpp"#include "openvino/op/squeeze.hpp"+#include "openvino/op/paged_attention.hpp"#include "openvino/op/unsqueeze.hpp"#include "openvino/op/util/sub_graph_base.hpp"#include "openvino/opsets/opset1_decl.hpp"@@ -480,18 +482,29 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {kv_cache_config.valueCachePrecision = config.get_kv_cache_precision();kv_cache_config.inferencePrecision = infer_precision;kv_cache_config.keyCacheBlockSize = 16;- kv_cache_config.valueCacheBlockSize = 16;kv_cache_config.keyCacheDimOrder = {0, 1, 3, 2};+ kv_cache_config.keyCacheQuantBychannel = (config.get_key_cache_quant_mode() == ov::internal::CacheQuantMode::BY_CHANNEL);+ kv_cache_config.keyCacheGroupSize = (config.get_key_cache_quant_mode() == ov::internal::CacheQuantMode::BY_CHANNEL) ? 16 : 0;+ kv_cache_config.valueCacheBlockSize = 16;kv_cache_config.valueCacheDimOrder = {0, 1, 2, 3};+ kv_cache_config.valueCacheQuantBychannel = false;+ kv_cache_config.valueCacheGroupSize = 0;+manager.register_pass<ov::pass::ConvertPagedAttnInputs>(kv_cache_config,[&infer_precision](const ov::element::Type& precision,const bool bychannel,const size_t group_num,int64_t& head_size,int64_t& block_size) {- OPENVINO_ASSERT(!bychannel, "[GPU] Unsupported KV-cache quantization mode");- if (precision == ov::element::i8 || precision == ov::element::u8) {- head_size += infer_precision.size() * 2 * group_num;+ if (bychannel) {+ // TODO: need to handle group size != block size case+ if (precision == ov::element::i8 || precision == ov::element::u8) {+ block_size += infer_precision.size() * 2;+ }+ } else {+ if (precision == ov::element::i8 || precision == ov::element::u8) {+ head_size += infer_precision.size() * 2 * group_num;+ }}});diff --git a/src/plugins/intel_gpu/src/runtime/execution_config.cpp b/src/plugins/intel_gpu/src/runtime/execution_config.cppindex 3c5e3e5cd62..e7ea0f179d1 100644--- a/src/plugins/intel_gpu/src/runtime/execution_config.cpp+++ b/src/plugins/intel_gpu/src/runtime/execution_config.cpp@@ -2,6 +2,7 @@// SPDX-License-Identifier: Apache-2.0//+#include "intel_gpu/primitives/paged_attention.hpp"#include "intel_gpu/runtime/execution_config.hpp"#include "intel_gpu/plugin/remote_context.hpp"#include "openvino/core/any.hpp"@@ -204,6 +205,16 @@ void ExecutionConfig::apply_model_specific_options(const IRemoteContext* context}}}++ // w/a : key_by_channel quant mode does not support cache rotation yet+ // CVS-170994+ if (auto paged_attn_op = ov::as_type_ptr<ov::op::PagedAttentionExtension>(op)) {+ bool has_rotated_blocks = paged_attn_op->get_input_size() > cldnn::paged_attention::PagedAttentionInputIdx::ROTATION_TRIG_LUT;+ if (has_rotated_blocks) {+ GPU_DEBUG_COUT << "[Warning] BY_CHANNEL quant mode is not supported for cache rotation yet. Switching to BY_TOKEN mode." << std::endl;+ m_key_cache_quant_mode = ov::internal::CacheQuantMode::BY_TOKEN;+ }+ }};for (const auto& op : ops) {@@ -211,6 +222,7 @@ void ExecutionConfig::apply_model_specific_options(const IRemoteContext* context}const auto& info = dynamic_cast<const RemoteContextImpl*>(context)->get_engine().get_device_info();+if (!is_set_by_user(ov::hint::kv_cache_precision) || get_kv_cache_precision() == ov::element::dynamic) {if (is_paged_attention_model || !info.supports_immad) {// Enable KV-cache compression by default for:@@ -222,10 +234,22 @@ void ExecutionConfig::apply_model_specific_options(const IRemoteContext* context}}+ if (!is_set_by_user(ov::internal::key_cache_quant_mode) || get_key_cache_quant_mode() == ov::internal::CacheQuantMode::AUTO) {+ m_key_cache_quant_mode = ov::internal::CacheQuantMode::BY_TOKEN;+ }++ if (!is_set_by_user(ov::internal::value_cache_quant_mode) || get_value_cache_quant_mode() == ov::internal::CacheQuantMode::AUTO) {+ m_value_cache_quant_mode = ov::internal::CacheQuantMode::BY_TOKEN;+ } else if (get_value_cache_quant_mode() == ov::internal::CacheQuantMode::BY_CHANNEL) {+ GPU_DEBUG_COUT << "[Warning] Value cache quantization mode BY_CHANNEL is not supported for GPU plugin. "+ << "Switching to BY_TOKEN mode." << std::endl;+ m_value_cache_quant_mode = ov::internal::CacheQuantMode::BY_TOKEN;+ }// Disable FlashAttn V2 online softmax tricks by default for non-LLMs.if (!is_set_by_user(ov::intel_gpu::could_use_flashattn_v2) && !is_LLM) {m_could_use_flashattn_v2 = false;}+m_optimize_data = true;}diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/paged_attention_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/paged_attention_gpu_test.cppindex ee1c72252b1..933da9f8d04 100644--- a/src/plugins/intel_gpu/tests/unit/test_cases/paged_attention_gpu_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/test_cases/paged_attention_gpu_test.cpp@@ -80,6 +80,7 @@ struct PagedAttentionManager {int block_size;int sliding_window_size;bool kv_cache_compression;+ ov::internal::CacheQuantMode key_cache_quant_mode;bool has_score_aggregation;CacheRotationDescriptor rotation_config;std::vector<SubsequenceDescriptor> subsequence_descs;@@ -119,6 +120,7 @@ struct PagedAttentionManager {int block_size,int sliding_window_size,bool kv_cache_compression,+ ov::internal::CacheQuantMode key_cache_quant_mode,bool has_score_aggregation,CacheRotationDescriptor rotation_config): num_heads(num_heads)@@ -127,6 +129,7 @@ struct PagedAttentionManager {, block_size(block_size), sliding_window_size(sliding_window_size), kv_cache_compression(kv_cache_compression)+ , key_cache_quant_mode(key_cache_quant_mode), has_score_aggregation(has_score_aggregation), rotation_config(rotation_config), subsequence_descs(subsequence_descs)@@ -214,16 +217,20 @@ struct PagedAttentionManager {memory::ptr get_key_cache_memory() {auto key_cache_dt = data_types::f16;auto adjusted_head_size = k_head_size;+ auto adjusted_block_size = block_size;if (kv_cache_compression) {key_cache_dt = data_types::i8;- adjusted_head_size += 4;+ if (key_cache_quant_mode == ov::internal::CacheQuantMode::BY_CHANNEL) {+ adjusted_block_size += 4;+ } else {+ adjusted_head_size += 4;+ }}auto num_blocks = block_indices.back() + 1;- auto key_cache_shape = ov::PartialShape{ num_blocks, num_heads, adjusted_head_size, block_size };+ auto key_cache_shape = ov::PartialShape{ num_blocks, num_heads, adjusted_head_size, adjusted_block_size };auto key_cache_layout = layout{ key_cache_shape, key_cache_dt, format::bfyx };auto memory = test_engine.allocate_memory(key_cache_layout);-for (int i = 0; i < static_cast<int>(subsequence_descs.size()); i++) {int past_len = subsequence_descs[i].past_len;if (past_len != 0) {@@ -232,32 +239,54 @@ struct PagedAttentionManager {for (int block_idx = 0; block_idx < blocks_num; block_idx++) {int last_token_idx = block_idx == blocks_num - 1 ? past_len % block_size: block_size;+ // quantize by channel+ if (kv_cache_compression && key_cache_quant_mode == ov::internal::CacheQuantMode::BY_CHANNEL) {+ for (int head_idx = 0; head_idx < num_heads; head_idx++) {+ for (int k_head_size_idx = 0; k_head_size_idx < k_head_size; k_head_size_idx++) {+ std::vector<ov::float16> token_block(block_size);+ for (int token_idx = 0; token_idx < last_token_idx; ++token_idx) {+ size_t input_token_offset = block_idx * block_size + token_idx;+ token_block[token_idx] = *(key_data[i].data() + input_token_offset * num_heads * k_head_size + head_idx * k_head_size + k_head_size_idx);+ }+ auto [quantized_data, scale, zp] = quantize_data(token_block.data(), last_token_idx, true);+ size_t output_block_offset = (start_block_idx + block_idx) * num_heads * adjusted_head_size * adjusted_block_size ++ head_idx * adjusted_head_size * adjusted_block_size;+ size_t output_offset = output_block_offset ++ k_head_size_idx * adjusted_block_size;+ set_values(test_stream, memory, quantized_data.data(), last_token_idx, output_offset);+ size_t comp_offset = (output_offset + block_size)/2;+ set_values(test_stream, memory, &scale, 1, comp_offset);+ set_values(test_stream, memory, &zp, 1, comp_offset + 1);+ }+ }+ }for (int token_idx = 0; token_idx < last_token_idx; token_idx++) {for (int head_idx = 0; head_idx < num_heads; head_idx++) {if (kv_cache_compression) {- size_t input_token_offset = block_idx * block_size + token_idx;- ov::float16* data_ptr = key_data[i].data() +- input_token_offset * num_heads * k_head_size +- head_idx * k_head_size;-- // shape: [num_blocks, num_heads, adjusted_head_size, block_size]- size_t output_block_offset = (start_block_idx + block_idx) * num_heads * adjusted_head_size * block_size +- head_idx * adjusted_head_size * block_size;-- auto [quantized_data, scale, zp] = quantize_data(data_ptr, k_head_size);- for (int k_head_size_idx = 0; k_head_size_idx < k_head_size; k_head_size_idx++) {- auto quantized_data_ptr = quantized_data.data() + k_head_size_idx;-- size_t output_offset = output_block_offset +- k_head_size_idx * block_size +- token_idx;-- set_values(test_stream, memory, quantized_data_ptr, 1, output_offset);+ if (key_cache_quant_mode == ov::internal::CacheQuantMode::BY_TOKEN) {+ // quantize by token+ size_t input_token_offset = block_idx * block_size + token_idx;+ ov::float16* data_ptr = key_data[i].data() ++ input_token_offset * num_heads * k_head_size ++ head_idx * k_head_size;+ // shape: [num_blocks, num_heads, adjusted_head_size, block_size]+ size_t output_block_offset = (start_block_idx + block_idx) * num_heads * adjusted_head_size * block_size ++ head_idx * adjusted_head_size * block_size;++ auto [quantized_data, scale, zp] = quantize_data(data_ptr, k_head_size);+ for (int k_head_size_idx = 0; k_head_size_idx < k_head_size; k_head_size_idx++) {+ auto quantized_data_ptr = quantized_data.data() + k_head_size_idx;++ size_t output_offset = output_block_offset ++ k_head_size_idx * block_size ++ token_idx;++ set_values(test_stream, memory, quantized_data_ptr, 1, output_offset);+ }+ size_t comp_offset = (output_block_offset + k_head_size * block_size) / 2;+ set_values(test_stream, memory, &scale, 1, comp_offset + token_idx);+ set_values(test_stream, memory, &zp, 1, comp_offset + block_size + token_idx);}-- size_t comp_offset = (output_block_offset + k_head_size * block_size) / 2;- set_values(test_stream, memory, &scale, 1, comp_offset + token_idx);- set_values(test_stream, memory, &zp, 1, comp_offset + block_size + token_idx);} else {for (int k_head_size_idx = 0; k_head_size_idx < k_head_size; k_head_size_idx++) {size_t input_token_offset = block_idx * block_size + token_idx;@@ -493,7 +522,7 @@ private:return data;}- static std::tuple<std::vector<int8_t>, ov::float16, ov::float16> quantize_data(ov::float16* data, size_t size) {+ static std::tuple<std::vector<int8_t>, ov::float16, ov::float16> quantize_data(ov::float16* data, size_t size, bool expand_range = false) {float min_value = std::numeric_limits<float>::max();float max_value = std::numeric_limits<float>::lowest();@@ -505,7 +534,10 @@ private:float diff_value = 0.001;if (max_value != min_value)diff_value = max_value - min_value;-+ if (expand_range && std::abs(diff_value) <= std::abs(max_value) * 0.1f) {+ // compensate too small range+ diff_value = (max_value - min_value) + std::max(1.0f, max_value * 0.1f);+ }float scale = (std::numeric_limits<int8_t>::max() - std::numeric_limits<int8_t>::lowest()) / diff_value;float zp = ((float)-min_value * scale) + std::numeric_limits<int8_t>::lowest();@@ -847,6 +879,7 @@ public:p.block_size,p.sliding_window_size,p.kv_cache_compression,+ p.key_cache_quant_mode,p.scores_mode == ScoresMode::SNAPKV,p.rotation_config);@@ -976,6 +1009,7 @@ public:pa_prim.has_rotated_blocks = p.rotation_config.apply_rotation;pa_prim.has_score_aggregation = p.scores_mode == ScoresMode::SNAPKV;pa_prim.sliding_window = p.sliding_window_size;+ pa_prim.is_key_by_channel = (p.key_cache_quant_mode == ov::internal::CacheQuantMode::BY_CHANNEL);topology topology;@@ -1016,7 +1050,7 @@ public:config.set_property(ov::intel_gpu::allow_new_shape_infer(true));// FlashAttn v1 or v2?config.set_property(ov::intel_gpu::could_use_flashattn_v2(p.disable_flashattn_v2));-+ config.set_property(ov::internal::key_cache_quant_mode(p.key_cache_quant_mode));network::ptr network = get_network(get_test_engine(), topology, config, get_test_stream_ptr(), false);network->set_input_data("query", query_mem);network->set_input_data("key", key_mem);@@ -1038,7 +1072,6 @@ public:network->set_input_data("rotation_deltas", rotation_deltas_mem);network->set_input_data("rotation_trig_lut", rotation_trig_lut_mem);}-auto outputs = network->execute();cldnn::memory::ptr output_data_mem = nullptr;@@ -1048,7 +1081,6 @@ public:if (p.scores_mode != ScoresMode::DISABLED) {output_scores_mem = outputs.at("output_scores").get_memory();}-auto ref_data = PagedAttentionReference(pam).get_reference();compare(output_data_mem, output_scores_mem, ref_data);}@@ -1080,6 +1112,7 @@ struct paged_attention_test_params {int block_size;int sliding_window_size;bool kv_cache_compression;+ ov::internal::CacheQuantMode key_cache_quant_mode;bool dynamic_paddings;ScoresMode scores_mode;CacheRotationDescriptor rotation_config;@@ -1109,96 +1142,111 @@ const auto DISABLE_FA_V2 = true;INSTANTIATE_TEST_SUITE_P(smoke_paged_attention, paged_attention_test, ::testing::ValuesIn(std::vector<paged_attention_test_params>{/* with scores output, use SnapKV */- paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{36, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{36, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES_SNAPKV, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token/* with scores output */- paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{10, 0}}, 2, 16, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{10, 0}}, 2, 128, 96, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{36, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{36, 0}}, 2, 64, 48, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{36, 0}}, 2, 96, 128, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{1024, 0}}, 2, 32, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 48, 96, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{1, 10}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 48, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 16, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 16, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 128, 96, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN,STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{36, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN,STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{36, 0}}, 2, 64, 48, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN,STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{36, 0}}, 2, 96, 128, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN,STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN,STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{1024, 0}}, 2, 32, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN,STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 48, 96, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 10}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 48, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 16, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token/* without scores output, dynamic input query paddings */- paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{10, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token/* with scores, per_block rotation */- paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{10, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{36, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{36, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 48, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 48, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{1, 10}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, ov::internal::CacheQuantMode::BY_TOKEN,STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{36, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{36, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 48, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 48, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 10}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token/* with scores, per_token rotation */- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 128, 192, 16, 0, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 128, 192, 16, 0, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token/* without scores output, dynamic input query paddings, KV-cache compression */- paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{10, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long- paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{1024, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token long+ paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{10, 0}, {81, 0}, {129, 0}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+/* with scores, per_block rotation, KV-cache compression */- paged_attention_test_params{ {{1, 34}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{1, 34}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 34}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 34}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, DISABLE_FA_V2 }, // 2nd token/* with scores, per_token rotation, KV-cache compression */- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token- paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {1, 515}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 64, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{1, 34}, {25, 0}, {10, 34}}, 2, 64, 32, 16, 0, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token/* With sliding windows */- paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 6, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{512, 0}}, 2, 64, 32, 16, 20, ENABLE_CACHE_COMPRESSION, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token- paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 8, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token- paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 48, 64, 16, 128, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token- paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 4, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{5, 10}}, 2, 64, 64, 16, 2, DISABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token- paged_attention_test_params{ {{1, 34}, {2, 20}, {10, 34}}, 2, 64, 64, 16, 10, ENABLE_CACHE_COMPRESSION, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 6, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}}, 2, 64, 64, 16, 6, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{512, 0}}, 2, 64, 32, 16, 20, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{512, 0}}, 2, 64, 32, 16, 20, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, DYNAMIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 1st token+ paged_attention_test_params{ {{10, 0}, {30, 0}}, 2, 64, 64, 16, 8, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // 2nd token + 2nd token+ paged_attention_test_params{ {{128, 0}, {256, 0}}, 2, 48, 64, 16, 128, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_BLOCK_ROTATION, ENABLE_FA_V2 }, // 1st token + 1st token+ paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 4, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 10}}, 2, 64, 64, 16, 4, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, STATIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{5, 10}}, 2, 64, 64, 16, 2, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{5, 10}}, 2, 64, 64, 16, 2, DISABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_CHANNEL, STATIC_INPUT_PAD, DISABLE_SCORES, DISABLE_ROTATION, DISABLE_FA_V2 }, // 2nd token+ paged_attention_test_params{ {{1, 34}, {2, 20}, {10, 34}}, 2, 64, 64, 16, 10, ENABLE_CACHE_COMPRESSION,ov::internal::CacheQuantMode::BY_TOKEN, STATIC_INPUT_PAD, ENABLE_SCORES, PER_TOKEN_ROTATION, DISABLE_FA_V2 }, // mixed: 2nd token + 1st token + part of 1st token}));