Skip to content

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

[GPU][CPU][CORE] Expose PagedAttention block size on compiled model (#37846) (#37928)

Pernav Jain907202c8e7ad
diff --git a/src/inference/dev_api/openvino/runtime/exec_model_info.hpp b/src/inference/dev_api/openvino/runtime/exec_model_info.hpp
index 6cf4665e24f..2aa40c52480 100644
--- a/src/inference/dev_api/openvino/runtime/exec_model_info.hpp
+++ b/src/inference/dev_api/openvino/runtime/exec_model_info.hpp
@@ -72,6 +72,13 @@ static const char LAYER_TYPE[] = "layerType";
*/
static const char RUNTIME_PRECISION[] = "runtimePrecision";
+/**
+ * @ingroup ov_dev_exec_model
+ * @brief Used to get the PagedAttention block size stored as a top-level rt_info entry
+ * on the runtime model returned by compiled_model.get_runtime_model().
+ */
+static const char PAGED_ATTENTION_BLOCK_SIZE[] = "paged_attention_block_size";
+
/**
* @ingroup ov_dev_exec_model
* @brief The Execution node which is used to represent node in execution graph.
diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cpp
index 01a6087df74..a1f27d776a8 100644
--- a/src/plugins/intel_cpu/src/graph.cpp
+++ b/src/plugins/intel_cpu/src/graph.cpp
@@ -24,6 +24,7 @@
#include <new>
#include <oneapi/dnnl/dnnl.hpp>
#include <oneapi/dnnl/dnnl_common.hpp>
+#include <optional>
#include <set>
#include <string>
#include <tuple>
@@ -50,6 +51,7 @@
#include "nodes/convert.h"
#include "nodes/input.h"
#include "nodes/memory.hpp"
+#include "nodes/paged_attn.h"
#include "nodes/reorder.h"
#include "nodes/subgraph.h"
#include "nodes/tensoriterator.h"
@@ -2248,6 +2250,27 @@ std::shared_ptr<ov::Model> Graph::dump() const {
return dump_graph_as_ie_ngraph_net(*this);
}
+std::optional<size_t> Graph::getPagedAttentionBlockSize() const {
+ std::optional<size_t> block_size;
+ for (const auto& node : graphNodes) {
+ if (node->getType() == Type::PagedAttention) {
+ auto* pa_node = dynamic_cast<node::PagedAttention*>(node.get());
+ OPENVINO_ASSERT(pa_node != nullptr, "[CPU] Unexpected: PagedAttention node cast failed");
+ size_t current_bs = pa_node->getBlockSize();
+ if (!block_size) {
+ block_size = current_bs;
+ } else {
+ OPENVINO_ASSERT(block_size.value() == current_bs,
+ "[CPU] All PagedAttention layers must agree on the same block size, got ",
+ block_size.value(),
+ " vs ",
+ current_bs);
+ }
+ }
+ }
+ return block_size;
+}
+
std::vector<MemStatePtr> Graph::memoryStates() const {
std::vector<MemStatePtr> resultVector;
diff --git a/src/plugins/intel_cpu/src/graph.h b/src/plugins/intel_cpu/src/graph.h
index a5b8bb96b76..6fe0e96ab01 100644
--- a/src/plugins/intel_cpu/src/graph.h
+++ b/src/plugins/intel_cpu/src/graph.h
@@ -8,6 +8,7 @@
#include <cstdint>
#include <memory>
#include <oneapi/dnnl/dnnl_common.hpp>
+#include <optional>
#include <string>
#include <unordered_map>
#include <unordered_set>
@@ -108,6 +109,8 @@ public:
return _name;
}
+ [[nodiscard]] std::optional<size_t> getPagedAttentionBlockSize() const;
+
NodePtr getInputNodeByIndex(std::size_t index) {
if (index >= inputNodes.size()) {
return nullptr;
diff --git a/src/plugins/intel_cpu/src/graph_dumper.cpp b/src/plugins/intel_cpu/src/graph_dumper.cpp
index 3a183cbce4e..7f7dc0de580 100644
--- a/src/plugins/intel_cpu/src/graph_dumper.cpp
+++ b/src/plugins/intel_cpu/src/graph_dumper.cpp
@@ -18,6 +18,7 @@
#include "cpu_types.h"
#include "graph.h"
#include "node.h"
+#include "nodes/paged_attn.h"
#include "nodes/scaled_attn.h"
#include "onednn/dnnl.h"
#include "openvino/core/except.hpp"
@@ -131,6 +132,11 @@ std::map<std::string, std::string> extract_node_metadata(const NodePtr& node) {
serialization_info["kv_cache_precision"] = sdpa_node->getKVCachePrecision().get_type_name();
}
}
+ if (node->getType() == Type::PagedAttention) {
+ auto* pa_node = dynamic_cast<node::PagedAttention*>(node.get());
+ OPENVINO_ASSERT(pa_node != nullptr, "[CPU] Unexpected: PagedAttention node cast failed");
+ serialization_info["block_size"] = std::to_string(pa_node->getBlockSize());
+ }
return serialization_info;
}
@@ -231,7 +237,11 @@ std::shared_ptr<ov::Model> dump_graph_as_ie_ngraph_net(const Graph& graph) {
holder->add_control_dependency(node);
}
- return std::make_shared<ov::Model>(results, params, graph._name);
+ auto runtime_model = std::make_shared<ov::Model>(results, params, graph._name);
+ if (auto pa_bs = graph.getPagedAttentionBlockSize()) {
+ runtime_model->get_rt_info()[ov::exec_model_info::PAGED_ATTENTION_BLOCK_SIZE] = *pa_bs;
+ }
+ return runtime_model;
}
#ifdef CPU_DEBUG_CAPS
diff --git a/src/plugins/intel_cpu/src/nodes/paged_attn.cpp b/src/plugins/intel_cpu/src/nodes/paged_attn.cpp
index 912d3fb0142..fa04afa764d 100644
--- a/src/plugins/intel_cpu/src/nodes/paged_attn.cpp
+++ b/src/plugins/intel_cpu/src/nodes/paged_attn.cpp
@@ -273,6 +273,51 @@ bool PagedAttention::isQuantByChannel(const Config::CacheQuantMode mode,
return byChannel;
}
+size_t PagedAttention::getKeyCacheParamsSize(const Config& cpuConfig) {
+ if (!isQuantByChannel(cpuConfig.keyCacheQuantMode, cpuConfig.keyCachePrecision, true)) {
+ return 0;
+ }
+ // For by-channel quantized caches, ConvertPagedAttnInputs appends per-channel
+ // scale/zero-point parameter rows to the block_size dim (i8: 1 row, u8: 2 rows,
+ // u4: 2 rows x 2 sub-byte). Return that byte count so callers can subtract it
+ // from dim[2] to recover the logical PA block size.
+ const auto precision = cpuConfig.keyCachePrecision;
+ if (precision == ov::element::i8) {
+ return sizeof(float);
+ }
+ if (precision == ov::element::u8) {
+ return 2 * sizeof(float);
+ }
+ if (precision == ov::element::u4) {
+ return 2 * sizeof(float) * 2;
+ }
+ return 0;
+}
+
+size_t PagedAttention::getBlockSize() const {
+ const auto& cpuConfig = context->getConfig();
+ const auto& kcache_shape = getInputShapeAtPort(PagedAttentionExecutor::ID_KCACHE);
+ // K-cache layout is [block_number, H, block_size, S]; dim[2] is the page block size.
+ // ConvertPagedAttnInputs fixes dim[2] to the plugin's compile-time block size (plus
+ // by-channel quantization parameter rows) — only block_number (dim[0]) stays dynamic.
+ // This reads the compile-time shape (getInputShapeAtPort), while execute() reads the live
+ // runtime tensor (getStaticDims()); they agree because dim[2] is static after that
+ // transformation.
+ const auto& dims = kcache_shape.getDims();
+ OPENVINO_ASSERT(dims.size() >= 3 && dims[2] != Shape::UNDEFINED_DIM,
+ "[CPU] PagedAttention K-cache block size dimension must be defined");
+ size_t block_size = dims[2];
+ const size_t key_params_size = getKeyCacheParamsSize(cpuConfig);
+ OPENVINO_ASSERT(block_size > key_params_size,
+ "[CPU] PagedAttention K-cache dim[2] (",
+ block_size,
+ ") must be greater than key params size (",
+ key_params_size,
+ ")");
+ block_size -= key_params_size;
+ return block_size;
+}
+
void PagedAttention::createPrimitive() {
auto rtPrecision = getRuntimePrecision();
@@ -373,14 +418,15 @@ void PagedAttention::execute([[maybe_unused]] const dnnl::stream& strm) {
// For by-channel quantized caches, dim[2] includes parameter header rows
// (scales/zps). Subtract them to get the actual PA block_size.
const auto& cpuConfig = context->getConfig();
- bool quantKeybyChannel = isQuantByChannel(cpuConfig.keyCacheQuantMode, cpuConfig.keyCachePrecision, true);
size_t block_size = inputs[K_CACHE_IDX]->getStaticDims()[2];
- if (quantKeybyChannel && cpuConfig.keyCachePrecision.is_integral()) {
- size_t params_count = (cpuConfig.keyCachePrecision == ov::element::i8) ? 1 : 2;
- size_t key_sub_byte_mult = (cpuConfig.keyCachePrecision == ov::element::u4) ? 2 : 1;
- size_t key_params_size = sizeof(float) * params_count * key_sub_byte_mult;
- block_size -= key_params_size;
- }
+ const size_t key_params_size = getKeyCacheParamsSize(cpuConfig);
+ OPENVINO_ASSERT(block_size > key_params_size,
+ "[CPU] PagedAttention K-cache dim[2] (",
+ block_size,
+ ") must be greater than key params size (",
+ key_params_size,
+ ")");
+ block_size -= key_params_size;
const size_t ADAPTIVE_RKV_EVICTABLE_SIZES_IDX = PagedAttentionExecutor::ID_ADAPTIVE_RKV_EVICTABLE_SIZES;
auto evictable_sizes_dims = inputs[ADAPTIVE_RKV_EVICTABLE_SIZES_IDX]->getStaticDims();
diff --git a/src/plugins/intel_cpu/src/nodes/paged_attn.h b/src/plugins/intel_cpu/src/nodes/paged_attn.h
index 82ec2f827da..a9c288a3952 100644
--- a/src/plugins/intel_cpu/src/nodes/paged_attn.h
+++ b/src/plugins/intel_cpu/src/nodes/paged_attn.h
@@ -51,6 +51,13 @@ public:
static bool isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept;
static bool isQuantByChannel(Config::CacheQuantMode mode, ov::element::Type precision, bool isKey);
+ static size_t getKeyCacheParamsSize(const Config& cpuConfig);
+ /**
+ * @brief Returns the PagedAttention block size for the K-cache.
+ * Reads compile-time input shape at port ID_KCACHE (where dim[2] is fixed by
+ * ConvertPagedAttnInputs) and adjusts for any by-channel quantization parameter rows.
+ */
+ size_t getBlockSize() const;
private:
ov::element::Type getRuntimePrecision() const override;
diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/paged_attn.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/paged_attn.cpp
index 31b26866957..616fdff6690 100644
--- a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/paged_attn.cpp
+++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/classes/paged_attn.cpp
@@ -29,6 +29,7 @@
#include "openvino/op/squeeze.hpp"
#include "openvino/op/transpose.hpp"
#include "openvino/op/unsqueeze.hpp"
+#include "openvino/runtime/exec_model_info.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "transformations/rt_info/keep_const_precision.hpp"
@@ -633,6 +634,33 @@ void PagedAttnTestBase::prepare() {
compile_model();
inferRequest = compiledModel.create_infer_request();
ASSERT_TRUE(inferRequest);
+ auto runtime_model = compiledModel.get_runtime_model();
+ ASSERT_NE(runtime_model, nullptr);
+ bool has_pa = false;
+ if (function) {
+ for (const auto& op : function->get_ops()) {
+ if (ov::is_type<ov::op::PagedAttentionExtension>(op)) {
+ has_pa = true;
+ break;
+ }
+ }
+ }
+ if (has_pa) {
+ // 32 is the CPU plugin's fixed PagedAttention block size: ConvertPagedAttnInputs
+ // bakes keyCacheBlockSize = 32 into the reshaped K-cache ([num_blocks, H, 32, S]),
+ // so the runtime model always reports 32 for the CPU plugin.
+ ASSERT_TRUE(runtime_model->has_rt_info(ov::exec_model_info::PAGED_ATTENTION_BLOCK_SIZE));
+ EXPECT_EQ(runtime_model->get_rt_info<size_t>(ov::exec_model_info::PAGED_ATTENTION_BLOCK_SIZE), 32);
+
+ auto pa_nodes = ov::test::GetNodesWithTypes(runtime_model, {"PagedAttention"});
+ EXPECT_FALSE(pa_nodes.empty());
+ for (const auto& node : pa_nodes) {
+ const auto& rt_info = node->get_rt_info();
+ auto it = rt_info.find("block_size");
+ ASSERT_NE(it, rt_info.end());
+ EXPECT_EQ(it->second.as<std::string>(), "32");
+ }
+ }
}
void PagedAttnTestBase::reset() {
for (auto&& state : inferRequest.query_state()) {
diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/graph.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/graph.hpp
index f0dab062e1d..b97aea10bcb 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/plugin/graph.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/graph.hpp
@@ -11,6 +11,7 @@
#include <condition_variable>
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -76,6 +77,9 @@ public:
std::mutex& get_mutex() { return m_infer_mutex; }
bool use_external_queue() const;
+ [[nodiscard]] std::optional<size_t> getPagedAttentionBlockSize() const {
+ return m_paged_attention_block_size;
+ }
std::set<std::shared_ptr<ov::AlignedBuffer>> get_weight_sharing_source_buffers() const {
return m_weight_sharing_source_buffers;
@@ -100,6 +104,7 @@ private:
std::vector<cldnn::primitive_id> profilingIDs;
std::map<size_t, cldnn::layout> m_input_layouts;
+ std::optional<size_t> m_paged_attention_block_size;
std::set<std::shared_ptr<ov::AlignedBuffer>> m_weight_sharing_source_buffers;
void build(std::shared_ptr<cldnn::program> program);
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.hpp
index cdf8a8eba1b..e06f52f7cc4 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
@@ -47,6 +47,14 @@ struct paged_attention : public primitive_base<paged_attention> {
static constexpr size_t block_size = 16;
static constexpr size_t block_size_xattn = 256;
+ static size_t get_block_size(bool has_xattention) {
+ return has_xattention ? block_size_xattn : block_size;
+ }
+
+ size_t get_block_size() const {
+ return get_block_size(has_xattention);
+ }
+
paged_attention() : primitive_base("", {}) {}
paged_attention(const primitive_id& id,
diff --git a/src/plugins/intel_gpu/src/graph/paged_attention.cpp b/src/plugins/intel_gpu/src/graph/paged_attention.cpp
index 3098a1ef36a..a2d8155c9dc 100644
--- a/src/plugins/intel_gpu/src/graph/paged_attention.cpp
+++ b/src/plugins/intel_gpu/src/graph/paged_attention.cpp
@@ -43,7 +43,7 @@ std::vector<layout> paged_attention_inst::calc_output_layouts(paged_attention_no
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 ||
data_type_traits::is_i4_u4(key_cache_dt);
- auto expected_block_size = desc->has_xattention ? paged_attention::block_size_xattn : paged_attention::block_size;
+ auto expected_block_size = desc->get_block_size();
// Both INT4 and INT8 BY_CHANNEL use dim order {0,1,3,2} with block_size at dim[3].
const bool is_int4 = data_type_traits::is_i4_u4(key_cache_dt);
if (key_cache_compressed && key_cache_quant_mode == ov::internal::CacheQuantMode::BY_CHANNEL) {
diff --git a/src/plugins/intel_gpu/src/plugin/graph.cpp b/src/plugins/intel_gpu/src/plugin/graph.cpp
index 2c3d637ae22..aba66e00a07 100644
--- a/src/plugins/intel_gpu/src/plugin/graph.cpp
+++ b/src/plugins/intel_gpu/src/plugin/graph.cpp
@@ -27,9 +27,11 @@
#include "intel_gpu/primitives/grouped_matmul.hpp"
#include "intel_gpu/primitives/fully_connected.hpp"
#include "intel_gpu/primitives/kv_cache.hpp"
+#include "intel_gpu/primitives/paged_attention.hpp"
#include "dynamic_quantize_inst.h"
#include "grouped_matmul_inst.h"
#include "fully_connected_inst.h"
+#include "paged_attention_inst.h"
#include <list>
#include <set>
@@ -154,7 +156,8 @@ Graph::Graph(std::shared_ptr<Graph> graph, uint16_t stream_id)
, prevPrimitiveIDs(graph->prevPrimitiveIDs)
, perfMap(graph->perfMap)
, profilingIDs(graph->profilingIDs)
- , m_input_layouts(graph->m_input_layouts) {
+ , m_input_layouts(graph->m_input_layouts)
+ , m_paged_attention_block_size(graph->m_paged_attention_block_size) {
build(graph->get_network()->get_program());
}
@@ -219,6 +222,22 @@ Graph::~Graph() {
void Graph::build(std::shared_ptr<cldnn::program> program) {
OV_ITT_SCOPED_TASK(itt::domains::intel_gpu_plugin, "Graph::build");
+ for (const auto& node : program->get_processing_order()) {
+ if (node->is_type<cldnn::paged_attention>()) {
+ auto pa_prim = node->as<cldnn::paged_attention>().get_primitive();
+ size_t current_bs = pa_prim->get_block_size();
+ if (!m_paged_attention_block_size) {
+ m_paged_attention_block_size = current_bs;
+ } else {
+ OPENVINO_ASSERT(m_paged_attention_block_size.value() == current_bs,
+ "[GPU] All PagedAttention layers must agree on the same block size, got ",
+ m_paged_attention_block_size.value(),
+ " vs ",
+ current_bs);
+ }
+ }
+ }
+
auto* external_queue = m_context->get_external_queue();
if (external_queue) {
OPENVINO_ASSERT(m_config.get_num_streams() == 1, "[GPU] Throughput streams can't be used with shared queue!");
@@ -530,6 +549,10 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitive
info["wzp_precision"] = ov::element::Type(zp_layout.data_type).get_type_name();
}
}
+ } else if (node.is_type<cldnn::paged_attention>()) {
+ auto pa_prim = node.as<cldnn::paged_attention>().get_primitive();
+ size_t block_size = pa_prim->get_block_size();
+ info["block_size"] = std::to_string(block_size);
}
}
}
@@ -608,7 +631,11 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitive
create_ov_node(pi);
}
- return std::make_shared<ov::Model>(results, params, "runtime_gpu_graph");
+ auto runtime_model = std::make_shared<ov::Model>(results, params, "runtime_gpu_graph");
+ if (auto pa_block_size = getPagedAttentionBlockSize()) {
+ runtime_model->get_rt_info()[ov::exec_model_info::PAGED_ATTENTION_BLOCK_SIZE] = *pa_block_size;
+ }
+ return runtime_model;
}
// Cache blob format:
diff --git a/src/plugins/intel_gpu/src/plugin/ops/pa_kv_reorder.cpp b/src/plugins/intel_gpu/src/plugin/ops/pa_kv_reorder.cpp
index 8343eee3e88..63dc37df59a 100644
--- a/src/plugins/intel_gpu/src/plugin/ops/pa_kv_reorder.cpp
+++ b/src/plugins/intel_gpu/src/plugin/ops/pa_kv_reorder.cpp
@@ -93,7 +93,7 @@ static void CreatePA_KV_ReorderOp(ProgramBuilder& p, const std::shared_ptr<ov::o
const size_t v_head_size = rt_info.at(v_head_size_id).as<int64_t>();
const size_t kv_heads_num = rt_info.at(num_k_heads_id).as<int64_t>();
- const size_t block_size = prim.has_xattention ? cldnn::paged_attention::block_size_xattn : cldnn::paged_attention::block_size;
+ const size_t block_size = cldnn::paged_attention::get_block_size(prim.has_xattention);
prim.kv_heads_num = kv_heads_num;
if (prim.is_kv_compressed) {
diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/paged_attention_block_size.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/paged_attention_block_size.cpp
new file mode 100644
index 00000000000..5775f319f69
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/paged_attention_block_size.cpp
@@ -0,0 +1,110 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <algorithm>
+#include <exception>
+
+#include "openvino/runtime/core.hpp"
+#include "openvino/runtime/exec_model_info.hpp"
+#include "openvino/runtime/intel_gpu/properties.hpp"
+#include "shared_test_classes/base/ov_subgraph.hpp"
+#include "shared_test_classes/single_op/paged_attention.hpp"
+
+namespace ov {
+namespace test {
+namespace {
+
+// Verifies that the GPU plugin publishes the PagedAttention block size it will
+// actually use (16 standard, 256 XAttention) on the runtime model. A swapped or
+// missing value here would silently corrupt logical-to-physical block mapping.
+class PagedAttentionBlockSizeTest : public PagedAttentionLayerTest {
+public:
+ void SetUp() override {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+ // We reuse only the protected make_paged_attn_model() helper and compile
+ // standalone models, so skip the parameterized PagedAttentionLayerTest flow.
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ }
+
+ void check_block_size(ov::element::Type data_type, bool enable_xattn, int64_t block_size, size_t expected) {
+ ov::Core core;
+ if (enable_xattn) {
+ const auto caps = core.get_property(ov::test::utils::DEVICE_GPU, ov::device::capabilities);
+ if (std::find(caps.begin(), caps.end(), ov::intel_gpu::capability::HW_MATMUL) == caps.end()) {
+ GTEST_SKIP() << "XAttention requires a GPU with HW_MATMUL capability (Xe2/Xe3)";
+ }
+ }
+
+ constexpr int64_t head_size = 64;
+ constexpr int64_t head_num = 8;
+ function = make_paged_attn_model(data_type,
+ enable_xattn,
+ head_size,
+ head_num,
+ /*use_sink_input=*/false,
+ /*sliding_window=*/0,
+ /*use_alibi=*/false,
+ /*max_ctx_len=*/1024,
+ /*use_rotation=*/false,
+ block_size);
+ // GPU lowering needs the feature width to infer the head count from a direct query parameter.
+ function->get_parameters().front()->set_partial_shape({ov::Dimension::dynamic(), head_size * head_num});
+
+ if (enable_xattn) {
+ // GPU TransformationsPipeline enables XAttention only when xattention_block_size
+ // is a Parameter named "xattention_block_size".
+ constexpr size_t xattention_block_size_idx = 18;
+ bool replaced = false;
+ for (const auto& op : function->get_ops()) {
+ if (ov::is_type<ov::op::PagedAttentionExtension>(op)) {
+ auto xattention_block_size = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, ov::Shape{});
+ xattention_block_size->set_friendly_name("xattention_block_size");
+ op->input(xattention_block_size_idx).replace_source_output(xattention_block_size->output(0));
+ function->add_parameters({xattention_block_size});
+ replaced = true;
+ break;
+ }
+ }
+ ASSERT_TRUE(replaced);
+ }
+ function->validate_nodes_and_infer_types();
+
+ ov::CompiledModel compiled;
+ try {
+ compiled = core.compile_model(function, ov::test::utils::DEVICE_GPU);
+ } catch (const std::exception& e) {
+ const std::string message = e.what();
+ if (enable_xattn && message.find("XAttention is not supported by your current GPU architecture or IGC version") != std::string::npos) {
+ GTEST_SKIP() << message;
+ }
+ throw;
+ }
+
+ auto runtime_model = compiled.get_runtime_model();
+ ASSERT_NE(runtime_model, nullptr);
+ ASSERT_TRUE(runtime_model->has_rt_info(ov::exec_model_info::PAGED_ATTENTION_BLOCK_SIZE));
+ EXPECT_EQ(runtime_model->get_rt_info<size_t>(ov::exec_model_info::PAGED_ATTENTION_BLOCK_SIZE), expected);
+
+ auto pa_nodes = ov::test::GetNodesWithTypes(runtime_model, {"paged_attention", "PagedAttention"});
+ ASSERT_FALSE(pa_nodes.empty());
+ for (const auto& op : pa_nodes) {
+ const auto& rt_info = op->get_rt_info();
+ auto it = rt_info.find("block_size");
+ ASSERT_NE(it, rt_info.end());
+ EXPECT_EQ(it->second.as<std::string>(), std::to_string(expected));
+ }
+ }
+};
+
+TEST_F(PagedAttentionBlockSizeTest, smoke_StandardBlockSize) {
+ check_block_size(ov::element::f16, /*enable_xattn=*/false, /*block_size=*/16, /*expected=*/16);
+}
+
+TEST_F(PagedAttentionBlockSizeTest, smoke_XAttentionBlockSize) {
+ check_block_size(ov::element::f16, /*enable_xattn=*/true, /*block_size=*/256, /*expected=*/256);
+}
+
+} // namespace
+} // namespace test
+} // namespace ov
diff --git a/src/plugins/intel_gpu/tests/functional/sources.cmake b/src/plugins/intel_gpu/tests/functional/sources.cmake
index 4ef2c8806ff..bd821c876e1 100644
--- a/src/plugins/intel_gpu/tests/functional/sources.cmake
+++ b/src/plugins/intel_gpu/tests/functional/sources.cmake
@@ -189,6 +189,7 @@ set(GPU_FUNCTIONAL_TEST_SOURCES
${CMAKE_CURRENT_LIST_DIR}/shared_tests_instances/single_layer_tests/non_max_suppression.cpp
${CMAKE_CURRENT_LIST_DIR}/shared_tests_instances/single_layer_tests/normalize_l2.cpp
${CMAKE_CURRENT_LIST_DIR}/shared_tests_instances/single_layer_tests/pad.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/shared_tests_instances/single_layer_tests/paged_attention_block_size.cpp
${CMAKE_CURRENT_LIST_DIR}/shared_tests_instances/single_layer_tests/paged_attention_token_type.cpp
${CMAKE_CURRENT_LIST_DIR}/shared_tests_instances/single_layer_tests/paged_gated_delta_net.cpp
${CMAKE_CURRENT_LIST_DIR}/shared_tests_instances/single_layer_tests/pooling.cpp