Instructions to use mlx-community/FLUX.2-klein-4B-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/FLUX.2-klein-4B-bf16 with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir FLUX.2-klein-4B-bf16 mlx-community/FLUX.2-klein-4B-bf16
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: mlx
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
license_link: https://huggingface.co/black-forest-labs/FLUX.2-klein-4B/blob/main/LICENSE.md
|
| 5 |
+
pipeline_tag: text-to-image
|
| 6 |
+
base_model: black-forest-labs/FLUX.2-klein-4B
|
| 7 |
+
tags: [mlx, safetensors, apple-silicon, text-to-image, diffusion, mmdit, flux2, klein]
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# mlx-community/FLUX.2-klein-4B-bf16
|
| 11 |
+
|
| 12 |
+
MLX (bf16) snapshot of **[black-forest-labs/FLUX.2-klein-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B)**
|
| 13 |
+
(Apache-2.0) for Apple Silicon — a compact rectified-flow **MMDiT** (5 double + 20 single blocks)
|
| 14 |
+
+ Qwen3-4B 3-layer-tap conditioner + FLUX.2 VAE. Standard diffusers tree
|
| 15 |
+
(`transformer/ text_encoder/ vae/ tokenizer/`), loaded by the Swift/MLX port; int8/int4 are
|
| 16 |
+
produced at load time (int4 DiT ~2.35 GB → a q4 pipeline fits a 16 GB Mac).
|
| 17 |
+
|
| 18 |
+
**4B only** — the 9B klein variants are FLUX Non-Commercial; this Apache-2.0 4B is the wrapped tier.
|
| 19 |
+
|
| 20 |
+
## Parity (Swift port vs diffusers goldens, fp32/CPU)
|
| 21 |
+
- MMDiT: cosine **≥0.9999995** at the 64×64 production grid (all blocks + norm_out + whole-forward)
|
| 22 |
+
- FLUX.2 VAE decode **105–130 dB** · Qwen3 3-layer-tap encoder cosine **0.9999999**
|
| 23 |
+
- GPU int4 1024²/4-step ~6 s.
|
| 24 |
+
|
| 25 |
+
## Use (Swift / MLXEngine)
|
| 26 |
+
```swift
|
| 27 |
+
import MLXKlein
|
| 28 |
+
import MLXToolKit
|
| 29 |
+
let pkg = Klein4BT2IPackage(configuration: .init(quant: .int4, snapshotPath: "<this repo dir>"))
|
| 30 |
+
try await pkg.load()
|
| 31 |
+
let r = try await pkg.run(T2IRequest(prompt: "a red fox in a snowy forest at sunrise, photorealistic",
|
| 32 |
+
width: 1024, height: 1024, seed: 42)) as! T2IResponse
|
| 33 |
+
```
|
| 34 |
+
Code: https://github.com/xocialize/flux2-klein-swift
|