Skip to content

flux.2-klein-4b enablement#36544

Open
mpaulitsch wants to merge 6 commits into
openvinotoolkit:masterfrom
mpaulitsch:mpa/flux.2-klein-enablement
Open

flux.2-klein-4b enablement#36544
mpaulitsch wants to merge 6 commits into
openvinotoolkit:masterfrom
mpaulitsch:mpa/flux.2-klein-enablement

Conversation

@mpaulitsch

Copy link
Copy Markdown

Details:

  • Align Mark Rope Inputs To Keep In Mixed Precision
  • Enable GLUFusion for FLUX.2 SwiGLU
  • Port RoPE mixed-precision marking for FLUX.2 GPU compile
  • text to image is focus of enablement

Tickets:

  • ticket-id

AI Assistance:

  • AI assistance used: yes
  • If yes, summarize how AI was used and what human validation was performed (build/tests/manual checks).
    yes, created and checked output aligning with expectations, created extensive performance tests, code review.

@mpaulitsch mpaulitsch requested review from a team as code owners June 23, 2026 18:55
@github-actions github-actions Bot added category: GPU OpenVINO GPU plugin category: transformations OpenVINO Runtime library - Transformations labels Jun 23, 2026
@p-durandin

Copy link
Copy Markdown
Contributor

build_jenkins

Comment thread src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp Outdated
@p-durandin

Copy link
Copy Markdown
Contributor

@mpaulitsch please resolve conflicts

@mpaulitsch

Copy link
Copy Markdown
Author

@mpaulitsch please resolve conflicts

resolved all conflicts -- mainly in src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp

mark_path_from_output(m.get_pattern_value_map().at(pattern_root).get_node(), m_visited, skip_pred);
return true;
};
register_matcher(std::make_shared<Matcher>(pattern_root, name), callback);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

register_mark_root calls register_matcher once per pattern, and it's invoked 6× at lines 74-79. But MatcherPass holds a single m_matcher/m_handler — each call overwrites the previous, so only the last (ref_sin, :79) survives. The other five — including the primary pos_cos/pos_sin — are dead code. The PR's goal (keeping RoPE cos/sin tables in FP32) is not achieved.

using namespace ov::pass::pattern;

// FLUX.2 pos_embed frequency tables: outer-product MatMul -> Cos / Sin.
auto outer_matmul = wrap_type<v0::MatMul>({any_input(), any_input()});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap_type<v0::MatMul>({any_input(), any_input()}) is unconstrained → pos_cos/pos_sin match any MatMul→Cos/Sin and pull the whole MatMul subgraph into FP32. Currently inert because of the blocker at 71 line, but once it's fixed this becomes an accuracy/perf regression. Constrain it to the RoPE context (shape/symbol constraints, or match the formed ov::op::internal::RoPE).

auto pos_sin = wrap_type<v0::Sin>({outer_matmul});

// rotary_emb / LLM-style tables: Concat -> Cos or Sin (e.g. text encoder rotary_emb).
auto rot_concat = wrap_type<v0::Concat>({any_input(), any_input()});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue — Concat→Cos/Sin is too broad and will catch non-RoPE subgraphs.


} // namespace

DisableFP16CompFlux2RoPEPattern::DisableFP16CompFlux2RoPEPattern() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test exists for this pass (the PR only adds tests in glu_fusion_test.cpp), which is why the blocker is invisible to CI. Add a graph-level test asserting is_conversion_disabled(cos/sin, f16) for all 6 patterns.

@p-durandin

Copy link
Copy Markdown
Contributor

build_jenkins

@mpaulitsch mpaulitsch force-pushed the mpa/flux.2-klein-enablement branch from 41e53c5 to 2744594 Compare July 9, 2026 12:31
@mpaulitsch

Copy link
Copy Markdown
Author

thanks for review Alexander ... addressed comments

OPENVINO_ASSERT(pattern_map.count(axis_const_m));
auto mul = ov::as_type_ptr<v1::Multiply>(pattern_map.at(mul_m).get_node_shared_ptr());
if (!mul || transformation_callback(mul))
const auto mul_node = pattern_map.at(mul_m).get_node_shared_ptr();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need renaming changes?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@mpaulitsch mpaulitsch force-pushed the mpa/flux.2-klein-enablement branch 2 times, most recently from ddb7b32 to 301532c Compare July 13, 2026 10:11
@mpaulitsch

Copy link
Copy Markdown
Author

rebaselined to be up-to-date with master branch.

@p-durandin

Copy link
Copy Markdown
Contributor

build_jenkins

Match VariadicSplit with runtime Concat split_lengths and TypeRelaxed multiply,
and run GLUFusion before f16 activation scaling and at PostLPT start so the
pattern is not rewritten by FC or MoveDownScalarMul passes.

Co-authored-by: Cursor <cursoragent@cursor.com>
mpaulitsch and others added 5 commits July 15, 2026 19:53
Align MarkRopeInputsToKeepInMixedPrecision with disable_conversion(f16),
add DisablePrecisionConversion rt_info (backed by legacy disable_fp16_compression
wrappers), and run the pass on the GPU plugin after RoPEFusion so cos/sin
subgraphs stay in FP32 under f16 compression.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mpaulitsch mpaulitsch force-pushed the mpa/flux.2-klein-enablement branch from 301532c to 2cb23a0 Compare July 15, 2026 17:56
@p-durandin

Copy link
Copy Markdown
Contributor

build_jenkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: GPU OpenVINO GPU plugin category: transformations OpenVINO Runtime library - Transformations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants