--- language: - en license: other license_name: flux-kommunity-license-v1-0 license_link: https://huggingface.co/black-forest-labs/flux-3-image-klein/blob/main/LICENSE.md base_model: black-forest-labs/flux-3-image-klein-comfy base_model_relation: quantized tags: - comfyui - flux3 - flux-3 - klein - quantization - mxfp8 - blackwell - text-to-image - image-to-image --- > **📌 Note — Downloading the Model** > > Please clone the complete repository rather than downloading individual files. This ensures you receive the model checkpoint, configuration, license, and required files together. > > ```bash > git clone https://huggingface.co/FP8Enjoyer/FLUX.3-Klein-Step-Distilled-MXFP8 > ``` > > **Prerequisites:** Git, Git LFS, and Git Xet for downloading large model files. # FLUX.3 Image Klein SD — MXFP8 (ComfyUI) **Unofficial community quantization** of the **distilled 16-step** FLUX 3 Image Klein *image transformer* by [Black Forest Labs](https://huggingface.co/black-forest-labs/flux-3-image-klein-comfy). Not affiliated with or endorsed by Black Forest Labs or Comfy-Org. This release contains **only the diffusion transformer**. Obtain the corresponding Qwen3-VL text encoder and FLUX VAE separately from the [official ComfyUI repository](https://huggingface.co/black-forest-labs/flux-3-image-klein-comfy). ## What changed - Original: `flux3_image_klein_sd_bf16.safetensors` (~11.1 GB). - Output: `flux3_image_klein_sd_MXFP8.safetensors` (**5.7222 GB**). - **273** two-dimensional weight matrices converted to **MXFP8 E4M3** with **E8M0 scales per 32 elements** and blocked ComfyUI scale storage. - **86** normalization scale tensors preserved as BF16. - **5,548,670,976 of 5,548,681,984 parameters** quantized (**99.999802%**). - File holds **905 tensors**: 273 FP8 weights + 273 scale tensors + 273 ComfyUI markers + 86 BF16 norms. - The original tensor names are retained; no architecture changes or training were performed. The checkpoint passed a structural audit (tensor names, shapes, types, quantization markers, scale layouts) and **successfully generated nine evaluation images** with ComfyUI on an **RTX 5070 Ti Laptop GPU (Blackwell SM120)** and **ComfyKitchen 0.2.37**, after applying the compatibility patch below. Local performance measurements and matched BF16/MXFP8 image comparisons are documented below; quantitative perceptual-quality validation remains to be done. ## Local performance benchmark Measured on an **NVIDIA GeForce RTX 5070 Ti Laptop GPU (12,199 MB reported VRAM)** with **32,125 MB system RAM**, Windows, **ComfyUI 0.41.0**, **PyTorch 2.10.0+cu130**, and **ComfyKitchen 0.2.37**. All sessions used **LOW_VRAM mode**, DynamicVRAM, async weight offloading with two streams, and PyTorch attention. Each configuration completed the same nine-prompt sequence in a separate ComfyUI session. The first execution is reported separately; warm results cover the remaining **eight executions**. Warm executions use different prompts, rather than eight repeats of one prompt. ### Matched generation settings The original PNGs retain their ComfyUI `prompt` and `workflow` metadata. For all **nine BF16/MXFP8 pairs**, comparison of the embedded execution graphs found **only one changed input: the diffusion model filename**. Both used `weight_dtype = default`. | Setting | Value in both BF16 and MXFP8 outputs | |---|---| | Output size | 1440 x 1440, 1:1 | | Resolution selector | 2.0 MP target, multiple of 8 | | Seed | 1 | | Steps | 16 | | CFG | 1.0 | | Sampler / scheduler | `euler` / `simple` | | Denoise | 1.0 | | Batch size | 1 | | Negative prompt | Empty | | Text encoder | `qwen3vl_4b_fp8_scaled.safetensors`, loader type `flux3`, device `default` | | VAE | `flux2-vae.safetensors` | | Positive prompts | Identical within each pair; nine different subjects | The forced-FP8 baseline loaded the original BF16 checkpoint with `weight_dtype = fp8_e4m3fn`. Its timings and weight dtype are recorded in the console log; those earlier output PNGs were deleted and are not included in the visual evaluation or PNG metadata audit. ### Timing and reported weight footprint | Metric | Original checkpoint, forced FP8 | Original checkpoint, BF16 | MXFP8 checkpoint | |---|---:|---:|---:| | First execution, including loading | 46.77 s | 52.99 s | 25.76 s | | Warm execution, mean (n=8) | 38.74 s | 38.89 s | 23.70 s | | Warm execution, range | 36.16-41.67 s | 38.15-40.14 s | 22.38-26.43 s | | Warm throughput, derived from mean execution time | 1.55 images/min | 1.54 images/min | 2.53 images/min | | Warm sampling, mean logged seconds/step | 2.133 s/step | 2.155 s/step | 1.275 s/step | | Diffusion weights reported as staged | 5,291 MB | 10,583 MB | 5,456 MB | On this setup, MXFP8 achieved **1.64x the warm throughput** of BF16 (**39.0% shorter mean execution time**). The first execution was **51.4% shorter**, and the reported staged diffusion-weight footprint was **48.4% smaller**. **Measurement boundaries:** First-execution time includes model loading, text encoding, sampling, VAE decoding, and saving; standalone model-load time was not measured. ComfyUI application startup is excluded. Throughput is derived from ComfyUI execution times and excludes queue waiting and user interaction. The staged-weight figure is a loader-reported footprint, **not peak VRAM or system RAM use**; peak runtime memory was not recorded. These are single-session observations on one laptop, without repeated sessions, controlled clocks/temperature, or statistical significance testing. Startup background tasks were still completing during some executions, so the results should be treated as a local comparison rather than a general hardware speed claim. The [per-execution timings](benchmarks/timings.csv) and [paired PNG metadata audit, full prompts, and original-file SHA-256 hashes](benchmarks/image_metadata.json) are included for inspection. ## Visual evaluation: BF16 vs MXFP8 All **nine matched pairs** are shown below: **BF16 on the left, MXFP8 on the right**. At normal viewing size, and in selected original-resolution detail crops, the outputs appear similar in overall color, contrast, and resolved detail. No consistent washed-out appearance or broad detail loss was apparent in this small set. The largest content change is in the fruit arrangement; wheel details, faces, hair, signs, and other small features also vary. This is a qualitative visual inspection, not a blinded study or a quantitative perceptual benchmark. The outputs are not pixel-identical, and these nine prompts at one seed do not establish quality parity across other prompts, seeds, resolutions, or hardware. ### Portrait, dog, and Tokyo street ![BF16 left and MXFP8 right: sunflower portrait, golden retriever, and Tokyo street](assets/comparisons/comparison_1.jpg) ### Cafe, mountains, and fruit ![BF16 left and MXFP8 right: cafe interior, mountain landscape, and tropical fruit](assets/comparisons/comparison_2.jpg) ### Car, butterfly, and anime ![BF16 left and MXFP8 right: sports car, butterfly, and anime portrait](assets/comparisons/comparison_3.jpg) The comparison sheets use equally resized previews with JPEG compression and no color or contrast adjustments. Use the original PNG links below to inspect full-resolution output and embedded metadata. The [detail-crop sheet](assets/comparisons/comparison_detail.png) is a lossless PNG containing selected original pixels without resizing. ### Pair observations and original PNGs | Subject | BF16 original | MXFP8 original | Visual observation | |---|---|---|---| | Sunflower portrait | [PNG 00001](assets/bf16/ComfyUI_00001_.png) | [PNG 00010](assets/mxfp8/ComfyUI_00010_.png) | Small facial and hair changes; skin texture and warm lighting remain visible. | | Golden retriever | [PNG 00002](assets/bf16/ComfyUI_00002_.png) | [PNG 00011](assets/mxfp8/ComfyUI_00011_.png) | Very similar pose, fur detail, grass, and color. | | Tokyo street | [PNG 00003](assets/bf16/ComfyUI_00003_.png) | [PNG 00012](assets/mxfp8/ComfyUI_00012_.png) | Signs and reflections vary; neon intensity and dark shadows remain comparable. | | Cafe interior | [PNG 00004](assets/bf16/ComfyUI_00004_.png) | [PNG 00013](assets/mxfp8/ComfyUI_00013_.png) | Small differences in cup geometry and foam pattern; similar lighting and surfaces. | | Mountain landscape | [PNG 00005](assets/bf16/ComfyUI_00005_.png) | [PNG 00014](assets/mxfp8/ComfyUI_00014_.png) | Similar mountain composition, snow detail, trees, and lighting. | | Tropical fruit | [PNG 00006](assets/bf16/ComfyUI_00006_.png) | [PNG 00015](assets/mxfp8/ComfyUI_00015_.png) | Largest composition change: fruit positions and papaya shapes differ; both retain detailed surfaces. | | Sports car | [PNG 00007](assets/bf16/ComfyUI_00007_.png) | [PNG 00016](assets/mxfp8/ComfyUI_00016_.png) | Wheel design and body details vary; reflections and sunset remain comparable. | | Butterfly | [PNG 00008](assets/bf16/ComfyUI_00008_.png) | [PNG 00017](assets/mxfp8/ComfyUI_00017_.png) | Wing markings differ; fine wing texture remains resolved in both. | | Anime portrait | [PNG 00009](assets/bf16/ComfyUI_00009_.png) | [PNG 00018](assets/mxfp8/ComfyUI_00018_.png) | Small changes to face, hair, and ornament details; crisp linework and shading remain visible. | ## Installation (Windows / ComfyUI) 1. Place `flux3_image_klein_sd_MXFP8.safetensors` in `ComfyUI/models/diffusion_models/` (or a configured extra model path). 2. Ensure your **ComfyUI Python environment** has working Blackwell MXFP8 support in ComfyKitchen. Version **0.2.37** was used in the successful local run; this is not a guarantee for every setup. 3. Apply the compatibility patch (see below) **with ComfyUI closed**. 4. Start ComfyUI and choose `flux3_image_klein_sd_MXFP8.safetensors` in the **Load Diffusion Model** / `UNETLoader` node. Leave **weight_dtype = default**. 5. Use the official FLUX 3 Klein distilled workflow and matching text encoder + VAE. The distilled model normally uses **16 steps**, with no separate CFG guidance requirement. ### One-command patcher `patch_comfyui_mxfp8.py` uses **only Python's standard library**. Run: ```powershell py -3.13 patch_comfyui_mxfp8.py ``` When prompted, enter the **ComfyUI installation root**, e.g. `C:\path\to\ComfyUI` (not `models` or `venv_adv`). The script locates `comfy/quant_ops.py`, makes a one-time **`quant_ops.py.mxfp8_backup`**, verifies syntax, and updates only this MXFP8 activation-quantization call: ```python # before ck.quantize_mxfp8(tensor, pad_32x=needs_padding) # after ck.quantize_mxfp8(tensor.contiguous(), pad_32x=needs_padding) ``` Why? The stock FLUX 3 forward path can supply a **non-contiguous** activation after a transpose. ComfyKitchen's MXFP8 CUDA kernel requires contiguous input. This patch is **runtime-only**; it does **not** change the checkpoint or produce new weights. It may become unnecessary after an upstream update. Additional commands: ```powershell py -3.13 patch_comfyui_mxfp8.py --check py -3.13 patch_comfyui_mxfp8.py --restore ``` The script is idempotent, refuses unknown ComfyUI source layouts, and does not overwrite a different backup. To use it without a prompt, pass `--comfyui "C:\path\to\ComfyUI"`. Restart ComfyUI after patching or restoring. **If the patch reports an unsupported source layout, do not force it.** ## Compatibility, limitations, and reproducibility - This is a **ComfyUI-native MXFP8 Safetensors** export, **not** a GGUF or Diffusers checkpoint. `config.json` records release metadata; the ComfyUI loader uses the Safetensors embedded metadata. - The official [Comfy Quants project](https://github.com/Comfy-Org/comfy-quants) provided the MXFP8 conversion function; weights were converted from the official BF16 distilled checkpoint. - MXFP8 activation quantization and GPU execution depend on ComfyUI, ComfyKitchen, PyTorch, GPU architecture, and driver compatibility. - The patch is tailored to the documented `comfy/quant_ops.py` implementation and could need adjustment on later ComfyUI versions. - Performance measurements and nine matched visual comparisons are reported for one configuration. Peak runtime memory, repeated-session performance, and quantitative perceptual-quality validation against BF16 remain unmeasured. ## Licensing and attribution **Original model:** © Black Forest Labs, FLUX 3 Image Klein, licensed under the **FLUX Kommunity License v1.0**. The checkpoint is a **quantized derivative**, and the license's restrictions and distribution conditions continue to apply. Read the [full original license](https://huggingface.co/black-forest-labs/flux-3-image-klein-comfy/blob/main/LICENSE.md) and [official NOTICE](https://huggingface.co/black-forest-labs/flux-3-image-klein-comfy/blob/main/NOTICE.md). **Modification notice:** Original 16-step distilled BF16 diffusion-transformer weights were converted offline to MXFP8 E4M3 with E8M0 block-32 scaling, maintaining 86 normalization tensors in BF16. This is not an official BFL checkpoint. ComfyKitchen is separately licensed under Apache-2.0. This patch script does not bundle ComfyKitchen source or code from Comfy Quants.