LeanQuant commited on
Commit
0e8271d
·
verified ·
1 Parent(s): c7b0289

Add files using upload-large-folder tool

Browse files
README.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - Wan-AI/Wan2.2-I2V-A14B
4
+ base_model_relation: quantized
5
+ pipeline_tag: image-to-video
6
+ tags:
7
+ - dfloat11
8
+ - df11
9
+ - lossless compression
10
+ - 70% size, 100% accuracy
11
+ ---
12
+
13
+ # DFloat11 Compressed Model: `Wan-AI/Wan2.2-I2V-A14B`
14
+
15
+ This is a **DFloat11 losslessly compressed** version of the original `Wan-AI/Wan2.2-I2V-A14B` 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, `Wan-AI/Wan2.2-I2V-A14B` can now generate a 5-second 720P video on a single 24GB GPU, while maintaining full model quality. 🔥🔥🔥
18
+
19
+ ### 📊 Performance Comparison
20
+
21
+ | Model | Model Size | Peak GPU Memory (5-second 720P generation) | Generation Time (A100 GPU) |
22
+ |----------------------------------------------------|--------------------|----------------------------------------------|----------------------------|
23
+ | Wan-AI/Wan2.2-I2V-A14B (BFloat16) | ~56 GB | O.O.M. | - |
24
+ | Wan-AI/Wan2.2-I2V-A14B (DFloat11) | 19.47 + 19.44 GB | 29.12 GB | 42 minutes |
25
+ | Wan-AI/Wan2.2-I2V-A14B (DFloat11 + CPU Offloading) | 19.47 + 19.44 GB | 20.01 GB | 44 minutes |
26
+
27
+ ### 🔍 How It Works
28
+
29
+ We apply Huffman coding to the exponent bits of BFloat16 model weights, which are highly compressible. We leverage hardware-aware algorithmic designs to enable highly efficient, on-the-fly weight decompression directly on the GPU. Find out more in our [research paper](https://arxiv.org/abs/2504.11651).
30
+
31
+ ### 🔧 How to Use
32
+
33
+ 1. Install or upgrade the DFloat11 pip package *(installs the CUDA kernel automatically; requires a CUDA-compatible GPU and PyTorch installed)*:
34
+
35
+ ```bash
36
+ pip install -U dfloat11[cuda12]
37
+ ```
38
+
39
+ 2. Install the latest `diffusers` package from source:
40
+
41
+ ```bash
42
+ pip install git+https://github.com/huggingface/diffusers
43
+ ```
44
+
45
+ 3. Save the following code to a Python file `i2v.py`:
46
+
47
+ ```python
48
+ import time
49
+ import torch
50
+ import numpy as np
51
+ import argparse
52
+ from diffusers import WanImageToVideoPipeline
53
+ from diffusers.utils import export_to_video, load_image
54
+ from dfloat11 import DFloat11Model
55
+
56
+ parser = argparse.ArgumentParser(description='Image to Video generation using Wan2.2-I2V model')
57
+ parser.add_argument('--cpu_offload', action='store_true', help='Enable CPU offloading')
58
+ parser.add_argument('--image_path', type=str, default="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG", help='Path or URL to the input image')
59
+ parser.add_argument('--width', type=int, default=1280, help='Output video width')
60
+ parser.add_argument('--height', type=int, default=720, help='Output video height')
61
+ parser.add_argument('--prompt', type=str, default="Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside.", help='Prompt for video generation')
62
+ parser.add_argument('--negative_prompt', type=str, default="色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走", help='Negative prompt for video generation')
63
+ parser.add_argument('--num_frames', type=int, default=81, help='Number of frames to generate')
64
+ parser.add_argument('--guidance_scale', type=float, default=3.5, help='Guidance scale for generation')
65
+ parser.add_argument('--num_inference_steps', type=int, default=40, help='Number of inference steps')
66
+ parser.add_argument('--seed', type=int, default=42, help='Random seed for generation')
67
+ parser.add_argument('--output', type=str, default='i2v_output.mp4', help='Output video path')
68
+ parser.add_argument('--fps', type=int, default=16, help='FPS of output video')
69
+
70
+ args = parser.parse_args()
71
+
72
+ image = load_image(args.image_path)
73
+
74
+ pipe = WanImageToVideoPipeline.from_pretrained("Wan-AI/Wan2.2-I2V-A14B-Diffusers", torch_dtype=torch.bfloat16)
75
+
76
+ DFloat11Model.from_pretrained(
77
+ "DFloat11/Wan2.2-I2V-A14B-DF11",
78
+ device="cpu",
79
+ cpu_offload=args.cpu_offload,
80
+ bfloat16_model=pipe.transformer,
81
+ )
82
+ DFloat11Model.from_pretrained(
83
+ "DFloat11/Wan2.2-I2V-A14B-2-DF11",
84
+ device="cpu",
85
+ cpu_offload=args.cpu_offload,
86
+ bfloat16_model=pipe.transformer_2,
87
+ )
88
+
89
+ pipe.enable_model_cpu_offload()
90
+
91
+ max_area = args.width * args.height
92
+ aspect_ratio = image.height / image.width
93
+ mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]
94
+ height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
95
+ width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
96
+ image = image.resize((width, height))
97
+
98
+ generator = torch.Generator(device="cuda").manual_seed(args.seed)
99
+
100
+ start_time = time.time()
101
+ output = pipe(
102
+ image=image,
103
+ prompt=args.prompt,
104
+ negative_prompt=args.negative_prompt,
105
+ height=height,
106
+ width=width,
107
+ num_frames=args.num_frames,
108
+ guidance_scale=args.guidance_scale,
109
+ num_inference_steps=args.num_inference_steps,
110
+ generator=generator,
111
+ ).frames[0]
112
+ print(f"Time taken: {time.time() - start_time:.2f} seconds")
113
+
114
+ export_to_video(output, args.output, fps=args.fps)
115
+
116
+ max_memory = torch.cuda.max_memory_allocated()
117
+ print(f"Max memory: {max_memory / (1000 ** 3):.2f} GB")
118
+ ```
119
+
120
+ 4. To run without CPU offloading (40GB VRAM required):
121
+ ```bash
122
+ PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True python i2v.py
123
+ ```
124
+
125
+ To run with CPU offloading (22.5GB VRAM required):
126
+ ```bash
127
+ PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True python i2v.py --cpu_offload
128
+ ```
129
+ > Setting `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True` is strongly recommended to prevent out-of-memory errors caused by GPU memory fragmentation.
130
+
131
+ ### 📄 Learn More
132
+
133
+ * **Paper**: [70% Size, 100% Accuracy: Lossless LLM Compression for Efficient GPU Inference via Dynamic-Length Float](https://arxiv.org/abs/2504.11651)
134
+ * **GitHub**: [https://github.com/LeanModels/DFloat11](https://github.com/LeanModels/DFloat11)
135
+ * **HuggingFace**: [https://huggingface.co/DFloat11](https://huggingface.co/DFloat11)
blocks_0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4a324342812eb85cf98a3bd867fccdbd92d293f4e1d8ebc2f6b6f4b8e2626eb
3
+ size 473161015
blocks_1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9f40a05f5e8899facdbd3cffacae6b0d0c3ff4e45cea88139edfc1286a2f427
3
+ size 474615568
blocks_10.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:542e7cfd87317225a0f628955aa146225dcf0d52eb8625b5023941aa10dcb1cf
3
+ size 475484959
blocks_11.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3ef65a6681b5154a0233d547053e12d72d9ddba34253cedbac0541cc5d9ae61
3
+ size 475354524
blocks_12.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7de0a1bb344360953baac6c244584839135ebdeed0fd8c7956b962a2d0debc4
3
+ size 475201326
blocks_13.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1843084fcc8f82006f39a3929c9ab8969517b95a316ac828abe32a4db59e1b2c
3
+ size 474970332
blocks_14.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:541f9a07448449398f044e41aa500fc8bd1b75897f5c8ae918b0136d881be0c7
3
+ size 474803606
blocks_15.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd42c00ea1c304ab70f0ba3d50537444737119dd5209134e582bfb548d3b7f8a
3
+ size 474511914
blocks_16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0aa87cbe985b1831f7146cb0bd3dabc32c99095949f80187fbb06cf7b314800f
3
+ size 474585500
blocks_17.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf8449a37f3c42a9d8d35e19b67f17838b4b0f9c143c281d32c92121892f2b3f
3
+ size 474372605
blocks_18.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4a9fde91610565a4fd9d7f59d296507f72438254ba136f11ce2fc91aa54c459
3
+ size 474520915
blocks_19.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:beac844d58d4003d4f842684dfca9e02cbac9b3d9a487b003c3cd841eb4cd51d
3
+ size 474268282
blocks_2.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:032c3b05b6f44eea5a5fde21ee1b441f30e15280644e43b7b1b5859e64d1b9c8
3
+ size 475042559
blocks_20.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6efa432da6579c898b295787a6ed5a6b0fbe6b8dfb2926fc4774f9d7bda6decb
3
+ size 474250749
blocks_21.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8bb4626b2adb82fc6f68b54bbf9ea6a557c1ee467d082fa947611678ee641aeb
3
+ size 474239584
blocks_22.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30e2b22362c635544e5da2742cdca1a16551b5a5befa8a36b7fa7cd034e7318e
3
+ size 474057128
blocks_23.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b11221d6a8fca83f8cab8f39dccb1a7b6e0354e90fe85717305a2a3763a4b90
3
+ size 473975556
blocks_24.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d34a822c5bfeb5a9894ccb1e5c5467c95d1801688f008947e27b0cda13b0bf63
3
+ size 473473196
blocks_25.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a4cb530fd896c8ba643f780b954688429a534f14b6d13702f90bc9280420d84
3
+ size 473201187
blocks_26.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b0475225d686d0b8af0cfd5f43539f32aefbd68e67182f638eda8721cc8a4b3
3
+ size 473077868
blocks_27.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57846a27bf2d7eb73662bb558ea5e2689a6f10a8bcf8aeb859f39ec6ff03c5de
3
+ size 472957197
blocks_28.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1258cd8757f74b9b40ecdea72de672cd4883480d9be2aef09bf0f289e3309e15
3
+ size 472806195
blocks_29.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58138a1e5b7a0f01aacbb744377d2b8858a89101babeef341b774b6b95b2389f
3
+ size 472543027
blocks_3.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9f5fa5d3d2effc9ef7ed99f0fb1f4315b905b44a8db7649d4284c1fae36eb9d
3
+ size 475056015
blocks_30.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7cd7dd6b4fa8b688d1c157a88ae474e4801c0e7e3bc83a008f4b1a4e4d138c20
3
+ size 472406322
blocks_31.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55886640cf56afb3d7506b175432b0dfb3df98ab0dc36567b32cb5f75aee129e
3
+ size 472219358
blocks_32.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97ebf0958d2aa0f7ade67e6c64a38be0635938b0adeb66d28918f991dd417cd8
3
+ size 471961135
blocks_33.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae2211e0b13b0213f214bcd8260f69dfd19d5ea49a39d761101f2c1a65fbda86
3
+ size 471359185
blocks_34.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f879542e12411988f43d4897308f76ba4b0a3e47ba290b258b478c62d26f4d9a
3
+ size 471420534
blocks_35.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08c7719457111bfe0008b14308e307796f1241c75f3debcb7fb79bae77c8628d
3
+ size 471849658
blocks_36.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfb159fb4320377c77f5307fc958229676e1a69c9eb19d839886360ec71f6e78
3
+ size 471253989
blocks_37.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:859a423dc9acb3ecbfaff5a57306b7b8a26598154556cadcdedcc9874146d7c8
3
+ size 471159202
blocks_38.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e69b2ee46b82b043984370823189c98c0cc377b7a5021ed91369219a9a3da82a
3
+ size 470391601
blocks_39.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba7d5343e8d22659a9ea58ef3ad65d7d477c6f41411115a8151aef7753e5d564
3
+ size 470099464
blocks_4.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:711856613180b9e0fa6d608aa9fce7580cbe90846fff57c55cf519746f775847
3
+ size 475013195
blocks_5.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2ca7fdafb35358aadd5e1bde151f0e19d1cf6f180362c4ba4c0f1c29941233e
3
+ size 475082697
blocks_6.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3e1cc8dad9a3a559dc027af5cdf30dd14ba965abadf81e6f9b17ce6ecef3b0c
3
+ size 475185086
blocks_7.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73e5f109a7e42ef4363f256def155c5be267118b3bd9b4423821f8357be07892
3
+ size 475243387
blocks_8.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8dd5c4572ef8c89b77413c710c9a9152f7783c4217c64f40870e90d50464ce71
3
+ size 475350733
blocks_9.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f71960bdb37de9d109fdebbe8cad9c54f4b84158a9ae30c4385ec46863c2d35
3
+ size 475554848
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dfloat11_config": {
3
+ "bytes_per_thread": 8,
4
+ "pattern_dict": {
5
+ "blocks\\.\\d+": [
6
+ "attn1.to_q",
7
+ "attn1.to_k",
8
+ "attn1.to_v",
9
+ "attn1.to_out.0",
10
+ "attn2.to_q",
11
+ "attn2.to_k",
12
+ "attn2.to_v",
13
+ "attn2.to_out.0",
14
+ "ffn.net.0.proj",
15
+ "ffn.net.2"
16
+ ]
17
+ },
18
+ "threads_per_block": [
19
+ 512
20
+ ],
21
+ "version": "0.3.1"
22
+ },
23
+ "model_type": "llama"
24
+ }
diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2fca4c76e97c2b346dc33466bac9da2b5eabf512dc7fa92a9655f84132c055ac
3
+ size 521350912