DFloat11 [NeurIPS '25]: Lossless Compression of LLMs and DiTs for Efficient GPU Inference
654
stars
12
commits
Python
primary language
Nov 24, 2025
updated
DFloat11 is a lossless compression framework that reduces the size of Large Language Models (LLMs) and diffusion models (e.g. FLUX.1, Qwen-Image, etc.) by approximately 30% while preserving bit-for-bit identical outputs to the original model. It enables efficient GPU inference on resource-constrained hardware without sacrificing any accuracy.
cpu_offload=True when calling DFloat11Model.from_pretrained(...).DFloat11/Wan2.1-T2V-14B-Diffusers-DF11
FLUX.1-dev
dfloat11 pip package has been upgraded to v0.2.0! Run pip install -U dfloat11[cuda12] to upgrade to the latest version. We have made the following important changes:
Requires a CUDA-compatible GPU (with CUDA 12) and PyTorch installed.
To install from PyPI:
pip install -U dfloat11[cuda12]
[Optional] To compile the GPU kernel and install locally:
nvcc -O3 -ptx dfloat11/decode.cu -o dfloat11/decode.ptx
pip install .[cuda12]
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:
dfloat11 pip package. See Installation.Qwen3-8B model and generates a response.import torch
from dfloat11 import DFloat11Model
from transformers import AutoTokenizer
model_id = "DFloat11/Qwen3-8B-DF11"
model = DFloat11Model.from_pretrained(model_id, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.eos_token
prompt = "Question: What is a binary tree and its applications? Answer:"
inputs = tokenizer(prompt, return_tensors="pt", padding=True).to(model.device)
with torch.no_grad():
output = model.generate(
**inputs,
max_new_tokens=256,
do_sample=True,
)
print(tokenizer.batch_decode(output, skip_special_tokens=True))
model_id in the script above with any pre-compressed model in the Model Hub.To test the speed and memory consumption a DFloat11 LLM during inference:
CUDA_VISIBLE_DEVICES=0 python inference.py \
--model_name_or_path DFloat11/Qwen3-8B-DF11 \
--prompt "Question: What is a binary tree and its applications? Answer:" \
--num_tokens 512 \
--batch_size 1
💡 Tip: If you specify multiple CUDA devices (e.g.,
CUDA_VISIBLE_DEVICES=0,1), the model will be automatically distributed across them using 🤗 Accelerate'sdevice_map="auto".
--model_name_or_path: HuggingFace name or local path of the DFloat11 model (e.g., DFloat11/Qwen3-8B-DF11). See the Model Hub section for a list of available DFloat11 models.--bf16: (Optional) Turn on this flag when passing a BFloat16 model to --model_name_or_path--prompt: Input prompt string for text generation--num_tokens: Number of new tokens to generate per sample--batch_size: Number of prompts to process in parallel--seed: (Optional) Random seed for reproducible resultsThe script prints:
| Model | DFloat11 Link |
|---|---|
| Wan2.1 T2V 14B (see examples/wan2.1) | DFloat11/Wan2.1-T2V-14B-Diffusers-DF11 |
| FLUX.1 dev (see examples/flux.1) | DFloat11/FLUX.1-dev-DF11 |
| Qwen 3 32B | DFloat11/Qwen3-32B-DF11 |
| Qwen 3 14B | DFloat11/Qwen3-14B-DF11 |
| Qwen 3 8B | DFloat11/Qwen3-8B-DF11 |
| Qwen 3 4B | DFloat11/Qwen3-4B-DF11 |
| Phi 4 Reasoning Plus | DFloat11/Phi-4-reasoning-plus-DF11 |
| Gemma 3 27B Instruct | DFloat11/gemma-3-27b-it-DF11 |
| Gemma 3 12B Instruct | DFloat11/gemma-3-12b-it-DF11 |
| Gemma 3 4B Instruct | DFloat11/gemma-3-4b-it-DF11 |
| Llama 3.1 8B Instruct | DFloat11/Llama-3.1-8B-Instruct-DF11 |
| DeepSeek R1 Distill Qwen 32B | DFloat11/DeepSeek-R1-Distill-Qwen-32B-DF11 |
| DeepSeek R1 Distill Qwen 14B | DFloat11/DeepSeek-R1-Distill-Qwen-14B-DF11 |
| DeepSeek R1 Distill Qwen 7B | DFloat11/DeepSeek-R1-Distill-Qwen-7B-DF11 |
| DeepSeek R1 Distill Llama 8B | DFloat11/DeepSeek-R1-Distill-Llama-8B-DF11 |
| ... | Discover more models on our HF page! |
huggingface-cli download \
DFloat11/Llama-3.1-8B-Instruct-DF11 \ # DFloat11 model name
--local-dir ./Llama-3.1-8B-Instruct-DF11 # local path to download the DFloat11 model
from dfloat11 import DFloat11Model
from transformers import AutoTokenizer
model_path = "./Llama-3.1-8B-Instruct-DF11"
model = DFloat11Model.from_pretrained(model_path, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_path)
The DFloat11 compression utility is exposed via the compress_model function.
Check examples/compress_flux1 for a detailed example on compressing the FLUX.1 model.
👉 Explore pre-compressed DFloat11 models ready to use on HuggingFace: https://huggingface.co/DFloat11
📂 Official Code Repository: https://github.com/LeanModels/DFloat11
This work is brought to you by the team at Rice University and xMAD.ai.
The GPU kernel was designed and implemented by Tianyi Zhang.
If you found our work useful or interesting, please consider citing our paper:
@inproceedings{
zhang2025,
title={70\% Size, 100\% Accuracy: Lossless {LLM} Compression for Efficient {GPU} Inference via Dynamic-Length Float ({DF}loat11)},
author={Tianyi Zhang and Mohsen Hariri and Shaochen Zhong and Vipin Chaudhary and Yang Sui and Xia Hu and Anshumali Shrivastava},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
url={https://openreview.net/forum?id=xdNAVP7TGy}
}
12 commits
Python
80.4%
Cuda
19.6%
DFloat11 [NeurIPS '25]: Lossless Compression of LLMs and DiTs for Efficient GPU Inference
654
stars
12
commits
Python
primary language
Nov 24, 2025
updated
DFloat11 is a lossless compression framework that reduces the size of Large Language Models (LLMs) and diffusion models (e.g. FLUX.1, Qwen-Image, etc.) by approximately 30% while preserving bit-for-bit identical outputs to the original model. It enables efficient GPU inference on resource-constrained hardware without sacrificing any accuracy.
cpu_offload=True when calling DFloat11Model.from_pretrained(...).DFloat11/Wan2.1-T2V-14B-Diffusers-DF11
FLUX.1-dev
dfloat11 pip package has been upgraded to v0.2.0! Run pip install -U dfloat11[cuda12] to upgrade to the latest version. We have made the following important changes:
Requires a CUDA-compatible GPU (with CUDA 12) and PyTorch installed.
To install from PyPI:
pip install -U dfloat11[cuda12]
[Optional] To compile the GPU kernel and install locally:
nvcc -O3 -ptx dfloat11/decode.cu -o dfloat11/decode.ptx
pip install .[cuda12]
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:
dfloat11 pip package. See Installation.Qwen3-8B model and generates a response.import torch
from dfloat11 import DFloat11Model
from transformers import AutoTokenizer
model_id = "DFloat11/Qwen3-8B-DF11"
model = DFloat11Model.from_pretrained(model_id, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.eos_token
prompt = "Question: What is a binary tree and its applications? Answer:"
inputs = tokenizer(prompt, return_tensors="pt", padding=True).to(model.device)
with torch.no_grad():
output = model.generate(
**inputs,
max_new_tokens=256,
do_sample=True,
)
print(tokenizer.batch_decode(output, skip_special_tokens=True))
model_id in the script above with any pre-compressed model in the Model Hub.To test the speed and memory consumption a DFloat11 LLM during inference:
CUDA_VISIBLE_DEVICES=0 python inference.py \
--model_name_or_path DFloat11/Qwen3-8B-DF11 \
--prompt "Question: What is a binary tree and its applications? Answer:" \
--num_tokens 512 \
--batch_size 1
💡 Tip: If you specify multiple CUDA devices (e.g.,
CUDA_VISIBLE_DEVICES=0,1), the model will be automatically distributed across them using 🤗 Accelerate'sdevice_map="auto".
--model_name_or_path: HuggingFace name or local path of the DFloat11 model (e.g., DFloat11/Qwen3-8B-DF11). See the Model Hub section for a list of available DFloat11 models.--bf16: (Optional) Turn on this flag when passing a BFloat16 model to --model_name_or_path--prompt: Input prompt string for text generation--num_tokens: Number of new tokens to generate per sample--batch_size: Number of prompts to process in parallel--seed: (Optional) Random seed for reproducible resultsThe script prints:
| Model | DFloat11 Link |
|---|---|
| Wan2.1 T2V 14B (see examples/wan2.1) | DFloat11/Wan2.1-T2V-14B-Diffusers-DF11 |
| FLUX.1 dev (see examples/flux.1) | DFloat11/FLUX.1-dev-DF11 |
| Qwen 3 32B | DFloat11/Qwen3-32B-DF11 |
| Qwen 3 14B | DFloat11/Qwen3-14B-DF11 |
| Qwen 3 8B | DFloat11/Qwen3-8B-DF11 |
| Qwen 3 4B | DFloat11/Qwen3-4B-DF11 |
| Phi 4 Reasoning Plus | DFloat11/Phi-4-reasoning-plus-DF11 |
| Gemma 3 27B Instruct | DFloat11/gemma-3-27b-it-DF11 |
| Gemma 3 12B Instruct | DFloat11/gemma-3-12b-it-DF11 |
| Gemma 3 4B Instruct | DFloat11/gemma-3-4b-it-DF11 |
| Llama 3.1 8B Instruct | DFloat11/Llama-3.1-8B-Instruct-DF11 |
| DeepSeek R1 Distill Qwen 32B | DFloat11/DeepSeek-R1-Distill-Qwen-32B-DF11 |
| DeepSeek R1 Distill Qwen 14B | DFloat11/DeepSeek-R1-Distill-Qwen-14B-DF11 |
| DeepSeek R1 Distill Qwen 7B | DFloat11/DeepSeek-R1-Distill-Qwen-7B-DF11 |
| DeepSeek R1 Distill Llama 8B | DFloat11/DeepSeek-R1-Distill-Llama-8B-DF11 |
| ... | Discover more models on our HF page! |
huggingface-cli download \
DFloat11/Llama-3.1-8B-Instruct-DF11 \ # DFloat11 model name
--local-dir ./Llama-3.1-8B-Instruct-DF11 # local path to download the DFloat11 model
from dfloat11 import DFloat11Model
from transformers import AutoTokenizer
model_path = "./Llama-3.1-8B-Instruct-DF11"
model = DFloat11Model.from_pretrained(model_path, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_path)
The DFloat11 compression utility is exposed via the compress_model function.
Check examples/compress_flux1 for a detailed example on compressing the FLUX.1 model.
👉 Explore pre-compressed DFloat11 models ready to use on HuggingFace: https://huggingface.co/DFloat11
📂 Official Code Repository: https://github.com/LeanModels/DFloat11
This work is brought to you by the team at Rice University and xMAD.ai.
The GPU kernel was designed and implemented by Tianyi Zhang.
If you found our work useful or interesting, please consider citing our paper:
@inproceedings{
zhang2025,
title={70\% Size, 100\% Accuracy: Lossless {LLM} Compression for Efficient {GPU} Inference via Dynamic-Length Float ({DF}loat11)},
author={Tianyi Zhang and Mohsen Hariri and Shaochen Zhong and Vipin Chaudhary and Yang Sui and Xia Hu and Anshumali Shrivastava},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
url={https://openreview.net/forum?id=xdNAVP7TGy}
}
12 commits
Python
80.4%
Cuda
19.6%