Skip to content

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

Increase position ids precision ltx video (#31887)

Paul Youngsoo Ahnb59186a064e1
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_for_periodic_funcs.cpp b/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_for_periodic_funcs.cpp
deleted file mode 100644
index 68acbbf1335..00000000000
--- a/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_for_periodic_funcs.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (C) 2025 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#include <memory>
-#include <queue>
-#include <unordered_set>
-
-#include "openvino/pass/pattern/op/or.hpp"
-#include "openvino/pass/pattern/op/wrap_type.hpp"
-
-#include "openvino/op/sin.hpp"
-#include "openvino/op/cos.hpp"
-#include "openvino/op/reshape.hpp"
-#include "openvino/op/slice.hpp"
-#include "openvino/op/strided_slice.hpp"
-#include "openvino/op/split.hpp"
-#include "openvino/op/concat.hpp"
-#include "openvino/op/unsqueeze.hpp"
-#include "openvino/op/squeeze.hpp"
-#include "openvino/op/tile.hpp"
-#include "openvino/op/constant.hpp"
-#include "openvino/op/convert.hpp"
-#include "openvino/op/util/broadcast_base.hpp"
-#include "openvino/op/variadic_split.hpp"
-#include "openvino/op/util/binary_elementwise_arithmetic.hpp"
-#include "openvino/op/util/unary_elementwise_arithmetic.hpp"
-#include "openvino/op/mvn.hpp"
-#include "openvino/op/normalize_l2.hpp"
-#include "openvino/op/sqrt.hpp"
-#include "openvino/op/reduce_sum.hpp"
-#include "openvino/op/reduce_mean.hpp"
-
-#include "transformations/utils/utils.hpp"
-#include "disable_fp16_comp_for_periodic_funcs.hpp"
-
-// Uses propagate_through_ops whitelist from mark_subgraph_to_keep_in_mixed_precision in convert precision pass
-// to ensure consistent behavior with OpenVINO's existing mixed precision logic.
-static bool is_propagate_through_node(const std::shared_ptr<ov::Node>& node) {
- return ov::is_type<ov::op::v0::Squeeze>(node) ||
- ov::is_type<ov::op::v0::Unsqueeze>(node) ||
- ov::is_type<ov::op::v1::Reshape>(node) ||
- ov::is_type<ov::op::util::BroadcastBase>(node) ||
- ov::is_type<ov::op::util::BinaryElementwiseArithmetic>(node) ||
- ov::is_type<ov::op::util::UnaryElementwiseArithmetic>(node) ||
- ov::is_type<ov::op::v6::MVN>(node) ||
- ov::is_type<ov::op::v0::MVN>(node) ||
- ov::is_type<ov::op::v0::NormalizeL2>(node) ||
- ov::is_type<ov::op::v0::Sqrt>(node) ||
- ov::is_type<ov::op::v1::StridedSlice>(node) ||
- ov::is_type<ov::op::v1::ReduceSum>(node) ||
- ov::is_type<ov::op::v1::ReduceMean>(node) ||
- ov::is_type<ov::op::v8::Slice>(node) ||
- ov::is_type<ov::op::v1::VariadicSplit>(node) ||
- ov::is_type<ov::op::v1::Split>(node) ||
- ov::is_type<ov::op::v0::Concat>(node) ||
- ov::is_type<ov::op::v0::Convert>(node) ||
- ov::is_type<ov::op::v0::Constant>(node) ||
- ov::is_type<ov::op::v0::Tile>(node);
-}
-
-ov::intel_gpu::DisableFP16CompressionForPeriodicFuncs::DisableFP16CompressionForPeriodicFuncs()
- : ov::pass::MatcherPass() {
- set_name("DisableFP16CompressionForPeriodicFuncs");
-
- auto cos = ov::pass::pattern::wrap_type<ov::op::v0::Cos>();
- auto sin = ov::pass::pattern::wrap_type<ov::op::v0::Sin>();
- auto sin_cos_func_pattern = std::make_shared<ov::pass::pattern::op::Or>(OutputVector{cos, sin});
-
- ov::matcher_pass_callback callback = [&](ov::pass::pattern::Matcher& m) {
- auto node = m.get_match_root();
- // Only disable FP16 compression for FP32 data type,
- // because sin/cos with fp64 should be converted to sin/cos with fp32.
- if (node->get_output_element_type(0) != ov::element::f32) {
- return false;
- }
-
- // Check if sin/cos is followed by propagate-through operations.
- // If so, skip disable_fp16_compression because convert_precision pass will insert
- // Convert nodes at the end of the propagate-through chain (before the first
- // non-propagate-through node), not immediately after sin/cos.
- // In this case, do not apply disable_fp16_compression.
- for (auto& user : node->get_users()) {
- if (is_propagate_through_node(user)) {
- return false;
- }
- }
-
- // Disable FP16 compression for the current sin/cos node
- ov::disable_fp16_compression(node);
-
- // Traverse the input chain to find non-propagate-through nodes
- // and apply disable_fp16_compression to prevent fp16 precision data loss
- std::queue<std::shared_ptr<ov::Node>> nodes_to_process;
- std::unordered_set<std::shared_ptr<ov::Node>> visited;
-
- nodes_to_process.push(node);
- visited.insert(node);
-
- /*
- * Use BFS to traverse input chain and find non-propagate-through nodes
- * to apply disable_fp16_compression, preventing fp16 precision data loss.
- */
- while (!nodes_to_process.empty()) {
- auto current_node = nodes_to_process.front();
- nodes_to_process.pop();
-
- OPENVINO_ASSERT(current_node, "current_node should not be null");
-
- if (current_node->inputs().empty()) {
- continue;
- }
-
- if ((node != current_node)
- && ov::fp16_compression_is_disabled(current_node)) {
- continue;
- }
-
- if (!is_propagate_through_node(current_node)) {
- ov::disable_fp16_compression(current_node);
- continue;
- }
-
- // For propagate-through nodes, add all input nodes to processing queue
- for (size_t i = 0; i < current_node->get_input_size(); ++i) {
- auto input_node = current_node->get_input_node_shared_ptr(i);
- if (input_node && visited.find(input_node) == visited.end()) {
- nodes_to_process.push(input_node);
- visited.insert(input_node);
- }
- }
- }
-
- return true;
- };
-
- auto m = std::make_shared<ov::pass::pattern::Matcher>(sin_cos_func_pattern, "DisableFP16CompressionForPeriodicFuncs");
- register_matcher(m, callback);
-}
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_for_periodic_funcs.hpp b/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_for_periodic_funcs.hpp
deleted file mode 100644
index 778e9879226..00000000000
--- a/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_for_periodic_funcs.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2025 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#pragma once
-
-/**
- * @file disable_fp16_comp_for_periodic_funcs.hpp
- * @brief Defines the transformation pass to disable FP16 compression for periodic functions
- */
-
-#include "openvino/pass/matcher_pass.hpp"
-
-namespace ov {
-namespace intel_gpu {
-
-/**
- * @ingroup ov_transformation_common_api
- * @brief DisableFP16CompressionForPeriodicFuncs is a transformation pass that disables FP16 compression
- * for specific nodes in the computation graph, particularly periodic functions like Sin and Cos.
- *
- * This transformation traverses the graph to identify nodes that modify values and disables FP16 compression
- * for those nodes. It ensures that FP16 compression is not applied to nodes where precision loss could
- * negatively impact the computation results.
- *
- * Specifically, for periodic functions like Sin and Cos, this transformation analyzes their inputs and identifies
- * the first node that performs calculations using inputs not classified as non-value-modifying nodes (as determined
- * by the is_non_value_modifying_node function). FP16 compression is disabled for such nodes to ensure computational
- * accuracy and prevent precision loss
- */
-class DisableFP16CompressionForPeriodicFuncs : public ov::pass::MatcherPass {
-public:
- OPENVINO_MATCHER_PASS_RTTI("DisableFP16CompressionForPeriodicFuncs");
- DisableFP16CompressionForPeriodicFuncs();
-};
-
-} // namespace intel_gpu
-} // namespace ov
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp
index b5e8bb8a37d..4bd9fa222b3 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp
@@ -19,14 +19,22 @@
#include "openvino/op/squeeze.hpp"
#include "openvino/op/transpose.hpp"
#include "openvino/op/unsqueeze.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/gather.hpp"
+#include "openvino/op/strided_slice.hpp"
+#include "openvino/op/shape_of.hpp"
+#include "openvino/op/broadcast.hpp"
+#include "openvino/op/scaled_dot_product_attention.hpp"
+#include "ov_ops/rms.hpp"
#include "openvino/pass/pattern/op/or.hpp"
#include "openvino/pass/pattern/op/wrap_type.hpp"
#include "transformations/utils/utils.hpp"
#include "openvino/core/graph_util.hpp"
+#include "transformations/symbolic_transformations/symbolic_optimizations.hpp"
namespace ov::intel_gpu {
-IncreasePositionIdsPrecision::IncreasePositionIdsPrecision() {
+IncreasePositionIdsPrecisionForRoPE::IncreasePositionIdsPrecisionForRoPE() {
using namespace ov::pass::pattern;
using ov::pass::pattern::op::Or;
@@ -71,69 +79,143 @@ IncreasePositionIdsPrecision::IncreasePositionIdsPrecision() {
const auto original_et = matmul_node->get_output_element_type(0);
if (original_et == desired_et)
return false;
-
- // Insert converts before if needed
- auto input_idx = 0;
- auto insert_converts_before_if_needed = [&](const std::shared_ptr<Node>& node) {
- bool is_changed = false;
- for (const auto& input : node->inputs()) {
- const auto& incoming_output = input.get_source_output();
- const auto& incoming_node = incoming_output.get_node_shared_ptr();
- const auto input_et = incoming_output.get_element_type();
-
- if (input_et == desired_et)
- continue;
-
- auto in_convert = ov::as_type_ptr<ov::op::v0::Convert>(incoming_node);
-
- if (in_convert && in_convert->get_users().size() == 1 && input_et.bitwidth() <= desired_et.bitwidth()) {
- auto convert = std::make_shared<ov::op::v0::Convert>(incoming_node->input_value(0), desired_et);
- convert->set_friendly_name(in_convert->get_friendly_name() + "_increase_precision_" + std::to_string(input_idx));
- copy_runtime_info(incoming_node, convert);
- ov::replace_node(incoming_node, convert);
- } else {
- auto convert = std::make_shared<ov::op::v0::Convert>(incoming_output, desired_et);
- convert->set_friendly_name(incoming_node->get_friendly_name() + "_increase_precision_" + std::to_string(input_idx));
- copy_runtime_info(incoming_node, convert);
- input.replace_source_output(convert);
- }
-
- input_idx++;
- is_changed = true;
- }
-
- return is_changed;
- };
-
- // Insert converts after if needed
- auto output_idx = 0;
- auto insert_converts_after_if_needed = [&](const std::shared_ptr<Node>& node) {
- for (const auto& output : node->outputs()) {
- for (const auto& out_inputs : output.get_target_inputs()) {
- auto out_node = out_inputs.get_node()->shared_from_this();
-
- auto convert = std::make_shared<ov::op::v0::Convert>(output, original_et);
- auto convert_name = out_node->get_friendly_name() + "_restore_precision_" + std::to_string(output_idx);
- convert->set_friendly_name(convert_name);
- copy_runtime_info(node, convert);
- out_inputs.replace_source_output(convert);
- output_idx++;
- }
- }
- };
-
- bool is_changed = insert_converts_before_if_needed(matmul_node);
+ size_t input_idx = 0;
+ bool is_changed = insert_converts_before_if_needed(matmul_node, desired_et, input_idx);
if (is_changed) {
- insert_converts_after_if_needed(cos_node);
- insert_converts_after_if_needed(sin_node);
+ size_t output_idx = 0;
+ insert_converts_after_if_needed(cos_node, original_et, output_idx);
+ insert_converts_after_if_needed(sin_node, original_et, output_idx);
}
+ return true;
+ };
+
+ auto m = std::make_shared<ov::pass::pattern::Matcher>(rope, "IncreasePositionIdsPrecisionForRoPE");
+ this->register_matcher(m, callback);
+}
+
+IncreasePositionIdsPrecisionForLtxVideo::IncreasePositionIdsPrecisionForLtxVideo() {
+ using namespace ov::pass::pattern;
+ using ov::pass::pattern::op::Or;
+
+ // for ltx-video pattern
+ auto mul = wrap_type<ov::op::v1::Multiply>({any_input(), any_input()});
+ auto add_constant = wrap_type<ov::op::v0::Constant>();
+ auto add = wrap_type<ov::op::v1::Add>({mul, add_constant});
+ auto transpose = wrap_type<ov::op::v1::Transpose>({add, any_input()});
+ auto reshape = wrap_type<ov::op::v1::Reshape>({transpose, any_input()});
+ auto sin = wrap_type<ov::op::v0::Sin>({reshape});
+ auto cos = wrap_type<ov::op::v0::Cos>({reshape});
+ auto gather_1 = wrap_type<ov::op::v8::Gather>({cos, any_input(), {-1}}, {{"batch_dims", 0}});
+ auto gather_3 = wrap_type<ov::op::v8::Gather>({sin, any_input(), {-1}}, {{"batch_dims", 0}});
+ auto slice = wrap_type<ov::op::v1::StridedSlice>({gather_1, {0, 0, 0}, {0, 0, 2}, {1, 1, 1}});
+ auto shape_of = wrap_type<ov::op::v3::ShapeOf>({slice});
+ auto broadcast_zero_like = wrap_type<ov::op::v3::Broadcast>({{0}, shape_of});
+ auto broadcast_ones_like = wrap_type<ov::op::v3::Broadcast>({{1}, shape_of});
+ auto concat = wrap_type<ov::op::v0::Concat>({broadcast_ones_like, gather_1});
+ auto concat_1 = wrap_type<ov::op::v0::Concat>({broadcast_zero_like, gather_3});
+ auto rms = wrap_type<ov::op::internal::RMS>({any_input(), any_input()});
+ auto mul_2 = wrap_type<ov::op::v1::Multiply>({rms, concat});
+ auto reshape_2 = wrap_type<ov::op::v1::Reshape>({any_input(), any_input()});
+ auto mul_3 = wrap_type<ov::op::v1::Multiply>({reshape_2, concat_1});
+ auto add_1 = wrap_type<ov::op::v1::Add>({mul_2, mul_3});
+ auto reshape_3 = wrap_type<ov::op::v1::Reshape>({add_1, any_input()});
+ auto tranpose_1 = wrap_type<ov::op::v1::Transpose>({reshape_3, any_input()});
+ auto sdpa = wrap_type<ov::op::v13::ScaledDotProductAttention>({any_input(), tranpose_1, any_input()});
+
+ ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {
+ const auto& pattern_map = m.get_pattern_value_map();
+
+ auto mul_node = ov::as_type_ptr<ov::op::v1::Multiply>(pattern_map.at(mul).get_node_shared_ptr());
+ auto constant_node = ov::as_type_ptr<ov::op::v0::Constant>(pattern_map.at(add_constant).get_node_shared_ptr());
+ auto cos_node = pattern_map.count(cos) > 0 ?
+ ov::as_type_ptr<ov::op::v0::Cos>(pattern_map.at(cos).get_node_shared_ptr())
+ : nullptr;
+ auto sin_node = pattern_map.count(sin) > 0 ?
+ ov::as_type_ptr<ov::op::v0::Sin>(pattern_map.at(sin).get_node_shared_ptr())
+ : nullptr;
+
+ if (!mul_node || transformation_callback(mul_node))
+ return false;
+ const auto desired_et = ov::element::f32;
+ const auto original_et = mul_node->get_output_element_type(0);
+ if (original_et == desired_et)
+ return false;
+
+ size_t input_idx = 0;
+ bool is_changed = insert_converts_before_if_needed(mul_node, desired_et, input_idx);
+ if (is_changed) {
+ if (constant_node)
+ insert_converts_after_if_needed(constant_node, desired_et, input_idx);
+ size_t output_idx = 0;
+ if (cos_node)
+ insert_converts_after_if_needed(cos_node, original_et, output_idx);
+ if (sin_node)
+ insert_converts_after_if_needed(sin_node, original_et, output_idx);
+ }
return true;
};
- auto m = std::make_shared<ov::pass::pattern::Matcher>(rope, "IncreasePositionIdsPrecision");
+ auto m = std::make_shared<ov::pass::pattern::Matcher>(sdpa, "IncreasePositionIdsPrecisionForLtxVideo");
this->register_matcher(m, callback);
}
+bool IncreasePositionIdsPrecisionForRoPE::insert_converts_before_if_needed(const std::shared_ptr<ov::Node>& node,
+ const ov::element::Type desired_et, size_t& input_idx) {
+ bool is_changed = false;
+ for (const auto& input : node->inputs()) {
+ const auto& incoming_output = input.get_source_output();
+ const auto& incoming_node = incoming_output.get_node_shared_ptr();
+ const auto input_et = incoming_output.get_element_type();
+
+ if (input_et == desired_et)
+ continue;
+
+ auto in_convert = ov::as_type_ptr<ov::op::v0::Convert>(incoming_node);
+
+ if (in_convert && in_convert->get_users().size() == 1 && input_et.bitwidth() <= desired_et.bitwidth()) {
+ auto convert = std::make_shared<ov::op::v0::Convert>(incoming_node->input_value(0), desired_et);
+ convert->set_friendly_name(in_convert->get_friendly_name() + "_increase_precision_" + std::to_string(input_idx));
+ copy_runtime_info(incoming_node, convert);
+ ov::replace_node(incoming_node, convert);
+ } else {
+ auto convert = std::make_shared<ov::op::v0::Convert>(incoming_output, desired_et);
+ convert->set_friendly_name(incoming_node->get_friendly_name() + "_increase_precision_" + std::to_string(input_idx));
+ copy_runtime_info(incoming_node, convert);
+ input.replace_source_output(convert);
+ }
+
+ input_idx++;
+ is_changed = true;
+ }
+
+ return is_changed;
+}
+
+void IncreasePositionIdsPrecisionForRoPE::insert_converts_after_if_needed(const std::shared_ptr<ov::Node>& node,
+ const ov::element::Type original_et, size_t& output_idx) {
+ for (const auto& output : node->outputs()) {
+ for (const auto& out_inputs : output.get_target_inputs()) {
+ auto out_node = out_inputs.get_node()->shared_from_this();
+
+ auto convert = std::make_shared<ov::op::v0::Convert>(output, original_et);
+ auto convert_name = out_node->get_friendly_name() + "_restore_precision_" + std::to_string(output_idx);
+ convert->set_friendly_name(convert_name);
+ copy_runtime_info(node, convert);
+ out_inputs.replace_source_output(convert);
+ output_idx++;
+ }
+ }
+}
+
+IncreasePositionIdsPrecision::IncreasePositionIdsPrecision() {}
+
+bool IncreasePositionIdsPrecision::run_on_model(const std::shared_ptr<ov::Model>& model) {
+ ov::pass::SymbolicOptimizations symbolic_optimizations(false, get_pass_config());
+ auto symbolic_ctx_manager = symbolic_optimizations.get_manager();
+ symbolic_ctx_manager->register_pass<IncreasePositionIdsPrecisionForRoPE>();
+ symbolic_ctx_manager->register_pass<IncreasePositionIdsPrecisionForLtxVideo>();
+ return symbolic_optimizations.run_on_model(model);
+}
} // namespace ov::intel_gpu
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.hpp b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.hpp
index 7f7896780fd..bc7a2230b8b 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.hpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.hpp
@@ -8,16 +8,32 @@
namespace ov::intel_gpu {
+class IncreasePositionIdsPrecisionForRoPE : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("IncreasePositionIdsPrecisionBase");
+ IncreasePositionIdsPrecisionForRoPE();
+protected:
+ bool insert_converts_before_if_needed(const std::shared_ptr<ov::Node>& node, const ov::element::Type desired_et, size_t& input_idx);
+ void insert_converts_after_if_needed(const std::shared_ptr<ov::Node>& node, const ov::element::Type original_et, size_t& output_idx);
+};
+
+class IncreasePositionIdsPrecisionForLtxVideo : public IncreasePositionIdsPrecisionForRoPE {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("IncreasePositionIdsPrecisionForLtxVideo");
+ IncreasePositionIdsPrecisionForLtxVideo();
+};
+
/**
- * @brief This pass adds additional convert nodes on the position_ids input branch (around MatMul operation),
+ * @brief This pass adds additional convert nodes on the position_ids input branch (around MatMul or Multiply operation),
* targeting to improve runtime rotary position embeddings calculation for FP16 models.
* Lack of these converts leads to lower accuracy in case if long input sequences (larger than 2048)
* due to position_ids representation in the FP16 data type.
*/
-class IncreasePositionIdsPrecision : public ov::pass::MatcherPass {
+class IncreasePositionIdsPrecision : public ov::pass::ModelPass {
public:
- OPENVINO_MATCHER_PASS_RTTI("IncreasePositionIdsPrecision");
+ OPENVINO_MODEL_PASS_RTTI("IncreasePositionIdsPrecision");
IncreasePositionIdsPrecision();
+ bool run_on_model(const std::shared_ptr<ov::Model>& model) override;
};
} // namespace ov::intel_gpu
diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
index 1458219e3ed..5fd1236b7d8 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
@@ -93,7 +93,6 @@
#include "plugin/transformations/transpose_fusion.hpp"
#include "plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.hpp"
#include "plugin/transformations/unsqueeze_broadcast_reshape_sdpa_fusion.hpp"
-#include "plugin/transformations/disable_fp16_comp_for_periodic_funcs.hpp"
#include "transformations/common_optimizations/activations_scaling.hpp"
#include "transformations/common_optimizations/broadcast_elementwise_fusion.hpp"
#include "transformations/common_optimizations/broadcast_transition.hpp"
@@ -444,9 +443,6 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
}
}
- if (infer_precision == ov::element::f16) {
- manager.register_pass<DisableFP16CompressionForPeriodicFuncs>();
- }
type_to_fuse_map empty_fuse_map = {};
manager.register_pass<ov::pass::Validate>();
diff --git a/src/plugins/intel_gpu/tests/unit/transformations/disable_fp16_compression_periodic_func_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/disable_fp16_compression_periodic_func_test.cpp
deleted file mode 100644
index 26d3270a4b1..00000000000
--- a/src/plugins/intel_gpu/tests/unit/transformations/disable_fp16_compression_periodic_func_test.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright (C) 2025 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#include <gtest/gtest.h>
-
-#include <string>
-#include <memory>
-
-#include <openvino/core/model.hpp>
-#include <openvino/pass/manager.hpp>
-#include <transformations/utils/utils.hpp>
-
-#include <plugin/transformations/disable_fp16_comp_for_periodic_funcs.hpp>
-#include <transformations/convert_precision.hpp>
-#include "openvino/op/constant.hpp"
-#include "openvino/op/convert.hpp"
-#include "openvino/op/parameter.hpp"
-#include "openvino/op/unsqueeze.hpp"
-#include "openvino/op/multiply.hpp"
-#include "openvino/op/add.hpp"
-#include "openvino/op/transpose.hpp"
-#include "openvino/op/reshape.hpp"
-#include "openvino/op/cos.hpp"
-#include "openvino/op/sin.hpp"
-#include "openvino/op/concat.hpp"
-#include "openvino/op/matmul.hpp"
-#include "openvino/op/gather.hpp"
-
-using namespace testing;
-using namespace ov::intel_gpu;
-
-static bool fuse_type_to_convert(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
- auto convert = ov::as_type_ptr<ov::op::v0::Convert>(node);
- if (!convert)
- return false;
- const auto& from = node->get_output_element_type(0);
- auto it = precisions.find(from);
- if (it == precisions.end())
- return false;
- const auto& to = it->second;
- convert->set_convert_element_type(to);
- return true;
-}
-
-static const std::string name_add = "add_1";
-static const std::string name_mul = "mul_1";
-static const std::string name_sin = "sin";
-static const std::string name_cos = "cos";
-
-static std::shared_ptr<ov::Model> create_model_with_periodic_func_with_matmul() {
- auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{ -1, -1, 3 });
- auto constant_1 = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, { -1 });
- auto unsqueeze_1 = std::make_shared<ov::op::v0::Unsqueeze>(input, constant_1 );
-
- auto constant_2_compressed = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1,1,341 }, { 3.14062f });
- auto constant_2 = std::make_shared<ov::op::v0::Convert>(constant_2_compressed, ov::element::f32);
-
- auto matmul_weight = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{ 1, 341 }, { 1.0f });
- auto matmul_1 = std::make_shared<ov::op::v0::MatMul>(unsqueeze_1, matmul_weight);
-
- auto multiply_1 = std::make_shared<ov::op::v1::Multiply>(matmul_1, constant_2);
-
- auto constant_3_compressed = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1,1,341 }, { -1.57031f });
- auto constant_3 = std::make_shared<ov::op::v0::Convert>(constant_3_compressed, ov::element::f32);
- auto constant_4 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 1, 3, 2 });
-
- auto add_1 = std::make_shared<ov::op::v1::Add>(multiply_1, constant_3);
- add_1->set_friendly_name(name_add);
- auto transpose_1 = std::make_shared<ov::op::v1::Transpose>(add_1, constant_4);
- auto reshape_1 = std::make_shared<ov::op::v1::Reshape>(transpose_1, ov::op::v0::Constant::create(ov::element::i64, ov::Shape{ 3 }, { 0, 0, 1023 }), false);
-
- auto sin = std::make_shared<ov::op::v0::Sin>(reshape_1);
- sin->set_friendly_name(name_sin);
- auto cos = std::make_shared<ov::op::v0::Cos>(reshape_1);
- cos->set_friendly_name(name_cos);
- auto constant_5 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 2046 }, { 0 });
- auto constant_6 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { 0 });
- auto gather_sin = std::make_shared<ov::op::v8::Gather>(sin, constant_5, constant_6);
- auto gather_cos = std::make_shared<ov::op::v8::Gather>(cos, constant_5, constant_6);
- auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{gather_sin, gather_cos}, 2);
-
- return std::make_shared<ov::Model>(ov::OutputVector{concat}, ov::ParameterVector{input});
-}
-
-
-static std::shared_ptr<ov::Model> create_model_with_periodic_func() {
- auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{ -1, -1, 3 });
- auto constant_1 = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, { -1 });
- auto unsqueeze_1 = std::make_shared<ov::op::v0::Unsqueeze>(input, constant_1 );
-
- auto constant_2_compressed = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1,1,341 }, { 3.14062f });
- auto constant_2 = std::make_shared<ov::op::v0::Convert>(constant_2_compressed, ov::element::f32);
-
- auto multiply_1 = std::make_shared<ov::op::v1::Multiply>(unsqueeze_1, constant_2);
-
- auto constant_3_compressed = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1,1,341 }, { -1.57031f });
- auto constant_3 = std::make_shared<ov::op::v0::Convert>(constant_3_compressed, ov::element::f32);
- auto constant_4 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 1, 3, 2 });
-
- auto add_1 = std::make_shared<ov::op::v1::Add>(multiply_1, constant_3);
- add_1->set_friendly_name(name_add);
- auto transpose_1 = std::make_shared<ov::op::v1::Transpose>(add_1, constant_4);
- auto reshape_1 = std::make_shared<ov::op::v1::Reshape>(transpose_1, ov::op::v0::Constant::create(ov::element::i64, ov::Shape{ 3 }, { 0, 0, 1023 }), false);
-
- auto sin = std::make_shared<ov::op::v0::Sin>(reshape_1);
- sin->set_friendly_name(name_sin);
- auto cos = std::make_shared<ov::op::v0::Cos>(reshape_1);
- cos->set_friendly_name(name_cos);
- auto constant_5 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 2046 }, { 0 });
- auto constant_6 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { 0 });
- auto gather_sin = std::make_shared<ov::op::v8::Gather>(sin, constant_5, constant_6);
- auto gather_cos = std::make_shared<ov::op::v8::Gather>(cos, constant_5, constant_6);
- auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{gather_sin, gather_cos}, 2);
-
- return std::make_shared<ov::Model>(ov::OutputVector{concat}, ov::ParameterVector{input});
-}
-
-static std::shared_ptr<ov::Model> create_simple_model_with_periodic_func() {
- auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{1, 3, 224, 224});
-
- auto sin = std::make_shared<ov::op::v0::Sin>(input);
- sin->set_friendly_name(name_sin);
-
- auto cos = std::make_shared<ov::op::v0::Cos>(input);
- cos->set_friendly_name(name_cos);
-
- return std::make_shared<ov::Model>(ov::OutputVector{sin, cos}, ov::ParameterVector{input});
-}
-
-static std::shared_ptr<ov::Model> create_no_available_disabled_fp16_model() {
- auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{-1, 1});
- auto input2 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{-1, 256});
- auto constant_1 = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{ 1, 128 }, { 1.f });
- auto matmul = std::make_shared<ov::op::v0::MatMul>(input, constant_1);
- matmul->set_friendly_name(name_mul);
-
- auto sin = std::make_shared<ov::op::v0::Sin>(matmul);
- sin->set_friendly_name(name_sin);
-
- auto cos = std::make_shared<ov::op::v0::Cos>(matmul);
- cos->set_friendly_name(name_cos);
-
- auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{sin,cos},1);
-
- return std::make_shared<ov::Model>(ov::OutputVector{concat}, ov::ParameterVector{input, input2});
-}
-
-static void run_disable_fp16_compression_for_periodic_func_test(std::shared_ptr<ov::Model> model,
- const std::unordered_set<std::string>& required_nodes, bool is_expected_disabled_fp16 = true) {
- ov::pass::Manager manager;
- manager.register_pass<DisableFP16CompressionForPeriodicFuncs>();
-
- type_to_fuse_map empty_fuse_map = {};
- const bool keep_precision_sensitive_in_fp32_1 = true;
- const bool convert_input_output_precision = false;
- const bool store_original_precision_as_rt_attribute = true;
-
- precisions_map fp_convert_precision_map = {
- {ov::element::f64, ov::element::f32},
- {ov::element::f32, ov::element::f16}
- };
-
- manager.register_pass<ov::pass::ConvertPrecision>(fp_convert_precision_map,
- empty_fuse_map,
- keep_precision_sensitive_in_fp32_1,
- convert_input_output_precision,
- store_original_precision_as_rt_attribute);
-
- const bool keep_precision_sensitive_in_fp32_2 = true;
- precisions_map int_convert_precision_map{
- {ov::element::i64, ov::element::i32},
- {ov::element::u64, ov::element::i32},
- {ov::element::i16, ov::element::i32},
- {ov::element::u16, ov::element::i32},
- {ov::element::u32, ov::element::i32},
- {ov::element::boolean, ov::element::u8},
- {ov::element::i4, ov::element::i8},
- {ov::element::u4, ov::element::u8},
- };
-
- type_to_fuse_map type_to_fuse = {{ov::op::v0::Convert::get_type_info_static(), fuse_type_to_convert}};
- manager.register_pass<ov::pass::ConvertPrecision>(int_convert_precision_map,
- type_to_fuse,
- keep_precision_sensitive_in_fp32_2,
- convert_input_output_precision);
- manager.run_passes(model);
- std::unordered_set<std::string> found_nodes; // Set of found node names
-
- for (auto& op : model->get_ops()) {
- if (required_nodes.count(op->get_friendly_name())) {
- found_nodes.insert(op->get_friendly_name()); // Add the found node name to the set
-
- if (is_expected_disabled_fp16) {
- ASSERT_TRUE(ov::fp16_compression_is_disabled(op))
- << "FP16 compression is not disabled for node: " << op->get_friendly_name();
- } else {
- ASSERT_FALSE(ov::fp16_compression_is_disabled(op))
- << "FP16 compression is unexpectedly disabled for node: " << op->get_friendly_name();
- }
- }
- }
-
- ASSERT_EQ(found_nodes, required_nodes)
- << "Mismatch between found nodes and required nodes.";
-}
-
-TEST(TransformationTests, DisableFP16CompressionForPeriodicFuncsTest) {
- std::unordered_set<std::string> required_nodes = {name_sin, name_cos, name_add};
- auto model = create_model_with_periodic_func();
- run_disable_fp16_compression_for_periodic_func_test(model, required_nodes);
-}
-
-TEST(TransformationTests, DisableFP16CompressionForPeriodicFuncsTestWithMatMul) {
- std::unordered_set<std::string> required_nodes = {name_sin, name_cos, name_add};
- auto model = create_model_with_periodic_func_with_matmul();
- run_disable_fp16_compression_for_periodic_func_test(model, required_nodes);
-}
-
-
-TEST(TransformationTests, DisableFP16CompressionForPeriodicFuncsTestSimple) {
- std::unordered_set<std::string> required_nodes = {name_sin, name_cos};
- auto model = create_simple_model_with_periodic_func();
- run_disable_fp16_compression_for_periodic_func_test(model, required_nodes);
-}
-
-TEST(TransformationTests, DisableFP16CompressionForPeriodicFuncsTestNoAvailableDisabledFP16) {
- std::unordered_set<std::string> required_nodes = {name_mul, name_sin, name_cos};
- auto model = create_no_available_disabled_fp16_model();
- run_disable_fp16_compression_for_periodic_func_test(model, required_nodes, false);
-}
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/tests/unit/transformations/increase_position_ids_precision_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/increase_position_ids_precision_test.cpp
index 9cdd75b9653..b7e7573352b 100644
--- a/src/plugins/intel_gpu/tests/unit/transformations/increase_position_ids_precision_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/transformations/increase_position_ids_precision_test.cpp
@@ -23,6 +23,15 @@
#include "openvino/op/reshape.hpp"
#include "openvino/op/squeeze.hpp"
#include "openvino/op/unsqueeze.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/gather.hpp"
+#include "openvino/op/strided_slice.hpp"
+#include "openvino/op/shape_of.hpp"
+#include "openvino/op/broadcast.hpp"
+#include "ov_ops/rms.hpp"
+#include "openvino/op/split.hpp"
+#include "openvino/op/scaled_dot_product_attention.hpp"
#include <plugin/transformations/increase_position_ids_precision.hpp>
#include <transformations/init_node_info.hpp>
@@ -292,3 +301,183 @@ TEST_F(TransformationTestsF, IncreasePositionIdsLongRoPE) {
}
comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
}
+
+TEST_F(TransformationTestsF, IncreasePositionIdsLTXVideo) {
+ {
+ auto input_1 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, 3, -1 });
+ auto input_2 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, -1, 2048 });
+
+ auto constant_01 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 2, 1 });
+ auto transpose = std::make_shared<ov::op::v1::Transpose>(input_1, constant_01);
+ auto constant_02 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 1 }, { -1 });
+ auto unsqueeze_1 = std::make_shared<ov::op::v0::Unsqueeze>(transpose, constant_02);
+ auto constant_03 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1, 1, 1, 341 }, { 3.14f });
+ auto multiply = std::make_shared<ov::op::v1::Multiply>(unsqueeze_1, constant_03);
+
+ auto constant_04 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1, 1, 1, 341 }, { 1e-6 });
+ auto add = std::make_shared<ov::op::v1::Add>(multiply, constant_04);
+
+ auto constant_05 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 1, 3, 2 });
+ auto transpose_1 = std::make_shared<ov::op::v1::Transpose>(add, constant_05);
+
+ auto constant_06 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 1023 });
+ auto reshape_1 = std::make_shared<ov::op::v1::Reshape>(transpose_1, constant_06, true);
+
+ auto cos = std::make_shared<ov::op::v0::Cos>(reshape_1);
+ auto sin = std::make_shared<ov::op::v0::Sin>(reshape_1);
+
+ auto constant_07 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 2046 }, { 0 });
+ auto constant_08 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 2046 }, { 0 });
+ auto constant_09 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto constant_10 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+
+ auto gather_1 = std::make_shared<ov::op::v8::Gather>(cos, constant_07, constant_09);
+ auto gather_3 = std::make_shared<ov::op::v8::Gather>(sin, constant_08, constant_10);
+
+ auto constant_11 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 0 });
+ auto constant_12 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 2 });
+ auto constant_13 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 1, 1, 1 });
+ auto slice = std::make_shared<ov::op::v1::StridedSlice>(gather_1, constant_11, constant_12, constant_13, std::vector<int64_t>{}, std::vector<int64_t>{});
+
+ auto shape_of = std::make_shared<ov::op::v3::ShapeOf>(slice);
+ auto constant_14 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ }, { 1 });
+ auto constant_15 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ }, { 0 });
+ auto broadcast_ones_like = std::make_shared<ov::op::v3::Broadcast>(constant_14, shape_of);
+ auto broadcast_zeros_like = std::make_shared<ov::op::v3::Broadcast>(constant_15, shape_of);
+
+ auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{broadcast_ones_like, gather_1}, -1);
+ auto concat_1 = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{broadcast_zeros_like, gather_3}, -1);
+
+ auto constant_16 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 1, 1, 2048 }, { 0 });
+ auto rms = std::make_shared<ov::op::internal::RMS>(input_2, constant_16, 1e-19);
+
+ auto constant_17 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 0, 1024, 2 });
+ auto reshape_2 = std::make_shared<ov::op::v1::Reshape>(rms, constant_17, true);
+
+ auto constant_18 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto split_1 = std::make_shared<ov::op::v1::Split>(reshape_2, constant_18, 2);
+
+ auto constant_19 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ }, { -1 });
+ auto multiply_2 = std::make_shared<ov::op::v1::Multiply>(split_1->output(0), constant_19);
+
+ auto constant_20 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto squeeze_1 = std::make_shared<ov::op::v0::Squeeze>(multiply_2, constant_20);
+
+ auto constant_21 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto unsqueeze_2 = std::make_shared<ov::op::v0::Unsqueeze>(squeeze_1, constant_21);
+
+ auto concat_stack_1 = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{unsqueeze_2, split_1->output(1)}, -1);
+ auto constant_22 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 2048 });
+ auto reshape_3 = std::make_shared<ov::op::v1::Reshape>(concat_stack_1, constant_22, true);
+
+ auto multiply_3 = std::make_shared<ov::op::v1::Multiply>(rms, concat);
+ auto multiply_4 = std::make_shared<ov::op::v1::Multiply>(reshape_3, concat_1);
+
+ auto add_1 = std::make_shared<ov::op::v1::Add>(multiply_3, multiply_4);
+ auto constant_23 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 0, 32, 64 });
+ auto reshape_4 = std::make_shared<ov::op::v1::Reshape>(add_1, constant_23, true);
+ auto constant_24 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 2, 1, 3 });
+ auto transpose_3 = std::make_shared<ov::op::v1::Transpose>(reshape_4, constant_24);
+
+ auto input_3 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, -1, 32, 64 });
+ auto input_4 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, -1, 32, 64 });
+ auto transpose_2 = std::make_shared<ov::op::v1::Transpose>(input_3, constant_24);
+ auto transpose_4 = std::make_shared<ov::op::v1::Transpose>(input_4, constant_24);
+ auto sdpa = std::make_shared<ov::op::v13::ScaledDotProductAttention>(transpose_2, transpose_3, transpose_4, true);
+
+ model = std::make_shared<ov::Model>(ov::OutputVector{sdpa}, ov::ParameterVector{input_1, input_2, input_3, input_4});
+ manager.register_pass<IncreasePositionIdsPrecision>();
+ }
+ {
+ auto input_1 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, 3, -1 });
+ auto input_2 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, -1, 2048 });
+
+ auto constant_01 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 2, 1 });
+ auto transpose = std::make_shared<ov::op::v1::Transpose>(input_1, constant_01);
+ auto constant_02 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 1 }, { -1 });
+ auto unsqueeze_1 = std::make_shared<ov::op::v0::Unsqueeze>(transpose, constant_02);
+ auto constant_03 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1, 1, 1, 341 }, { 3.14f });
+
+ auto convert_1 = std::make_shared<ov::op::v0::Convert>(unsqueeze_1, ov::element::f32);
+ auto convert_2 = std::make_shared<ov::op::v0::Convert>(constant_03, ov::element::f32);
+ auto multiply = std::make_shared<ov::op::v1::Multiply>(convert_1, convert_2);
+
+ auto constant_04 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ 1, 1, 1, 341 }, { 1e-6 });
+ auto convert_3 = std::make_shared<ov::op::v0::Convert>(constant_04, ov::element::f32);
+ auto add = std::make_shared<ov::op::v1::Add>(multiply, convert_3);
+
+ auto constant_05 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 1, 3, 2 });
+ auto transpose_1 = std::make_shared<ov::op::v1::Transpose>(add, constant_05);
+
+ auto constant_06 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 1023 });
+ auto reshape_1 = std::make_shared<ov::op::v1::Reshape>(transpose_1, constant_06, true);
+
+ auto cos = std::make_shared<ov::op::v0::Cos>(reshape_1);
+ auto sin = std::make_shared<ov::op::v0::Sin>(reshape_1);
+
+ auto convert_4 = std::make_shared<ov::op::v0::Convert>(cos, ov::element::f16);
+ auto convert_5 = std::make_shared<ov::op::v0::Convert>(sin, ov::element::f16);
+
+ auto constant_07 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 2046 }, { 0 });
+ auto constant_08 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 2046 }, { 0 });
+ auto constant_09 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto constant_10 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+
+ auto gather_1 = std::make_shared<ov::op::v8::Gather>(convert_4, constant_07, constant_09);
+ auto gather_3 = std::make_shared<ov::op::v8::Gather>(convert_5, constant_08, constant_10);
+
+ auto constant_11 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 0 });
+ auto constant_12 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 2 });
+ auto constant_13 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 1, 1, 1 });
+ auto slice = std::make_shared<ov::op::v1::StridedSlice>(gather_1, constant_11, constant_12, constant_13, std::vector<int64_t>{}, std::vector<int64_t>{});
+
+ auto shape_of = std::make_shared<ov::op::v3::ShapeOf>(slice);
+ auto constant_14 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ }, { 1 });
+ auto constant_15 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ }, { 0 });
+ auto broadcast_ones_like = std::make_shared<ov::op::v3::Broadcast>(constant_14, shape_of);
+ auto broadcast_zeros_like = std::make_shared<ov::op::v3::Broadcast>(constant_15, shape_of);
+
+ auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{broadcast_ones_like, gather_1}, -1);
+ auto concat_1 = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{broadcast_zeros_like, gather_3}, -1);
+
+ auto constant_16 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 1, 1, 2048 }, { 0 });
+ auto rms = std::make_shared<ov::op::internal::RMS>(input_2, constant_16, 1e-19);
+
+ auto constant_17 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 0, 1024, 2 });
+ auto reshape_2 = std::make_shared<ov::op::v1::Reshape>(rms, constant_17, true);
+
+ auto constant_18 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto split_1 = std::make_shared<ov::op::v1::Split>(reshape_2, constant_18, 2);
+
+ auto constant_19 = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{ }, { -1 });
+ auto multiply_2 = std::make_shared<ov::op::v1::Multiply>(split_1->output(0), constant_19);
+
+ auto constant_20 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto squeeze_1 = std::make_shared<ov::op::v0::Squeeze>(multiply_2, constant_20);
+
+ auto constant_21 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, { -1 });
+ auto unsqueeze_2 = std::make_shared<ov::op::v0::Unsqueeze>(squeeze_1, constant_21);
+
+ auto concat_stack_1 = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{unsqueeze_2, split_1->output(1)}, -1);
+ auto constant_22 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 3 }, { 0, 0, 2048 });
+ auto reshape_3 = std::make_shared<ov::op::v1::Reshape>(concat_stack_1, constant_22, true);
+
+ auto multiply_3 = std::make_shared<ov::op::v1::Multiply>(rms, concat);
+ auto multiply_4 = std::make_shared<ov::op::v1::Multiply>(reshape_3, concat_1);
+
+ auto add_1 = std::make_shared<ov::op::v1::Add>(multiply_3, multiply_4);
+ auto constant_23 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 0, 32, 64 });
+ auto reshape_4 = std::make_shared<ov::op::v1::Reshape>(add_1, constant_23, true);
+ auto constant_24 = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ 4 }, { 0, 2, 1, 3 });
+ auto transpose_3 = std::make_shared<ov::op::v1::Transpose>(reshape_4, constant_24);
+
+ auto input_3 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, -1, 32, 64 });
+ auto input_4 = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::PartialShape{ -1, -1, 32, 64 });
+ auto transpose_2 = std::make_shared<ov::op::v1::Transpose>(input_3, constant_24);
+ auto transpose_4 = std::make_shared<ov::op::v1::Transpose>(input_4, constant_24);
+ auto sdpa = std::make_shared<ov::op::v13::ScaledDotProductAttention>(transpose_2, transpose_3, transpose_4, true);
+
+ model_ref = std::make_shared<ov::Model>(ov::OutputVector{sdpa}, ov::ParameterVector{input_1, input_2, input_3, input_4});
+ }
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+}