ugonfor/1.58bit-flux-reproduction
1
1.58-Bit FLUX Reproduction: Ternary Quantization + LoRA
Reproduction of 1.58-bit FLUX (Yang et al., 2024). Ternary ({-1, 0, +1}) quantization of FLUX.1-dev transformer with LoRA compensation, trained via offline flow-matching distillation.
Results
- 30.8% inference VRAM reduction (33.83 → 23.41 GB peak)
- Evaluated on 20 out-of-distribution diverse prompts
- All experiments on single NVIDIA A100-SXM4-80GB
Checkpoints
Model Weights (Ternary + LoRA)
Training Datasets
Usage
from diffusers import FluxPipeline
from models.ternary import quantize_to_ternary
import torch
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev",
torch_dtype=torch.bfloat16).to("cuda")
# Quantize to ternary + LoRA
quantize_to_ternary(pipe.transformer, lora_rank=128, svd_init=False)
# Load checkpoint
ckpt = torch.load("ternary_distilled_r128_res1024_s12000_fm_lpips1e-01.pt",
map_location="cuda", weights_only=True)
state = {k: v for k, v in pipe.transformer.named_parameters()}
for name, tensor in ckpt.items():
if name in state:
state[name].data.copy_(tensor.to(torch.bfloat16))
# Generate
image = pipe("A majestic lion resting on a savanna at golden hour",
height=1024, width=1024, num_inference_steps=30,
guidance_scale=3.5).images[0]Key Findings
- Offline FM distillation with pre-generated teacher latents is strictly superior to online methods
- Data scaling follows log₂ law up to LoRA capacity ceiling:
OOD CLIP % = 0.0115 × log₂(prompts) + 0.7744 - Scaling law breaks at ~4,000 prompts for rank-64 (capacity saturation)
- Rank-128 LoRA breaks the ceiling (90.0% → 90.4%) but needs 2× training steps from cold start
Citation
@misc{ugonfor2026ternaryflux,
title={Reproducing 1.58-Bit FLUX: Ternary Quantization with LoRA Compensation},
author={Ugon For},
year={2026},
url={https://github.com/ugonfor/1.58bit-flux}
}Acknowledgments
Based on 1.58-bit FLUX by Yang et al. Base model: FLUX.1-dev by Black Forest Labs.
