21
stars
3
commits
1
linked in READMEs
Aug 28, 2025
updated
black-forest-labs/FLUX.1-devThis is a losslessly compressed version of black-forest-labs/FLUX.1-dev using our custom DFloat11 format. The outputs of this compressed model are bit-for-bit identical to the original BFloat16 model, while reducing GPU memory consumption by approximately 30%.
DFloat11 compresses model weights using Huffman coding of BFloat16 exponent bits, combined with hardware-aware algorithmic designs that enable efficient on-the-fly decompression directly on the GPU. During inference, the weights remain compressed in GPU memory and are decompressed just before matrix multiplications, then immediately discarded after use to minimize memory footprint.
Key benefits:
Install or upgrade the DFloat11 package (installs the CUDA kernel automatically; requires a CUDA-compatible GPU and PyTorch installed):
pip install dfloat11[cuda12]
# or if you have CUDA version 11:
# pip install dfloat11[cuda11]
Install or upgrade the diffusers package:
pip install -U diffusers
Save the following code as a Python file flux1.py:
import torch
from diffusers import FluxPipeline, FluxTransformer2DModel
from dfloat11 import DFloat11Model
from transformers.modeling_utils import no_init_weights
with no_init_weights():
transformer = FluxTransformer2DModel.from_config(
FluxTransformer2DModel.load_config(
"black-forest-labs/FLUX.1-dev", subfolder="transformer"
)
).to(torch.bfloat16)
pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
transformer=transformer,
torch_dtype=torch.bfloat16
)
DFloat11Model.from_pretrained(
'DFloat11/FLUX.1-dev-DF11',
device='cpu',
bfloat16_model=pipe.transformer,
)
pipe.enable_model_cpu_offload()
prompt = "A scenic landscape with mountains, a river, and a clear sky."
image = pipe(
prompt,
width=1024,
height=1024,
guidance_scale=3.5,
num_inference_steps=50,
max_sequence_length=512,
generator=torch.Generator(device="cuda").manual_seed(0)
).images[0]
image.save("image.png")
Run python flux1.py in your terminal.
3 commits
21
stars
3
commits
1
linked in READMEs
Aug 28, 2025
updated
black-forest-labs/FLUX.1-devThis is a losslessly compressed version of black-forest-labs/FLUX.1-dev using our custom DFloat11 format. The outputs of this compressed model are bit-for-bit identical to the original BFloat16 model, while reducing GPU memory consumption by approximately 30%.
DFloat11 compresses model weights using Huffman coding of BFloat16 exponent bits, combined with hardware-aware algorithmic designs that enable efficient on-the-fly decompression directly on the GPU. During inference, the weights remain compressed in GPU memory and are decompressed just before matrix multiplications, then immediately discarded after use to minimize memory footprint.
Key benefits:
Install or upgrade the DFloat11 package (installs the CUDA kernel automatically; requires a CUDA-compatible GPU and PyTorch installed):
pip install dfloat11[cuda12]
# or if you have CUDA version 11:
# pip install dfloat11[cuda11]
Install or upgrade the diffusers package:
pip install -U diffusers
Save the following code as a Python file flux1.py:
import torch
from diffusers import FluxPipeline, FluxTransformer2DModel
from dfloat11 import DFloat11Model
from transformers.modeling_utils import no_init_weights
with no_init_weights():
transformer = FluxTransformer2DModel.from_config(
FluxTransformer2DModel.load_config(
"black-forest-labs/FLUX.1-dev", subfolder="transformer"
)
).to(torch.bfloat16)
pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
transformer=transformer,
torch_dtype=torch.bfloat16
)
DFloat11Model.from_pretrained(
'DFloat11/FLUX.1-dev-DF11',
device='cpu',
bfloat16_model=pipe.transformer,
)
pipe.enable_model_cpu_offload()
prompt = "A scenic landscape with mountains, a river, and a clear sky."
image = pipe(
prompt,
width=1024,
height=1024,
guidance_scale=3.5,
num_inference_steps=50,
max_sequence_length=512,
generator=torch.Generator(device="cuda").manual_seed(0)
).images[0]
image.save("image.png")
Run python flux1.py in your terminal.
3 commits