Skip to content

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

[TRANSFORMATIONS][CPU][SNIPPETS] Keep LTX-Video RoPE angle computation in f32 under bf16 (#36719)

Aditya Goyale83ffa96a705
diff --git a/src/common/snippets/include/snippets/op/subgraph.hpp b/src/common/snippets/include/snippets/op/subgraph.hpp
index 814a3ff9965..b1d68188cc9 100644
--- a/src/common/snippets/include/snippets/op/subgraph.hpp
+++ b/src/common/snippets/include/snippets/op/subgraph.hpp
@@ -266,6 +266,13 @@ static inline auto build_subgraph(const std::shared_ptr<ov::Node>& node,
const std::string& name = "") -> std::shared_ptr<Subgraph> {
auto subgraph = std::make_shared<Subgraph>(inputs, body);
copy_runtime_info(node, subgraph);
+ // copy_runtime_info drops the non-copyable DisablePrecisionConversion; propagate it by rt_info key
+ // (snippets cannot depend on transformations) so precision markup survives tokenization.
+ for (const auto& item : node->get_rt_info()) {
+ if (item.first.rfind("DisablePrecisionConversion", 0) == 0) {
+ subgraph->get_rt_info()[item.first] = item.second;
+ }
+ }
subgraph->set_friendly_name(name.empty() ? node->get_friendly_name() : name);
return subgraph;
}
diff --git a/src/common/snippets/src/utils/tokenization_utils.cpp b/src/common/snippets/src/utils/tokenization_utils.cpp
index 420534a627b..c26cb633456 100644
--- a/src/common/snippets/src/utils/tokenization_utils.cpp
+++ b/src/common/snippets/src/utils/tokenization_utils.cpp
@@ -50,6 +50,20 @@
namespace ov::snippets::utils {
namespace {
+// copy_runtime_info drops the non-copyable DisablePrecisionConversion attribute; propagate it
+// explicitly from the tokenized nodes to the Subgraph so precision markup (e.g. kept-in-fp32 sin/cos
+// inputs) survives tokenization. Copied by rt_info key because snippets cannot depend on the
+// transformations library.
+void propagate_precision_conversion_disable(const ov::NodeVector& from, const std::shared_ptr<ov::Node>& to) {
+ for (const auto& node : from) {
+ for (const auto& item : node->get_rt_info()) {
+ if (item.first.rfind("DisablePrecisionConversion", 0) == 0) {
+ to->get_rt_info()[item.first] = item.second;
+ }
+ }
+ }
+}
+
auto has_result_child(const std::shared_ptr<const Node>& node) -> bool {
const auto& users = node->get_users();
return std::any_of(users.begin(), users.end(), [](const std::shared_ptr<Node>& child) {
@@ -446,6 +460,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const ov::snippets::pa
}
auto subgraph = op::build_subgraph(node, external_inputs, body, subgraph_name);
copy_runtime_info(replaced_nodes, subgraph);
+ propagate_precision_conversion_disable(replaced_nodes, subgraph);
const auto& act_body = subgraph->body();
for (size_t i = 0; i < act_body.get_parameters().size(); i++) {
act_body.get_parameters()[i]->set_friendly_name(body_parameters[i]->get_friendly_name());
@@ -556,6 +571,7 @@ std::shared_ptr<ov::snippets::op::Subgraph> tokenize_ordered_nodes(const ov::Nod
auto body = op::create_body(last_node->get_friendly_name(), body_results, body_parameters);
auto subgraph = std::make_shared<op::Subgraph>(subgraph_inputs, body);
copy_runtime_info(last_node, subgraph);
+ propagate_precision_conversion_disable({last_node}, subgraph);
subgraph->set_friendly_name(last_node->get_friendly_name());
for (size_t i = 0; i < subgraph->get_output_size(); ++i) {
diff --git a/src/common/transformations/include/transformations/fp16_compression/disable_bf16_comp_ltx_rope.hpp b/src/common/transformations/include/transformations/fp16_compression/disable_bf16_comp_ltx_rope.hpp
new file mode 100644
index 00000000000..c28797e6363
--- /dev/null
+++ b/src/common/transformations/include/transformations/fp16_compression/disable_bf16_comp_ltx_rope.hpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/pass/matcher_pass.hpp"
+#include "transformations_visibility.hpp"
+
+namespace ov {
+namespace pass {
+
+/**
+ * @ingroup ov_transformation_common_api
+ * @brief Keeps the decomposed LTX-Video RoPE angle chain (Multiply -> Add -> Transpose -> Reshape ->
+ * Sin/Cos) in f32: the angles reach ~1.6e4 rad, which bf16 quantizes in steps larger than 2*pi.
+ *
+ * The CPU plugin registers this pass only under bf16 enforcement. The fused RoPE variant is handled
+ * on GPU by IncreasePositionIdsPrecisionForLtxVideo.
+ */
+class TRANSFORMATIONS_API DisableBF16CompForLtxVideoRopePattern : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("DisableBF16CompForLtxVideoRopePattern");
+ DisableBF16CompForLtxVideoRopePattern();
+};
+
+} // namespace pass
+} // namespace ov
diff --git a/src/common/transformations/src/transformations/fp16_compression/disable_bf16_comp_ltx_rope.cpp b/src/common/transformations/src/transformations/fp16_compression/disable_bf16_comp_ltx_rope.cpp
new file mode 100644
index 00000000000..76cfde3893a
--- /dev/null
+++ b/src/common/transformations/src/transformations/fp16_compression/disable_bf16_comp_ltx_rope.cpp
@@ -0,0 +1,50 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "transformations/fp16_compression/disable_bf16_comp_ltx_rope.hpp"
+
+#include "itt.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/cos.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/sin.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+#include "transformations/rt_info/disable_precision_conversion.hpp"
+
+namespace v0 = ov::op::v0;
+namespace v1 = ov::op::v1;
+
+namespace ov::pass {
+
+DisableBF16CompForLtxVideoRopePattern::DisableBF16CompForLtxVideoRopePattern() {
+ MATCHER_SCOPE(DisableBF16CompForLtxVideoRopePattern);
+ using namespace ov::pass::pattern;
+
+ // grid values are small; the large magnitude appears only from the frequency Multiply onwards
+ auto mul = wrap_type<v1::Multiply>({any_input(), any_input()});
+ auto add_constant = wrap_type<v0::Constant>();
+ auto add = wrap_type<v1::Add>({mul, add_constant});
+ auto transpose = wrap_type<v1::Transpose>({add, any_input()});
+ auto reshape = wrap_type<v1::Reshape>({transpose, any_input()});
+ auto sin_or_cos = wrap_type<v0::Sin, v0::Cos>({reshape});
+
+ matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) {
+ const auto& pattern_map = m.get_pattern_value_map();
+ // disable_conversion tags each node with the shared "keep original precision" marker. This pass is
+ // registered by the CPU plugin only under bf16, where EnforceInferencePrecision honors the tag and
+ // leaves the angle chain in f32 instead of lowering it. element::f16 names the marker, not a target.
+ for (const auto& node : {mul, add_constant, add, transpose, reshape, sin_or_cos}) {
+ ov::disable_conversion(pattern_map.at(node).get_node_shared_ptr(), element::f16);
+ }
+ return false;
+ };
+
+ auto m = std::make_shared<Matcher>(sin_or_cos, matcher_name);
+ this->register_matcher(m, callback);
+}
+
+} // namespace ov::pass
diff --git a/src/common/transformations/tests/fp16_compression/disable_bf16_comp_ltx_rope_test.cpp b/src/common/transformations/tests/fp16_compression/disable_bf16_comp_ltx_rope_test.cpp
new file mode 100644
index 00000000000..a076187b116
--- /dev/null
+++ b/src/common/transformations/tests/fp16_compression/disable_bf16_comp_ltx_rope_test.cpp
@@ -0,0 +1,78 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+#include "transformations/fp16_compression/disable_bf16_comp_ltx_rope.hpp"
+
+#include "common_test_utils/ov_test_utils.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/cos.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/sin.hpp"
+#include "openvino/op/transpose.hpp"
+#include "transformations/rt_info/disable_precision_conversion.hpp"
+
+namespace v0 = ov::op::v0;
+namespace v1 = ov::op::v1;
+
+namespace {
+// Multiply -> Add(Constant) -> Transpose -> Reshape -> Sin/Cos, the decomposed LTX-Video rope angles.
+struct RopeChain {
+ std::shared_ptr<v0::Parameter> grid;
+ std::shared_ptr<v1::Multiply> mul;
+ std::shared_ptr<v0::Constant> add_const;
+ std::shared_ptr<v1::Add> add;
+ std::shared_ptr<v1::Transpose> transpose;
+ std::shared_ptr<v1::Reshape> reshape;
+ std::shared_ptr<v0::Sin> sin;
+ std::shared_ptr<v0::Cos> cos;
+ std::shared_ptr<ov::Model> model(const std::string& name) const {
+ return std::make_shared<ov::Model>(ov::OutputVector{sin, cos}, ov::ParameterVector{grid}, name);
+ }
+};
+
+RopeChain make_rope_chain() {
+ RopeChain c;
+ c.grid = std::make_shared<v0::Parameter>(ov::element::f32, ov::Shape{1, 8, 1});
+ auto freqs = v0::Constant::create(ov::element::f32, ov::Shape{1, 1, 16}, std::vector<float>(16, 1000.0f));
+ c.mul = std::make_shared<v1::Multiply>(c.grid, freqs);
+ c.add_const = v0::Constant::create(ov::element::f32, ov::Shape{}, {-1.0f});
+ c.add = std::make_shared<v1::Add>(c.mul, c.add_const);
+ auto order = v0::Constant::create(ov::element::i32, ov::Shape{3}, {0, 2, 1});
+ c.transpose = std::make_shared<v1::Transpose>(c.add, order);
+ auto shape = v0::Constant::create(ov::element::i32, ov::Shape{2}, {1, 128});
+ c.reshape = std::make_shared<v1::Reshape>(c.transpose, shape, false);
+ c.sin = std::make_shared<v0::Sin>(c.reshape);
+ c.cos = std::make_shared<v0::Cos>(c.reshape);
+ return c;
+}
+} // namespace
+
+// The whole angle chain from the frequency Multiply up to Sin/Cos is kept in f32.
+TEST_F(TransformationTestsF, DisableBF16CompForLtxVideoRopeMarksAngleChain) {
+ model = make_rope_chain().model("model");
+
+ manager.register_pass<ov::pass::DisableBF16CompForLtxVideoRopePattern>();
+
+ {
+ auto c = make_rope_chain();
+ for (const auto& node :
+ std::vector<std::shared_ptr<ov::Node>>{c.mul, c.add_const, c.add, c.transpose, c.reshape, c.sin, c.cos}) {
+ disable_conversion(node, ov::element::f16);
+ }
+ model_ref = c.model("model_ref");
+ }
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+ comparator.enable(FunctionsComparator::CmpValues::RUNTIME_KEYS);
+}
+
+// Sin/Cos outside the rope pattern are left untouched, so unrelated subgraphs keep low precision.
+TEST_F(TransformationTestsF, DisableBF16CompForLtxVideoRopeSkipsUnrelatedSinCos) {
+ auto x = std::make_shared<v0::Parameter>(ov::element::f32, ov::Shape{1, 8});
+ auto sin = std::make_shared<v0::Sin>(x);
+ model = std::make_shared<ov::Model>(ov::OutputVector{sin}, ov::ParameterVector{x}, "model");
+
+ manager.register_pass<ov::pass::DisableBF16CompForLtxVideoRopePattern>();
+}
diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp
index 6c505b3d069..1ff830b75dd 100644
--- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp
+++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp
@@ -36,6 +36,7 @@
#include "ov_ops/fully_connected.hpp"
#include "transformations/cpu_opset/common/op/power_static.hpp"
#include "transformations/rt_info/dequantization_node.hpp"
+#include "transformations/rt_info/disable_precision_conversion.hpp"
#include "utils/general_utils.h"
namespace {
@@ -184,6 +185,12 @@ ov::intel_cpu::ConvertToPowerStatic::ConvertToPowerStatic() {
}
toReplace->set_friendly_name(node->get_friendly_name());
ov::copy_runtime_info(node, toReplace);
+ // DisablePrecisionConversion is non-copyable and dropped by copy_runtime_info, re-apply it
+ const auto& rt_info = node->get_rt_info();
+ const auto dpc_it = rt_info.find(ov::DisablePrecisionConversion::get_type_info_static());
+ if (dpc_it != rt_info.end()) {
+ toReplace->get_rt_info().insert(*dpc_it);
+ }
ov::replace_node(node, toReplace);
return true;
};
diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
index 0b101bce38e..d2f75b0cd11 100644
--- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
+++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
@@ -81,6 +81,7 @@
#include "transformations/common_optimizations/wrap_interpolate_into_transposes.hpp"
#include "transformations/convert_precision.hpp"
#include "transformations/fp16_compression/convert_compression_only_to_legacy.hpp"
+#include "transformations/fp16_compression/disable_bf16_comp_ltx_rope.hpp"
#include "transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp"
#include "transformations/fp16_compression/mark_floatpoint_range.hpp"
#include "transformations/init_node_info.hpp"
@@ -1205,6 +1206,11 @@ void Transformations::PostLpt() {
CPU_REGISTER_PASS_COMMON(postLPTPassManager, ov::pass::MarkRopeInputsToKeepInMixedPrecision);
CPU_REGISTER_PASS_COMMON(postLPTPassManager, ov::pass::MarkFloatingPointRange);
}
+ // Only bf16 needs the rope markup: under f16 the angle chain is already kept precise by
+ // ConvertPrecision, and marking it there regresses accuracy.
+ if (config.inferencePrecision == ov::element::bf16) {
+ CPU_REGISTER_PASS_COMMON(postLPTPassManager, ov::pass::DisableBF16CompForLtxVideoRopePattern);
+ }
// Should be before Snippets pipeline because Ngram pattern contains eltwise nodes that can be tokenized by
// Snippets.
diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/rope_table_precision.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/rope_table_precision.cpp
new file mode 100644
index 00000000000..9cda653967f
--- /dev/null
+++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/rope_table_precision.cpp
@@ -0,0 +1,124 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <algorithm>
+
+#include "common_test_utils/node_builders/constant.hpp"
+#include "common_test_utils/ov_tensor_utils.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/cos.hpp"
+#include "openvino/op/matmul.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/sin.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/runtime/properties.hpp"
+#include "shared_test_classes/base/ov_subgraph.hpp"
+
+namespace ov::test {
+
+// Decomposed LTX-Video rope table applied to a projection: the angle chain must stay f32 under bf16
+// enforcement, MatMuls stay bf16. The static case also exercises Snippets tokenization.
+using RopeTablePrecisionParams = std::tuple<ov::element::Type, // inference precision
+ InputShape>; // hidden states shape
+
+class RopeTablePrecisionCPUTest : public testing::WithParamInterface<RopeTablePrecisionParams>,
+ public SubgraphBaseTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<RopeTablePrecisionParams>& obj) {
+ const auto& [infer_prc, shape] = obj.param;
+ std::ostringstream result;
+ result << "inferPRC=" << infer_prc << "_" << (shape.first.is_dynamic() ? "dynamic" : "static");
+ result << "_IS=" << ov::test::utils::partialShape2str({shape.first});
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ const auto& [infer_prc, hidden_shape] = GetParam();
+ targetDevice = utils::DEVICE_CPU;
+ configuration.insert({ov::hint::inference_precision.name(), infer_prc});
+ // low precision angles give O(1) errors; honest rounding stays well under this
+ rel_threshold = 0.05;
+ abs_threshold = 0.5;
+
+ // the rope table size is fixed; only the hidden states shape varies
+ init_input_shapes({InputShape{ov::PartialShape{1, GRID, 1}, {ov::Shape{1, GRID, 1}}}, hidden_shape});
+
+ ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(ov::element::f32, inputDynamicShapes[0]),
+ std::make_shared<ov::op::v0::Parameter>(ov::element::f32, inputDynamicShapes[1])};
+
+ // ~500 rad max after the freq multiply: fatal for bf16 (~2 rad steps), exact for f32 sin/cos
+ auto freqs = utils::make_constant(ov::element::f32, ov::Shape{1, 1, BANDS}, std::vector<float>{1, 2, 4, 8});
+ auto angles = std::make_shared<ov::op::v1::Multiply>(params[0], freqs);
+ auto shifted = std::make_shared<ov::op::v1::Add>(
+ angles,
+ utils::make_constant(ov::element::f32, ov::Shape{}, std::vector<float>{-1.0F}));
+ auto order = utils::make_constant(ov::element::i32, ov::Shape{3}, std::vector<int>{0, 2, 1});
+ auto transpose = std::make_shared<ov::op::v1::Transpose>(shifted, order);
+ auto target_shape =
+ utils::make_constant(ov::element::i32, ov::Shape{2}, std::vector<int>{1, static_cast<int>(HIDDEN_SIZE)});
+ auto reshape = std::make_shared<ov::op::v1::Reshape>(transpose, target_shape, false);
+ auto cos = std::make_shared<ov::op::v0::Cos>(reshape);
+ auto sin = std::make_shared<ov::op::v0::Sin>(reshape);
+
+ ov::test::utils::InputGenerateData weights_data(-1, 2, 256);
+ auto proj_weights = utils::make_constant(ov::element::f32, ov::Shape{HIDDEN_SIZE, HIDDEN_SIZE}, weights_data);
+ auto q = std::make_shared<ov::op::v0::MatMul>(params[1], proj_weights);
+
+ auto q_cos = std::make_shared<ov::op::v1::Multiply>(q, cos);
+ auto q_sin = std::make_shared<ov::op::v1::Multiply>(q, sin);
+ auto rotated = std::make_shared<ov::op::v1::Add>(q_cos, q_sin);
+
+ auto out_weights = utils::make_constant(ov::element::f32, ov::Shape{HIDDEN_SIZE, HIDDEN_SIZE}, weights_data);
+ auto matmul = std::make_shared<ov::op::v0::MatMul>(rotated, out_weights);
+
+ function = std::make_shared<ov::Model>(ov::OutputVector{std::make_shared<ov::op::v0::Result>(matmul)},
+ params,
+ "RopeTablePrecision");
+ }
+
+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
+ inputs.clear();
+ const auto& funcInputs = function->inputs();
+
+ ov::Tensor grid{ov::element::f32, targetInputStaticShapes[0]};
+ auto* grid_data = grid.data<float>();
+ for (size_t i = 0; i < grid.get_size(); ++i) {
+ grid_data[i] = static_cast<float>(i);
+ }
+ inputs.insert({funcInputs[0].get_node_shared_ptr(), grid});
+
+ utils::InputGenerateData in_data;
+ in_data.start_from = -1;
+ in_data.range = 2;
+ in_data.resolution = 256;
+ auto hidden =
+ utils::create_and_fill_tensor(funcInputs[1].get_element_type(), targetInputStaticShapes[1], in_data);
+ inputs.insert({funcInputs[1].get_node_shared_ptr(), hidden});
+ }
+
+ static constexpr size_t GRID = 64;
+ static constexpr size_t BANDS = 4;
+ static constexpr size_t HIDDEN_SIZE = GRID * BANDS;
+};
+
+TEST_P(RopeTablePrecisionCPUTest, CompareWithRefs) {
+ // bf16-only test: skip on CPUs without bf16 support
+ if (!ov::with_cpu_x86_bfloat16()) {
+ GTEST_SKIP() << "No BF16 support";
+ }
+ run();
+}
+
+INSTANTIATE_TEST_SUITE_P(smoke_RopeTablePrecision,
+ RopeTablePrecisionCPUTest,
+ testing::Combine(testing::Values(ov::element::bf16),
+ testing::Values(InputShape{ov::PartialShape{-1, 256},
+ {ov::Shape{64, 256}, ov::Shape{32, 256}}},
+ InputShape{ov::PartialShape{64, 256}, {ov::Shape{64, 256}}})),
+ RopeTablePrecisionCPUTest::getTestCaseName);
+
+} // namespace ov::test