
FLUX.2 [klein] 9B-KV is an optimized variant of FLUX.2 [klein] 9B with KV-cache support for accelerated multi-reference editing. This variant caches key-value pairs from reference images during the first denoising step, eliminating redundant computation in subsequent steps for significantly faster multi-image editing workflows.
For more information about FLUX.2 [klein], please read our blog post.
In standard image editing, reference image tokens are processed at every denoising step. With KV-caching:
This is particularly beneficial when:
We provide a reference implementation in our GitHub repository.
FLUX.2 [klein] 9B-KV is available via the BFL API at bfl.ai.
To use FLUX.2 [klein] 9B-KV with the 🧨 Diffusers python library, first install or upgrade diffusers:
pip install git+https://github.com/huggingface/diffusers.git
Then you can use Flux2KleinKVPipeline to run the model:
import torch
from diffusers import Flux2KleinKVPipeline
device = "cuda"
dtype = torch.bfloat16
model_path = "black-forest-labs/FLUX.2-klein-9b-kv"
pipe = Flux2KleinKVPipeline.from_pretrained(model_path, torch_dtype=dtype)
pipe.to(device)
# Text-to-image (no reference image)
print("Generating text-to-image...")
image = pipe(
prompt="A cat holding a sign that says hello world",
height=1024,
width=1024,
num_inference_steps=4,
generator=torch.Generator(device=device).manual_seed(0),
).images[0]
image.save("t2i_output.png")
print("Saved t2i_output.png")
# Image-to-image with KV cache (using the generated image as reference)
print("Generating image-to-image with KV cache...")
image_kv = pipe(
prompt="A cat dressed like a wizard",
image=image,
height=1024,
width=1024,
num_inference_steps=4,
generator=torch.Generator(device=device).manual_seed(0),
).images[0]
image_kv.save("kv_output.png")
print("Saved kv_output.png")
This model and its derivatives may not be used outside the scope of the license, including for unlawful, fraudulent, defamatory, abusive, or otherwise violative purposes as further explained in our Usage Policies.
The FLUX.2 [klein] 9B-KV model fits in ~29GB VRAM and is accessible on NVIDIA RTX 5090 and above.
Black Forest Labs is committed to responsible model development and deployment. Prior to releasing FLUX.2 [klein] 9B-KV, we evaluated and mitigated a number of risks, including child sexual abuse material (CSAM) and nonconsensual intimate imagery (NCII). For detailed information about our mitigations, evaluation processes, content provenance features, and policies, please see our post: Capable, Open, and Safe: Combating AI Misuse.
To report safety concerns, contact safety@blackforestlabs.ai.
This model falls under the FLUX Non-Commercial License.
This project may contain trademarks or logos for projects, products, or services. Use of Black Forest Labs and FLUX trademarks or logos in modified versions of this project must not cause confusion or imply sponsorship or endorsement. Any use of third-party trademarks, intellectual property or logos are subject to those third-party's policies.