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

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("TDSXn9hai/ecflux", dtype=torch.bfloat16, device_map="cuda")

prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]

EC-FLUX

Structured-pruned and distilled FLUX.2 Klein 4B Base DiT checkpoints from the EC-FLUX GitHub repository.

Recommended checkpoint

Directory DiT parameters Description HPSv2.1 drop (D_val 200, new split)
stage5_main_long 2.891B Final model. stage5_main_pruned distilled from FLUX.2 Klein 9B Base for 20000 steps ร— batch 64 0.0240
stage5_main_pruned 2.891B Remove Single Blocks 6, 8, 10, 13 first, then dynamic APRA (heads / FFN neurons); not distilled 0.0421

stage5_main_long contains model.safetensors, prune_spec.json, projectors.pt (hidden-state projectors, only needed to continue distillation), metrics.json (per-checkpoint HPSv2 / trajectory velocity MSE) and run_config.json. stage5_main_pruned contains model.safetensors, prune_spec.json, history.json (APRA rounds and gates) and run_config.json.

HPS drop is relative to the unpruned 4B (HPSv2.1 = 0.2878) on the first 200 prompts of the re-built D_val (data/val_prompts.txt in the GitHub repo), 512px, 20 steps, CFG 4.0, seed 42. These numbers are not comparable with the Stage 2 v2 numbers below, which used an earlier D_val split.

Stage 2 v2 checkpoints (earlier pipeline)

Directory DiT parameters Parameter ratio Removed Single Blocks
full 2.891B 0.746 6, 8, 10, 13
fixed_ratio 3.227B 0.833 6, 8, 10, 13
no_block 3.340B 0.862 none

Each directory contains model.safetensors, prune_spec.json, history.json, run_config.json, eval_summary.json and eff_summary.json.

Usage

Use the original FLUX.2 Klein 4B pipeline for the text encoder, tokenizer, VAE, and scheduler, replacing its transformer with one of these DiT checkpoints, loaded via ecflux.flux_utils.load_transformer:

python scripts/generate.py --pipeline weights/FLUX.2-klein-base-4B \
  --transformer stage5_main_long --prompts prompts.txt --out outputs/gen

Sharded large files

The two model.safetensors checkpoints and stage5_main_long/projectors.pt are stored as ordered Base64 text shards, not as directly loadable files. This keeps each uploaded blob below the Hub's regular-file threshold without requiring S3 accelerated uploads. Merge and verify them after downloading the repository:

hf download TDSXn9hai/ecflux --local-dir ecflux-hf
python ecflux-hf/_shards/merge_shards.py \
  --manifest ecflux-hf/stage5_main_long/model.safetensors.shards/manifest.json \
  --output merged/stage5_main_long/model.safetensors
python ecflux-hf/_shards/merge_shards.py \
  --manifest ecflux-hf/stage5_main_pruned/model.safetensors.shards/manifest.json \
  --output merged/stage5_main_pruned/model.safetensors
python ecflux-hf/_shards/merge_shards.py \
  --manifest ecflux-hf/stage5_main_long/projectors.pt.shards/manifest.json \
  --output merged/stage5_main_long/projectors.pt

Each manifest records the original size, full SHA256, chunk size, and the raw and encoded hashes of every shard. merge_shards.py validates all three levels before atomically publishing the merged output. See _shards/README.md for details.

The checkpoints inherit the FLUX.2 Klein non-commercial license and acceptable use policy. See the upstream model: https://huggingface.co/black-forest-labs/FLUX.2-klein-base-4B.

Source results

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support