[OpenVINO] Support Flux.2-Klein Models on OpenVINO#1644
Open
osabnis wants to merge 8 commits intohuggingface:mainfrom
Open
[OpenVINO] Support Flux.2-Klein Models on OpenVINO#1644osabnis wants to merge 8 commits intohuggingface:mainfrom
osabnis wants to merge 8 commits intohuggingface:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Optimum-Intel OpenVINO export + inference path to handle Flux.2 “Klein” variants (e.g., black-forest-labs/FLUX.2-klein-4B) by making Flux component export/configuration more adaptive (text encoder type resolution, dynamic RoPE id width, optional pooled projections) and registering a new OV pipeline class for Flux2Klein.
Changes:
- Add Flux text-encoder type resolution and make Flux export more tolerant of *ForCausalLM-wrapped encoders and signature differences.
- Infer Flux RoPE id width dynamically and use it in Flux dummy input generation; conditionally include pooled projections.
- Introduce
OVFlux2KleinPipelineand register it in the OpenVINO diffusion pipeline mappings.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
optimum/exporters/openvino/convert.py |
Adds Flux text-encoder model-type resolution, pooled-projection guarding, and ONNX fallback in export_models. |
optimum/exporters/openvino/model_configs.py |
Adds _get_flux_ids_dim, updates Flux dummy generators to use inferred id width, and makes pooled projections optional for Flux transformer export config. |
optimum/intel/openvino/modeling_diffusion.py |
Adds Flux2Klein pipeline support and makes transformer reshape / transformer inputs more flexible for ids + hidden-states behavior. |
optimum/intel/openvino/__init__.py |
Re-exports OVFlux2KleinPipeline when diffusers is available. |
optimum/intel/__init__.py |
Adds OVFlux2KleinPipeline to lazy import structures and dummy objects mapping. |
optimum/intel/utils/dummy_openvino_and_diffusers_objects.py |
Adds dummy OVFlux2KleinPipeline for optional dependency environments. |
optimum/exporters/openvino/__init__.py |
Re-exports _resolve_flux_text_encoder_model_type from convert.py. |
tests/openvino/test_export.py |
Adds unit tests for _get_flux_ids_dim and _resolve_flux_text_encoder_model_type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR enables OpenVINO export for
black-forest-labs/FLUX.2-klein-4Bby making the Flux export path more robust to Flux2/Klein-specific config and signature differences.Main changes:
optimum/exporters/openvino/convert.pyoptimum/exporters/openvino/model_configs.pyThese changes keep the existing Flux path intact while supporting Flux2-Klein variants.
Example of conversion cmd-line for
black-forest-labs/FLUX.2-klein-4B:optimum-cli export openvino --model black-forest-labs/FLUX.2-klein-4B ov_flux.2-klein-4bExample of inference for
black-forest-labs/FLUX.2-klein-4Busing OpenVINO backend:Converted Model Output from above script:
Before submitting