Skip to content

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

Support dilation attribute for PagedCausalConv1D (#38634)

Andrii Staikovfc310be5d695
diff --git a/docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/internal/paged-causal-conv1d.rst b/docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/internal/paged-causal-conv1d.rst
index 8f77bf754e2..11b71372d38 100644
--- a/docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/internal/paged-causal-conv1d.rst
+++ b/docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/internal/paged-causal-conv1d.rst
@@ -14,18 +14,22 @@ PagedCausalConv1D
The *PagedCausalConv1D* operation performs a causal 1D grouped convolution over a batch of token sequences,
maintaining the convolution state in paged memory blocks. The causal 1D-convolution is a 1D convolution layer where each output
at time step ``t`` depends only on inputs from time ``<=t`` (not future values),
-making it suitable for time-series and autoregressive models.
+making it suitable for time-series and autoregressive models. An optional *dilation* attribute spaces the
+convolution taps across the cached state window, as in a standard dilated causal convolution.
**Detailed description**
*PagedCausalConv1D* processes a flat batch of tokens that may belong to multiple independent sequences.
The token sequences are described by ``subsequence_begins``. Paged memory uses a fixed ``BLOCK_SIZE=1``,
-meaning each physical block in ``conv_state_table`` stores exactly one convolution state snapshot of shape ``[hidden_size, kernel_size]``.
+meaning each physical block in ``conv_state_table`` stores exactly one convolution state snapshot of shape
+``[hidden_size, causal_window]``, where ``causal_window = (kernel_taps-1)*dilation+1`` and ``kernel_taps`` is
+``conv_weight``'s 3rd dimension. With the default ``dilation == 1``, ``causal_window`` equals ``kernel_taps``.
For each sequence, the operation:
-1. Loads the current convolution state (a window of the last `kernel_size` input vectors) from paged memory using the block table.
+1. Loads the current convolution state (a window of the last ``causal_window`` input vectors) from paged memory using the block table.
-2. For each token, shifts the state window, inserts the new token, and applies a grouped causal 1D convolution to produce the output embedding.
+2. For each token, shifts the state window, inserts the new token, and applies a grouped causal 1D convolution over taps
+ spaced ``dilation`` positions apart within the window to produce the output embedding.
3. Caches intermediate states to paged memory blocks at intervals controlled by `cache_interval`
(used during prefill to support prefix caching and chunked prefill).
@@ -82,6 +86,8 @@ Cases for reading and updating blocks:
.. code-block:: py
:force:
+ causal_window = (kernel_taps - 1) * dilation + 1 # kernel_taps is conv_weight's 3rd dimension
+
for s in range(batch_size_in_sequences):
token_start = subsequence_begins[s]
token_end = subsequence_begins[s + 1]
@@ -93,19 +99,19 @@ Cases for reading and updating blocks:
seq_blocks = la_block_indices[blk_start:blk_end] # list of physical block indices
# Load current convolution state from the last assigned block.
- # state shape: [hidden_size, kernel_size], where state[:, -1] is
+ # state shape: [hidden_size, causal_window], where state[:, -1] is
# the most recently seen input and state[:, 0] is the oldest.
# Initially zero if the sequence has not been processed before.
- state = conv_state_table[seq_blocks[-1]] # [hidden_size, kernel_size]
+ state = conv_state_table[seq_blocks[-1]] # [hidden_size, causal_window]
for t in range(seq_len):
x = input_embeds[token_start + t] # [hidden_size]
# Shift state left and append the new token on the right
- state = concat([state[:, 1:], x[:, newaxis]], axis=-1) # [hidden_size, kernel_size]
+ state = concat([state[:, 1:], x[:, newaxis]], axis=-1) # [hidden_size, causal_window]
- # Grouped causal 1D convolution output
- output_embeds[token_start + t] = grouped_conv1d(state, conv_weight, conv_bias)
+ # Grouped causal 1D convolution output, sampling taps `dilation` positions apart
+ output_embeds[token_start + t] = grouped_conv1d(state, conv_weight, conv_bias, dilation)
# Cache state at regular intervals (for prefix caching / chunked prefill)
abs_pos = num_processed_tokens[s] + t # 0-based absolute position of the token
@@ -116,8 +122,10 @@ Cases for reading and updating blocks:
# Persist the final state for this sequence into the last block
conv_state_table[seq_blocks[-1]] = state
-Where ``grouped_conv1d`` computes a standard grouped (or depthwise when ``group_size == hidden_size``) convolution
-over the state window. Here ``group_size`` is the number of input channels per group, ``groups = hidden_size // group_size``
+Where ``grouped_conv1d`` computes a standard grouped (or depthwise when ``group_size == hidden_size``) convolution,
+sampling ``kernel_taps`` positions spaced ``dilation`` apart out of the ``causal_window``
+(the last tap always aligns with the most recent token, ``state[:, -1]``). Here ``group_size`` is the number of
+input channels per group, ``groups = hidden_size // group_size``
is the total number of groups (equivalent to ``out_channels // (hidden_size // group_size)`` given
the constraint ``out_channels == hidden_size``), and ``out_channels`` must equal ``hidden_size``
(as required by the output shape). The weight tensor second dimension is ``hidden_size // group_size`` (channels per group):
@@ -125,9 +133,9 @@ the constraint ``out_channels == hidden_size``), and ``out_channels`` must equal
.. code-block:: py
:force:
- def grouped_conv1d(state, conv_weight, conv_bias):
- # state: [hidden_size, kernel_size]
- # conv_weight: [out_channels, hidden_size // group_size, kernel_size]
+ def grouped_conv1d(state, conv_weight, conv_bias, dilation):
+ # state: [hidden_size, causal_window], causal_window = (kernel_taps-1)*dilation+1
+ # conv_weight: [out_channels, hidden_size // group_size, kernel_taps]
# where out_channels == hidden_size (constraint for this operation)
# conv_bias: [out_channels]
# returns: [out_channels]
@@ -136,16 +144,29 @@ the constraint ``out_channels == hidden_size``), and ``out_channels`` must equal
# (equals hidden_size for depthwise; 1 for channel-wise)
groups = hidden_size // group_size # total number of groups (== out_channels / ic_per_group, given out_channels == hidden_size)
ic_per_group = hidden_size // groups # == group_size
+ kernel_taps = conv_weight.shape[-1]
output = zeros(out_channels)
for oc in range(out_channels):
g = oc * groups // out_channels # group index for output channel oc
ic_start = g * ic_per_group
ic_end = ic_start + ic_per_group
- output[oc] = sum(conv_weight[oc, :, :] * state[ic_start:ic_end, :]) + conv_bias[oc]
+ # tap k reads state[:, k*dilation]; with dilation == 1 this is a contiguous window
+ sampled = state[ic_start:ic_end, 0:kernel_taps * dilation:dilation]
+ output[oc] = sum(conv_weight[oc, :, :] * sampled) + conv_bias[oc]
return output
-**Attributes**: *PagedCausalConv1D* operation has no attributes.
+**Attributes**
+
+* *dilation*
+
+ * **Description**: *dilation* specifies the spacing between the convolution taps sampled from the causal
+ window, analogous to the ``dilations`` attribute of *GroupConvolution* applied to a single spatial axis.
+ With the default ``dilation == 1``, ``causal_window`` equals ``kernel_taps`` and taps are contiguous.
+ * **Range of values**: a positive integer
+ * **Type**: ``size_t``
+ * **Default value**: 1
+ * **Required**: *no*
**Inputs**
@@ -155,20 +176,22 @@ the constraint ``out_channels == hidden_size``), and ``out_channels`` must equal
Input token embeddings from all sequences in the batch. **Required.**
* **1**: ``conv_state_table``
- A 3D tensor of type *T_cache* with shape ``[num_physical_blocks, hidden_size, kernel_size]``.
+ A 3D tensor of type *T_cache* with shape ``[num_physical_blocks, hidden_size, causal_window]``, where
+ ``causal_window = (kernel_taps-1)*dilation+1`` (``kernel_taps`` is the 3rd dimension of ``conv_weight``).
+ With the default ``dilation == 1``, ``causal_window`` equals ``kernel_taps``.
Paged block table holding the convolution cache states. The paged memory block size is fixed at ``BLOCK_SIZE=1``,
- meaning each physical block stores exactly one convolution state of shape ``[hidden_size, kernel_size]``,
- representing the last ``kernel_size`` input vectors seen by the corresponding sequence.
+ meaning each physical block stores exactly one convolution state of shape ``[hidden_size, causal_window]``,
+ representing the last ``causal_window`` input vectors seen by the corresponding sequence.
``num_physical_blocks`` equals the total number of physical state rows allocated in the table. It may be
smaller than the number of logical entries in ``la_block_indices`` when several entries refer to the same row.
The table is updated in-place: during prefill by the plugin, during decoding by GenAI. Initially all states are zero tensors.
**Required.**
* **2**: ``conv_weight``
- A 3D tensor of type *T* with shape ``[out_channels, hidden_size / group_size, kernel_size]``.
+ A 3D tensor of type *T* with shape ``[out_channels, hidden_size / group_size, kernel_taps]``.
Convolution filter weights, where ``group_size`` is the number of input channels per convolution group
(``1 <= group_size <= hidden_size``). For a depthwise convolution
- ``group_size == hidden_size`` and ``out_channels == hidden_size``, so the shape becomes ``[hidden_size, 1, kernel_size]``.
+ ``group_size == hidden_size`` and ``out_channels == hidden_size``, so the shape becomes ``[hidden_size, 1, kernel_taps]``.
The constraint ``out_channels == hidden_size`` is required so that the output shape matches the input shape. **Required.**
* **3**: ``conv_bias``
diff --git a/src/common/transformations/include/transformations/paged_attention/paged_causal_conv1d_fusion.hpp b/src/common/transformations/include/transformations/paged_attention/paged_causal_conv1d_fusion.hpp
index 7217b88e360..42d08e3d869 100644
--- a/src/common/transformations/include/transformations/paged_attention/paged_causal_conv1d_fusion.hpp
+++ b/src/common/transformations/include/transformations/paged_attention/paged_causal_conv1d_fusion.hpp
@@ -6,7 +6,7 @@
#include <unordered_set>
-#include "openvino/pass/matcher_pass.hpp"
+#include "openvino/pass/backward_graph_rewrite.hpp"
#include "openvino/pass/sdpa_to_paged_attention.hpp"
#include "transformations_visibility.hpp"
@@ -17,6 +17,11 @@ namespace pass {
* @ingroup ov_transformation_common_api
* @brief Fuses GroupConvolution-based causal Conv1D state update into internal::PagedCausalConv1D.
*
+ * Supports two history layouts for a window of (kernel_size - 1) * dilation + 1:
+ * a full-window history followed by output trimming, and a window-minus-one history
+ * without output trimming. The paged state table always stores the full window.
+ * Traverses backwards to match optional output trimming and bias before the convolution alone.
+ *
* For example, the following graph
*
* +------------------+
@@ -38,7 +43,7 @@ namespace pass {
* |
* v
* +------------------+
- * | Slice (axis=2) |
+ * | [Slice(axis=2)] |
* +------------------+
* |
* v
@@ -74,11 +79,12 @@ namespace pass {
* v
* ...
*
- * [optional] legacy present-state Result is rewired to preserve external behavior.
+ * The replaced state's variable ID is recorded so that the enclosing paged-attention
+ * pipeline can remove its Assign. Explicit present-state Results are left intact.
*/
-class TRANSFORMATIONS_API PagedCausalConv1DFusion : public ov::pass::MatcherPass {
+class TRANSFORMATIONS_API PagedCausalConv1DFusion : public ov::pass::BackwardGraphRewrite {
public:
- OPENVINO_MATCHER_PASS_RTTI("PagedCausalConv1DFusion");
+ OPENVINO_GRAPH_REWRITE_RTTI("PagedCausalConv1DFusion");
PagedCausalConv1DFusion(ov::pass::paged_attention::PaParams& pa_params,
std::unordered_set<std::string>& var_ids_to_remove);
diff --git a/src/common/transformations/src/transformations/paged_attention/paged_causal_conv1d_fusion.cpp b/src/common/transformations/src/transformations/paged_attention/paged_causal_conv1d_fusion.cpp
index be867eef1cf..ecfa30ad38c 100644
--- a/src/common/transformations/src/transformations/paged_attention/paged_causal_conv1d_fusion.cpp
+++ b/src/common/transformations/src/transformations/paged_attention/paged_causal_conv1d_fusion.cpp
@@ -19,7 +19,6 @@
#include "openvino/op/assign.hpp"
#include "openvino/op/concat.hpp"
#include "openvino/op/constant.hpp"
-#include "openvino/op/gather.hpp"
#include "openvino/op/group_conv.hpp"
#include "openvino/op/multiply.hpp"
#include "openvino/op/paged_causal_conv1d.hpp"
@@ -29,7 +28,9 @@
#include "openvino/op/slice.hpp"
#include "openvino/op/transpose.hpp"
#include "openvino/op/unsqueeze.hpp"
+#include "openvino/op/util/gather_base.hpp"
#include "openvino/op/util/read_value_base.hpp"
+#include "openvino/pass/matcher_pass.hpp"
#include "openvino/pass/pattern/matcher.hpp"
#include "openvino/pass/pattern/op/optional.hpp"
#include "openvino/pass/pattern/op/or.hpp"
@@ -49,73 +50,91 @@ namespace v8 = ov::op::v8;
namespace {
-ov::PartialShape make_conv_state_table_shape(const ov::PartialShape& past_state_shape) {
- if (past_state_shape.rank().is_static() && past_state_shape.rank().get_length() == 3) {
- return ov::PartialShape{ov::Dimension::dynamic(), past_state_shape[1], past_state_shape[2]};
- }
- return ov::PartialShape::dynamic(3);
+// PagedCausalConv1D has no stride/padding attributes: it always produces one output per
+// input token. A strided or padded GroupConvolution would change the output token count
+// and is not representable by the fused op.
+ov::pass::pattern::op::Predicate has_unit_stride_and_no_padding() {
+ return ov::pass::pattern::op::Predicate(
+ [](const ov::Output<ov::Node>& output) -> bool {
+ const auto group_conv = ov::as_type_ptr<v1::GroupConvolution>(output.get_node_shared_ptr());
+ const auto& strides = group_conv->get_strides();
+ const auto& pads_begin = group_conv->get_pads_begin();
+ const auto& pads_end = group_conv->get_pads_end();
+ return (strides.empty() || strides[0] == 1) && (pads_begin.empty() || pads_begin[0] == 0) &&
+ (pads_end.empty() || pads_end[0] == 0);
+ },
+ "has_unit_stride_and_no_padding");
}
} // namespace
namespace ov::pass {
-PagedCausalConv1DFusion::PagedCausalConv1DFusion(ov::pass::paged_attention::PaParams& pa_params,
- std::unordered_set<std::string>& var_ids_to_remove) {
- MATCHER_SCOPE(PagedCausalConv1DFusion);
+class PagedCausalConv1DFusionMatcher : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("PagedCausalConv1DFusionMatcher");
+ PagedCausalConv1DFusionMatcher(ov::pass::paged_attention::PaParams& pa_params,
+ std::unordered_set<std::string>& var_ids_to_remove,
+ size_t& layer_index);
+};
+
+PagedCausalConv1DFusionMatcher::PagedCausalConv1DFusionMatcher(ov::pass::paged_attention::PaParams& pa_params,
+ std::unordered_set<std::string>& var_ids_to_remove,
+ size_t& layer_index) {
+ MATCHER_SCOPE(PagedCausalConv1DFusionMatcher);
auto p_read_value = wrap_type<ov::op::util::ReadValueBase>(has_static_rank() && rank_equals(3));
- auto p_past_via_gather = ov::pass::pattern::optional<v8::Gather>({p_read_value, any_input(), any_input()});
+ auto p_past_via_gather =
+ ov::pass::pattern::optional<ov::op::util::GatherBase>({p_read_value, any_input(), any_input()});
auto p_token_input = any_input(rank_equals(3));
auto p_concat_past_first = wrap_type<v0::Concat>({p_past_via_gather, p_token_input}, {{"axis", -1}});
auto p_concat_token_first = wrap_type<v0::Concat>({p_token_input, p_past_via_gather}, {{"axis", -1}});
- auto p_state_concat =
- std::make_shared<ov::pass::pattern::op::Or>(ov::OutputVector{p_concat_past_first, p_concat_token_first});
+ auto p_state_concat = p_concat_past_first | p_concat_token_first;
auto p_weight_input = any_input(has_static_shape() && rank_equals(4));
- auto p_group_conv = wrap_type<v1::GroupConvolution>({p_state_concat, p_weight_input});
+ auto p_group_conv =
+ wrap_type<v1::GroupConvolution>({p_state_concat, p_weight_input}, has_unit_stride_and_no_padding());
auto p_bias_input = any_input(has_static_shape());
auto p_add_bias = ov::pass::pattern::optional<v1::Add>({p_group_conv, p_bias_input});
+ auto p_slice_out =
+ ov::pass::pattern::optional<v8::Slice>({p_add_bias, any_input(), any_input(), any_input(), any_input()});
- auto p_slice_out = wrap_type<v8::Slice>({p_add_bias, any_input(), any_input(), any_input(), any_input()});
-
- ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS, &pa_params, &var_ids_to_remove](
+ ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS, &pa_params, &var_ids_to_remove, &layer_index](
ov::pass::pattern::Matcher& m) {
if (transformation_callback(m.get_match_root())) {
return false;
}
const auto& pm = m.get_pattern_value_map();
+ const bool with_output_slice = pm.count(p_slice_out) != 0;
- const auto state_concat = pm.at(p_state_concat).get_node_shared_ptr();
const auto group_conv_node = ov::as_type_ptr<v1::GroupConvolution>(pm.at(p_group_conv).get_node_shared_ptr());
const auto weight_node = pm.at(p_weight_input).get_node_shared_ptr();
const auto cache_rv = ov::as_type_ptr<ov::op::util::ReadValueBase>(pm.at(p_read_value).get_node_shared_ptr());
- const auto slice_out = pm.at(p_slice_out).get_node_shared_ptr();
-
- pa_params.add("subsequence_begins", ov::element::i32, ov::PartialShape{-1});
- pa_params.add("la.block_indices", ov::element::i32, ov::PartialShape{-1});
- pa_params.add("la.block_indices_begins", ov::element::i32, ov::PartialShape{-1});
- pa_params.add("la.past_lens", ov::element::i32, ov::PartialShape{-1});
- pa_params.add("la.cache_interval", ov::element::i32, ov::PartialShape{-1});
-
- const auto conv_state_table = pa_params.add("conv_state_table." + std::to_string(m_layer_index++),
- ov::element::dynamic,
- make_conv_state_table_shape(cache_rv->get_output_partial_shape(0)));
-
- enable_keep_const_precision(conv_state_table);
- var_ids_to_remove.insert(cache_rv->get_variable_id());
-
- auto token_input = pm.at(p_token_input).get_node_shared_ptr();
const auto past_state = pm.count(p_past_via_gather) ? pm.at(p_past_via_gather).get_node_shared_ptr() : cache_rv;
+ auto token_input = pm.at(p_token_input).get_node_shared_ptr();
+
+ OPENVINO_ASSERT(group_conv_node);
+ OPENVINO_ASSERT(cache_rv);
const auto& weight_shape = weight_node->get_output_shape(0);
const size_t hidden_size = weight_shape[0];
const size_t kernel_size = weight_shape[3];
+ const size_t dilation = group_conv_node->get_dilations().size() > 0 ? group_conv_node->get_dilations()[0] : 1;
+ const size_t causal_window = (kernel_size - 1) * dilation + 1;
+ // A full-window history produces one extra output, removed by the output Slice.
+ // The history-only form (e.g. PLE) already produces one output per current token.
+ const size_t history_length = with_output_slice ? causal_window : causal_window - 1;
+
const auto& state_pshape = past_state->get_output_partial_shape(0);
- if (!state_pshape[1].compatible(hidden_size) || !state_pshape[2].compatible(kernel_size)) {
+ // Without output trimming, history must precede the tokens and have an exact length.
+ // TODO: remove the case where first goes present then past (it pobably doesn't exist in real life)
+ if (!with_output_slice && (!pm.count(p_concat_past_first) || state_pshape[2].is_dynamic())) {
+ return false;
+ }
+ if (!state_pshape[1].compatible(hidden_size) || !state_pshape[2].compatible(history_length)) {
return false;
}
@@ -145,19 +164,12 @@ PagedCausalConv1DFusion::PagedCausalConv1DFusion(ov::pass::paged_attention::PaPa
if (pm.count(p_add_bias)) {
const auto bias_input = pm.at(p_bias_input).get_node_shared_ptr();
const auto& bias_shape = bias_input->get_output_partial_shape(0);
- if (bias_shape.rank().is_static() && bias_shape.rank().get_length() == 1 &&
- bias_shape[0].compatible(hidden_size)) {
+ if (bias_shape.rank().get_length() == 1 && bias_shape[0].compatible(hidden_size)) {
bias_node = bias_input;
} else {
- if (bias_shape.is_static()) {
+ if (bias_shape.is_static() && ov::shape_size(bias_shape.to_shape()) != hidden_size) {
// Validate that the total element count matches hidden_size
- size_t num_elements = 1;
- for (size_t i = 0; i < static_cast<size_t>(bias_shape.rank().get_length()); ++i) {
- num_elements *= bias_shape[i].get_length();
- }
- if (num_elements != hidden_size) {
- return false;
- }
+ return false;
}
const auto bias_shape_node =
v0::Constant::create(ov::element::i64, ov::Shape{1}, std::vector<int64_t>{-1});
@@ -167,6 +179,23 @@ PagedCausalConv1DFusion::PagedCausalConv1DFusion(ov::pass::paged_attention::PaPa
bias_node = v0::Constant::create(elem_type, ov::Shape{0}, std::vector<float>{});
}
+ pa_params.add("subsequence_begins", ov::element::i32, ov::PartialShape{-1});
+ pa_params.add("la.block_indices", ov::element::i32, ov::PartialShape{-1});
+ pa_params.add("la.block_indices_begins", ov::element::i32, ov::PartialShape{-1});
+ pa_params.add("la.past_lens", ov::element::i32, ov::PartialShape{-1});
+ pa_params.add("la.cache_interval", ov::element::i32, ov::PartialShape{-1});
+
+ // The paged kernel shifts before inserting the current token and always stores
+ // the full window, even when the source graph only stores window - 1 inputs.
+ const auto conv_state_table = pa_params.add("conv_state_table." + std::to_string(layer_index++),
+ ov::element::dynamic,
+ ov::PartialShape{ov::Dimension::dynamic(),
+ static_cast<int64_t>(hidden_size),
+ static_cast<int64_t>(causal_window)});
+
+ enable_keep_const_precision(conv_state_table);
+ var_ids_to_remove.insert(cache_rv->get_variable_id());
+
const auto paged_conv =
std::make_shared<ov::op::internal::PagedCausalConv1D>(input_embeds_node,
conv_state_table,
@@ -176,7 +205,8 @@ PagedCausalConv1DFusion::PagedCausalConv1DFusion(ov::pass::paged_attention::PaPa
pa_params["la.block_indices"],
pa_params["la.block_indices_begins"],
pa_params["la.past_lens"],
- pa_params["la.cache_interval"]);
+ pa_params["la.cache_interval"],
+ dilation);
paged_conv->set_friendly_name(group_conv_node->get_friendly_name() + "/PagedCausalConv1D");
@@ -193,7 +223,7 @@ PagedCausalConv1DFusion::PagedCausalConv1DFusion(ov::pass::paged_attention::PaPa
unsqueeze};
ov::copy_runtime_info(m.get_matched_nodes(), new_nodes);
- ov::replace_node(slice_out, unsqueeze);
+ ov::replace_node(m.get_match_root(), unsqueeze);
return true;
};
@@ -202,3 +232,8 @@ PagedCausalConv1DFusion::PagedCausalConv1DFusion(ov::pass::paged_attention::PaPa
}
} // namespace ov::pass
+
+ov::pass::PagedCausalConv1DFusion::PagedCausalConv1DFusion(ov::pass::paged_attention::PaParams& pa_params,
+ std::unordered_set<std::string>& var_ids_to_remove) {
+ add_matcher<PagedCausalConv1DFusionMatcher>(pa_params, var_ids_to_remove, m_layer_index);
+}
diff --git a/src/common/transformations/tests/common_optimizations/paged_causal_conv1d_fusion.cpp b/src/common/transformations/tests/common_optimizations/paged_causal_conv1d_fusion.cpp
index a4b3960f2a2..56a37b95fbf 100644
--- a/src/common/transformations/tests/common_optimizations/paged_causal_conv1d_fusion.cpp
+++ b/src/common/transformations/tests/common_optimizations/paged_causal_conv1d_fusion.cpp
@@ -8,20 +8,24 @@
#include <cstdlib>
#include <string>
+#include <tuple>
#include <unordered_set>
+#include "common_test_utils/node_builders/constant.hpp"
#include "common_test_utils/ov_test_utils.hpp"
#include "openvino/core/model.hpp"
#include "openvino/op/add.hpp"
#include "openvino/op/concat.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/convert.hpp"
+#include "openvino/op/gather.hpp"
#include "openvino/op/group_conv.hpp"
#include "openvino/op/multiply.hpp"
#include "openvino/op/paged_causal_conv1d.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/reshape.hpp"
#include "openvino/op/result.hpp"
+#include "openvino/op/shape_of.hpp"
#include "openvino/op/slice.hpp"
#include "openvino/op/swish.hpp"
#include "openvino/op/transpose.hpp"
@@ -435,6 +439,128 @@ std::shared_ptr<ov::Model> build_model_without_concat_lfm2_like_multiple() {
return std::make_shared<ov::Model>(results, params);
}
+constexpr size_t hidden_size = 3;
+constexpr size_t kernel_size = 4;
+constexpr size_t seq_len = 8;
+
+std::shared_ptr<v8::Slice> make_last_n_slice(const ov::Output<ov::Node>& data, size_t n) {
+ auto begin = v0::Constant::create(element::i64, Shape{1}, {-static_cast<int64_t>(n)});
+ auto end = v0::Constant::create(element::i64, Shape{1}, {std::numeric_limits<int64_t>::max()});
+ auto step = v0::Constant::create(element::i64, Shape{1}, {1});
+ auto axis = v0::Constant::create(element::i64, Shape{1}, {2});
+ return std::make_shared<v8::Slice>(data, begin, end, step, axis);
+}
+
+// past[B, H, state_len] ++ tokens[B, H, T] -> GroupConv(dilation) -> keep last T outputs.
+std::shared_ptr<ov::Model> build_dilated_conv_model(size_t state_len,
+ size_t dilation,
+ bool with_output_slice = true,
+ bool with_bias = false,
+ size_t stride = 1,
+ size_t pad = 0) {
+ auto past_state_param = std::make_shared<v0::Parameter>(element::f32, Shape{2, hidden_size, state_len});
+ auto read_value = std::make_shared<ov::op::v3::ReadValue>(past_state_param->output(0), "past_cache");
+ read_value->get_output_tensor(0).set_names({"cache_params.past.conv.0"});
+
+ auto token = std::make_shared<v0::Parameter>(element::f32, Shape{2, hidden_size, seq_len});
+ auto state_concat = std::make_shared<v0::Concat>(OutputVector{read_value, token}, -1);
+
+ auto weights = v0::Constant::create(element::f32,
+ Shape{hidden_size, 1, 1, kernel_size},
+ std::vector<float>(hidden_size * kernel_size, 0.25f));
+ auto group_conv = std::make_shared<v1::GroupConvolution>(state_concat,
+ weights,
+ Strides{stride},
+ CoordinateDiff{static_cast<ptrdiff_t>(pad)},
+ CoordinateDiff{static_cast<ptrdiff_t>(pad)},
+ Strides{dilation});
+ std::shared_ptr<ov::Node> conv_out = group_conv;
+ if (with_bias) {
+ auto bias = v0::Constant::create(element::f32, Shape{1, hidden_size, 1}, {0.25f, -0.5f, 1.0f});
+ conv_out = std::make_shared<v1::Add>(conv_out, bias);
+ }
+ if (with_output_slice) {
+ conv_out = make_last_n_slice(conv_out, seq_len);
+ }
+
+ auto present_res = std::make_shared<v0::Result>(make_last_n_slice(state_concat, state_len));
+ present_res->get_output_tensor(0).set_names({"cache_params.present.conv.0"});
+
+ auto conv_res = std::make_shared<v0::Result>(conv_out);
+ return std::make_shared<ov::Model>(ResultVector{conv_res, present_res}, ParameterVector{token, past_state_param});
+}
+
+std::shared_ptr<ov::Model> build_dilated_conv_fused_reference(size_t state_len,
+ size_t dilation,
+ bool with_bias = false) {
+ using ov::test::utils::make_param;
+ auto past_state_param = std::make_shared<v0::Parameter>(element::f32, Shape{2, hidden_size, state_len});
+ auto read_value = std::make_shared<ov::op::v3::ReadValue>(past_state_param->output(0), "past_cache");
+ read_value->get_output_tensor(0).set_names({"cache_params.past.conv.0"});
+
+ // The present-state branch is untouched by the fusion.
+ auto token = std::make_shared<v0::Parameter>(element::f32, Shape{2, hidden_size, seq_len});
+ auto state_concat = std::make_shared<v0::Concat>(OutputVector{read_value, token}, -1);
+ auto present_res = std::make_shared<v0::Result>(make_last_n_slice(state_concat, state_len));
+ present_res->get_output_tensor(0).set_names({"cache_params.present.conv.0"});
+
+ auto transpose_order = v0::Constant::create(element::i64, Shape{3}, {0, 2, 1});
+ auto token_transpose = std::make_shared<v1::Transpose>(token, transpose_order);
+ auto input_embeds_shape =
+ v0::Constant::create(element::i64, Shape{2}, std::vector<int64_t>{-1, static_cast<int64_t>(hidden_size)});
+ auto input_embeds = std::make_shared<v1::Reshape>(token_transpose, input_embeds_shape, false);
+
+ auto weights = v0::Constant::create(element::f32,
+ Shape{hidden_size, 1, 1, kernel_size},
+ std::vector<float>(hidden_size * kernel_size, 0.25f));
+ auto pa_weight_shape = v0::Constant::create(
+ element::i64,
+ Shape{3},
+ std::vector<int64_t>{static_cast<int64_t>(hidden_size), 1, static_cast<int64_t>(kernel_size)});
+ auto weight_reshaped = std::make_shared<v1::Reshape>(weights, pa_weight_shape, false);
+ std::shared_ptr<ov::Node> bias = v0::Constant::create(element::f32, Shape{0}, std::vector<float>{});
+ if (with_bias) {
+ auto bias_input = v0::Constant::create(element::f32, Shape{1, hidden_size, 1}, {0.25f, -0.5f, 1.0f});
+ auto bias_shape = v0::Constant::create(element::i64, Shape{1}, {-1});
+ bias = std::make_shared<v1::Reshape>(bias_input, bias_shape, false);
+ }
+
+ auto subsequence_begins = make_param(element::i32, PartialShape{-1}, "subsequence_begins");
+ auto block_indices = make_param(element::i32, PartialShape{-1}, "la.block_indices");
+ auto block_indices_begins = make_param(element::i32, PartialShape{-1}, "la.block_indices_begins");
+ auto past_lens = make_param(element::i32, PartialShape{-1}, "la.past_lens");
+ auto cache_interval = make_param(element::i32, PartialShape{-1}, "la.cache_interval");
+
+ auto conv_state_table = make_param(
+ element::dynamic,
+ PartialShape{-1, static_cast<int64_t>(hidden_size), static_cast<int64_t>((kernel_size - 1) * dilation + 1)},
+ "conv_state_table.0");
+
+ auto paged_conv = std::make_shared<ov::op::internal::PagedCausalConv1D>(input_embeds,
+ conv_state_table,
+ weight_reshaped,
+ bias,
+ subsequence_begins,
+ block_indices,
+ block_indices_begins,
+ past_lens,
+ cache_interval,
+ dilation);
+ auto unsqueeze_axis = v0::Constant::create(element::i64, Shape{1}, {2});
+ auto unsqueeze = std::make_shared<v0::Unsqueeze>(paged_conv, unsqueeze_axis);
+ auto conv_res = std::make_shared<v0::Result>(unsqueeze);
+
+ ParameterVector params{token,
+ past_state_param,
+ subsequence_begins,
+ block_indices,
+ block_indices_begins,
+ past_lens,
+ cache_interval,
+ conv_state_table};
+ return std::make_shared<ov::Model>(ResultVector{conv_res, present_res}, params);
+}
+
} // namespace
class PagedCausalConv1DFusionTest : public ::TransformationTestsF {};
@@ -596,3 +722,102 @@ TEST_F(PagedCausalConv1DFusionTest, FusesNoBiasUsesEmptyBiasConstant) {
model_ref = build_fused_reference_model(false);
}
+
+// Dilated conv whose state holds the full causal window (K-1)*d+1 fuses and keeps the dilation.
+TEST_F(PagedCausalConv1DFusionTest, FusesDilatedConvWithCausalWindowState) {
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+
+ constexpr size_t dilation = 3;
+ constexpr size_t causal_window = (kernel_size - 1) * dilation + 1;
+
+ model = build_dilated_conv_model(causal_window, dilation);
+ run_paged_causal_conv1d_fusion(model);
+ model_ref = build_dilated_conv_fused_reference(causal_window, dilation);
+}
+
+// Dilated conv whose state is only K long does not match the paged state layout and must stay untouched.
+TEST_F(PagedCausalConv1DFusionTest, DoesNotFuseDilatedConvWhenStateIsKernelSize) {
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+
+ constexpr size_t dilation = 3;
+
+ model = build_dilated_conv_model(kernel_size, dilation);
+ run_paged_causal_conv1d_fusion(model);
+ model_ref = build_dilated_conv_model(kernel_size, dilation);
+}
+
+// PagedCausalConv1D has no stride attribute and always emits one output per input token.
+// With 4 taps, dilation 3, 9 history entries and 8 current tokens, GroupConvolution with
+// stride 2 would produce 4 outputs, while the fused op would wrongly produce 8. Must not fuse.
+TEST_F(PagedCausalConv1DFusionTest, DoesNotFuseStridedConv) {
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+
+ constexpr size_t dilation = 3;
+ constexpr size_t history_length = (kernel_size - 1) * dilation;
+ constexpr size_t stride = 2;
+
+ model = build_dilated_conv_model(history_length,
+ dilation,
+ /*with_output_slice=*/false,
+ /*with_bias=*/false,
+ stride);
+ run_paged_causal_conv1d_fusion(model);
+ model_ref = build_dilated_conv_model(history_length,
+ dilation,
+ /*with_output_slice=*/false,
+ /*with_bias=*/false,
+ stride);
+}
+
+// PagedCausalConv1D has no padding attribute, so implicit zero padding from GroupConvolution
+// cannot be represented by the fused op. Must not fuse.
+TEST_F(PagedCausalConv1DFusionTest, DoesNotFusePaddedConv) {
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+
+ constexpr size_t dilation = 3;
+ constexpr size_t causal_window = (kernel_size - 1) * dilation + 1;
+ constexpr size_t pad = 1;
+
+ model = build_dilated_conv_model(causal_window,
+ dilation,
+ /*with_output_slice=*/true,
+ /*with_bias=*/false,
+ /*stride=*/1,
+ pad);
+ run_paged_causal_conv1d_fusion(model);
+ model_ref = build_dilated_conv_model(causal_window,
+ dilation,
+ /*with_output_slice=*/true,
+ /*with_bias=*/false,
+ /*stride=*/1,
+ pad);
+}
+
+TEST_F(PagedCausalConv1DFusionTest, FusesPLEWithHistoryOnlyAndNoOutputSlice) {
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+
+ // PLE saves nine past inputs; the paged operation requires a ten-entry window.
+ constexpr size_t dilation = 3;
+ constexpr size_t history_length = (kernel_size - 1) * dilation;
+
+ model = build_dilated_conv_model(history_length, dilation, /*with_output_slice=*/false);
+ run_paged_causal_conv1d_fusion(model);
+ model_ref = build_dilated_conv_fused_reference(history_length, dilation);
+}
+
+TEST_F(PagedCausalConv1DFusionTest, FusesPLEWithBiasAndNoOutputSlice) {
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+
+ constexpr size_t dilation = 3;
+ constexpr size_t history_length = (kernel_size - 1) * dilation;
+
+ model = build_dilated_conv_model(history_length, dilation, /*with_output_slice=*/false, /*with_bias=*/true);
+ run_paged_causal_conv1d_fusion(model);
+ model_ref = build_dilated_conv_fused_reference(history_length, dilation, /*with_bias=*/true);
+}
diff --git a/src/core/dev_api/openvino/op/paged_causal_conv1d.hpp b/src/core/dev_api/openvino/op/paged_causal_conv1d.hpp
index 20a3f5fb48f..fb695ce052d 100644
--- a/src/core/dev_api/openvino/op/paged_causal_conv1d.hpp
+++ b/src/core/dev_api/openvino/op/paged_causal_conv1d.hpp
@@ -22,7 +22,9 @@ public:
///
/// \param input_embeds Input embeddings [batch_size_in_tokens, hidden_size].
/// \param conv_state_table Physical block table containing conv_cache states
- /// [num_physical_blocks, hidden_size, kernel_size].
+ /// [num_physical_blocks, hidden_size, causal_window], where causal_window is
+ /// (kernel_taps-1)*dilation+1. With the default dilation=1, causal_window equals
+ /// conv_weight's raw tap count K, so the two terms merge in the common case.
/// \param conv_weight Convolution weight [out_channels, hidden_size/group_size, conv_kernel_size].
/// \param conv_bias Convolution bias [out_channels] or [0] (empty = no bias).
/// \param subsequence_begins Start indices of tokens from current sequences [batch_size_in_sequences+1],
@@ -35,6 +37,7 @@ public:
/// element type i32.
/// \param cache_interval Interval between tokens to cache conv_state [batch_size_in_sequences],
/// element type i32.
+ /// \param dilation Dilation factor for the convolution.
PagedCausalConv1D(const Output<Node>& input_embeds,
const Output<Node>& conv_state_table,
const Output<Node>& conv_weight,
@@ -43,16 +46,29 @@ public:
const Output<Node>& la_block_indices,
const Output<Node>& la_block_indices_begins,
const Output<Node>& processed_tokens,
- const Output<Node>& cache_interval);
+ const Output<Node>& cache_interval,
+ size_t dilation = 1);
/// \brief Constructs a PagedCausalConv1D operation from input vector.
///
/// \param args Input tensor vector (9 inputs in order listed above).
- PagedCausalConv1D(const ov::OutputVector& args);
+ /// \param dilation Dilation factor for the convolution.
+ PagedCausalConv1D(const ov::OutputVector& args, size_t dilation = 1);
void validate_and_infer_types() override;
bool visit_attributes(AttributeVisitor& visitor) override;
std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& new_args) const override;
+
+ size_t get_dilation() const {
+ return m_dilation;
+ }
+
+ void set_dilation(size_t dilation) {
+ m_dilation = dilation;
+ }
+
+private:
+ size_t m_dilation{1};
};
} // namespace ov::op::internal
diff --git a/src/core/shape_inference/include/paged_causal_conv1d_shape_inference.hpp b/src/core/shape_inference/include/paged_causal_conv1d_shape_inference.hpp
index ff681e63280..0315a4898bd 100644
--- a/src/core/shape_inference/include/paged_causal_conv1d_shape_inference.hpp
+++ b/src/core/shape_inference/include/paged_causal_conv1d_shape_inference.hpp
@@ -4,6 +4,7 @@
#pragma once
+#include "dimension_util.hpp"
#include "openvino/op/paged_causal_conv1d.hpp"
#include "utils.hpp"
@@ -40,11 +41,13 @@ std::vector<TRShape> shape_infer(const PagedCausalConv1D* op, const std::vector<
}
if (conv_state_table_rank_is_static && conv_weight_rank_is_static) {
+ const auto dilation = static_cast<typename T::value_type::value_type>(op->get_dilation());
+ const auto expected_window = ov::util::dim::dilated(input_shapes[2][2], dilation);
NODE_SHAPE_INFER_CHECK(op,
input_shapes,
- input_shapes[1][2].compatible(input_shapes[2][2]),
- "The kernel_size dimensions of conv_state_table and conv_weight inputs must be "
- "compatible.");
+ input_shapes[1][2].compatible(expected_window),
+ "The causal-window dimension of conv_state_table must be compatible with "
+ "(kernel_taps-1)*dilation+1 derived from conv_weight and the dilation attribute.");
}
if (input_embeds_rank_is_static && conv_weight_rank_is_static) {
diff --git a/src/core/src/op/paged_causal_conv1d.cpp b/src/core/src/op/paged_causal_conv1d.cpp
index d1079a430dc..377d51a2857 100644
--- a/src/core/src/op/paged_causal_conv1d.cpp
+++ b/src/core/src/op/paged_causal_conv1d.cpp
@@ -19,7 +19,8 @@ PagedCausalConv1D::PagedCausalConv1D(const Output<Node>& input_embeds,
const Output<Node>& la_block_indices,
const Output<Node>& la_block_indices_begins,
const Output<Node>& processed_tokens,
- const Output<Node>& cache_interval)
+ const Output<Node>& cache_interval,
+ size_t dilation)
: Op({input_embeds,
conv_state_table,
conv_weight,
@@ -28,11 +29,14 @@ PagedCausalConv1D::PagedCausalConv1D(const Output<Node>& input_embeds,
la_block_indices,
la_block_indices_begins,
processed_tokens,
- cache_interval}) {
+ cache_interval}),
+ m_dilation(dilation) {
constructor_validate_and_infer_types();
}
-PagedCausalConv1D::PagedCausalConv1D(const ov::OutputVector& args) : ov::op::Op(args) {
+PagedCausalConv1D::PagedCausalConv1D(const ov::OutputVector& args, size_t dilation)
+ : ov::op::Op(args),
+ m_dilation(dilation) {
constructor_validate_and_infer_types();
}
@@ -41,6 +45,7 @@ void PagedCausalConv1D::validate_and_infer_types() {
NODE_VALIDATION_CHECK(this, get_input_size() == 9);
+ NODE_VALIDATION_CHECK(this, m_dilation >= 1, "PagedCausalConv1D expects dilation >= 1, got ", m_dilation);
// input_embeds (0), conv_weight (2), conv_bias (3) participate in the convolution MAC and
// therefore must share a common float element type; it also determines the output precision.
// conv_state_table (1) is an in-place state cache and is allowed to use an independent float
@@ -75,13 +80,14 @@ void PagedCausalConv1D::validate_and_infer_types() {
bool PagedCausalConv1D::visit_attributes(AttributeVisitor& visitor) {
OV_OP_SCOPE(PagedCausalConv1D_visit_attributes);
+ visitor.on_attribute("dilation", m_dilation);
return true;
}
std::shared_ptr<ov::Node> PagedCausalConv1D::clone_with_new_inputs(const ov::OutputVector& new_args) const {
OV_OP_SCOPE(PagedCausalConv1D_clone_with_new_inputs);
check_new_args_count(this, new_args);
- return std::make_shared<PagedCausalConv1D>(new_args);
+ return std::make_shared<PagedCausalConv1D>(new_args, m_dilation);
}
} // namespace ov::op::internal
diff --git a/src/core/tests/type_prop/paged_causal_conv1d.cpp b/src/core/tests/type_prop/paged_causal_conv1d.cpp
index 05710a23d05..58d5c2eeb35 100644
--- a/src/core/tests/type_prop/paged_causal_conv1d.cpp
+++ b/src/core/tests/type_prop/paged_causal_conv1d.cpp
@@ -259,8 +259,8 @@ TEST_F(TypePropPagedCausalConv1DTest, kernel_size_mismatch) {
processed_tokens,
cache_interval}),
NodeValidationFailure,
- testing::HasSubstr("kernel_size dimensions of conv_state_table and conv_weight inputs must be "
- "compatible"));
+ testing::HasSubstr("causal-window dimension of conv_state_table must be compatible with "
+ "(kernel_taps-1)*dilation+1"));
}
TEST_F(TypePropPagedCausalConv1DTest, wrong_input_count) {
@@ -565,4 +565,109 @@ TEST_F(TypePropPagedCausalConv1DTest, cache_interval_size_mismatch) {
NodeValidationFailure,
testing::HasSubstr("size of cache_interval must be batch_size_in_sequences"));
}
+
+TEST_F(TypePropPagedCausalConv1DTest, default_dilation_via_nine_arg_ctor_is_one) {
+ const auto input_embeds = std::make_shared<op::v0::Parameter>(element::f32, Shape{10, 256});
+ const auto conv_state_table = std::make_shared<op::v0::Parameter>(element::f32, Shape{5, 256, 4});
+ const auto conv_weight = std::make_shared<op::v0::Parameter>(element::f32, Shape{256, 256, 4});
+ const auto conv_bias = std::make_shared<op::v0::Parameter>(element::f32, Shape{256});
+ const auto subsequence_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto la_block_indices = std::make_shared<op::v0::Parameter>(element::i32, Shape{5});
+ const auto la_block_indices_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto processed_tokens = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+ const auto cache_interval = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+
+ const auto op = make_op(OutputVector{input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ subsequence_begins,
+ la_block_indices,
+ la_block_indices_begins,
+ processed_tokens,
+ cache_interval});
+
+ EXPECT_EQ(op->get_dilation(), 1u);
+ EXPECT_EQ(op->get_output_partial_shape(0), PartialShape(Shape{10, 256}));
+}
+
+TEST_F(TypePropPagedCausalConv1DTest, explicit_dilation_via_ten_arg_ctor) {
+ const auto input_embeds = std::make_shared<op::v0::Parameter>(element::f32, Shape{10, 256});
+ // causal window = (num_taps-1)*dilation+1 = (4-1)*3+1 = 10
+ const auto conv_state_table = std::make_shared<op::v0::Parameter>(element::f32, Shape{5, 256, 10});
+ const auto conv_weight = std::make_shared<op::v0::Parameter>(element::f32, Shape{256, 256, 4});
+ const auto conv_bias = std::make_shared<op::v0::Parameter>(element::f32, Shape{256});
+ const auto subsequence_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto la_block_indices = std::make_shared<op::v0::Parameter>(element::i32, Shape{5});
+ const auto la_block_indices_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto processed_tokens = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+ const auto cache_interval = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+
+ const auto op = std::make_shared<op::internal::PagedCausalConv1D>(input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ subsequence_begins,
+ la_block_indices,
+ la_block_indices_begins,
+ processed_tokens,
+ cache_interval,
+ /*dilation=*/3);
+
+ EXPECT_EQ(op->get_dilation(), 3u);
+ EXPECT_EQ(op->get_output_element_type(0), element::f32);
+ EXPECT_EQ(op->get_output_partial_shape(0), PartialShape(Shape{10, 256}));
+}
+
+TEST_F(TypePropPagedCausalConv1DTest, dilated_window_mismatch) {
+ const auto input_embeds = std::make_shared<op::v0::Parameter>(element::f32, Shape{10, 256});
+ // Wrong: with num_taps=4 and dilation=3, window should be 10, not 4.
+ const auto conv_state_table = std::make_shared<op::v0::Parameter>(element::f32, Shape{5, 256, 4});
+ const auto conv_weight = std::make_shared<op::v0::Parameter>(element::f32, Shape{256, 256, 4});
+ const auto conv_bias = std::make_shared<op::v0::Parameter>(element::f32, Shape{256});
+ const auto subsequence_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto la_block_indices = std::make_shared<op::v0::Parameter>(element::i32, Shape{5});
+ const auto la_block_indices_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto processed_tokens = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+ const auto cache_interval = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+
+ OV_EXPECT_THROW(std::ignore = std::make_shared<op::internal::PagedCausalConv1D>(input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ subsequence_begins,
+ la_block_indices,
+ la_block_indices_begins,
+ processed_tokens,
+ cache_interval,
+ /*dilation=*/3),
+ NodeValidationFailure,
+ testing::HasSubstr("causal-window dimension of conv_state_table must be compatible with "
+ "(kernel_taps-1)*dilation+1"));
+}
+
+TEST_F(TypePropPagedCausalConv1DTest, invalid_dilation_zero) {
+ const auto input_embeds = std::make_shared<op::v0::Parameter>(element::f32, Shape{10, 256});
+ const auto conv_state_table = std::make_shared<op::v0::Parameter>(element::f32, Shape{5, 256, 4});
+ const auto conv_weight = std::make_shared<op::v0::Parameter>(element::f32, Shape{256, 256, 4});
+ const auto conv_bias = std::make_shared<op::v0::Parameter>(element::f32, Shape{256});
+ const auto subsequence_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto la_block_indices = std::make_shared<op::v0::Parameter>(element::i32, Shape{5});
+ const auto la_block_indices_begins = std::make_shared<op::v0::Parameter>(element::i32, Shape{3});
+ const auto processed_tokens = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+ const auto cache_interval = std::make_shared<op::v0::Parameter>(element::i32, Shape{2});
+
+ OV_EXPECT_THROW(std::ignore = std::make_shared<op::internal::PagedCausalConv1D>(input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ subsequence_begins,
+ la_block_indices,
+ la_block_indices_begins,
+ processed_tokens,
+ cache_interval,
+ /*dilation=*/0),
+ NodeValidationFailure,
+ testing::HasSubstr("m_dilation >= 1"));
+}
} // namespace ov::test
diff --git a/src/core/tests/visitors/op/paged_causal_conv1d.cpp b/src/core/tests/visitors/op/paged_causal_conv1d.cpp
index 309e7504cec..2731828fb1c 100644
--- a/src/core/tests/visitors/op/paged_causal_conv1d.cpp
+++ b/src/core/tests/visitors/op/paged_causal_conv1d.cpp
@@ -45,9 +45,55 @@ TEST(attributes, paged_causal_conv1d_roundtrip) {
cache_interval});
auto g_op = as_type_ptr<op::internal::PagedCausalConv1D>(builder.create());
- constexpr auto expected_attr_count = 0;
+ constexpr auto expected_attr_count = 1;
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
+ EXPECT_EQ(g_op->get_dilation(), op->get_dilation());
+ EXPECT_EQ(g_op->get_output_element_type(0), op->get_output_element_type(0));
+ EXPECT_EQ(g_op->get_output_partial_shape(0), op->get_output_partial_shape(0));
+}
+
+TEST(attributes, paged_causal_conv1d_roundtrip_explicit_dilation) {
+ NodeBuilder::opset().insert<op::internal::PagedCausalConv1D>();
+
+ const auto input_embeds = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{4, 8});
+ // causal window = (num_taps-1)*dilation+1 = (4-1)*3+1 = 10
+ const auto conv_state_table = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{2, 8, 10});
+ const auto conv_weight = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{8, 1, 4});
+ const auto conv_bias = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{8});
+ const auto subsequence_begins = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{2});
+ const auto la_block_indices = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{2});
+ const auto la_block_indices_begins = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{2});
+ const auto processed_tokens = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{1});
+ const auto cache_interval = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{1});
+
+ const auto op = std::make_shared<op::internal::PagedCausalConv1D>(input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ subsequence_begins,
+ la_block_indices,
+ la_block_indices_begins,
+ processed_tokens,
+ cache_interval,
+ /*dilation=*/3);
+
+ NodeBuilder builder(op,
+ {input_embeds,
+ conv_state_table,
+ conv_weight,
+ conv_bias,
+ subsequence_begins,
+ la_block_indices,
+ la_block_indices_begins,
+ processed_tokens,
+ cache_interval});
+ auto g_op = as_type_ptr<op::internal::PagedCausalConv1D>(builder.create());
+
+ constexpr auto expected_attr_count = 1;
+ EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
+
+ EXPECT_EQ(g_op->get_dilation(), 3u);
EXPECT_EQ(g_op->get_output_element_type(0), op->get_output_element_type(0));
EXPECT_EQ(g_op->get_output_partial_shape(0), op->get_output_partial_shape(0));
}
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
index 1483603c1ba..22d22a2a006 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.cpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.cpp
@@ -42,7 +42,7 @@ void maybe_flush_state(StateType* conv_state_table,
const size_t state_stride,
const size_t state_off,
const size_t h_count,
- const size_t kernel_size) {
+ const size_t window) {
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);
@@ -50,7 +50,7 @@ void maybe_flush_state(StateType* conv_state_table,
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;
+ const size_t write_count = h_count * window;
cvt_copy(conv_state_table + static_cast<size_t>(physical_block) * state_stride + state_off,
local_state + state_off,
/*m=*/size_t{1},
@@ -62,7 +62,8 @@ void maybe_flush_state(StateType* conv_state_table,
}
// Scalar conv1d computation for a channel range [h_begin, h_end).
-// Shifts state, inserts new token, computes dot product with weight.
+// Shifts state (over the full causal window), inserts new token, computes dot product with
+// weight (over num_taps taps spaced `dilation` apart within the window).
// 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>
@@ -74,18 +75,20 @@ void conv1d_scalar(float* local_state,
DataT* out_ptr,
const size_t h_begin,
const size_t h_end,
- const size_t kernel_size) {
+ const size_t num_taps,
+ const size_t dilation,
+ const size_t window) {
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++) {
+ float* state_h = local_state + h * window;
+ for (size_t k = 0; k + 1 < window; k++) {
state_h[k] = state_h[k + 1];
}
- state_h[kernel_size - 1] = static_cast<float>(token_ptr[h]);
+ state_h[window - 1] = static_cast<float>(token_ptr[h]);
- const DataT* weight_h = conv_weight + h * kernel_size;
+ const DataT* weight_h = conv_weight + h * num_taps;
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]);
+ for (size_t k = 0; k < num_taps; k++) {
+ sum += state_h[k * dilation] * static_cast<float>(weight_h[k]);
}
out_ptr[h] = static_cast<DataT>(sum);
}
@@ -105,11 +108,13 @@ void paged_causal_conv1d_ref(const DataT* input_embeds,
DataT* output_embeds,
const size_t batch_size_in_tokens,
const size_t hidden_size,
- const size_t kernel_size,
+ const size_t num_taps,
+ const size_t dilation,
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 window = (num_taps - 1) * dilation + 1;
+ const size_t state_stride = hidden_size * window;
const size_t block_count = (hidden_size + kChannelBlock - 1) / kChannelBlock;
// Parallelize across (sequence, channel_block).
@@ -154,7 +159,7 @@ void paged_causal_conv1d_ref(const DataT* input_embeds,
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;
+ const size_t state_off = h_begin * window;
// 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
@@ -167,9 +172,9 @@ void paged_causal_conv1d_ref(const DataT* input_embeds,
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);
+ /*n=*/h_count * window,
+ /*src_stride=*/h_count * window,
+ /*dst_stride=*/h_count * window);
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);
@@ -184,7 +189,9 @@ void paged_causal_conv1d_ref(const DataT* input_embeds,
out_ptr,
h_begin,
h_end,
- kernel_size);
+ num_taps,
+ dilation,
+ window);
maybe_flush_state(conv_state_table,
thread_local_state,
@@ -198,7 +205,7 @@ void paged_causal_conv1d_ref(const DataT* input_embeds,
state_stride,
state_off,
h_count,
- kernel_size);
+ window);
}
});
}
@@ -217,7 +224,8 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
DataT* output_embeds,
const size_t batch_size_in_tokens,
const size_t hidden_size,
- const size_t kernel_size,
+ const size_t num_taps,
+ const size_t dilation,
const size_t seq_count,
float* local_state,
const ov::intel_cpu::CpuParallelPtr& cpu_parallel) {
@@ -235,12 +243,13 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
output_embeds,
batch_size_in_tokens,
hidden_size,
- kernel_size,
+ num_taps,
+ dilation,
seq_count,
local_state,
cpu_parallel);
#else
- if (kernel_size != 3 && kernel_size != 4) {
+ if (num_taps != 3 && num_taps != 4) {
paged_causal_conv1d_ref(input_embeds,
conv_state_table,
conv_weight,
@@ -254,14 +263,16 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
output_embeds,
batch_size_in_tokens,
hidden_size,
- kernel_size,
+ num_taps,
+ dilation,
seq_count,
local_state,
cpu_parallel);
return;
}
- const size_t state_stride = hidden_size * kernel_size;
+ const size_t window = (num_taps - 1) * dilation + 1;
+ const size_t state_stride = hidden_size * window;
const size_t block_count = (hidden_size + kChannelBlock - 1) / kChannelBlock;
// Parallelize across (sequence, channel_block).
@@ -306,7 +317,7 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
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;
+ const size_t state_off = h_begin * window;
// 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
@@ -319,16 +330,16 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
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);
+ /*n=*/h_count * window,
+ /*src_stride=*/h_count * window,
+ /*dst_stride=*/h_count * window);
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.
+ // SIMD-accelerated paths for num_taps 3 and 4.
// Each path: shift state, gather into aligned buffers, vectorized MAC, scalar tail.
size_t h = h_begin;
@@ -355,22 +366,22 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
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++) {
+ float* state_h = thread_local_state + ch * window;
+ for (size_t k = 0; k + 1 < window; 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];
+ state_h[window - 1] = static_cast<float>(token_ptr[ch]);
+ for (size_t k = 0; k < num_taps; k++) {
+ st[k][i] = state_h[k * dilation];
}
- const DataT* weight_h = conv_weight + ch * kernel_size;
- for (size_t k = 0; k < kernel_size; k++) {
+ const DataT* weight_h = conv_weight + ch * num_taps;
+ for (size_t k = 0; k < num_taps; 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++) {
+ for (size_t k = 0; k < num_taps; k++) {
acc = simd_fmadd(simd_loadu(st[k]), simd_loadu(wt[k]), acc);
}
# if defined(HAVE_AVX512F)
@@ -389,7 +400,9 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
out_ptr,
h,
h_end,
- kernel_size);
+ num_taps,
+ dilation,
+ window);
maybe_flush_state(conv_state_table,
thread_local_state,
@@ -403,7 +416,7 @@ void paged_causal_conv1d_optimized(const DataT* input_embeds,
state_stride,
state_off,
h_count,
- kernel_size);
+ window);
}
});
#endif
@@ -424,7 +437,8 @@ void paged_causal_conv1d_exec(const void* input_embeds,
void* output_embeds,
const size_t batch_size_in_tokens,
const size_t hidden_size,
- const size_t kernel_size,
+ const size_t num_taps,
+ const size_t dilation,
const size_t seq_count,
const ov::element::Type data_precision,
const ov::element::Type state_precision,
@@ -449,7 +463,8 @@ void paged_causal_conv1d_exec(const void* input_embeds,
static_cast<DataT*>(output_embeds),
batch_size_in_tokens,
hidden_size,
- kernel_size,
+ num_taps,
+ dilation,
seq_count,
local_state,
cpu_parallel);
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
index 35354bf5336..c27525958c1 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.hpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/paged_causal_conv1d.hpp
@@ -28,7 +28,8 @@ void paged_causal_conv1d_exec(const void* input_embeds,
void* output_embeds,
size_t batch_size_in_tokens,
size_t hidden_size,
- size_t kernel_size,
+ size_t num_taps,
+ size_t dilation,
size_t seq_count,
ov::element::Type data_precision,
ov::element::Type state_precision,
diff --git a/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.cpp b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.cpp
index c8b3a36f10a..4c9f00e31be 100644
--- a/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.cpp
+++ b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.cpp
@@ -35,6 +35,7 @@ PagedCausalConv1D::PagedCausalConv1D(const std::shared_ptr<ov::Node>& op, const
if (!isSupportedOperation(op, errorMessage)) {
OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage);
}
+ m_dilation = ov::as_type_ptr<ov::op::internal::PagedCausalConv1D>(op)->get_dilation();
}
bool PagedCausalConv1D::isSupportedOperation(const std::shared_ptr<const ov::Node>& op,
@@ -86,17 +87,16 @@ void PagedCausalConv1D::initSupportedPrimitiveDescriptors() {
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)
+ // Shape: [num_worker_threads, hidden_size * window]. 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.
+ // hidden_size (port 0 dim 1) and window (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 size_t window = 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});
+ auto mem_desc = std::make_shared<CpuBlockedMemoryDesc>(ov::element::f32,
+ ov::intel_cpu::Shape{num_threads, hidden_size * window});
m_tmpLocalState = context->getScratchPad()->createScratchPadMem(mem_desc);
}
@@ -108,7 +108,8 @@ void PagedCausalConv1D::execute([[maybe_unused]] const dnnl::stream& strm) {
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];
+ const size_t num_taps = weight_shape[2];
+ const size_t window = state_table_shape[2];
OPENVINO_ASSERT(state_table_shape[1] == hidden_size,
"PagedCausalConv1D: conv_state_table hidden_size (",
@@ -117,6 +118,17 @@ void PagedCausalConv1D::execute([[maybe_unused]] const dnnl::stream& strm) {
hidden_size,
").");
+ OPENVINO_ASSERT(window == (num_taps - 1) * m_dilation + 1,
+ "PagedCausalConv1D: conv_state_table causal window (",
+ window,
+ ") != (num_taps-1)*dilation+1 (",
+ (num_taps - 1) * m_dilation + 1,
+ ") for num_taps=",
+ num_taps,
+ ", dilation=",
+ m_dilation,
+ ".");
+
// 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,
@@ -164,7 +176,8 @@ void PagedCausalConv1D::execute([[maybe_unused]] const dnnl::stream& strm) {
output_embeds_raw,
batch_size_in_tokens,
hidden_size,
- kernel_size,
+ num_taps,
+ m_dilation,
seq_count,
data_precision,
state_precision,
diff --git a/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.h b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.h
index 0ed747e5717..edc2d51661a 100644
--- a/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.h
+++ b/src/plugins/intel_cpu/src/nodes/paged_causal_conv1d.h
@@ -49,10 +49,11 @@ public:
}
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.
+ // Per-node f32 scratch buffer holding one promoted conv-state block (hidden_size * window
+ // floats, window = (num_taps-1)*dilation+1). Allocated once via the plugin scratchpad in
+ // createPrimitive() so that repeated execute() calls avoid per-invocation heap allocation.
MemoryPtr m_tmpLocalState;
+ size_t m_dilation = 1;
};
} // namespace ov::intel_cpu::node
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
index 0a3a72933da..7f12a5f9cac 100644
--- 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
@@ -25,7 +25,7 @@ TEST_P(PagedCausalConv1DLayerTest, Inference) {
// hidden_size, kernel_size, has_bias,
// seq_lengths_sets (multiple sets for dynamic shapes),
// cache_intervals_sets (matching intervals),
-// element_type, target_device
+// element_type, target_device, dilation (defaults to 1)
std::vector<PagedCausalConv1DLayerParams> paged_conv1d_test_cases = {
// --- Static shape tests (single seq_lengths set) ---
@@ -71,6 +71,14 @@ std::vector<PagedCausalConv1DLayerParams> paged_conv1d_test_cases = {
{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"},
+
+ // --- Dilated causal conv (dilation > 1): causal_window = (kernel_size-1)*dilation+1 ---
+ // Scalar path: num_taps=2, dilation=2 -> window=3
+ {1, 2, true, {{3, 2}}, {{2, 3}}, ov::element::f32, "CPU", /*dilation=*/2},
+ // AVX2/AVX512 fast-path num_taps=4 with PLE's ngram_size=3 dilation -> window=10
+ {8, 4, true, {{4, 2, 3}}, {{3, 2, 5}}, ov::element::f32, "CPU", /*dilation=*/3},
+ // AVX2/AVX512 fast-path num_taps=3, dilation=2 -> window=5, dynamic shapes
+ {32, 3, true, {{2}, {5, 3}, {1, 1, 1, 1}}, {{1}, {2, 0}, {1, 1, 1, 1}}, ov::element::f32, "CPU", /*dilation=*/2},
};
INSTANTIATE_TEST_SUITE_P(smoke_PagedCausalConv1D,
diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hpp
index 3cd6ff32679..ba143ec344e 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hpp
@@ -39,7 +39,8 @@ struct paged_causal_conv1d : public primitive_base<paged_causal_conv1d> {
size_t hash() const override {
size_t seed = primitive::hash();
seed = hash_combine(seed, hidden_size);
- seed = hash_combine(seed, kernel_size);
+ seed = hash_combine(seed, causal_window);
+ seed = hash_combine(seed, dilation);
return seed;
}
@@ -49,23 +50,28 @@ struct paged_causal_conv1d : public primitive_base<paged_causal_conv1d> {
}
auto rhs_casted = downcast<const paged_causal_conv1d>(rhs);
- return hidden_size == rhs_casted.hidden_size && kernel_size == rhs_casted.kernel_size;
+ return hidden_size == rhs_casted.hidden_size && causal_window == rhs_casted.causal_window &&
+ dilation == rhs_casted.dilation;
}
void save(BinaryOutputBuffer& ob) const override {
primitive_base<paged_causal_conv1d>::save(ob);
ob << hidden_size;
- ob << kernel_size;
+ ob << causal_window;
+ ob << dilation;
}
void load(BinaryInputBuffer& ib) override {
primitive_base<paged_causal_conv1d>::load(ib);
ib >> hidden_size;
- ib >> kernel_size;
+ ib >> causal_window;
+ ib >> dilation;
}
size_t hidden_size = 0;
- size_t kernel_size = 0;
+ // Causal window: (num_taps-1)*dilation+1. Equals conv_weight's raw tap count K only when dilation==1.
+ size_t causal_window = 0;
+ size_t dilation = 1;
};
} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cl b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cl
index dbb8346aca9..260275ede97 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cl
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cl
@@ -86,10 +86,10 @@ KERNEL(paged_causal_conv1d_ref)
const int seq_interval = cache_interval[seq];
const int prev_nums = (seq_interval > 0) ? (past_lens[seq] % seq_interval) : 0;
- float state[KERNEL_SIZE];
+ float state[CAUSAL_WINDOW];
const int read_state_base = read_physical_block * state_block_stride + h * state_hidden_stride;
- for (int k = 0; k < KERNEL_SIZE; k++) {
+ for (int k = 0; k < CAUSAL_WINDOW; k++) {
state[k] = convert_float(conv_state_table[read_state_base + k * state_kernel_stride]);
}
@@ -101,17 +101,17 @@ KERNEL(paged_causal_conv1d_ref)
for (int t = 0; t < seq_tokens; t++) {
const int token_idx = token_begin + t;
- for (int k = 0; k + 1 < KERNEL_SIZE; k++) {
+ for (int k = 0; k + 1 < CAUSAL_WINDOW; k++) {
state[k] = state[k + 1];
}
const int in_off = token_idx * input_token_stride + h * input_hidden_stride;
- state[KERNEL_SIZE - 1] = convert_float(input_embeds[in_off]);
+ state[CAUSAL_WINDOW - 1] = convert_float(input_embeds[in_off]);
float sum = bias_val;
const int w_base = h * weight_hidden_stride;
- for (int k = 0; k < KERNEL_SIZE; k++) {
- sum = fma(state[k], convert_float(conv_weight[w_base + k * weight_kernel_stride]), sum);
+ for (int k = 0; k < NUM_TAPS; k++) {
+ sum = fma(state[k * DILATION], convert_float(conv_weight[w_base + k * weight_kernel_stride]), sum);
}
const int out_off = token_idx * output_token_stride + h * output_hidden_stride;
@@ -126,7 +126,7 @@ KERNEL(paged_causal_conv1d_ref)
const int physical_block = block_indices[blk_begin + slot];
if (physical_block >= 0 && physical_block < num_blocks) {
const int state_base = physical_block * state_block_stride + h * state_hidden_stride;
- for (int k = 0; k < KERNEL_SIZE; k++) {
+ for (int k = 0; k < CAUSAL_WINDOW; k++) {
conv_state_table[state_base + k * state_kernel_stride] = TO_INPUT1_TYPE(state[k]);
}
}
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cpp
index 182d15b66f2..15e0e31bab2 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_causal_conv1d_ref.cpp
@@ -52,11 +52,16 @@ protected:
const auto& input_shape = params.get_input_layout(paged_causal_conv1d::INPUT_EMBEDS).get_partial_shape();
const auto& state_shape = params.get_input_layout(paged_causal_conv1d::CONV_STATE_TABLE).get_partial_shape();
+ const auto& weight_shape = params.get_input_layout(paged_causal_conv1d::CONV_WEIGHT).get_partial_shape();
const auto& bias_shape = params.get_input_layout(paged_causal_conv1d::CONV_BIAS).get_partial_shape();
const bool has_bias = bias_shape.rank().is_static() && bias_shape.size() == 1 && bias_shape[0].is_static() && bias_shape[0].get_length() != 0;
+ auto desc = params.typed_desc<paged_causal_conv1d>();
+
jit.make("HIDDEN_SIZE", static_cast<int>(input_shape[1].get_length()));
- jit.make("KERNEL_SIZE", static_cast<int>(state_shape[2].get_length()));
+ jit.make("CAUSAL_WINDOW", static_cast<int>(state_shape[2].get_length()));
+ jit.make("NUM_TAPS", static_cast<int>(weight_shape[2].get_length()));
+ jit.make("DILATION", static_cast<int>(desc->dilation));
jit.make("HAS_BIAS", has_bias ? 1 : 0);
return jit;
diff --git a/src/plugins/intel_gpu/src/graph/paged_causal_conv1d.cpp b/src/plugins/intel_gpu/src/graph/paged_causal_conv1d.cpp
index 64c59a0958e..fd995df7aca 100644
--- a/src/plugins/intel_gpu/src/graph/paged_causal_conv1d.cpp
+++ b/src/plugins/intel_gpu/src/graph/paged_causal_conv1d.cpp
@@ -34,6 +34,7 @@ std::vector<layout> paged_causal_conv1d_inst::calc_output_layouts(const paged_ca
}
ov::op::internal::PagedCausalConv1D op;
+ op.set_dilation(node.get_primitive()->dilation);
const auto output_shapes = ov::op::internal::shape_infer(&op, input_shapes);
return {layout(output_shapes[0], input_layout.data_type, input_layout.format)};
@@ -59,7 +60,8 @@ std::string paged_causal_conv1d_inst::to_string(const paged_causal_conv1d_node&
pcc_info.add("past_lens", node.input(7).id());
pcc_info.add("cache_interval", node.input(8).id());
pcc_info.add("hidden_size", desc->hidden_size);
- pcc_info.add("kernel_size", desc->kernel_size);
+ pcc_info.add("causal_window", desc->causal_window);
+ pcc_info.add("dilation", desc->dilation);
node_info->add("paged_causal_conv1d_info", pcc_info);
node_info->dump(primitive_description);
diff --git a/src/plugins/intel_gpu/src/plugin/ops/paged_causal_conv1d.cpp b/src/plugins/intel_gpu/src/plugin/ops/paged_causal_conv1d.cpp
index e0f68824a5a..7b68b1d90c6 100644
--- a/src/plugins/intel_gpu/src/plugin/ops/paged_causal_conv1d.cpp
+++ b/src/plugins/intel_gpu/src/plugin/ops/paged_causal_conv1d.cpp
@@ -39,11 +39,12 @@ static void CreatePagedCausalConv1DOp(ProgramBuilder& p, const std::shared_ptr<o
}
}
if (state_ps.rank().is_static() && state_ps.rank().get_length() == 3) {
- const auto kernel = state_ps[2];
- if (kernel.is_static()) {
- prim.kernel_size = kernel.get_length();
+ const auto causal_window = state_ps[2];
+ if (causal_window.is_static()) {
+ prim.causal_window = causal_window.get_length();
}
}
+ prim.dilation = op->get_dilation();
prim.num_outputs = 1;
p.add_primitive(*op, prim);
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/paged_causal_conv1d.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/paged_causal_conv1d.cpp
index 2f8613fc1c6..6339dc4e148 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/paged_causal_conv1d.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/paged_causal_conv1d.cpp
@@ -27,6 +27,8 @@ struct paged_causal_conv1d_test_params {
bool with_bias;
bool is_caching_test = false;
bool padded_input = false;
+ // Spacing between convolution taps; causal_window = (kernel_size-1)*dilation+1.
+ int32_t dilation = 1;
};
struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_causal_conv1d_test_params> {
@@ -121,13 +123,15 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
const std::vector<int32_t>& past_lens,
const std::vector<int32_t>& cache_interval,
int32_t hidden_size,
- int32_t kernel_size,
+ int32_t num_taps,
+ int32_t dilation,
std::vector<T>& output_embeds) {
+ const int32_t window = (num_taps - 1) * dilation + 1;
const int32_t token_count = static_cast<int32_t>(input_embeds.size()) / hidden_size;
output_embeds.resize(static_cast<size_t>(token_count) * hidden_size);
- auto state_off = [hidden_size, kernel_size](int32_t block, int32_t h, int32_t k) {
- return (block * hidden_size + h) * kernel_size + k;
+ auto state_off = [hidden_size, window](int32_t block, int32_t h, int32_t k) {
+ return (block * hidden_size + h) * window + k;
};
for (int32_t seq = 0; seq < static_cast<int32_t>(subsequence_begins.size()) - 1; seq++) {
@@ -151,25 +155,25 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
const int32_t read_physical_block = block_indices[blk_begin];
for (int32_t h = 0; h < hidden_size; h++) {
- std::vector<float> state(static_cast<size_t>(kernel_size), 0.0f);
- for (int32_t k = 0; k < kernel_size; k++) {
+ std::vector<float> state(static_cast<size_t>(window), 0.0f);
+ for (int32_t k = 0; k < window; k++) {
state[k] = static_cast<float>(conv_state_table[state_off(read_physical_block, h, k)]);
}
const float bias_val = conv_bias.empty() ? 0.0f : static_cast<float>(conv_bias[h]);
for (int32_t t = 0; t < seq_tokens; t++) {
- for (int32_t k = 0; k + 1 < kernel_size; k++) {
+ for (int32_t k = 0; k + 1 < window; k++) {
state[k] = state[k + 1];
}
const int32_t token_idx = token_begin + t;
- state[kernel_size - 1] = static_cast<float>(input_embeds[token_idx * hidden_size + h]);
+ state[window - 1] = static_cast<float>(input_embeds[token_idx * hidden_size + h]);
float sum = bias_val;
- const int32_t w_base = h * kernel_size;
- for (int32_t k = 0; k < kernel_size; k++) {
- sum = std::fma(state[k], static_cast<float>(conv_weight[w_base + k]), sum);
+ const int32_t w_base = h * num_taps;
+ for (int32_t k = 0; k < num_taps; k++) {
+ sum = std::fma(state[k * dilation], static_cast<float>(conv_weight[w_base + k]), sum);
}
output_embeds[token_idx * hidden_size + h] = to_data_type<T>(sum);
@@ -181,7 +185,7 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
const int32_t slot = (seq_interval > 0) ? (1 + (cached_tokens - 1) / seq_interval) : 1;
if (slot >= 1 && slot < block_span) {
const int32_t physical_block = block_indices[blk_begin + slot];
- for (int32_t k = 0; k < kernel_size; k++) {
+ for (int32_t k = 0; k < window; k++) {
conv_state_table[state_off(physical_block, h, k)] = to_data_type<T>(state[k]);
}
}
@@ -200,7 +204,8 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
layout block_idx_begins_data_layout,
layout past_lens_data_layout,
layout cache_interval_data_layout,
- data_types output_dt) {
+ data_types output_dt,
+ int32_t dilation = 1) {
topology topo;
topo.add(input_layout("input_embeds", input_data_layout));
@@ -213,16 +218,18 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
topo.add(input_layout("past_lens", past_lens_data_layout));
topo.add(input_layout("cache_interval", cache_interval_data_layout));
- topo.add(paged_causal_conv1d("paged_causal_conv1d",
- {input_info("input_embeds"),
- input_info("conv_state_table"),
- input_info("conv_weight"),
- input_info("conv_bias"),
- input_info("subsequence_begins"),
- input_info("block_indices"),
- input_info("block_indices_begins"),
- input_info("past_lens"),
- input_info("cache_interval")}));
+ paged_causal_conv1d prim("paged_causal_conv1d",
+ {input_info("input_embeds"),
+ input_info("conv_state_table"),
+ input_info("conv_weight"),
+ input_info("conv_bias"),
+ input_info("subsequence_begins"),
+ input_info("block_indices"),
+ input_info("block_indices_begins"),
+ input_info("past_lens"),
+ input_info("cache_interval")});
+ prim.dilation = static_cast<size_t>(dilation);
+ topo.add(prim);
topo.add(reorder("output", input_info("paged_causal_conv1d"), format::bfyx, output_dt));
return topo;
@@ -267,10 +274,11 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
auto& engine = get_test_engine();
const auto page = make_paging_desc(p.tokens, p.num_sequences);
+ const int32_t window = (p.kernel_size - 1) * p.dilation + 1;
const auto input_padding = p.padded_input ? padding({0, 3}, {0, 5}) : padding{};
const layout input_layout({p.tokens, p.hidden_size}, data_type, format::bfyx, input_padding);
- const layout state_layout({page.num_blocks, p.hidden_size, p.kernel_size}, data_type, format::bfyx);
+ const layout state_layout({page.num_blocks, p.hidden_size, window}, data_type, format::bfyx);
const layout weight_layout({p.hidden_size, 1, p.kernel_size}, data_type, format::bfyx);
const layout bias_layout({p.with_bias ? p.hidden_size : 0}, data_type, format::bfyx);
@@ -311,6 +319,7 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
page.cache_interval,
p.hidden_size,
p.kernel_size,
+ p.dilation,
ref_output);
if (p.padded_input)
@@ -337,7 +346,8 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
block_idx_begins_layout,
past_lens_layout,
cache_interval_layout,
- data_type);
+ data_type,
+ p.dilation);
auto [out_mem, net] = run_network(topo,
input_mem,
@@ -390,7 +400,7 @@ struct paged_causal_conv1d_gpu_test : public ::testing::TestWithParam<paged_caus
const auto& p = info.param;
return "paged_causal_conv1d_gpu_test_" + p.precision.to_string() + "_tokens_" + std::to_string(p.tokens) + "_seq_" + std::to_string(p.num_sequences) +
"_hidden_" + std::to_string(p.hidden_size) + "_kernel_" + std::to_string(p.kernel_size) + (p.with_bias ? "_bias" : "_no_bias") +
- (p.is_caching_test ? "_cached" : "") + (p.padded_input ? "_padded_input" : "");
+ (p.is_caching_test ? "_cached" : "") + (p.padded_input ? "_padded_input" : "") + "_dilation_" + std::to_string(p.dilation);
}
};
@@ -409,7 +419,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_paged_causal_conv1d_gpu_test,
paged_causal_conv1d_test_params{8, 2, 16, 4, ov::element::f32, false},
paged_causal_conv1d_test_params{8, 2, 16, 4, ov::element::f16, true, true},
paged_causal_conv1d_test_params{8, 2, 16, 4, ov::element::f32, true, false, true},
- paged_causal_conv1d_test_params{8, 2, 16, 4, ov::element::f16, true, false, true}),
+ paged_causal_conv1d_test_params{8, 2, 16, 4, ov::element::f16, true, false, true},
+ // PLE scenario: num_taps=4, dilation=ngram_size=3 -> window=10.
+ paged_causal_conv1d_test_params{8, 2, 16, 4, ov::element::f32, true, false, false, 3},
+ paged_causal_conv1d_test_params{12, 3, 32, 5, ov::element::f16, true, false, false, 2},
+ // Dilated conv combined with padded input and prefix-caching writes.
+ paged_causal_conv1d_test_params{8, 2, 16, 4, ov::element::f32, true, true, true, 3}),
paged_causal_conv1d_gpu_test::PrintToStringParamName);
} // namespace
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
index 5737b214189..4503bb3240e 100644
--- 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
@@ -24,6 +24,8 @@ struct PagedCausalConv1DLayerParams {
std::vector<std::vector<int32_t>> cache_intervals_sets;
ov::element::Type element_type;
std::string target_device;
+ // Spacing between convolution taps; causal_window = (kernel_size-1)*dilation+1.
+ int32_t dilation = 1;
};
class PagedCausalConv1DLayerTest : public testing::WithParamInterface<PagedCausalConv1DLayerParams>,
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
index 60cb462e018..b7fc6af0048 100644
--- 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
@@ -57,9 +57,11 @@ void run_reference(const std::vector<T>& input_embeds,
const std::vector<int32_t>& past_lens,
const std::vector<int32_t>& cache_interval,
int32_t hidden_size,
- int32_t kernel_size,
+ int32_t num_taps,
+ int32_t dilation,
std::vector<T>& output) {
- const size_t state_stride = static_cast<size_t>(hidden_size) * kernel_size;
+ const int32_t window = (num_taps - 1) * dilation + 1;
+ const size_t state_stride = static_cast<size_t>(hidden_size) * window;
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);
@@ -88,16 +90,16 @@ void run_reference(const std::vector<T>& input_embeds,
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++) {
+ float* state_h = local_state.data() + static_cast<size_t>(h) * window;
+ for (int32_t k = 0; k + 1 < window; k++) {
state_h[k] = state_h[k + 1];
}
- state_h[kernel_size - 1] = static_cast<float>(input_embeds[token_idx * hidden_size + h]);
+ state_h[window - 1] = static_cast<float>(input_embeds[token_idx * hidden_size + h]);
- const size_t weight_off = static_cast<size_t>(h) * kernel_size;
+ const size_t weight_off = static_cast<size_t>(h) * num_taps;
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]);
+ for (int32_t k = 0; k < num_taps; k++) {
+ sum += state_h[k * dilation] * static_cast<float>(conv_weight[weight_off + k]);
}
output[token_idx * hidden_size + h] = static_cast<T>(sum);
}
@@ -136,6 +138,7 @@ std::vector<ov::Tensor> calculate_typed_refs(const std::map<std::shared_ptr<ov::
const std::shared_ptr<ov::Model>& function,
int32_t hidden_size,
int32_t kernel_size,
+ int32_t dilation,
bool has_bias,
const ov::element::Type& data_type) {
const auto& params = function->get_parameters();
@@ -163,6 +166,7 @@ std::vector<ov::Tensor> calculate_typed_refs(const std::map<std::shared_ptr<ov::
cache_interval,
hidden_size,
kernel_size,
+ dilation,
ref_output);
ov::Tensor output_tensor(data_type, host_inputs.at(params[0]).get_shape());
@@ -203,6 +207,7 @@ std::string PagedCausalConv1DLayerTest::getTestCaseName(
}
result << "_Type=" << p.element_type;
result << "_Target=" << p.target_device;
+ result << "_Dilation=" << p.dilation;
return result.str();
}
@@ -221,6 +226,8 @@ void PagedCausalConv1DLayerTest::SetUp() {
const auto hidden = static_cast<size_t>(p.hidden_size);
const auto kernel = static_cast<size_t>(p.kernel_size);
+ const auto dilation = static_cast<size_t>(p.dilation);
+ const auto window = (kernel - 1) * dilation + 1;
const ov::Shape weight_shape{hidden, 1, kernel};
const ov::Shape bias_shape = p.has_bias ? ov::Shape{hidden} : ov::Shape{0};
@@ -241,7 +248,7 @@ void PagedCausalConv1DLayerTest::SetUp() {
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});
+ state_targets.push_back({static_cast<size_t>(cfg.num_blocks), hidden, window});
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)});
@@ -288,7 +295,7 @@ void PagedCausalConv1DLayerTest::SetUp() {
// 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{-1, static_cast<int64_t>(hidden), static_cast<int64_t>(window)}, 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},
@@ -317,7 +324,8 @@ void PagedCausalConv1DLayerTest::SetUp() {
p_blocks,
p_block_begins,
p_past_lens,
- p_cache_interval);
+ p_cache_interval,
+ dilation);
function = std::make_shared<ov::Model>(ov::ResultVector{std::make_shared<ov::op::v0::Result>(conv1d)},
ov::ParameterVector{p_embeds,
@@ -403,6 +411,7 @@ std::vector<ov::Tensor> PagedCausalConv1DLayerTest::calculate_refs() {
function,
p.hidden_size,
p.kernel_size,
+ p.dilation,
p.has_bias,
data_type);
}
@@ -412,11 +421,18 @@ std::vector<ov::Tensor> PagedCausalConv1DLayerTest::calculate_refs() {
function,
p.hidden_size,
p.kernel_size,
+ p.dilation,
p.has_bias,
data_type);
}
- return calculate_typed_refs<float>(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.dilation,
+ p.has_bias,
+ data_type);
}
std::vector<ov::Tensor> PagedCausalConv1DLayerTest::get_plugin_outputs() {