How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("AcademiaSD/FLUX.2-Klein-9B-NF4-for-LoRA-Training", dtype=torch.bfloat16, device_map="cuda")

prompt = "Turn this cat into a dog"
input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")

image = pipe(image=input_image, prompt=prompt).images[0]

FLUX.2 [klein] 9B NF4 for LoRA Training

FLUX.2 [klein] Base 9B (the undistilled base model by Black Forest Labs) quantized to 4-bit NF4 for the FLUX.2 Klein 9B trainer of AcademiaSD LoRAlab Trainer Studio: image and edit LoRA training on consumer NVIDIA GPUs.

You do not need to download this repository by hand: the trainer downloads it on first use.

This FLUX Model is licensed by Black Forest Labs Inc. under the FLUX Non-Commercial License. Copyright Black Forest Labs Inc. IN NO EVENT SHALL BLACK FOREST LABS INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH USE OF THIS MODEL.

This is a modified version of FLUX.2 [klein] Base 9B made by AcademiaSD: the weights were quantized to NF4 and the text encoder was truncated as described below. It is not an official product of Black Forest Labs and has not been endorsed, approved or validated by Black Forest Labs.

Contents

Folder Content Size
transformer/ 9B transformer: the layers of the 8 double and 24 single blocks in NF4 (bitsandbytes, pre-quantized); embedders, shared modulations, timestep and output layers in BF16 4.9 GB
text_encoder/ Qwen3-8B text encoder in NF4 (Qwen3Model, first 28 of 36 layers, without lm_head) 3.8 GB
vae/, tokenizer/, scheduler/ Unchanged from the original model 0.2 GB
Total 8.8 GB (original: 34.7 GB)

Format

  • text_encoder/ loads with transformers: Qwen3Model.from_pretrained(".../text_encoder"). Klein reads the hidden states of layers 9, 18 and 27, so only the first 28 layers are kept. Their outputs are identical to the full model (the final norm of the last layer is not used).
  • transformer/ is not a standard diffusers checkpoint. It is a pre-quantized cache: one .safetensors file per layer in weights/ (NF4 weight plus its packed bitsandbytes QuantState, or BF16 for the excluded layers), others.safetensors with the norms, and index.json. The trainer builds an empty Flux2Transformer2DModel from config.json and fills it from this cache, so the BF16 transformer is never downloaded or loaded. metadata.json lists the quantized blocks.
  • The converter that produced it is tools/klein/5_conversor_Klein9B_NF4.py in the Trainer Studio repository.

NF4 is meant for training. Images generated with this NF4 model are visually equivalent to BF16 (same subject, composition and legible text). For inference, use the original model in ComfyUI.

LoRAs trained with it

The trainer exports LoRAs in diffusers format (transformer.<layer>.lora_A / lora_B plus alpha), which ComfyUI loads directly. LoRAs trained on Base 9B also load on the distilled FLUX.2 [klein] 9B. They are not compatible with the 4B models.

Measured on an RTX 5080 at 768×768, rank 16: ~10 GB of VRAM and ~2.6 s per step.

License

FLUX Non-Commercial License, the same as the original black-forest-labs/FLUX.2-klein-base-9B. Non-commercial use only; the license and the Acceptable Use Policy also apply to the LoRAs you train with it. All credit for the model goes to Black Forest Labs; this repository only changes the storage precision.

Links

Downloads last month
83
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for AcademiaSD/FLUX.2-Klein-9B-NF4-for-LoRA-Training

Quantized
(17)
this model