Skip to content

Add support for FLUX.2 Klein 9B and 4B in single_file_utils#13237

Open
eliemichel wants to merge 2 commits intohuggingface:mainfrom
eliemichel:patch-2
Open

Add support for FLUX.2 Klein 9B and 4B in single_file_utils#13237
eliemichel wants to merge 2 commits intohuggingface:mainfrom
eliemichel:patch-2

Conversation

@eliemichel
Copy link
Copy Markdown

@eliemichel eliemichel commented Mar 9, 2026

What does this PR do?

It enables detection of FLUX.2 Klein models when loading transformers from single file, like in the following example:

import torch
from diffusers import Flux2KleinPipeline, Flux2Transformer2DModel, GGUFQuantizationConfig
dtype = torch.bfloat16

ckpt_path = "https://huggingface.co/unsloth/FLUX.2-klein-4B-GGUF/blob/main/flux-2-klein-4b-Q2_K.gguf"
transformer = Flux2Transformer2DModel.from_single_file(
    ckpt_path,
    quantization_config=GGUFQuantizationConfig(compute_dtype=dtype),
    torch_dtype=dtype,
)
pipe2 = Flux2KleinPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein-4B",
    transformer=transformer,
    torch_dtype=dtype,
)
pipe2.enable_model_cpu_offload()

Before this PR, Klein models were detected as flux-2-dev, leading to wrong expected tensor sizes.

Before submitting

Who can review?

@sayakpaul @yiyixuxu @DN6

@sayakpaul sayakpaul requested a review from DN6 March 10, 2026 02:21
@vladmandic
Copy link
Copy Markdown
Contributor

@yiyixuxu @sayakpaul @DN6 gentle ping?

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@github-actions github-actions bot added single-file size/S PR with diff < 50 LOC labels Apr 8, 2026
DN6
DN6 previously approved these changes Apr 8, 2026
Copy link
Copy Markdown
Collaborator

@DN6 DN6 left a comment

Choose a reason for hiding this comment

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

Thank you @eliemichel 👍🏽

@DN6
Copy link
Copy Markdown
Collaborator

DN6 commented Apr 8, 2026

@eliemichel Just checked against the unquantized versions of the Klein checkpoints and it looks like the proposed shape checks only work with GGUF checkpoints.

@DN6 DN6 self-requested a review April 8, 2026 11:44
@DN6 DN6 dismissed their stale review April 8, 2026 11:45

Proposed shape checks don't work with unquantized checkpoints.

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

Labels

single-file size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants