Views
No views yet
diffusers, I am still investigating the issue with the ComfyUI implementation.diffusers library, ComfyUI, or any other model), although models that use architectures which are unfamiliar to me might be more difficult.diffusers1import torch
2from diffusers import Flux2KleinPipeline, Flux2Transformer2DModel
3from transformers.modeling_utils import no_init_weights
4from dfloat11 import DFloat11Model
5text_encoder = DFloat11Model.from_pretrained("DFloat11/Qwen3-8B-DF11", device="cpu")
6with no_init_weights():
7 transformer = Flux2Transformer2DModel.from_config(
8 Flux2Transformer2DModel.load_config(
9 "black-forest-labs/FLUX.2-klein-base-9B", subfolder="transformer"
10 ),
11 torch_dtype=torch.bfloat16
12 ).to(torch.bfloat16)
13DFloat11Model.from_pretrained("mingyi456/FLUX.2-klein-base-9B-DF11", device="cpu", bfloat16_model=transformer)
14pipe = Flux2KleinPipeline.from_pretrained("black-forest-labs/FLUX.2-klein-base-9B", text_encoder=text_encoder, transformer=transformer, torch_dtype=torch.bfloat16)
15pipe.to("cuda")
16prompt = "A cat holding a sign that says hello world"
17image = pipe(
18 prompt=prompt,
19 height=1024,
20 width=1024,
21 guidance_scale=4.0,
22 num_inference_steps=50,
23 generator=torch.Generator(device="cpu").manual_seed(0)
24).images[0]
25image.save("flux-klein.png")pattern_dict for compression:1pattern_dict = {
2 r"double_stream_modulation_img.linear": [],
3 r"double_stream_modulation_txt.linear": [],
4 r"single_stream_modulation.linear": [],
5 r"context_embedder": [],
6 r"transformer_blocks\.\d+" : (
7 "attn.to_q",
8 "attn.to_k",
9 "attn.to_v",
10 "attn.to_out.0",
11 "attn.add_q_proj",
12 "attn.add_k_proj",
13 "attn.add_v_proj",
14 "attn.to_add_out",
15 "ff.linear_in",
16 "ff.linear_out",
17 "ff_context.linear_in",
18 "ff_context.linear_out",
19 ),
20 r"single_transformer_blocks\.\d+" : (
21 "attn.to_qkv_mlp_proj",
22 "attn.to_out",
23 ),
24 r"norm_out.linear": [],
25}