Skip to content

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

[CPU] Add CPU support for PagedCausalConv1D (#35200)

Bo Liu99b861f1446a
diff --git a/src/plugins/intel_cpu/CMakeLists.txt b/src/plugins/intel_cpu/CMakeLists.txt
index cb27d7931ca..0cf00efbaf8 100644
--- a/src/plugins/intel_cpu/CMakeLists.txt
+++ b/src/plugins/intel_cpu/CMakeLists.txt
@@ -343,6 +343,14 @@ cross_compiled_file(${TARGET_NAME}
NAMESPACE ov::Extensions::Cpu::XARCH
)
+cross_compiled_file(${TARGET_NAME}
+ ARCH AVX512F AVX2 ANY
+ src/nodes/kernels/paged_causal_conv1d.cpp
+ API src/nodes/kernels/paged_causal_conv1d.hpp
+ NAME paged_causal_conv1d_exec
+ NAMESPACE ov::Extensions::Cpu::XARCH
+)
+
# system dependencies must go last
target_link_libraries(${TARGET_NAME} PRIVATE openvino::pugixml)
ov_set_threading_interface_for(${TARGET_NAME})
diff --git a/src/plugins/intel_cpu/src/cpu_types.cpp b/src/plugins/intel_cpu/src/cpu_types.cpp
index df0d25c51ac..989a7b3dd26 100644
--- a/src/plugins/intel_cpu/src/cpu_types.cpp
+++ b/src/plugins/intel_cpu/src/cpu_types.cpp
@@ -265,7 +265,8 @@ static const TypeToNameMap& get_type_to_name_tbl() {
{"GatherMatmul", Type::GatherMatmul},
{"GatherMatmulCompressed", Type::GatherMatmul},
{"GatedDeltaNet", Type::GatedDeltaNet},
- {"PagedGatedDeltaNet", Type::PagedGatedDeltaNet}};
+ {"PagedGatedDeltaNet", Type::PagedGatedDeltaNet},
+ {"PagedCausalConv1D", Type::PagedCausalConv1D}};
return type_to_name_tbl;
}
@@ -403,6 +404,7 @@ std::string NameFromType(const Type type) {
CASE(GatherMatmul);
CASE(GatedDeltaNet);
CASE(PagedGatedDeltaNet);
+ CASE(PagedCausalConv1D);
CASE(Unknown);
}
#undef CASE
diff --git a/src/plugins/intel_cpu/src/cpu_types.h b/src/plugins/intel_cpu/src/cpu_types.h
index 8c78206c659..cbc58f6e04b 100644
--- a/src/plugins/intel_cpu/src/cpu_types.h
+++ b/src/plugins/intel_cpu/src/cpu_types.h
@@ -140,7 +140,8 @@ enum class Type : uint8_t {
LoRA,
GatherMatmul,
GatedDeltaNet,
- PagedGatedDeltaNet
+ PagedGatedDeltaNet,
+ PagedCausalConv1D
};
enum class Algorithm : uint8_t {
diff --git a/src/plugins/intel_cpu/src/extension.cpp b/src/plugins/intel_cpu/src/extension.cpp
index 37dfe7cb99a..5d7ca97a00b 100644
--- a/src/plugins/intel_cpu/src/extension.cpp
+++ b/src/plugins/intel_cpu/src/extension.cpp
@@ -44,6 +44,7 @@
#include "openvino/op/normalize_l2.hpp"
#include "openvino/op/not_equal.hpp"
#include "openvino/op/paged_attention.hpp"
+#include "openvino/op/paged_causal_conv1d.hpp"
#include "openvino/op/paged_gated_delta_net.hpp"
#include "openvino/op/prelu.hpp"
#include "openvino/op/prior_box.hpp"
@@ -201,6 +202,7 @@ OPENVINO_CREATE_EXTENSIONS(std::vector<ov::Extension::Ptr>({
std::make_shared<ov::OpExtension<ov::op::PagedAttentionExtension>>(),
std::make_shared<ov::OpExtension<ov::op::internal::GatedDeltaNet>>(),
std::make_shared<ov::OpExtension<ov::op::internal::PagedGatedDeltaNet>>(),
+ std::make_shared<ov::OpExtension<ov::op::internal::PagedCausalConv1D>>(),
// clang-format off
OP_EXTENSION_X64(std::make_shared<ov::OpExtension<ov::intel_cpu::InteractionNode>>())
OP_EXTENSION_X64(std::make_shared<ov::OpExtension<ov::intel_cpu::LLMMLPNode>>())
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.cpp b/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.cpp
new file mode 100644
index 00000000000..1483603c1ba
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.cpp
@@ -0,0 +1,490 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "paged_causal_conv1d.hpp"
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <type_traits>
+
+#include "cpu_parallel.hpp"
+#include "openvino/core/except.hpp"
+#include "openvino/core/parallel.hpp"
+#include "openvino/core/type/bfloat16.hpp"
+#include "openvino/core/type/element_type.hpp"
+#include "openvino/core/type/float16.hpp"
+#include "scaled_attn/common.hpp"
+
+#if defined(HAVE_AVX2)
+# include <immintrin.h>
+#endif
+
+namespace ov::Extensions::Cpu::XARCH {
+
+namespace {
+
+constexpr size_t kChannelBlock = 64;
+
+// Flush state to conv_state_table when interval or last-token condition is met.
+// Called from the inner token loop of both ref and optimized kernels.
+template <typename StateType>
+void maybe_flush_state(StateType* conv_state_table,
+ const float* local_state,
+ const int32_t* block_indices,
+ const int32_t blk_begin,
+ const int32_t block_span,
+ const int32_t prev_nums,
+ const int32_t seq_interval,
+ const int32_t t,
+ const int32_t seq_tokens,
+ const size_t state_stride,
+ const size_t state_off,
+ const size_t h_count,
+ const size_t kernel_size) {
+ const int32_t cached_tokens = prev_nums + (t + 1);
+ const bool interval_hit = (seq_interval > 0) && ((cached_tokens % seq_interval) == 0);
+ const bool is_last_token = (t == seq_tokens - 1);
+ if (interval_hit || is_last_token) {
+ const int32_t slot = (seq_interval > 0) ? (1 + (cached_tokens - 1) / seq_interval) : 1;
+ if (slot < block_span) {
+ const int32_t physical_block = block_indices[blk_begin + slot];
+ const size_t write_count = h_count * kernel_size;
+ cvt_copy(conv_state_table + static_cast<size_t>(physical_block) * state_stride + state_off,
+ local_state + state_off,
+ /*m=*/size_t{1},
+ /*n=*/write_count,
+ /*src_stride=*/write_count,
+ /*dst_stride=*/write_count);
+ }
+ }
+}
+
+// Scalar conv1d computation for a channel range [h_begin, h_end).
+// Shifts state, inserts new token, computes dot product with weight.
+// DataT may be f32/bf16/f16 for token_ptr/conv_weight/conv_bias/out_ptr;
+// local_state remains f32 to preserve accumulation precision.
+template <typename DataT>
+void conv1d_scalar(float* local_state,
+ const DataT* token_ptr,
+ const DataT* conv_weight,
+ const DataT* conv_bias,
+ const bool has_bias,
+ DataT* out_ptr,
+ const size_t h_begin,
+ const size_t h_end,
+ const size_t kernel_size) {
+ for (size_t h = h_begin; h < h_end; h++) {
+ float* state_h = local_state + h * kernel_size;
+ for (size_t k = 0; k + 1 < kernel_size; k++) {
+ state_h[k] = state_h[k + 1];
+ }
+ state_h[kernel_size - 1] = static_cast<float>(token_ptr[h]);
+
+ const DataT* weight_h = conv_weight + h * kernel_size;
+ float sum = has_bias ? static_cast<float>(conv_bias[h]) : 0.0F;
+ for (size_t k = 0; k < kernel_size; k++) {
+ sum += state_h[k] * static_cast<float>(weight_h[k]);
+ }
+ out_ptr[h] = static_cast<DataT>(sum);
+ }
+}
+
+template <typename DataT, typename StateType>
+void paged_causal_conv1d_ref(const DataT* input_embeds,
+ StateType* conv_state_table,
+ const DataT* conv_weight,
+ const DataT* conv_bias,
+ const bool has_bias,
+ const int32_t* subsequence_begins,
+ const int32_t* block_indices,
+ const int32_t* block_indices_begins,
+ const int32_t* past_lens,
+ const int32_t* cache_interval,
+ DataT* output_embeds,
+ const size_t batch_size_in_tokens,
+ const size_t hidden_size,
+ const size_t kernel_size,
+ const size_t seq_count,
+ float* local_state,
+ const ov::intel_cpu::CpuParallelPtr& cpu_parallel) {
+ const size_t state_stride = hidden_size * kernel_size;
+ const size_t block_count = (hidden_size + kChannelBlock - 1) / kChannelBlock;
+
+ // Parallelize across (sequence, channel_block).
+ cpu_parallel->parallel_for2d(seq_count, block_count, [&](size_t s, size_t blk) {
+ const int32_t token_begin = subsequence_begins[s];
+ const int32_t token_end = subsequence_begins[s + 1];
+ OPENVINO_ASSERT(token_begin >= 0 && token_end >= token_begin,
+ "PagedCausalConv1D has invalid subsequence range [",
+ token_begin,
+ ", ",
+ token_end,
+ ") at sequence ",
+ s);
+ OPENVINO_ASSERT(static_cast<size_t>(token_end) <= batch_size_in_tokens,
+ "PagedCausalConv1D has subsequence end out of bounds. token_end=",
+ token_end,
+ ", batch_size_in_tokens=",
+ batch_size_in_tokens);
+
+ const int32_t blk_begin = block_indices_begins[s];
+ const int32_t blk_end = block_indices_begins[s + 1];
+ OPENVINO_ASSERT(blk_begin >= 0 && blk_end > blk_begin,
+ "PagedCausalConv1D expects at least one block per sequence, got [",
+ blk_begin,
+ ", ",
+ blk_end,
+ ") at sequence ",
+ s);
+
+ const int32_t block_span = blk_end - blk_begin;
+ OPENVINO_ASSERT(
+ block_span > 1,
+ "PagedCausalConv1D expects at least two logical blocks per sequence (read block 0, write block 1..N), got ",
+ block_span,
+ " at sequence ",
+ s);
+
+ const int32_t seq_interval = cache_interval[s];
+ const int32_t prev_nums = (seq_interval > 0) ? (past_lens[s] % seq_interval) : 0;
+ const int32_t seq_tokens = token_end - token_begin;
+
+ const size_t h_begin = blk * kChannelBlock;
+ const size_t h_end = std::min(h_begin + kChannelBlock, hidden_size);
+ const size_t h_count = h_end - h_begin;
+ const size_t state_off = h_begin * kernel_size;
+
+ // Each worker thread owns a private [state_stride] row of local_state. Since different
+ // (s, blk) pairs may land on the same thread, the row is reused across pairs but always
+ // holds only the current task's data.
+ const size_t tid = static_cast<size_t>(parallel_get_thread_num());
+ float* thread_local_state = local_state + tid * state_stride;
+
+ // Promote only the channel slice this task owns from the state table to f32.
+ const int32_t read_physical_block = block_indices[blk_begin];
+ cvt_copy(thread_local_state + state_off,
+ conv_state_table + static_cast<size_t>(read_physical_block) * state_stride + state_off,
+ /*m=*/size_t{1},
+ /*n=*/h_count * kernel_size,
+ /*src_stride=*/h_count * kernel_size,
+ /*dst_stride=*/h_count * kernel_size);
+
+ for (int32_t t = 0; t < seq_tokens; t++) {
+ const size_t token_idx = static_cast<size_t>(token_begin) + static_cast<size_t>(t);
+ const auto* token_ptr = input_embeds + token_idx * hidden_size;
+ auto* out_ptr = output_embeds + token_idx * hidden_size;
+
+ conv1d_scalar(thread_local_state,
+ token_ptr,
+ conv_weight,
+ conv_bias,
+ has_bias,
+ out_ptr,
+ h_begin,
+ h_end,
+ kernel_size);
+
+ maybe_flush_state(conv_state_table,
+ thread_local_state,
+ block_indices,
+ blk_begin,
+ block_span,
+ prev_nums,
+ seq_interval,
+ t,
+ seq_tokens,
+ state_stride,
+ state_off,
+ h_count,
+ kernel_size);
+ }
+ });
+}
+
+template <typename DataT, typename StateType>
+void paged_causal_conv1d_optimized(const DataT* input_embeds,
+ StateType* conv_state_table,
+ const DataT* conv_weight,
+ const DataT* conv_bias,
+ const bool has_bias,
+ const int32_t* subsequence_begins,
+ const int32_t* block_indices,
+ const int32_t* block_indices_begins,
+ const int32_t* past_lens,
+ const int32_t* cache_interval,
+ DataT* output_embeds,
+ const size_t batch_size_in_tokens,
+ const size_t hidden_size,
+ const size_t kernel_size,
+ const size_t seq_count,
+ float* local_state,
+ const ov::intel_cpu::CpuParallelPtr& cpu_parallel) {
+#if !defined(HAVE_AVX2)
+ paged_causal_conv1d_ref(input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ has_bias,
+ subsequence_begins,
+ block_indices,
+ block_indices_begins,
+ past_lens,
+ cache_interval,
+ output_embeds,
+ batch_size_in_tokens,
+ hidden_size,
+ kernel_size,
+ seq_count,
+ local_state,
+ cpu_parallel);
+#else
+ if (kernel_size != 3 && kernel_size != 4) {
+ paged_causal_conv1d_ref(input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ has_bias,
+ subsequence_begins,
+ block_indices,
+ block_indices_begins,
+ past_lens,
+ cache_interval,
+ output_embeds,
+ batch_size_in_tokens,
+ hidden_size,
+ kernel_size,
+ seq_count,
+ local_state,
+ cpu_parallel);
+ return;
+ }
+
+ const size_t state_stride = hidden_size * kernel_size;
+ const size_t block_count = (hidden_size + kChannelBlock - 1) / kChannelBlock;
+
+ // Parallelize across (sequence, channel_block).
+ cpu_parallel->parallel_for2d(seq_count, block_count, [&](size_t s, size_t blk) {
+ const int32_t token_begin = subsequence_begins[s];
+ const int32_t token_end = subsequence_begins[s + 1];
+ OPENVINO_ASSERT(token_begin >= 0 && token_end >= token_begin,
+ "PagedCausalConv1D has invalid subsequence range [",
+ token_begin,
+ ", ",
+ token_end,
+ ") at sequence ",
+ s);
+ OPENVINO_ASSERT(static_cast<size_t>(token_end) <= batch_size_in_tokens,
+ "PagedCausalConv1D has subsequence end out of bounds. token_end=",
+ token_end,
+ ", batch_size_in_tokens=",
+ batch_size_in_tokens);
+
+ const int32_t blk_begin = block_indices_begins[s];
+ const int32_t blk_end = block_indices_begins[s + 1];
+ OPENVINO_ASSERT(blk_begin >= 0 && blk_end > blk_begin,
+ "PagedCausalConv1D expects at least one block per sequence, got [",
+ blk_begin,
+ ", ",
+ blk_end,
+ ") at sequence ",
+ s);
+
+ const int32_t block_span = blk_end - blk_begin;
+ OPENVINO_ASSERT(
+ block_span > 1,
+ "PagedCausalConv1D expects at least two logical blocks per sequence (read block 0, write block 1..N), got ",
+ block_span,
+ " at sequence ",
+ s);
+
+ const int32_t seq_interval = cache_interval[s];
+ const int32_t prev_nums = (seq_interval > 0) ? (past_lens[s] % seq_interval) : 0;
+ const int32_t seq_tokens = token_end - token_begin;
+
+ const size_t h_begin = blk * kChannelBlock;
+ const size_t h_end = std::min(h_begin + kChannelBlock, hidden_size);
+ const size_t h_count = h_end - h_begin;
+ const size_t state_off = h_begin * kernel_size;
+
+ // Each worker thread owns a private [state_stride] row of local_state. Since different
+ // (s, blk) pairs may land on the same thread, the row is reused across pairs but always
+ // holds only the current task's data.
+ const size_t tid = static_cast<size_t>(parallel_get_thread_num());
+ float* thread_local_state = local_state + tid * state_stride;
+
+ // Promote only the channel slice this task owns from the state table to f32.
+ const int32_t read_physical_block = block_indices[blk_begin];
+ cvt_copy(thread_local_state + state_off,
+ conv_state_table + static_cast<size_t>(read_physical_block) * state_stride + state_off,
+ /*m=*/size_t{1},
+ /*n=*/h_count * kernel_size,
+ /*src_stride=*/h_count * kernel_size,
+ /*dst_stride=*/h_count * kernel_size);
+
+ for (int32_t t = 0; t < seq_tokens; t++) {
+ const size_t token_idx = static_cast<size_t>(token_begin) + static_cast<size_t>(t);
+ const auto* token_ptr = input_embeds + token_idx * hidden_size;
+ auto* out_ptr = output_embeds + token_idx * hidden_size;
+
+ // SIMD-accelerated paths for kernel_size 3 and 4.
+ // Each path: shift state, gather into aligned buffers, vectorized MAC, scalar tail.
+ size_t h = h_begin;
+
+# if defined(HAVE_AVX512F)
+ constexpr size_t simd_step = vec_len_f32_avx512;
+ const auto simd_loadu = [](const float* p) {
+ return mm512_uni_loadu_ps(p);
+ };
+ const auto simd_fmadd = [](__m512 a, __m512 b, __m512 c) {
+ return _mm512_fmadd_ps(a, b, c);
+ };
+# else
+ constexpr size_t simd_step = vec_len_f32_avx2;
+ const auto simd_loadu = [](const float* p) {
+ return mm256_uni_loadu_ps(p);
+ };
+ const auto simd_fmadd = [](__m256 a, __m256 b, __m256 c) {
+ return _mm256_fmadd_ps(a, b, c);
+ };
+# endif
+ for (; h + simd_step <= h_end; h += simd_step) {
+ float st[4][simd_step];
+ float wt[4][simd_step];
+ float bias_buf[simd_step];
+ for (size_t i = 0; i < simd_step; i++) {
+ const size_t ch = h + i;
+ float* state_h = thread_local_state + ch * kernel_size;
+ for (size_t k = 0; k + 1 < kernel_size; k++) {
+ state_h[k] = state_h[k + 1];
+ }
+ state_h[kernel_size - 1] = static_cast<float>(token_ptr[ch]);
+ for (size_t k = 0; k < kernel_size; k++) {
+ st[k][i] = state_h[k];
+ }
+ const DataT* weight_h = conv_weight + ch * kernel_size;
+ for (size_t k = 0; k < kernel_size; k++) {
+ wt[k][i] = static_cast<float>(weight_h[k]);
+ }
+ bias_buf[i] = has_bias ? static_cast<float>(conv_bias[ch]) : 0.0F;
+ }
+ auto acc = simd_loadu(bias_buf);
+ for (size_t k = 0; k < kernel_size; k++) {
+ acc = simd_fmadd(simd_loadu(st[k]), simd_loadu(wt[k]), acc);
+ }
+# if defined(HAVE_AVX512F)
+ mm512_uni_storeu_ps(out_ptr + h, acc);
+# else
+ mm256_uni_storeu_ps(out_ptr + h, acc);
+# endif
+ }
+
+ // Scalar tail for remaining channels
+ conv1d_scalar(thread_local_state,
+ token_ptr,
+ conv_weight,
+ conv_bias,
+ has_bias,
+ out_ptr,
+ h,
+ h_end,
+ kernel_size);
+
+ maybe_flush_state(conv_state_table,
+ thread_local_state,
+ block_indices,
+ blk_begin,
+ block_span,
+ prev_nums,
+ seq_interval,
+ t,
+ seq_tokens,
+ state_stride,
+ state_off,
+ h_count,
+ kernel_size);
+ }
+ });
+#endif
+}
+
+} // namespace
+
+void paged_causal_conv1d_exec(const void* input_embeds,
+ void* conv_state_table,
+ const void* conv_weight,
+ const void* conv_bias,
+ const bool has_bias,
+ const int32_t* subsequence_begins,
+ const int32_t* block_indices,
+ const int32_t* block_indices_begins,
+ const int32_t* past_lens,
+ const int32_t* cache_interval,
+ void* output_embeds,
+ const size_t batch_size_in_tokens,
+ const size_t hidden_size,
+ const size_t kernel_size,
+ const size_t seq_count,
+ const ov::element::Type data_precision,
+ const ov::element::Type state_precision,
+ float* local_state,
+ const ov::intel_cpu::CpuParallelPtr& cpu_parallel) {
+ // Dispatch one of the 9 supported (data, state) precision combinations to the kernel.
+ // `data_tag`/`state_tag` carry the types via pointer tags; their nullptr values are never
+ // dereferenced.
+ auto run = [&](auto* data_tag, auto* state_tag) {
+ using DataT = std::remove_pointer_t<decltype(data_tag)>;
+ using StateT = std::remove_pointer_t<decltype(state_tag)>;
+ paged_causal_conv1d_optimized(static_cast<const DataT*>(input_embeds),
+ static_cast<StateT*>(conv_state_table),
+ static_cast<const DataT*>(conv_weight),
+ has_bias ? static_cast<const DataT*>(conv_bias) : nullptr,
+ has_bias,
+ subsequence_begins,
+ block_indices,
+ block_indices_begins,
+ past_lens,
+ cache_interval,
+ static_cast<DataT*>(output_embeds),
+ batch_size_in_tokens,
+ hidden_size,
+ kernel_size,
+ seq_count,
+ local_state,
+ cpu_parallel);
+ };
+
+ auto* const f32_tag = static_cast<float*>(nullptr);
+ auto* const f16_tag = static_cast<ov::float16*>(nullptr);
+ auto* const bf16_tag = static_cast<ov::bfloat16*>(nullptr);
+
+ if (data_precision == ov::element::f32 && state_precision == ov::element::f32) {
+ run(f32_tag, f32_tag);
+ } else if (data_precision == ov::element::f32 && state_precision == ov::element::f16) {
+ run(f32_tag, f16_tag);
+ } else if (data_precision == ov::element::f32 && state_precision == ov::element::bf16) {
+ run(f32_tag, bf16_tag);
+ } else if (data_precision == ov::element::f16 && state_precision == ov::element::f32) {
+ run(f16_tag, f32_tag);
+ } else if (data_precision == ov::element::f16 && state_precision == ov::element::f16) {
+ run(f16_tag, f16_tag);
+ } else if (data_precision == ov::element::f16 && state_precision == ov::element::bf16) {
+ run(f16_tag, bf16_tag);
+ } else if (data_precision == ov::element::bf16 && state_precision == ov::element::f32) {
+ run(bf16_tag, f32_tag);
+ } else if (data_precision == ov::element::bf16 && state_precision == ov::element::f16) {
+ run(bf16_tag, f16_tag);
+ } else if (data_precision == ov::element::bf16 && state_precision == ov::element::bf16) {
+ run(bf16_tag, bf16_tag);
+ } else {
+ OPENVINO_ASSERT(false,
+ "PagedCausalConv1D: unsupported (input_embeds, conv_state_table) precision pair (",
+ data_precision,
+ ", ",
+ state_precision,
+ "). Expected each of f32/f16/bf16.");
+ }
+}
+
+} // namespace ov::Extensions::Cpu::XARCH
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.hpp b/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.hpp
new file mode 100644
index 00000000000..35354bf5336
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.hpp
@@ -0,0 +1,38 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <cstddef>
+#include <cstdint>
+
+#include "cpu_parallel.hpp"
+#include "openvino/core/type/element_type.hpp"
+
+namespace ov::Extensions::Cpu::XARCH {
+
+// Public entry. The CPU plugin registers this function with `cross_compiled_file`, so a
+// per-ISA (AVX512F/AVX2/ANY) copy is built and the runtime dispatcher picks the right one.
+// Inside, runtime precision dispatch selects the (data, state) template instantiation.
+void paged_causal_conv1d_exec(const void* input_embeds,
+ void* conv_state_table,
+ const void* conv_weight,
+ const void* conv_bias,
+ bool has_bias,
+ const int32_t* subsequence_begins,
+ const int32_t* block_indices,
+ const int32_t* block_indices_begins,
+ const int32_t* past_lens,
+ const int32_t* cache_interval,
+ void* output_embeds,
+ size_t batch_size_in_tokens,
+ size_t hidden_size,
+ size_t kernel_size,
+ size_t seq_count,
+ ov::element::Type data_precision,
+ ov::element::Type state_precision,
+ float* local_state,
+ const ov::intel_cpu::CpuParallelPtr& cpu_parallel);
+
+} // namespace ov::Extensions::Cpu::XARCH
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp
index bedfb13479c..f83403c60d6 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp
@@ -40,9 +40,9 @@
namespace ov::Extensions::Cpu::XARCH {
// avx512/avx2 register length in byte
-static constexpr size_t vec_len_avx512 = 64lu;
-static constexpr size_t vec_len_avx2 = 32lu;
-static constexpr size_t vec_len_neon = 16lu;
+static constexpr size_t vec_len_avx512 = 64LU;
+static constexpr size_t vec_len_avx2 = 32LU;
+static constexpr size_t vec_len_neon = 16LU;
// avx512/avx2 register length in float
static constexpr size_t vec_len_f32_avx512 = vec_len_avx512 / sizeof(float);
static constexpr size_t vec_len_f32_avx2 = vec_len_avx2 / sizeof(float);
@@ -456,16 +456,16 @@ inline float32x4_t exp_ps_neon_f32(const float32x4_t& src) {
const auto c5 = vreinterpretq_f32_u32(vdupq_n_u32(0x3c072010));
const auto shift = vreinterpretq_f32_u32(vdupq_n_u32(0x4b00007f)); // 2^23 + 127 = 0x1.0000fep23f
- const auto one = vdupq_n_f32(1.0f); // 1
- const auto two = vdupq_n_f32(2.0f); // 2
+ const auto one = vdupq_n_f32(1.0F); // 1
+ const auto two = vdupq_n_f32(2.0F); // 2
const auto inv_ln2 = vreinterpretq_f32_u32(vdupq_n_u32(0x3fb8aa3b));
const auto neg_ln2_hi = vreinterpretq_f32_u32(vdupq_n_u32(0xbf317200));
const auto neg_ln2_lo = vreinterpretq_f32_u32(vdupq_n_u32(0xb5bfbe8e));
const auto inf = vdupq_n_f32(std::numeric_limits<float>::infinity());
- const auto max_input = vdupq_n_f32(88.37f); // Approximately ln(2^127.5)
+ const auto max_input = vdupq_n_f32(88.37F); // Approximately ln(2^127.5)
const auto zero = vdupq_n_f32(0.F);
- const auto min_input = vdupq_n_f32(-86.64f); // Approximately ln(2^-125)
+ const auto min_input = vdupq_n_f32(-86.64F); // Approximately ln(2^-125)
auto x = vminq_f32(src, max_input);
x = vmaxq_f32(x, min_input);
@@ -498,27 +498,27 @@ inline float32x4_t exp_ps_neon_f32(const float32x4_t& src) {
return poly;
}
-inline float32x4_t __vld1q_f32(const ov::bfloat16* a) {
+inline float32x4_t _vld1q_f32(const ov::bfloat16* a) {
uint16x4_t vec_bf16 = vld1_u16(reinterpret_cast<const uint16_t*>(a));
float32x4_t vec_f32 = vcvtq_f32_u32(vmovl_u16(vec_bf16));
return vec_f32;
}
-inline float32x4_t __vld1q_f32(const float* a) {
+inline float32x4_t _vld1q_f32(const float* a) {
return vld1q_f32(a);
}
-inline float32x4_t __vld1q_f32(const ov::float16* a) {
- auto _a = reinterpret_cast<const float16_t*>(a);
+inline float32x4_t _vld1q_f32(const ov::float16* a) {
+ const auto* _a = reinterpret_cast<const float16_t*>(a);
return vcvt_f32_f16(vld1_f16(_a));
}
-inline void __vst1q_f32(float* a, float32x4_t b) {
+inline void _vst1q_f32(float* a, float32x4_t b) {
vst1q_f32(a, b);
}
-inline void __vst1q_f32(ov::float16* a, float32x4_t b) {
+inline void _vst1q_f32(ov::float16* a, float32x4_t b) {
float16x4_t v_f16 = vcvt_f16_f32(b);
vst1_f16(reinterpret_cast<float16_t*>(a), v_f16);
}
-inline void __vst1q_f32(ov::bfloat16* a, float32x4_t b) {
+inline void _vst1q_f32(ov::bfloat16* a, float32x4_t b) {
uint32x4_t v_int32 = vreinterpretq_u32_f32(b);
uint16x4_t v_bf16 = vshrn_n_u32(v_int32, 16);
@@ -615,11 +615,11 @@ void cvt_add(TDST* dst, TA* a, TB* b, size_t m, size_t n, size_t a_stride, size_
template <typename TA, typename TB>
float dot_product(TA* a,
- TB* b,
+ const TB* b,
size_t n,
- float* scale,
- float* zp,
- float* head_sum,
+ [[maybe_unused]] const float* scale,
+ [[maybe_unused]] const float* zp,
+ [[maybe_unused]] const float* head_sum,
[[maybe_unused]] size_t group_size) {
size_t i = 0;
float sum = 0.0F;
@@ -722,7 +722,7 @@ float dot_product(TA* a,
auto vec_len = vec_len_f32_sve();
auto _a = reinterpret_cast<float32_t*>(a);
- auto _b = reinterpret_cast<float32_t*>(b);
+ const auto* _b = reinterpret_cast<const float32_t*>(b);
for (; i + 4 * vec_len <= n; i += 4 * vec_len) {
svfloat32_t a0 = svld1_f32(pg, _a + i);
@@ -773,21 +773,21 @@ float dot_product(TA* a,
} else
# endif
{
- float32x4_t vsum0 = vdupq_n_f32(0.0f);
- float32x4_t vsum1 = vdupq_n_f32(0.0f);
- float32x4_t vsum2 = vdupq_n_f32(0.0f);
- float32x4_t vsum3 = vdupq_n_f32(0.0f);
+ float32x4_t vsum0 = vdupq_n_f32(0.0F);
+ float32x4_t vsum1 = vdupq_n_f32(0.0F);
+ float32x4_t vsum2 = vdupq_n_f32(0.0F);
+ float32x4_t vsum3 = vdupq_n_f32(0.0F);
for (; i + 4 * vec_len_f32_neon <= n; i += vec_len_f32_neon * 4) {
- float32x4_t va0 = __vld1q_f32(a + i);
- float32x4_t va1 = __vld1q_f32(a + i + vec_len_f32_neon);
- float32x4_t va2 = __vld1q_f32(a + i + vec_len_f32_neon * 2);
- float32x4_t va3 = __vld1q_f32(a + i + vec_len_f32_neon * 3);
+ float32x4_t va0 = _vld1q_f32(a + i);
+ float32x4_t va1 = _vld1q_f32(a + i + vec_len_f32_neon);
+ float32x4_t va2 = _vld1q_f32(a + i + vec_len_f32_neon * 2);
+ float32x4_t va3 = _vld1q_f32(a + i + vec_len_f32_neon * 3);
- float32x4_t vb0 = __vld1q_f32(b + i);
- float32x4_t vb1 = __vld1q_f32(b + i + vec_len_f32_neon);
- float32x4_t vb2 = __vld1q_f32(b + i + vec_len_f32_neon * 2);
- float32x4_t vb3 = __vld1q_f32(b + i + vec_len_f32_neon * 3);
+ float32x4_t vb0 = _vld1q_f32(b + i);
+ float32x4_t vb1 = _vld1q_f32(b + i + vec_len_f32_neon);
+ float32x4_t vb2 = _vld1q_f32(b + i + vec_len_f32_neon * 2);
+ float32x4_t vb3 = _vld1q_f32(b + i + vec_len_f32_neon * 3);
vsum0 = vmlaq_f32(vsum0, va0, vb0);
vsum1 = vmlaq_f32(vsum1, va1, vb1);
@@ -795,19 +795,19 @@ float dot_product(TA* a,
vsum3 = vmlaq_f32(vsum3, va3, vb3);
}
if (i + 2 * vec_len_f32_neon <= n) {
- float32x4_t va0 = __vld1q_f32(a + i);
- float32x4_t va1 = __vld1q_f32(a + i + vec_len_f32_neon);
+ float32x4_t va0 = _vld1q_f32(a + i);
+ float32x4_t va1 = _vld1q_f32(a + i + vec_len_f32_neon);
- float32x4_t vb0 = __vld1q_f32(b + i);
- float32x4_t vb1 = __vld1q_f32(b + i + vec_len_f32_neon);
+ float32x4_t vb0 = _vld1q_f32(b + i);
+ float32x4_t vb1 = _vld1q_f32(b + i + vec_len_f32_neon);
vsum0 = vmlaq_f32(vsum0, va0, vb0);
vsum1 = vmlaq_f32(vsum1, va1, vb1);
i += 2 * vec_len_f32_neon;
}
if (i + vec_len_f32_neon <= n) {
- float32x4_t va0 = __vld1q_f32(a + i);
- float32x4_t vb0 = __vld1q_f32(b + i);
+ float32x4_t va0 = _vld1q_f32(a + i);
+ float32x4_t vb0 = _vld1q_f32(b + i);
vsum0 = vmlaq_f32(vsum0, va0, vb0);
i += vec_len_f32_neon;
}
@@ -828,8 +828,14 @@ float dot_product(TA* a,
}
template <typename TA>
-float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* head_sum, size_t group_size) {
- float sum = 0.0f;
+float dot_product(TA* a,
+ const uint8_t* b,
+ size_t n,
+ const float* scale,
+ const float* zp,
+ [[maybe_unused]] const float* head_sum,
+ size_t group_size) {
+ float sum = 0.0F;
size_t group_id = 0;
#if defined(HAVE_AVX512F)
while (group_id < n / group_size) {
@@ -848,10 +854,10 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
auto va2 = mm512_uni_loadu_ps(a + offset + i + vec_len_f32_avx512 * 2);
auto va3 = mm512_uni_loadu_ps(a + offset + i + vec_len_f32_avx512 * 3);
- auto vb0_128 = _mm_loadu_si128(reinterpret_cast<__m128i*>(b + offset + i));
- auto vb1_128 = _mm_loadu_si128(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx512));
- auto vb2_128 = _mm_loadu_si128(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx512 * 2));
- auto vb3_128 = _mm_loadu_si128(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx512 * 3));
+ auto vb0_128 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + offset + i));
+ auto vb1_128 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx512));
+ auto vb2_128 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx512 * 2));
+ auto vb3_128 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx512 * 3));
auto vb0_256 = _mm512_cvtepu8_epi32(vb0_128);
auto vb1_256 = _mm512_cvtepu8_epi32(vb1_128);
@@ -877,8 +883,8 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
auto va0 = mm512_uni_loadu_ps(a + offset + i);
auto va1 = mm512_uni_loadu_ps(a + offset + i + vec_len_f32_avx512);
- auto vb0_128 = _mm_loadu_si128(reinterpret_cast<__m128i*>(b + offset + i));
- auto vb1_128 = _mm_loadu_si128(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx512));
+ auto vb0_128 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + offset + i));
+ auto vb1_128 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx512));
auto vb0_256 = _mm512_cvtepu8_epi32(vb0_128);
auto vb1_256 = _mm512_cvtepu8_epi32(vb1_128);
@@ -895,7 +901,7 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
}
if (i + vec_len_f32_avx512 <= group_size) {
auto va0 = mm512_uni_loadu_ps(a + offset + i);
- auto vb0_128 = _mm_loadu_si128(reinterpret_cast<__m128i*>(b + offset + i));
+ auto vb0_128 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + offset + i));
auto vb0_256 = _mm512_cvtepu8_epi32(vb0_128);
auto vb0 = _mm512_cvtepi32_ps(vb0_256);
vb0 = _mm512_sub_ps(vb0, v_zp);
@@ -907,7 +913,7 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
vsum0 = _mm512_add_ps(vsum0, vsum2);
float group_sum = _mm512_reduce_add_ps(vsum0);
for (; i < group_size; i++) {
- group_sum += a[offset + i] * (b[offset + i] - group_zp);
+ group_sum += a[offset + i] * (static_cast<float>(b[offset + i]) - group_zp);
}
sum += group_scale * group_sum;
group_id += 1;
@@ -930,10 +936,10 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
auto va2 = mm256_uni_loadu_ps(a + offset + i + vec_len_f32_avx2 * 2);
auto va3 = mm256_uni_loadu_ps(a + offset + i + vec_len_f32_avx2 * 3);
- auto vb0_128 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(b + offset + i));
- auto vb1_128 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx2));
- auto vb2_128 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx2 * 2));
- auto vb3_128 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx2 * 3));
+ auto vb0_128 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(b + offset + i));
+ auto vb1_128 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx2));
+ auto vb2_128 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx2 * 2));
+ auto vb3_128 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx2 * 3));
auto vb0_256 = _mm256_cvtepu8_epi32(vb0_128);
auto vb1_256 = _mm256_cvtepu8_epi32(vb1_128);
@@ -954,8 +960,8 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
auto va0 = mm256_uni_loadu_ps(a + offset + i);
auto va1 = mm256_uni_loadu_ps(a + offset + i + vec_len_f32_avx2);
- auto vb0_128 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(b + offset + i));
- auto vb1_128 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(b + offset + i + vec_len_f32_avx2));
+ auto vb0_128 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(b + offset + i));
+ auto vb1_128 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(b + offset + i + vec_len_f32_avx2));
auto vb0_256 = _mm256_cvtepu8_epi32(vb0_128);
auto vb1_256 = _mm256_cvtepu8_epi32(vb1_128);
@@ -969,7 +975,7 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
}
if (i + vec_len_f32_avx2 <= group_size) {
auto va0 = mm256_uni_loadu_ps(a + offset + i);
- auto vb0_128 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(b + offset + i));
+ auto vb0_128 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(b + offset + i));
auto vb0_256 = _mm256_cvtepu8_epi32(vb0_128);
auto vb0 = _mm256_cvtepi32_ps(vb0_256);
vsum0 = _mm256_fmadd_ps(va0, vb0, vsum0);
@@ -1060,7 +1066,7 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
}
}
for (; i < group_size; i++) {
- group_sum += a[i + offset] * (b[i + offset] - group_zp);
+ group_sum += a[i + offset] * (static_cast<float>(b[i + offset]) - group_zp);
}
sum += group_scale * group_sum;
group_id += 1;
@@ -1074,7 +1080,7 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
size_t offset = group_id * group_size;
float group_sum = 0.0F;
for (; i < group_size; i++) {
- group_sum += a[i + offset] * (b[i + offset] - group_zp);
+ group_sum += a[i + offset] * (static_cast<float>(b[i + offset]) - group_zp);
}
sum += group_scale * group_sum;
group_id += 1;
@@ -1083,7 +1089,7 @@ float dot_product(TA* a, uint8_t* b, size_t n, float* scale, float* zp, float* h
#endif
}
-inline void multiply_scalar(float* a, float* a_dst, const float val, const size_t size) {
+inline void multiply_scalar(const float* a, float* a_dst, const float val, const size_t size) {
size_t i = 0;
#if defined(HAVE_AVX512F)
auto v_scale = _mm512_set1_ps(val);
@@ -1203,9 +1209,9 @@ inline void multiply_scalar_f32(ov::float16* a, ov::float16* a_dst, const ov::fl
float32x4_t v_val = vdupq_n_f32(val);
size_t i = 0;
for (; i + vec_len_f32_neon <= size; i += vec_len_f32_neon) {
- v_a = __vld1q_f32((a + i));
+ v_a = _vld1q_f32((a + i));
v_res = vmulq_f32(v_a, v_val);
- __vst1q_f32(a_dst + i, v_res);
+ _vst1q_f32(a_dst + i, v_res);
}
auto val_f32 = static_cast<float>(val);
for (; i < size; ++i) {
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp
index d4c155db260..28e25dbc8c4 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp
@@ -107,8 +107,8 @@ template <>
void cvt_copy(float* dst, float* src, size_t n) {
size_t i = 0;
for (; i + vec_len_f32_neon <= n; i += vec_len_f32_neon) {
- float32x4_t vb1 = __vld1q_f32(src + i);
- __vst1q_f32(dst + i, vb1);
+ float32x4_t vb1 = _vld1q_f32(src + i);
+ _vst1q_f32(dst + i, vb1);
}
for (; i < n; i++) {
dst[i] = src[i];
@@ -160,10 +160,10 @@ static void attn_acc_value(float* out, float weight, T* v, size_t S, float* scal
# else
float32x4_t attn_w_vec_fp32 = vdupq_n_f32(weight);
for (; i + vec_len_f32_neon <= S; i += vec_len_f32_neon) {
- float32x4_t v_value = __vld1q_f32(v + i);
- float32x4_t v_out = __vld1q_f32(out + i);
+ float32x4_t v_value = _vld1q_f32(v + i);
+ float32x4_t v_out = _vld1q_f32(out + i);
v_out = vmlaq_f32(v_out, attn_w_vec_fp32, v_value);
- __vst1q_f32(out + i, v_out);
+ _vst1q_f32(out + i, v_out);
}
# endif
#endif
@@ -1150,11 +1150,11 @@ static void attn_reduce(T* dst, float* temp, size_t M, size_t S, size_t temp_str
auto* src = temp + i;
auto result_vec_fp32 = vdupq_n_f32(0.0f);
for (size_t m = 0; m < M; m++) {
- auto o_vec_fp32 = __vld1q_f32(src);
+ auto o_vec_fp32 = _vld1q_f32(src);
result_vec_fp32 = vaddq_f32(result_vec_fp32, o_vec_fp32);
src += temp_stride;
}
- __vst1q_f32(dst + i, result_vec_fp32);
+ _vst1q_f32(dst + i, result_vec_fp32);
}
# endif
#endif
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp
index 6f533dd4390..8fa70edc297 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp
@@ -557,7 +557,7 @@ inline void scale_add2_reduce_max(float* a,
}
if (has_attn_mask) {
- float32x4_t v_mask = __vld1q_f32(attn_mask + i);
+ float32x4_t v_mask = _vld1q_f32(attn_mask + i);
v_a = vaddq_f32(v_a, v_mask);
}
diff --git a/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.cpp b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.cpp
new file mode 100644
index 00000000000..c8b3a36f10a
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.cpp
@@ -0,0 +1,175 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "paged_causal_conv1d.h"
+
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <oneapi/dnnl/dnnl_common.hpp>
+#include <string>
+#include <vector>
+
+#include "cpu_memory.h"
+#include "cpu_shape.h"
+#include "graph_context.h"
+#include "memory_desc/cpu_blocked_memory_desc.h"
+#include "memory_desc/cpu_memory_desc.h"
+#include "node.h"
+#include "nodes/kernels/paged_causal_conv1d.hpp"
+#include "onednn/iml_type_mapper.h"
+#include "openvino/core/except.hpp"
+#include "openvino/core/node.hpp"
+#include "openvino/core/type.hpp"
+#include "openvino/core/type/element_type.hpp"
+#include "openvino/op/paged_causal_conv1d.hpp"
+#include "shape_inference/shape_inference_cpu.hpp"
+#include "utils/general_utils.h"
+
+namespace ov::intel_cpu::node {
+
+PagedCausalConv1D::PagedCausalConv1D(const std::shared_ptr<ov::Node>& op, const GraphContext::CPtr& context)
+ : Node(op, context, NgraphShapeInferFactory(op)) {
+ std::string errorMessage;
+ if (!isSupportedOperation(op, errorMessage)) {
+ OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage);
+ }
+}
+
+bool PagedCausalConv1D::isSupportedOperation(const std::shared_ptr<const ov::Node>& op,
+ std::string& errorMessage) noexcept {
+ if (op == nullptr || !ov::is_type<ov::op::internal::PagedCausalConv1D>(op)) {
+ errorMessage = "Node is not an instance of ov::op::internal::PagedCausalConv1D.";
+ return false;
+ }
+
+ return true;
+}
+
+void PagedCausalConv1D::initSupportedPrimitiveDescriptors() {
+ if (!supportedPrimitiveDescriptors.empty()) {
+ return;
+ }
+
+ // Natively accept f32/f16/bf16 on the float-typed ports. The kernel treats input_embeds,
+ // conv_weight, conv_bias and output uniformly as DataT; we declare all of them with the
+ // same precision as input_embeds (port 0).
+ // conv_state_table (port 1) is declared independently; the kernel converts its elements
+ // to/from f32 during accumulation and write-back.
+ const auto data_precision = getOriginalInputPrecisionAtPort(0);
+ OPENVINO_ASSERT(any_of(data_precision, ov::element::f32, ov::element::f16, ov::element::bf16),
+ "PagedCausalConv1D supports only f32/f16/bf16 input_embeds precision, got ",
+ data_precision);
+ const auto state_precision = getOriginalInputPrecisionAtPort(1);
+ OPENVINO_ASSERT(any_of(state_precision, ov::element::f32, ov::element::f16, ov::element::bf16),
+ "PagedCausalConv1D supports only f32/f16/bf16 conv_state_table precision, got ",
+ state_precision);
+
+ std::vector<PortConfigurator> input_configs;
+ input_configs.reserve(getParentEdges().size());
+ input_configs.emplace_back(LayoutType::ncsp, data_precision, getInputShapeAtPort(0), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, state_precision, getInputShapeAtPort(1), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, data_precision, getInputShapeAtPort(2), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, data_precision, getInputShapeAtPort(3), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, ov::element::i32, getInputShapeAtPort(4), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, ov::element::i32, getInputShapeAtPort(5), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, ov::element::i32, getInputShapeAtPort(6), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, ov::element::i32, getInputShapeAtPort(7), false, -1);
+ input_configs.emplace_back(LayoutType::ncsp, ov::element::i32, getInputShapeAtPort(8), false, -1);
+
+ std::vector<PortConfigurator> output_configs = {
+ PortConfigurator{LayoutType::ncsp, data_precision, getOutputShapeAtPort(0), false, -1}};
+
+ addSupportedPrimDesc(input_configs, output_configs, impl_desc_type::ref_any);
+}
+
+void PagedCausalConv1D::createPrimitive() {
+ // Allocate a per-worker-thread f32 scratch buffer holding one promoted conv_state block.
+ // Shape: [num_worker_threads, hidden_size * kernel_size]. Each parallel (sequence, channel-block)
+ // task picks its buffer row via parallel_get_thread_num() in the kernel.
+ // hidden_size (port 0 dim 1) and kernel_size (port 1 dim 2) are static by model convention.
+ const auto& input_embeds_dims = getInputShapeAtPort(0).getDims();
+ const auto& state_table_dims = getInputShapeAtPort(1).getDims();
+ const size_t hidden_size = input_embeds_dims[1];
+ const size_t kernel_size = state_table_dims[2];
+ const auto num_threads = static_cast<size_t>(context->getCpuParallel()->get_num_worker_threads());
+ auto mem_desc =
+ std::make_shared<CpuBlockedMemoryDesc>(ov::element::f32,
+ ov::intel_cpu::Shape{num_threads, hidden_size * kernel_size});
+ m_tmpLocalState = context->getScratchPad()->createScratchPadMem(mem_desc);
+}
+
+void PagedCausalConv1D::execute([[maybe_unused]] const dnnl::stream& strm) {
+ const auto& input_embeds_shape = getSrcMemoryAtPort(0)->getStaticDims();
+ const auto& state_table_shape = getSrcMemoryAtPort(1)->getStaticDims();
+ const auto& weight_shape = getSrcMemoryAtPort(2)->getStaticDims();
+ const auto& bias_shape = getSrcMemoryAtPort(3)->getStaticDims();
+
+ const size_t batch_size_in_tokens = input_embeds_shape[0];
+ const size_t hidden_size = input_embeds_shape[1];
+ const size_t kernel_size = state_table_shape[2];
+
+ OPENVINO_ASSERT(state_table_shape[1] == hidden_size,
+ "PagedCausalConv1D: conv_state_table hidden_size (",
+ state_table_shape[1],
+ ") != input_embeds hidden_size (",
+ hidden_size,
+ ").");
+
+ // Linear attention models use depthwise convolution where group_size == hidden_size,
+ // i.e. conv_weight[1] (in_channels per group) must be 1.
+ OPENVINO_ASSERT(weight_shape.size() == 3 && weight_shape[1] == 1,
+ "PagedCausalConv1D only supports depthwise convolution (conv_weight[1] must be 1). "
+ "Got conv_weight shape [",
+ weight_shape[0],
+ ", ",
+ weight_shape[1],
+ ", ",
+ weight_shape[2],
+ "].");
+
+ const bool has_bias = bias_shape[0] != 0;
+
+ const auto data_precision = getSrcMemoryAtPort(0)->getDescPtr()->getPrecision();
+ const auto state_precision = getSrcMemoryAtPort(1)->getDescPtr()->getPrecision();
+ const auto* input_embeds_raw = getSrcMemoryAtPort(0)->getData();
+ auto* conv_state_raw = getSrcMemoryAtPort(1)->getData();
+ const auto* conv_weight_raw = getSrcMemoryAtPort(2)->getData();
+ const auto* conv_bias_raw = has_bias ? getSrcMemoryAtPort(3)->getData() : nullptr;
+ const auto* subsequence_begins = getSrcDataAtPortAs<const int32_t>(4);
+ const auto* block_indices = getSrcDataAtPortAs<const int32_t>(5);
+ const auto* block_indices_begins = getSrcDataAtPortAs<const int32_t>(6);
+ const auto* past_lens = getSrcDataAtPortAs<const int32_t>(7);
+ const auto* cache_interval = getSrcDataAtPortAs<const int32_t>(8);
+
+ auto* output_embeds_raw = getDstMemoryAtPort(0)->getData();
+
+ const auto& subseq_shape = getSrcMemoryAtPort(4)->getStaticDims();
+ OPENVINO_ASSERT(!subseq_shape.empty(), "PagedCausalConv1D expects non-empty subsequence_begins input.");
+ OPENVINO_ASSERT(subseq_shape[0] >= 1, "PagedCausalConv1D expects subsequence_begins shape[0] >= 1.");
+
+ const size_t seq_count = subseq_shape[0] - 1;
+
+ ov::Extensions::Cpu::XARCH::paged_causal_conv1d_exec(input_embeds_raw,
+ conv_state_raw,
+ conv_weight_raw,
+ conv_bias_raw,
+ has_bias,
+ subsequence_begins,
+ block_indices,
+ block_indices_begins,
+ past_lens,
+ cache_interval,
+ output_embeds_raw,
+ batch_size_in_tokens,
+ hidden_size,
+ kernel_size,
+ seq_count,
+ data_precision,
+ state_precision,
+ m_tmpLocalState->getDataAs<float>(),
+ context->getCpuParallel());
+}
+
+} // namespace ov::intel_cpu::node
diff --git a/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.h b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.h
new file mode 100644
index 00000000000..0ed747e5717
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <memory>
+#include <oneapi/dnnl/dnnl_common.hpp>
+#include <string>
+
+#include "cpu_memory.h"
+#include "cpu_types.h"
+#include "graph_context.h"
+#include "node.h"
+#include "openvino/core/node.hpp"
+
+namespace ov::intel_cpu::node {
+
+class PagedCausalConv1D : public Node {
+public:
+ PagedCausalConv1D(const std::shared_ptr<ov::Node>& op, const GraphContext::CPtr& context);
+
+ static bool isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept;
+
+ void getSupportedDescriptors() override {}
+ void initSupportedPrimitiveDescriptors() override;
+ void createPrimitive() override;
+ void execute(const dnnl::stream& strm) override;
+ void executeDynamicImpl(const dnnl::stream& strm) override {
+ execute(strm);
+ }
+
+ bool created() const override {
+ return getType() == Type::PagedCausalConv1D;
+ }
+
+ // conv_bias (port 3) may have zero dimension when bias is absent
+ bool neverExecute() const override {
+ return getSelectedPrimitiveDescriptor()->hasZeroInputDimsAtPort(0);
+ }
+
+ // conv_bias (port 3) may have zero dimension when bias is absent
+ bool isExecutable() const override {
+ return !isInputTensorAtPortEmpty(0);
+ }
+
+ bool needPrepareParams() const override {
+ return false;
+ }
+
+private:
+ // Per-node f32 scratch buffer holding one promoted conv-state block (hidden_size * kernel_size
+ // floats). Allocated once via the plugin scratchpad in createPrimitive() so that repeated
+ // execute() calls avoid per-invocation heap allocation.
+ MemoryPtr m_tmpLocalState;
+};
+
+} // namespace ov::intel_cpu::node
diff --git a/src/plugins/intel_cpu/src/nodes_factory.cpp b/src/plugins/intel_cpu/src/nodes_factory.cpp
index aca425fca01..d8a4bcac6af 100644
--- a/src/plugins/intel_cpu/src/nodes_factory.cpp
+++ b/src/plugins/intel_cpu/src/nodes_factory.cpp
@@ -67,6 +67,7 @@
#include "nodes/normalize.h"
#include "nodes/one_hot.h"
#include "nodes/pad.h"
+#include "nodes/paged_causal_conv1d.h"
#include "nodes/paged_gated_delta_net.h"
#include "nodes/pooling.h"
#include "nodes/priorbox.h"
@@ -246,6 +247,7 @@ Node::NodesFactory::NodesFactory() : Factory("NodesFactory") {
INTEL_CPU_NODE(GatherMatmul, Type::GatherMatmul);
INTEL_CPU_NODE(GatedDeltaNet, Type::GatedDeltaNet);
INTEL_CPU_NODE(PagedGatedDeltaNet, Type::PagedGatedDeltaNet);
+ INTEL_CPU_NODE(PagedCausalConv1D, Type::PagedCausalConv1D);
#if defined(OPENVINO_ARCH_X86_64)
INTEL_CPU_NODE(FakeQuantize, Type::FakeQuantize);
INTEL_CPU_NODE(GridSample, Type::GridSample);
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/paged_causal_conv1d.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/paged_causal_conv1d.cpp
new file mode 100644
index 00000000000..0a3a72933da
--- /dev/null
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/paged_causal_conv1d.cpp
@@ -0,0 +1,81 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "shared_test_classes/single_op/paged_causal_conv1d.hpp"
+
+#include "openvino/runtime/system_conf.hpp"
+
+namespace ov::test {
+
+TEST_P(PagedCausalConv1DLayerTest, Inference) {
+ const auto& p = GetParam();
+ // On platforms without native f16/bf16 support, the CPU plugin may insert a Reorder
+ // between the input Parameter and the PagedCausalConv1D node, converting conv_state_table
+ // to f32. The kernel then writes updated state into this intermediate f32 buffer, but
+ // the test reads back the original f16/bf16 Parameter tensor which remains stale.
+ if (p.element_type == ov::element::f16 && !ov::with_cpu_x86_avx512_core_fp16())
+ GTEST_SKIP() << "Platform does not natively support f16.";
+ if (p.element_type == ov::element::bf16 && !ov::with_cpu_x86_bfloat16())
+ GTEST_SKIP() << "Platform does not natively support bf16.";
+ run();
+}
+
+// PagedCausalConv1DLayerParams fields:
+// hidden_size, kernel_size, has_bias,
+// seq_lengths_sets (multiple sets for dynamic shapes),
+// cache_intervals_sets (matching intervals),
+// element_type, target_device
+
+std::vector<PagedCausalConv1DLayerParams> paged_conv1d_test_cases = {
+ // --- Static shape tests (single seq_lengths set) ---
+ // Basic: single sequence, interval=1
+ {1, 3, true, {{2}}, {{1}}, ov::element::f32, "CPU"},
+ // Single sequence, interval=0 (only final flush)
+ {1, 3, true, {{2}}, {{0}}, ov::element::f32, "CPU"},
+ // Multiple sequences
+ {1, 2, true, {{2, 1}}, {{1, 1}}, ov::element::f32, "CPU"},
+ // Kernel size 4 with bias
+ {1, 4, true, {{3}}, {{1}}, ov::element::f32, "CPU"},
+ // No bias
+ {1, 2, false, {{2}}, {{2}}, ov::element::f32, "CPU"},
+ // Larger hidden size
+ {8, 3, true, {{3, 2}}, {{2, 3}}, ov::element::f32, "CPU"},
+ {64, 4, true, {{4, 2, 3}}, {{3, 2, 5}}, ov::element::f32, "CPU"},
+ // past_lens offset affecting flush schedule
+ {1, 2, false, {{3}}, {{2}}, ov::element::f32, "CPU"},
+ // Large sequence lengths
+ {32, 4, true, {{15, 32, 33}}, {{16, 16, 16}}, ov::element::f32, "CPU"},
+ {128, 3, true, {{15, 32, 33}}, {{16, 16, 16}}, ov::element::f32, "CPU"},
+
+ // --- Dynamic shape tests (multiple seq_lengths sets per test case) ---
+ // Two iterations with different token counts and sequence counts
+ {1, 3, true, {{2}, {3, 1}}, {{1}, {1, 0}}, ov::element::f32, "CPU"},
+ // Different number of sequences between iterations
+ {8, 3, true, {{3, 2}, {5, 1, 3}}, {{2, 3}, {1, 0, 2}}, ov::element::f32, "CPU"},
+ // Varying total tokens significantly
+ {64, 4, true, {{4, 2}, {15, 32, 33}}, {{3, 2}, {16, 16, 16}}, ov::element::f32, "CPU"},
+ // Three iterations with progressively different shapes
+ {32, 3, true, {{2}, {5, 3}, {1, 1, 1, 1}}, {{1}, {2, 0}, {1, 1, 1, 1}}, ov::element::f32, "CPU"},
+ // Dynamic with no bias
+ {8, 4, false, {{3}, {2, 2}}, {{1}, {1, 1}}, ov::element::f32, "CPU"},
+
+ // --- f16 tests with dynamic shapes ---
+ {1, 3, true, {{2}, {3, 1}}, {{1}, {1, 0}}, ov::element::f16, "CPU"},
+ {8, 3, true, {{3, 2}, {5, 1, 3}}, {{2, 3}, {1, 0, 2}}, ov::element::f16, "CPU"},
+ {64, 4, true, {{4, 2}, {15, 32, 33}}, {{3, 2}, {16, 16, 16}}, ov::element::f16, "CPU"},
+ {32, 3, true, {{2}, {5, 3}, {1, 1, 1, 1}}, {{1}, {2, 0}, {1, 1, 1, 1}}, ov::element::f16, "CPU"},
+
+ // --- bf16 tests with dynamic shapes ---
+ {1, 3, true, {{2}, {3, 1}}, {{1}, {1, 0}}, ov::element::bf16, "CPU"},
+ {8, 3, true, {{3, 2}, {5, 1, 3}}, {{2, 3}, {1, 0, 2}}, ov::element::bf16, "CPU"},
+ {64, 4, true, {{4, 2}, {15, 32, 33}}, {{3, 2}, {16, 16, 16}}, ov::element::bf16, "CPU"},
+ {32, 3, true, {{2}, {5, 3}, {1, 1, 1, 1}}, {{1}, {2, 0}, {1, 1, 1, 1}}, ov::element::bf16, "CPU"},
+};
+
+INSTANTIATE_TEST_SUITE_P(smoke_PagedCausalConv1D,
+ PagedCausalConv1DLayerTest,
+ ::testing::ValuesIn(paged_conv1d_test_cases),
+ PagedCausalConv1DLayerTest::getTestCaseName);
+
+} // namespace ov::test
diff --git a/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/paged_causal_conv1d.hpp b/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/paged_causal_conv1d.hpp
new file mode 100644
index 00000000000..5737b214189
--- /dev/null
+++ b/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/paged_causal_conv1d.hpp
@@ -0,0 +1,56 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <cstdint>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "shared_test_classes/base/ov_subgraph.hpp"
+
+namespace ov::test {
+
+struct PagedCausalConv1DLayerParams {
+ int32_t hidden_size;
+ int32_t kernel_size;
+ bool has_bias;
+ // Multiple sets of seq_lengths/cache_intervals to exercise dynamic shapes.
+ // Each inner vector represents one inference iteration with different token counts.
+ std::vector<std::vector<int32_t>> seq_lengths_sets;
+ std::vector<std::vector<int32_t>> cache_intervals_sets;
+ ov::element::Type element_type;
+ std::string target_device;
+};
+
+class PagedCausalConv1DLayerTest : public testing::WithParamInterface<PagedCausalConv1DLayerParams>,
+ virtual public ov::test::SubgraphBaseTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<PagedCausalConv1DLayerParams>& obj);
+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;
+
+protected:
+ std::vector<ov::Tensor> calculate_refs() override;
+ std::vector<ov::Tensor> get_plugin_outputs() override;
+ void compare(const std::vector<ov::Tensor>& expected, const std::vector<ov::Tensor>& actual) override;
+ void SetUp() override;
+
+private:
+ struct IterationData {
+ std::vector<int32_t> subsequence_begins;
+ std::vector<int32_t> block_indices;
+ std::vector<int32_t> block_indices_begins;
+ std::vector<int32_t> past_lens;
+ std::vector<int32_t> cache_interval;
+ };
+
+ std::map<std::shared_ptr<ov::Node>, ov::Tensor> host_inputs;
+ ov::element::Type data_type;
+ std::vector<IterationData> m_iteration_data;
+ size_t m_current_iteration = 0;
+};
+
+} // namespace ov::test
diff --git a/src/tests/functional/plugin/shared/src/single_op/paged_causal_conv1d.cpp b/src/tests/functional/plugin/shared/src/single_op/paged_causal_conv1d.cpp
new file mode 100644
index 00000000000..60cb462e018
--- /dev/null
+++ b/src/tests/functional/plugin/shared/src/single_op/paged_causal_conv1d.cpp
@@ -0,0 +1,452 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "shared_test_classes/single_op/paged_causal_conv1d.hpp"
+
+#include <algorithm>
+#include <cstdint>
+#include <numeric>
+#include <sstream>
+#include <vector>
+
+#include "common_test_utils/ov_tensor_utils.hpp"
+#include "openvino/core/type/bfloat16.hpp"
+#include "openvino/op/paged_causal_conv1d.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/runtime/remote_context.hpp"
+#include "openvino/runtime/remote_tensor.hpp"
+#include "openvino/runtime/tensor.hpp"
+
+namespace {
+
+struct ShapeConfig {
+ int32_t tokens;
+ int32_t num_sequences;
+ int32_t num_blocks;
+};
+
+ShapeConfig compute_shape_config(const std::vector<int32_t>& seq_lengths, const std::vector<int32_t>& cache_intervals) {
+ const int32_t tokens = std::accumulate(seq_lengths.begin(), seq_lengths.end(), 0);
+ const int32_t num_sequences = static_cast<int32_t>(seq_lengths.size());
+
+ int32_t num_blocks = 0;
+ for (size_t i = 0; i < seq_lengths.size(); i++) {
+ const int32_t past_len = 1 + static_cast<int32_t>(i % 3);
+ if (cache_intervals[i] == 0) {
+ num_blocks += 2;
+ } else {
+ const int32_t prev_nums = past_len % cache_intervals[i];
+ const int32_t write_blocks = (prev_nums + seq_lengths[i] + cache_intervals[i] - 1) / cache_intervals[i];
+ num_blocks += 1 + write_blocks;
+ }
+ }
+ return {tokens, num_sequences, num_blocks};
+}
+
+template <typename T>
+void run_reference(const std::vector<T>& input_embeds,
+ std::vector<T>& conv_state_table,
+ const std::vector<T>& conv_weight,
+ const std::vector<T>& conv_bias,
+ bool has_bias,
+ const std::vector<int32_t>& subsequence_begins,
+ const std::vector<int32_t>& block_indices,
+ const std::vector<int32_t>& block_indices_begins,
+ const std::vector<int32_t>& past_lens,
+ const std::vector<int32_t>& cache_interval,
+ int32_t hidden_size,
+ int32_t kernel_size,
+ std::vector<T>& output) {
+ const size_t state_stride = static_cast<size_t>(hidden_size) * kernel_size;
+ const int32_t num_sequences = static_cast<int32_t>(subsequence_begins.size()) - 1;
+ const size_t total_tokens = input_embeds.size() / hidden_size;
+ output.resize(total_tokens * hidden_size);
+
+ std::vector<float> local_state(state_stride);
+
+ for (int32_t s = 0; s < num_sequences; s++) {
+ const int32_t token_begin = subsequence_begins[s];
+ const int32_t token_end = subsequence_begins[s + 1];
+ const int32_t blk_begin = block_indices_begins[s];
+ const int32_t blk_end = block_indices_begins[s + 1];
+ const int32_t block_span = blk_end - blk_begin;
+ if (block_span <= 1)
+ continue;
+
+ const int32_t seq_interval = cache_interval[s];
+ const int32_t prev_nums = (seq_interval > 0) ? (past_lens[s] % seq_interval) : 0;
+ const int32_t seq_tokens = token_end - token_begin;
+
+ const int32_t read_block = block_indices[blk_begin];
+ for (size_t i = 0; i < state_stride; i++) {
+ local_state[i] = static_cast<float>(conv_state_table[static_cast<size_t>(read_block) * state_stride + i]);
+ }
+
+ for (int32_t t = 0; t < seq_tokens; t++) {
+ const size_t token_idx = static_cast<size_t>(token_begin + t);
+
+ for (int32_t h = 0; h < hidden_size; h++) {
+ float* state_h = local_state.data() + static_cast<size_t>(h) * kernel_size;
+ for (int32_t k = 0; k + 1 < kernel_size; k++) {
+ state_h[k] = state_h[k + 1];
+ }
+ state_h[kernel_size - 1] = static_cast<float>(input_embeds[token_idx * hidden_size + h]);
+
+ const size_t weight_off = static_cast<size_t>(h) * kernel_size;
+ float sum = has_bias ? static_cast<float>(conv_bias[h]) : 0.0f;
+ for (int32_t k = 0; k < kernel_size; k++) {
+ sum += state_h[k] * static_cast<float>(conv_weight[weight_off + k]);
+ }
+ output[token_idx * hidden_size + h] = static_cast<T>(sum);
+ }
+
+ const int32_t cached_tokens = prev_nums + (t + 1);
+ const bool interval_hit = (seq_interval > 0) && ((cached_tokens % seq_interval) == 0);
+ const bool is_last_token = (t == seq_tokens - 1);
+ if (interval_hit || is_last_token) {
+ const int32_t slot = (seq_interval > 0) ? (1 + (cached_tokens - 1) / seq_interval) : 1;
+ if (slot < block_span) {
+ const int32_t phys_block = block_indices[blk_begin + slot];
+ for (size_t i = 0; i < state_stride; i++) {
+ conv_state_table[static_cast<size_t>(phys_block) * state_stride + i] =
+ static_cast<T>(local_state[i]);
+ }
+ }
+ }
+ }
+ }
+}
+
+template <typename T>
+std::vector<T> tensor_to_vector(const ov::Tensor& tensor) {
+ const auto* ptr = tensor.data<const T>();
+ return std::vector<T>(ptr, ptr + tensor.get_size());
+}
+
+ov::Tensor make_i32_tensor(const std::vector<int32_t>& values) {
+ ov::Tensor tensor(ov::element::i32, ov::Shape{values.size()});
+ std::copy(values.begin(), values.end(), tensor.data<int32_t>());
+ return tensor;
+}
+
+template <typename T>
+std::vector<ov::Tensor> calculate_typed_refs(const std::map<std::shared_ptr<ov::Node>, ov::Tensor>& host_inputs,
+ const std::shared_ptr<ov::Model>& function,
+ int32_t hidden_size,
+ int32_t kernel_size,
+ bool has_bias,
+ const ov::element::Type& data_type) {
+ const auto& params = function->get_parameters();
+
+ auto input_embeds = tensor_to_vector<T>(host_inputs.at(params[0]));
+ auto state = tensor_to_vector<T>(host_inputs.at(params[1]));
+ auto weight = tensor_to_vector<T>(host_inputs.at(params[2]));
+ auto bias = tensor_to_vector<T>(host_inputs.at(params[3]));
+ auto subsequence_begins = tensor_to_vector<int32_t>(host_inputs.at(params[4]));
+ auto block_indices = tensor_to_vector<int32_t>(host_inputs.at(params[5]));
+ auto block_indices_begins = tensor_to_vector<int32_t>(host_inputs.at(params[6]));
+ auto past_lens = tensor_to_vector<int32_t>(host_inputs.at(params[7]));
+ auto cache_interval = tensor_to_vector<int32_t>(host_inputs.at(params[8]));
+
+ std::vector<T> ref_output;
+ run_reference(input_embeds,
+ state,
+ weight,
+ bias,
+ has_bias,
+ subsequence_begins,
+ block_indices,
+ block_indices_begins,
+ past_lens,
+ cache_interval,
+ hidden_size,
+ kernel_size,
+ ref_output);
+
+ ov::Tensor output_tensor(data_type, host_inputs.at(params[0]).get_shape());
+ std::copy(ref_output.begin(), ref_output.end(), output_tensor.data<T>());
+
+ ov::Tensor state_tensor(data_type, host_inputs.at(params[1]).get_shape());
+ std::copy(state.begin(), state.end(), state_tensor.data<T>());
+
+ return {output_tensor, state_tensor};
+}
+
+} // namespace
+
+namespace ov::test {
+
+std::string PagedCausalConv1DLayerTest::getTestCaseName(
+ const testing::TestParamInfo<PagedCausalConv1DLayerParams>& obj) {
+ const auto& p = obj.param;
+ std::ostringstream result;
+ result << "Hidden=" << p.hidden_size;
+ result << "_Kernel=" << p.kernel_size;
+ result << "_Bias=" << (p.has_bias ? "yes" : "no");
+ for (size_t s = 0; s < p.seq_lengths_sets.size(); s++) {
+ result << "_SeqSet" << s << "=";
+ for (size_t i = 0; i < p.seq_lengths_sets[s].size(); i++) {
+ if (i > 0)
+ result << "x";
+ result << p.seq_lengths_sets[s][i];
+ }
+ }
+ for (size_t s = 0; s < p.cache_intervals_sets.size(); s++) {
+ result << "_IntSet" << s << "=";
+ for (size_t i = 0; i < p.cache_intervals_sets[s].size(); i++) {
+ if (i > 0)
+ result << "x";
+ result << p.cache_intervals_sets[s][i];
+ }
+ }
+ result << "_Type=" << p.element_type;
+ result << "_Target=" << p.target_device;
+ return result.str();
+}
+
+void PagedCausalConv1DLayerTest::SetUp() {
+ const auto& p = GetParam();
+ targetDevice = p.target_device;
+ data_type = p.element_type;
+ configuration[ov::hint::inference_precision.name()] = p.element_type;
+
+ const size_t num_iters = p.seq_lengths_sets.size();
+ OPENVINO_ASSERT(num_iters > 0);
+ OPENVINO_ASSERT(num_iters == p.cache_intervals_sets.size());
+
+ m_iteration_data.resize(num_iters);
+ m_current_iteration = 0;
+
+ const auto hidden = static_cast<size_t>(p.hidden_size);
+ const auto kernel = static_cast<size_t>(p.kernel_size);
+ const ov::Shape weight_shape{hidden, 1, kernel};
+ const ov::Shape bias_shape = p.has_bias ? ov::Shape{hidden} : ov::Shape{0};
+
+ // Build per-iteration target shapes and metadata
+ std::vector<ov::Shape> embeds_targets;
+ std::vector<ov::Shape> state_targets;
+ std::vector<ov::Shape> subseq_targets;
+ std::vector<ov::Shape> blocks_targets;
+ std::vector<ov::Shape> block_begins_targets;
+ std::vector<ov::Shape> past_lens_targets;
+ std::vector<ov::Shape> interval_targets;
+
+ for (size_t iter = 0; iter < num_iters; iter++) {
+ const auto& sl = p.seq_lengths_sets[iter];
+ const auto& ci = p.cache_intervals_sets[iter];
+ OPENVINO_ASSERT(sl.size() == ci.size());
+
+ const auto cfg = compute_shape_config(sl, ci);
+
+ embeds_targets.push_back({static_cast<size_t>(cfg.tokens), hidden});
+ state_targets.push_back({static_cast<size_t>(cfg.num_blocks), hidden, kernel});
+ subseq_targets.push_back({static_cast<size_t>(cfg.num_sequences + 1)});
+ blocks_targets.push_back({static_cast<size_t>(cfg.num_blocks)});
+ block_begins_targets.push_back({static_cast<size_t>(cfg.num_sequences + 1)});
+ past_lens_targets.push_back({static_cast<size_t>(cfg.num_sequences)});
+ interval_targets.push_back({static_cast<size_t>(cfg.num_sequences)});
+
+ // Precompute metadata for generate_inputs
+ auto& data = m_iteration_data[iter];
+ const int32_t num_sequences = static_cast<int32_t>(sl.size());
+
+ data.subsequence_begins.clear();
+ data.block_indices.clear();
+ data.block_indices_begins.clear();
+ data.past_lens.clear();
+ data.cache_interval.clear();
+
+ data.subsequence_begins.push_back(0);
+ data.block_indices_begins.push_back(0);
+
+ int32_t total_blocks = 0;
+ for (int32_t seq = 0; seq < num_sequences; seq++) {
+ const int32_t seq_len = sl[seq];
+ const int32_t seq_interval = ci[seq];
+ const int32_t seq_past_len = 1 + (seq % 3);
+
+ data.subsequence_begins.push_back(data.subsequence_begins.back() + seq_len);
+ data.past_lens.push_back(seq_past_len);
+ data.cache_interval.push_back(seq_interval);
+
+ int32_t required_slots = 2;
+ if (seq_interval > 0) {
+ const int32_t prev_nums = seq_past_len % seq_interval;
+ const int32_t write_blocks = (prev_nums + seq_len + seq_interval - 1) / seq_interval;
+ required_slots = 1 + write_blocks;
+ }
+ for (int32_t i = 0; i < required_slots; i++) {
+ data.block_indices.push_back(total_blocks + i);
+ }
+ total_blocks += required_slots;
+ data.block_indices_begins.push_back(total_blocks);
+ }
+ }
+
+ // Use dynamic partial shapes for dimensions that vary across iterations
+ init_input_shapes({
+ InputShape{ov::PartialShape{-1, static_cast<int64_t>(hidden)}, embeds_targets},
+ InputShape{ov::PartialShape{-1, static_cast<int64_t>(hidden), static_cast<int64_t>(kernel)}, state_targets},
+ InputShape{ov::PartialShape{static_cast<int64_t>(hidden), 1, static_cast<int64_t>(kernel)}, {weight_shape}},
+ InputShape{ov::PartialShape{static_cast<int64_t>(p.has_bias ? p.hidden_size : 0)}, {bias_shape}},
+ InputShape{ov::PartialShape{-1}, subseq_targets},
+ InputShape{ov::PartialShape{-1}, blocks_targets},
+ InputShape{ov::PartialShape{-1}, block_begins_targets},
+ InputShape{ov::PartialShape{-1}, past_lens_targets},
+ InputShape{ov::PartialShape{-1}, interval_targets},
+ });
+
+ // Build model with dynamic shapes
+ auto p_embeds = std::make_shared<ov::op::v0::Parameter>(data_type, inputDynamicShapes[0]);
+ auto p_state = std::make_shared<ov::op::v0::Parameter>(data_type, inputDynamicShapes[1]);
+ auto p_weight = std::make_shared<ov::op::v0::Parameter>(data_type, inputDynamicShapes[2]);
+ auto p_bias = std::make_shared<ov::op::v0::Parameter>(data_type, inputDynamicShapes[3]);
+ auto p_subseq = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, inputDynamicShapes[4]);
+ auto p_blocks = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, inputDynamicShapes[5]);
+ auto p_block_begins = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, inputDynamicShapes[6]);
+ auto p_past_lens = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, inputDynamicShapes[7]);
+ auto p_cache_interval = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, inputDynamicShapes[8]);
+
+ auto conv1d = std::make_shared<ov::op::internal::PagedCausalConv1D>(p_embeds,
+ p_state,
+ p_weight,
+ p_bias,
+ p_subseq,
+ p_blocks,
+ p_block_begins,
+ p_past_lens,
+ p_cache_interval);
+
+ function = std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(conv1d)},
+ ov::ParameterVector{p_embeds,
+ p_state,
+ p_weight,
+ p_bias,
+ p_subseq,
+ p_blocks,
+ p_block_begins,
+ p_past_lens,
+ p_cache_interval});
+}
+
+void PagedCausalConv1DLayerTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {
+ inputs.clear();
+ host_inputs.clear();
+
+ const auto& p = GetParam();
+ const size_t iter = m_current_iteration;
+ m_current_iteration = (m_current_iteration + 1) % m_iteration_data.size();
+ const auto& iter_data = m_iteration_data[iter];
+
+ const auto& params = function->get_parameters();
+ const bool use_remote_tensors = targetDevice == "GPU";
+ ov::RemoteContext remote_context;
+ if (use_remote_tensors) {
+ remote_context = compiledModel.get_context();
+ }
+
+ for (size_t i = 0; i < params.size(); i++) {
+ const auto& param = params[i];
+ const auto& shape = targetInputStaticShapes[i];
+ ov::Tensor tensor;
+
+ if (i <= 1) {
+ // input_embeds and conv_state_table
+ tensor = ov::test::utils::create_and_fill_tensor(param->get_element_type(),
+ shape,
+ ov::test::utils::InputGenerateData(-1, 1, 1000, 1));
+ } else if (i == 2) {
+ // conv_weight
+ tensor = ov::test::utils::create_and_fill_tensor(param->get_element_type(),
+ shape,
+ ov::test::utils::InputGenerateData(-1, 1, 1000, 1));
+ } else if (i == 3) {
+ // conv_bias
+ if (p.has_bias) {
+ tensor = ov::test::utils::create_and_fill_tensor(param->get_element_type(),
+ shape,
+ ov::test::utils::InputGenerateData(-1, 1, 1000, 1));
+ } else {
+ tensor = ov::Tensor(param->get_element_type(), shape);
+ }
+ } else if (i == 4) {
+ tensor = make_i32_tensor(iter_data.subsequence_begins);
+ } else if (i == 5) {
+ tensor = make_i32_tensor(iter_data.block_indices);
+ } else if (i == 6) {
+ tensor = make_i32_tensor(iter_data.block_indices_begins);
+ } else if (i == 7) {
+ tensor = make_i32_tensor(iter_data.past_lens);
+ } else if (i == 8) {
+ tensor = make_i32_tensor(iter_data.cache_interval);
+ }
+
+ host_inputs[param] = tensor;
+
+ if (use_remote_tensors && i <= 3) {
+ auto remote_tensor = remote_context.create_tensor(param->get_element_type(), shape);
+ remote_tensor.copy_from(tensor);
+ inputs[param] = remote_tensor;
+ } else {
+ inputs[param] = tensor;
+ }
+ }
+}
+
+std::vector<ov::Tensor> PagedCausalConv1DLayerTest::calculate_refs() {
+ const auto& p = GetParam();
+
+ if (data_type == ov::element::f16) {
+ return calculate_typed_refs<ov::float16>(host_inputs,
+ function,
+ p.hidden_size,
+ p.kernel_size,
+ p.has_bias,
+ data_type);
+ }
+
+ if (data_type == ov::element::bf16) {
+ return calculate_typed_refs<ov::bfloat16>(host_inputs,
+ function,
+ p.hidden_size,
+ p.kernel_size,
+ p.has_bias,
+ data_type);
+ }
+
+ return calculate_typed_refs<float>(host_inputs, function, p.hidden_size, p.kernel_size, p.has_bias, data_type);
+}
+
+std::vector<ov::Tensor> PagedCausalConv1DLayerTest::get_plugin_outputs() {
+ auto outputs = SubgraphBaseTest::get_plugin_outputs();
+
+ // Read back the state table (input 1) which was modified in-place
+ const auto& state_param = function->get_parameters().at(1);
+ const auto actual_state_tensor = inferRequest.get_tensor(state_param);
+ ov::Tensor host_state_tensor(actual_state_tensor.get_element_type(), actual_state_tensor.get_shape());
+ actual_state_tensor.copy_to(host_state_tensor);
+ outputs.push_back(host_state_tensor);
+
+ return outputs;
+}
+
+void PagedCausalConv1DLayerTest::compare(const std::vector<ov::Tensor>& expected,
+ const std::vector<ov::Tensor>& actual) {
+ ASSERT_EQ(expected.size(), actual.size());
+ if (data_type == ov::element::bf16) {
+ abs_threshold = 1e-2f;
+ rel_threshold = 1e-2f;
+ } else if (data_type == ov::element::f16) {
+ abs_threshold = 1e-3f;
+ rel_threshold = 1e-3f;
+ } else {
+ abs_threshold = 1e-5f;
+ rel_threshold = 1e-5f;
+ }
+ ov::test::utils::compare(expected[0], actual[0], abs_threshold, rel_threshold);
+ ov::test::utils::compare(expected[1], actual[1], abs_threshold, rel_threshold);
+}
+
+} // namespace ov::test