LeanQuant commited on
Commit
ba3e7ce
·
verified ·
1 Parent(s): 0a13de4

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README.md +83 -0
  2. config.json +36 -0
  3. diffusion_pytorch_model.safetensors +3 -0
  4. single_transformer_blocks_0.safetensors +3 -0
  5. single_transformer_blocks_1.safetensors +3 -0
  6. single_transformer_blocks_10.safetensors +3 -0
  7. single_transformer_blocks_11.safetensors +3 -0
  8. single_transformer_blocks_12.safetensors +3 -0
  9. single_transformer_blocks_13.safetensors +3 -0
  10. single_transformer_blocks_14.safetensors +3 -0
  11. single_transformer_blocks_15.safetensors +3 -0
  12. single_transformer_blocks_16.safetensors +3 -0
  13. single_transformer_blocks_17.safetensors +3 -0
  14. single_transformer_blocks_18.safetensors +3 -0
  15. single_transformer_blocks_19.safetensors +3 -0
  16. single_transformer_blocks_2.safetensors +3 -0
  17. single_transformer_blocks_20.safetensors +3 -0
  18. single_transformer_blocks_21.safetensors +3 -0
  19. single_transformer_blocks_22.safetensors +3 -0
  20. single_transformer_blocks_23.safetensors +3 -0
  21. single_transformer_blocks_24.safetensors +3 -0
  22. single_transformer_blocks_25.safetensors +3 -0
  23. single_transformer_blocks_26.safetensors +3 -0
  24. single_transformer_blocks_27.safetensors +3 -0
  25. single_transformer_blocks_28.safetensors +3 -0
  26. single_transformer_blocks_29.safetensors +3 -0
  27. single_transformer_blocks_3.safetensors +3 -0
  28. single_transformer_blocks_30.safetensors +3 -0
  29. single_transformer_blocks_31.safetensors +3 -0
  30. single_transformer_blocks_32.safetensors +3 -0
  31. single_transformer_blocks_33.safetensors +3 -0
  32. single_transformer_blocks_34.safetensors +3 -0
  33. single_transformer_blocks_35.safetensors +3 -0
  34. single_transformer_blocks_36.safetensors +3 -0
  35. single_transformer_blocks_37.safetensors +3 -0
  36. single_transformer_blocks_4.safetensors +3 -0
  37. single_transformer_blocks_5.safetensors +3 -0
  38. single_transformer_blocks_6.safetensors +3 -0
  39. single_transformer_blocks_7.safetensors +3 -0
  40. single_transformer_blocks_8.safetensors +3 -0
  41. single_transformer_blocks_9.safetensors +3 -0
  42. transformer_blocks_0.safetensors +3 -0
  43. transformer_blocks_1.safetensors +3 -0
  44. transformer_blocks_10.safetensors +3 -0
  45. transformer_blocks_11.safetensors +3 -0
  46. transformer_blocks_12.safetensors +3 -0
  47. transformer_blocks_13.safetensors +3 -0
  48. transformer_blocks_14.safetensors +3 -0
  49. transformer_blocks_15.safetensors +3 -0
  50. transformer_blocks_16.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - black-forest-labs/FLUX.1-Kontext-dev
4
+ base_model_relation: quantized
5
+ pipeline_tag: text-to-image
6
+ tags:
7
+ - dfloat11
8
+ - df11
9
+ - lossless compression
10
+ - 70% size, 100% accuracy
11
+ ---
12
+
13
+ # DFloat11 Compressed Model: `black-forest-labs/FLUX.1-Kontext-dev`
14
+
15
+ This is a **DFloat11 losslessly compressed** version of the original `black-forest-labs/FLUX.1-Kontext-dev` model. It reduces model size by **32%** compared to the original BFloat16 model, while maintaining **bit-identical outputs** and supporting **efficient GPU inference**.
16
+
17
+ 🔥🔥🔥 Thanks to DFloat11 compression, FLUX.1-Kontext-dev can now run smoothly on a single 24GB GPU without any quality loss. 🔥🔥🔥
18
+
19
+ ### 📊 Performance Comparison
20
+
21
+ | Metric | FLUX.1-Kontext-dev (BFloat16) | FLUX.1-Kontext-dev (DFloat11) |
22
+ | ----------------------------------------------- | ------------------- | ------------------- |
23
+ | Model Size | 23.80 GB | 16.33 GB |
24
+ | Peak GPU Memory<br>(1024×1024 image generation) | 24.86 GB | 18.12 GB |
25
+ | Generation Time<br>(A100 GPU) | 72 seconds | 83 seconds |
26
+
27
+ ### 🔧 How to Use
28
+
29
+ 1. Install or upgrade the DFloat11 pip package *(installs the CUDA kernel automatically; requires a CUDA-compatible GPU and PyTorch installed)*:
30
+
31
+ ```bash
32
+ pip install -U dfloat11[cuda12]
33
+ # or if you have CUDA version 11:
34
+ # pip install -U dfloat11[cuda11]
35
+ ```
36
+
37
+ 2. Install diffusers from the main branch until future stable release.
38
+
39
+ ```bash
40
+ pip install git+https://github.com/huggingface/diffusers.git
41
+ ```
42
+
43
+ 3. To use the DFloat11 model, run the following example code in Python:
44
+
45
+ ```python
46
+ import torch
47
+ from diffusers import FluxKontextPipeline
48
+ from diffusers.utils import load_image
49
+ from dfloat11 import DFloat11Model
50
+
51
+ pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16)
52
+ DFloat11Model.from_pretrained(
53
+ "DFloat11/FLUX.1-Kontext-dev-DF11",
54
+ device="cpu",
55
+ bfloat16_model=pipe.transformer,
56
+ )
57
+ pipe.enable_model_cpu_offload()
58
+
59
+ input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")
60
+
61
+ image = pipe(
62
+ image=input_image,
63
+ prompt="Add a hat to the cat",
64
+ guidance_scale=2.5,
65
+ ).images[0]
66
+
67
+ image.save("kontext.png")
68
+ ```
69
+
70
+
71
+ ### 🔍 How It Works
72
+
73
+ We apply **Huffman coding** to losslessly compress the exponent bits of BFloat16 model weights, which are highly compressible (their 8 bits carry only ~2.6 bits of actual information). To enable fast inference, we implement a highly efficient CUDA kernel that performs on-the-fly weight decompression directly on the GPU.
74
+
75
+ The result is a model that is **~32% smaller**, delivers **bit-identical outputs**, and achieves performance **comparable to the original** BFloat16 model.
76
+
77
+ Learn more in our [research paper](https://arxiv.org/abs/2504.11651).
78
+
79
+ ### 📄 Learn More
80
+
81
+ * **Paper**: [70% Size, 100% Accuracy: Lossless LLM Compression for Efficient GPU Inference via Dynamic-Length Float](https://arxiv.org/abs/2504.11651)
82
+ * **GitHub**: [https://github.com/LeanModels/DFloat11](https://github.com/LeanModels/DFloat11)
83
+ * **HuggingFace**: [https://huggingface.co/DFloat11](https://huggingface.co/DFloat11)
config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dfloat11_config": {
3
+ "bytes_per_thread": 8,
4
+ "pattern_dict": {
5
+ "transformer_blocks\\.\\d+": [
6
+ "norm1.linear",
7
+ "norm1_context.linear",
8
+ "attn.to_q",
9
+ "attn.to_k",
10
+ "attn.to_v",
11
+ "attn.add_k_proj",
12
+ "attn.add_v_proj",
13
+ "attn.add_q_proj",
14
+ "attn.to_out.0",
15
+ "attn.to_add_out",
16
+ "ff.net.0.proj",
17
+ "ff.net.2",
18
+ "ff_context.net.0.proj",
19
+ "ff_context.net.2"
20
+ ],
21
+ "single_transformer_blocks\\.\\d+": [
22
+ "norm.linear",
23
+ "proj_mlp",
24
+ "proj_out",
25
+ "attn.to_q",
26
+ "attn.to_k",
27
+ "attn.to_v"
28
+ ]
29
+ },
30
+ "threads_per_block": [
31
+ 512
32
+ ],
33
+ "version": "0.2.0"
34
+ },
35
+ "model_type": "llama"
36
+ }
diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bb6dd6d0350e069c5ba2a5de6f07cbcd29d029390760e2f65cdbdf35eb4fa71
3
+ size 128252176
single_transformer_blocks_0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18b68387ab00a9e272d111ea834231cee730b3d59ad73b31eda630955ddcd1af
3
+ size 192033822
single_transformer_blocks_1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c14357d9c100087f2075585f7cefd8feb681061c5288b4dda0a40a4ba2a2323
3
+ size 192123718
single_transformer_blocks_10.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9aae8f3c73bc438710d6ef1f591cb8d320a63ff3049a884fb79931ba9f9c5a9
3
+ size 193263315
single_transformer_blocks_11.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c26ce7dadd8c81553a086d2d8d82656cf2ad0ff2469adfd72bfe269a275bc372
3
+ size 193518219
single_transformer_blocks_12.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:675fa8d20a8ee840d4dd3ef37cc74c722199b2a3de41efe53bb604839fdad85c
3
+ size 193686586
single_transformer_blocks_13.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:455fdb0989578c72fce9aab6c5a0e0360f1068a42b9411f45eaa43dbba4d0250
3
+ size 193704658
single_transformer_blocks_14.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22fccbc809c28a58b65a966f03f3334395c729bceb48353fc385d5f1488dae74
3
+ size 193708917
single_transformer_blocks_15.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa92a957a79f6fe93162e3a0b3eee9e3e844c4ee81280d726a6b8323c159655d
3
+ size 193663902
single_transformer_blocks_16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02d96968ed256a31ac783a840de25c86ab7f4e384dce3ec766e072ef8dec5adf
3
+ size 193685537
single_transformer_blocks_17.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8db6580147873b4de60a09f9ddc45d848ade40ce5986197aa5969d5ca50ff6cd
3
+ size 193784314
single_transformer_blocks_18.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06df6f026874ecebed6599c953cb1e99b67c8022485d627bae5961f16dc2e00a
3
+ size 193886102
single_transformer_blocks_19.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8c9703389dcecd8622a40b973815dfa42f9d68ff152f1fd01f77ad5e709e0c0
3
+ size 193870502
single_transformer_blocks_2.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c375a5b2c25ad8c945a054ba288cc4e8128daa98be78a6629c5e73b0515ef473
3
+ size 192159460
single_transformer_blocks_20.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:baa2b5156de7e3656cacfd5d4a3ee7afd2f5acd978189d937d5abef14ee8d35d
3
+ size 193929034
single_transformer_blocks_21.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a46443c5f43c0684f79a39118c1f1818fb04b854618f2ae08af95ef1fc8eb862
3
+ size 194164133
single_transformer_blocks_22.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f299cfd2a591c7d38027ca7913752bde1d9258a53f51ba50e2f7b2acfb188da1
3
+ size 194268421
single_transformer_blocks_23.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d644989f4fd0223230a7f6ec3515464c0ae59bd012b1ebeed8b2455e7b134d11
3
+ size 194471284
single_transformer_blocks_24.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:abfc5ffda32cc34f89ed65f100280746b1e0ca7970b0c6130c40eb6dc7abe7f9
3
+ size 194512113
single_transformer_blocks_25.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2dc6bb1a21cc386b451aebddeceb9c8dc05f82434c200a02ce0e462702f858b9
3
+ size 194795840
single_transformer_blocks_26.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa17fc6d8e26a621915e08058d5070205a8141a9fd212c6cf77746010b18d8ed
3
+ size 194893612
single_transformer_blocks_27.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:88980859109bb118e2d450f59c54b1544e149395c7a3941cfc2dd670efef5f01
3
+ size 195189695
single_transformer_blocks_28.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a81fc3f997b3c54dcb2d298c3cd731a42d3396810c970ce00da608039296cdc7
3
+ size 195343128
single_transformer_blocks_29.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b6c4cbc286e6be9a0a0b392fc654439945d202cfa93e4676144ffa3db0cc976
3
+ size 195201749
single_transformer_blocks_3.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcafd70edb0fa4c00241bb430911ae2d51ad1bf5d231f6af84e4f369d3968a42
3
+ size 192248425
single_transformer_blocks_30.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1f8941e07a0642d4efea258d252bd53149fdf3be3e43468d5b8fea8803f9a37
3
+ size 195613967
single_transformer_blocks_31.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:055180610502ce0be0e2c283e1391f46495876a567498b025239ce69d2e2dba7
3
+ size 195814574
single_transformer_blocks_32.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bb22775a5a702ec53ed70c75f593ce8e0645f34dd8a7972619efa934bc9d79d
3
+ size 195768453
single_transformer_blocks_33.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b8dcd487dae4461149e19d70dd29f6949fdc695be66966ef57c96331db6066e
3
+ size 195874381
single_transformer_blocks_34.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:326977c649be64e56ee7b164fea797988c59274fe4808ebef95212cdb0708b48
3
+ size 196189131
single_transformer_blocks_35.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea0f4ff90517295bc4056810bea58959584cc907925b3fc9ee51464c14cf869a
3
+ size 196482565
single_transformer_blocks_36.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0958aec6cb9cb28c90f88a13ea531478dbddd9ac5590621c1b96663d581381d9
3
+ size 194886684
single_transformer_blocks_37.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b3b2ec96cea410032c080fa09838736d5de0d76544dd437eb40fc74d6c9d6e1
3
+ size 196263804
single_transformer_blocks_4.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4198f0f379db0ae051778e0eb4ca8ebb83a1c6d10a5c89a846508ec2e31b1856
3
+ size 192331341
single_transformer_blocks_5.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee2f4e392a2acfcd19bc9c3dbc384a0839b49d58b86ec1cc49672aeb410fa71e
3
+ size 192523541
single_transformer_blocks_6.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7654276e767b3075a5fd24b44887941e535363233cb4b81723dac1834df06a5
3
+ size 192634063
single_transformer_blocks_7.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58216a9fa9d53ef069e66cccccbdc2b7e692c184a92a2ca6feebba7bca21b153
3
+ size 192729831
single_transformer_blocks_8.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92127a7dae93f8b1eacebe03637e1f69b80460fc71cb723131555c7bc6d8eb35
3
+ size 192948410
single_transformer_blocks_9.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf9a30e24263c5a492b40f4ead39c0c723e8f8f12533878f09bcd68661c569aa
3
+ size 193104490
transformer_blocks_0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44b174cc14c797410181389031fe764cac8bea1f32854368b935eff683571c14
3
+ size 470396511
transformer_blocks_1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:32da807065c62d4f43c89bc2edb7dd2e596d6b48262a09d76b7c82e7c80d0405
3
+ size 471899885
transformer_blocks_10.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0bc33ccdb598b4b06155a2d4d15bcb39ed73e980324c6eb34094c03e89ce7e1
3
+ size 463457437
transformer_blocks_11.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b24897f43e0c46403270cf9a5c858bf93cab9214234ea2e059f1af1e2d48a25e
3
+ size 463054607
transformer_blocks_12.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8acdab1c5255f088b21b462b68227fa9d4c6ea8748e7bb2ad11eb306424023ba
3
+ size 462677194
transformer_blocks_13.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8708bc7a152a6335e6bf9ead78d002842ce2d93bcffa7aca7756c628a52851f8
3
+ size 463613511
transformer_blocks_14.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f43b5334ccfd0a372531253daf6cd319b0091372ff2d2695bbf3b941d1132195
3
+ size 462338083
transformer_blocks_15.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01eef43dad0a0cde3d44cb408a5e2def14dda2cd8d3b623ff7e97b3b9546cf2f
3
+ size 461793444
transformer_blocks_16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3256d9958dcdb10baf9b21f8d8d1bda96d8758855c2db07c4c55fbdb08447ba
3
+ size 461897129