Views
No views yet
--bf16-unet command-line flag to work with this model. There will be differences in output with this flag enabled vs without the flag, even when using the normal 16-bit checkpoint. However, with the flag enabled, this DF11 model should produce identical outputs to the 16-bit model. Also, the original checkpoint weights are still required because of the Clip and VAE components.torch.nn.Conv2D tensors, even though they compress just fine, so I chose to skip compressing them, in order to avoid the need for users to manually patch the DFloat11 codebase. This makes the final compressed model ~200 MB larger than the expected size, but that is the price to pay for compatibility. Nevertheless, the reduction in VRAM footprint is still rather significant, from 5.14 GB to 3.66 GB, which should make the unet fit in 6 GB GPUs (assuming it has BF16 support).diffusers library, ComfyUI, or any other model), although models that use architectures which are unfamiliar to me might be more difficult.
diffuserspattern_dict for compression:1pattern_dict_comfyui = {
2 r"time_embed" : (
3 "0",
4 "2",
5 ),
6 r"label_emb.0" : (
7 "0",
8 "2",
9 ),
10
11 r"input_blocks\.[12]\.0" : (
12 "emb_layers.1",
13 ),
14
15 r"input_blocks\.4\.0" : (
16 "emb_layers.1",
17 ),
18
19 r"input_blocks\.4\.1\.transformer_blocks\.\d+" : (
20 "attn1.to_q",
21 "attn1.to_k",
22 "attn1.to_v",
23 "attn1.to_out.0",
24 "ff.net.0.proj",
25 "ff.net.2",
26 "attn2.to_q",
27 "attn2.to_k",
28 "attn2.to_v",
29 "attn2.to_out.0",
30 ),
31
32 r"input_blocks\.5\.0" : (
33 "emb_layers.1",
34 ),
35
36 r"input_blocks\.5\.1\.transformer_blocks\.\d+" : (
37 "attn1.to_q",
38 "attn1.to_k",
39 "attn1.to_v",
40 "attn1.to_out.0",
41 "ff.net.0.proj",
42 "ff.net.2",
43 "attn2.to_q",
44 "attn2.to_k",
45 "attn2.to_v",
46 "attn2.to_out.0",
47 ),
48
49
50 r"input_blocks\.7\.0" : (
51 "emb_layers.1",
52 ),
53
54 r"input_blocks\.7\.1\.transformer_blocks\.\d+" : (
55 "attn1.to_q",
56 "attn1.to_k",
57 "attn1.to_v",
58 "attn1.to_out.0",
59 "ff.net.0.proj",
60 "ff.net.2",
61 "attn2.to_q",
62 "attn2.to_k",
63 "attn2.to_v",
64 "attn2.to_out.0",
65 ),
66
67 r"input_blocks\.8\.0" : (
68 "emb_layers.1",
69 ),
70
71 r"input_blocks\.8\.1\.transformer_blocks\.\d+" : (
72 "attn1.to_q",
73 "attn1.to_k",
74 "attn1.to_v",
75 "attn1.to_out.0",
76 "ff.net.0.proj",
77 "ff.net.2",
78 "attn2.to_q",
79 "attn2.to_k",
80 "attn2.to_v",
81 "attn2.to_out.0",
82 ),
83
84
85 r"middle_block\.0" : (
86 "emb_layers.1",
87 ),
88 r"middle_block\.1\.transformer_blocks\.\d+" : (
89 "attn1.to_q",
90 "attn1.to_k",
91 "attn1.to_v",
92 "attn1.to_out.0",
93 "ff.net.0.proj",
94 "ff.net.2",
95 "attn2.to_q",
96 "attn2.to_k",
97 "attn2.to_v",
98 "attn2.to_out.0",
99 ),
100 r"middle_block\.2" : (
101 "emb_layers.1",
102 ),
103
104
105 r"output_blocks\.[01]\.0" : (
106 "emb_layers.1",
107 ),
108 r"output_blocks\.[01]\.1\.transformer_blocks\.\d+" : (
109 "attn1.to_q",
110 "attn1.to_k",
111 "attn1.to_v",
112 "attn1.to_out.0",
113 "ff.net.0.proj",
114 "ff.net.2",
115 "attn2.to_q",
116 "attn2.to_k",
117 "attn2.to_v",
118 "attn2.to_out.0",
119 ),
120 r"output_blocks\.2\.0" : (
121 "emb_layers.1",
122 ),
123 r"output_blocks\.2\.1\.transformer_blocks\.\d+" : (
124 "attn1.to_q",
125 "attn1.to_k",
126 "attn1.to_v",
127 "attn1.to_out.0",
128 "ff.net.0.proj",
129 "ff.net.2",
130 "attn2.to_q",
131 "attn2.to_k",
132 "attn2.to_v",
133 "attn2.to_out.0",
134 ),
135
136 r"output_blocks\.3\.0" : (
137 "emb_layers.1",
138 ),
139 r"output_blocks\.3\.1\.transformer_blocks\.\d+" : (
140 "attn1.to_q",
141 "attn1.to_k",
142 "attn1.to_v",
143 "attn1.to_out.0",
144 "ff.net.0.proj",
145 "ff.net.2",
146 "attn2.to_q",
147 "attn2.to_k",
148 "attn2.to_v",
149 "attn2.to_out.0",
150 ),
151 r"output_blocks\.4\.0" : (
152 "emb_layers.1",
153 ),
154 r"output_blocks\.4\.1\.transformer_blocks\.\d+" : (
155 "attn1.to_q",
156 "attn1.to_k",
157 "attn1.to_v",
158 "attn1.to_out.0",
159 "ff.net.0.proj",
160 "ff.net.2",
161 "attn2.to_q",
162 "attn2.to_k",
163 "attn2.to_v",
164 "attn2.to_out.0",
165 ),
166 r"output_blocks\.5\.0" : (
167 "emb_layers.1",
168 ),
169 r"output_blocks\.5\.1\.transformer_blocks\.\d+" : (
170 "attn1.to_q",
171 "attn1.to_k",
172 "attn1.to_v",
173 "attn1.to_out.0",
174 "ff.net.0.proj",
175 "ff.net.2",
176 "attn2.to_q",
177 "attn2.to_k",
178 "attn2.to_v",
179 "attn2.to_out.0",
180 ),
181
182 r"output_blocks\.[678]\.0" : (
183 "emb_layers.1",
184 ),
185}