catplusplus commited on
Commit
0c17c2b
·
verified ·
1 Parent(s): d28dbd0

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
added_tokens.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|box_end|>": 151649,
9
+ "<|box_start|>": 151648,
10
+ "<|endoftext|>": 151643,
11
+ "<|file_sep|>": 151664,
12
+ "<|fim_middle|>": 151660,
13
+ "<|fim_pad|>": 151662,
14
+ "<|fim_prefix|>": 151659,
15
+ "<|fim_suffix|>": 151661,
16
+ "<|im_end|>": 151645,
17
+ "<|im_start|>": 151644,
18
+ "<|image_pad|>": 151655,
19
+ "<|object_ref_end|>": 151647,
20
+ "<|object_ref_start|>": 151646,
21
+ "<|quad_end|>": 151651,
22
+ "<|quad_start|>": 151650,
23
+ "<|repo_name|>": 151663,
24
+ "<|video_pad|>": 151656,
25
+ "<|vision_end|>": 151653,
26
+ "<|vision_pad|>": 151654,
27
+ "<|vision_start|>": 151652
28
+ }
chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "dtype": "bfloat16",
9
+ "eos_token_id": 151645,
10
+ "head_dim": 128,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 4096,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 12288,
15
+ "layer_types": [
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention",
49
+ "full_attention",
50
+ "full_attention",
51
+ "full_attention"
52
+ ],
53
+ "max_position_embeddings": 40960,
54
+ "max_window_layers": 36,
55
+ "model_type": "qwen3",
56
+ "num_attention_heads": 32,
57
+ "num_hidden_layers": 36,
58
+ "num_key_value_heads": 8,
59
+ "quantization_config": {
60
+ "config_groups": {
61
+ "group_0": {
62
+ "format": "nvfp4-pack-quantized",
63
+ "input_activations": {
64
+ "actorder": null,
65
+ "block_structure": null,
66
+ "dynamic": "local",
67
+ "group_size": 16,
68
+ "num_bits": 4,
69
+ "observer": "minmax",
70
+ "observer_kwargs": {},
71
+ "strategy": "tensor_group",
72
+ "symmetric": true,
73
+ "type": "float"
74
+ },
75
+ "output_activations": null,
76
+ "targets": [
77
+ "Linear"
78
+ ],
79
+ "weights": {
80
+ "actorder": null,
81
+ "block_structure": null,
82
+ "dynamic": false,
83
+ "group_size": 16,
84
+ "num_bits": 4,
85
+ "observer": "minmax",
86
+ "observer_kwargs": {},
87
+ "strategy": "tensor_group",
88
+ "symmetric": true,
89
+ "type": "float"
90
+ }
91
+ }
92
+ },
93
+ "format": "nvfp4-pack-quantized",
94
+ "global_compression_ratio": null,
95
+ "ignore": [
96
+ "model.layers.0.self_attn.q_proj",
97
+ "model.layers.0.self_attn.k_proj",
98
+ "model.layers.0.self_attn.v_proj",
99
+ "model.layers.0.self_attn.o_proj",
100
+ "model.layers.0.mlp.gate_proj",
101
+ "model.layers.0.mlp.up_proj",
102
+ "model.layers.0.mlp.down_proj",
103
+ "model.layers.1.self_attn.q_proj",
104
+ "model.layers.1.self_attn.k_proj",
105
+ "model.layers.1.self_attn.v_proj",
106
+ "model.layers.1.self_attn.o_proj",
107
+ "model.layers.2.self_attn.q_proj",
108
+ "model.layers.2.self_attn.k_proj",
109
+ "model.layers.2.self_attn.v_proj",
110
+ "model.layers.2.self_attn.o_proj",
111
+ "model.layers.3.self_attn.q_proj",
112
+ "model.layers.3.self_attn.k_proj",
113
+ "model.layers.3.self_attn.v_proj",
114
+ "model.layers.3.self_attn.o_proj",
115
+ "model.layers.4.self_attn.q_proj",
116
+ "model.layers.4.self_attn.k_proj",
117
+ "model.layers.4.self_attn.v_proj",
118
+ "model.layers.4.self_attn.o_proj",
119
+ "model.layers.5.self_attn.q_proj",
120
+ "model.layers.5.self_attn.k_proj",
121
+ "model.layers.5.self_attn.v_proj",
122
+ "model.layers.5.self_attn.o_proj",
123
+ "model.layers.6.self_attn.q_proj",
124
+ "model.layers.6.self_attn.k_proj",
125
+ "model.layers.6.self_attn.v_proj",
126
+ "model.layers.6.self_attn.o_proj",
127
+ "model.layers.7.self_attn.q_proj",
128
+ "model.layers.7.self_attn.k_proj",
129
+ "model.layers.7.self_attn.v_proj",
130
+ "model.layers.7.self_attn.o_proj",
131
+ "model.layers.8.self_attn.q_proj",
132
+ "model.layers.8.self_attn.k_proj",
133
+ "model.layers.8.self_attn.v_proj",
134
+ "model.layers.8.self_attn.o_proj",
135
+ "model.layers.8.mlp.gate_proj",
136
+ "model.layers.8.mlp.up_proj",
137
+ "model.layers.8.mlp.down_proj",
138
+ "model.layers.9.self_attn.q_proj",
139
+ "model.layers.9.self_attn.k_proj",
140
+ "model.layers.9.self_attn.v_proj",
141
+ "model.layers.9.self_attn.o_proj",
142
+ "model.layers.9.mlp.gate_proj",
143
+ "model.layers.9.mlp.up_proj",
144
+ "model.layers.9.mlp.down_proj",
145
+ "model.layers.10.self_attn.q_proj",
146
+ "model.layers.10.self_attn.k_proj",
147
+ "model.layers.10.self_attn.v_proj",
148
+ "model.layers.10.self_attn.o_proj",
149
+ "model.layers.11.self_attn.q_proj",
150
+ "model.layers.11.self_attn.k_proj",
151
+ "model.layers.11.self_attn.v_proj",
152
+ "model.layers.11.self_attn.o_proj",
153
+ "model.layers.12.self_attn.q_proj",
154
+ "model.layers.12.self_attn.k_proj",
155
+ "model.layers.12.self_attn.v_proj",
156
+ "model.layers.12.self_attn.o_proj",
157
+ "model.layers.13.self_attn.q_proj",
158
+ "model.layers.13.self_attn.k_proj",
159
+ "model.layers.13.self_attn.v_proj",
160
+ "model.layers.13.self_attn.o_proj",
161
+ "model.layers.14.self_attn.q_proj",
162
+ "model.layers.14.self_attn.k_proj",
163
+ "model.layers.14.self_attn.v_proj",
164
+ "model.layers.14.self_attn.o_proj",
165
+ "model.layers.15.self_attn.q_proj",
166
+ "model.layers.15.self_attn.k_proj",
167
+ "model.layers.15.self_attn.v_proj",
168
+ "model.layers.15.self_attn.o_proj",
169
+ "model.layers.16.self_attn.q_proj",
170
+ "model.layers.16.self_attn.k_proj",
171
+ "model.layers.16.self_attn.v_proj",
172
+ "model.layers.16.self_attn.o_proj",
173
+ "model.layers.17.self_attn.q_proj",
174
+ "model.layers.17.self_attn.k_proj",
175
+ "model.layers.17.self_attn.v_proj",
176
+ "model.layers.17.self_attn.o_proj",
177
+ "model.layers.17.mlp.gate_proj",
178
+ "model.layers.17.mlp.up_proj",
179
+ "model.layers.17.mlp.down_proj",
180
+ "model.layers.18.self_attn.q_proj",
181
+ "model.layers.18.self_attn.k_proj",
182
+ "model.layers.18.self_attn.v_proj",
183
+ "model.layers.18.self_attn.o_proj",
184
+ "model.layers.18.mlp.gate_proj",
185
+ "model.layers.18.mlp.up_proj",
186
+ "model.layers.18.mlp.down_proj",
187
+ "model.layers.19.self_attn.q_proj",
188
+ "model.layers.19.self_attn.k_proj",
189
+ "model.layers.19.self_attn.v_proj",
190
+ "model.layers.19.self_attn.o_proj",
191
+ "model.layers.20.self_attn.q_proj",
192
+ "model.layers.20.self_attn.k_proj",
193
+ "model.layers.20.self_attn.v_proj",
194
+ "model.layers.20.self_attn.o_proj",
195
+ "model.layers.21.self_attn.q_proj",
196
+ "model.layers.21.self_attn.k_proj",
197
+ "model.layers.21.self_attn.v_proj",
198
+ "model.layers.21.self_attn.o_proj",
199
+ "model.layers.22.self_attn.q_proj",
200
+ "model.layers.22.self_attn.k_proj",
201
+ "model.layers.22.self_attn.v_proj",
202
+ "model.layers.22.self_attn.o_proj",
203
+ "model.layers.23.self_attn.q_proj",
204
+ "model.layers.23.self_attn.k_proj",
205
+ "model.layers.23.self_attn.v_proj",
206
+ "model.layers.23.self_attn.o_proj",
207
+ "model.layers.24.self_attn.q_proj",
208
+ "model.layers.24.self_attn.k_proj",
209
+ "model.layers.24.self_attn.v_proj",
210
+ "model.layers.24.self_attn.o_proj",
211
+ "model.layers.25.self_attn.q_proj",
212
+ "model.layers.25.self_attn.k_proj",
213
+ "model.layers.25.self_attn.v_proj",
214
+ "model.layers.25.self_attn.o_proj",
215
+ "model.layers.26.self_attn.q_proj",
216
+ "model.layers.26.self_attn.k_proj",
217
+ "model.layers.26.self_attn.v_proj",
218
+ "model.layers.26.self_attn.o_proj",
219
+ "model.layers.26.mlp.gate_proj",
220
+ "model.layers.26.mlp.up_proj",
221
+ "model.layers.26.mlp.down_proj",
222
+ "model.layers.27.self_attn.q_proj",
223
+ "model.layers.27.self_attn.k_proj",
224
+ "model.layers.27.self_attn.v_proj",
225
+ "model.layers.27.self_attn.o_proj",
226
+ "model.layers.27.mlp.gate_proj",
227
+ "model.layers.27.mlp.up_proj",
228
+ "model.layers.27.mlp.down_proj",
229
+ "model.layers.28.self_attn.q_proj",
230
+ "model.layers.28.self_attn.k_proj",
231
+ "model.layers.28.self_attn.v_proj",
232
+ "model.layers.28.self_attn.o_proj",
233
+ "model.layers.29.self_attn.q_proj",
234
+ "model.layers.29.self_attn.k_proj",
235
+ "model.layers.29.self_attn.v_proj",
236
+ "model.layers.29.self_attn.o_proj",
237
+ "model.layers.30.self_attn.q_proj",
238
+ "model.layers.30.self_attn.k_proj",
239
+ "model.layers.30.self_attn.v_proj",
240
+ "model.layers.30.self_attn.o_proj",
241
+ "model.layers.31.self_attn.q_proj",
242
+ "model.layers.31.self_attn.k_proj",
243
+ "model.layers.31.self_attn.v_proj",
244
+ "model.layers.31.self_attn.o_proj",
245
+ "model.layers.32.self_attn.q_proj",
246
+ "model.layers.32.self_attn.k_proj",
247
+ "model.layers.32.self_attn.v_proj",
248
+ "model.layers.32.self_attn.o_proj",
249
+ "model.layers.33.self_attn.q_proj",
250
+ "model.layers.33.self_attn.k_proj",
251
+ "model.layers.33.self_attn.v_proj",
252
+ "model.layers.33.self_attn.o_proj",
253
+ "model.layers.34.self_attn.q_proj",
254
+ "model.layers.34.self_attn.k_proj",
255
+ "model.layers.34.self_attn.v_proj",
256
+ "model.layers.34.self_attn.o_proj",
257
+ "model.layers.35.self_attn.q_proj",
258
+ "model.layers.35.self_attn.k_proj",
259
+ "model.layers.35.self_attn.v_proj",
260
+ "model.layers.35.self_attn.o_proj",
261
+ "lm_head",
262
+ "re:.*self_attn.*",
263
+ "re:.*layers\\.(0|8|9|17|18|26|27)\\.mlp.*"
264
+ ],
265
+ "kv_cache_scheme": null,
266
+ "quant_method": "compressed-tensors",
267
+ "quantization_status": "compressed",
268
+ "sparsity_config": {},
269
+ "transform_config": {},
270
+ "version": "0.12.2"
271
+ },
272
+ "rms_norm_eps": 1e-06,
273
+ "rope_scaling": null,
274
+ "rope_theta": 1000000,
275
+ "sliding_window": null,
276
+ "tie_word_embeddings": false,
277
+ "transformers_version": "4.57.1",
278
+ "use_cache": true,
279
+ "use_sliding_window": false,
280
+ "vocab_size": 151936
281
+ }
extras/Flux2KleinBackend.py ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Flux2KleinBackend.py
3
+ FLUX.2 Klein 9B KV Nunchaku + NVFP4 Qwen3 Text Encoder Backend.
4
+
5
+ Optimized for 16GB GPUs (Blackwell sm_120 / sm_110):
6
+ - Distilled 4-step inference with KV-cache for multi-reference editing.
7
+ - Sequential GPU stage execution:
8
+ Stage 1: Qwen3 NVFP4 Text Encoder on GPU -> offload to CPU.
9
+ Stage 2: AutoencoderKLFlux2 VAE on GPU (if image conditioning) -> offload to CPU.
10
+ Stage 3: NunchakuFlux2Transformer2DModel (FP4/INT4 SVDQuant) on GPU -> offload to CPU.
11
+ Stage 4: AutoencoderKLFlux2 VAE on GPU (decode) -> offload to CPU.
12
+ - All models reside on CPU when idle, leaving the GPU with 0% VRAM allocation
13
+ for other concurrent workloads.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import gc
19
+ import os
20
+ import time
21
+ from typing import Any, List, Optional, Union
22
+
23
+ import numpy as np
24
+ import PIL.Image
25
+ import torch
26
+ from diffusers import AutoencoderKLFlux2, FlowMatchEulerDiscreteScheduler
27
+ from diffusers.pipelines.flux2.pipeline_flux2_klein_kv import (
28
+ Flux2KleinKVPipeline,
29
+ compute_empirical_mu,
30
+ retrieve_timesteps,
31
+ )
32
+ from diffusers.pipelines.flux2.pipeline_output import Flux2PipelineOutput
33
+ from nunchaku import NunchakuFlux2Transformer2DModel
34
+ from nunchaku.utils import get_precision
35
+ from transformers import AutoTokenizer
36
+
37
+ from NVFP4TextEncoder import load_nvfp4_text_encoder
38
+
39
+
40
+ def _flush():
41
+ gc.collect()
42
+ if torch.cuda.is_available():
43
+ torch.cuda.empty_cache()
44
+
45
+
46
+ class SequentialFlux2KleinPipeline:
47
+ """Wrapper that runs Flux2KleinKVPipeline stages sequentially on CUDA,
48
+ offloading each component to CPU immediately after its stage finishes.
49
+ """
50
+
51
+ def __init__(
52
+ self,
53
+ scheduler: FlowMatchEulerDiscreteScheduler,
54
+ vae: AutoencoderKLFlux2,
55
+ text_encoder: torch.nn.Module,
56
+ tokenizer: AutoTokenizer,
57
+ transformer: NunchakuFlux2Transformer2DModel,
58
+ device: str | torch.device = "cuda",
59
+ ):
60
+ self.scheduler = scheduler
61
+ self.vae = vae
62
+ self.text_encoder = text_encoder
63
+ self.tokenizer = tokenizer
64
+ self.transformer = transformer
65
+ self.device = torch.device(device)
66
+
67
+ # Standard diffusers pipeline attributes for compatibility
68
+ self.inner_pipe = Flux2KleinKVPipeline(
69
+ scheduler=scheduler,
70
+ vae=vae,
71
+ text_encoder=text_encoder,
72
+ tokenizer=tokenizer,
73
+ transformer=transformer,
74
+ is_distilled=True,
75
+ )
76
+ self.image_processor = self.inner_pipe.image_processor
77
+ self.vae_scale_factor = self.inner_pipe.vae_scale_factor
78
+
79
+ # Expose components dictionary for server sleep / memory introspection
80
+ self.components = {
81
+ "text_encoder": self.text_encoder,
82
+ "transformer": self.transformer,
83
+ "vae": self.vae,
84
+ "scheduler": self.scheduler,
85
+ "tokenizer": self.tokenizer,
86
+ }
87
+
88
+ # Keep everything on CPU at initialization
89
+ self.to("cpu")
90
+
91
+ def to(self, device: str | torch.device):
92
+ """Move components to specified device (typically 'cpu')."""
93
+ target = str(device)
94
+ if target == "cpu":
95
+ for mod in [self.text_encoder, self.transformer, self.vae]:
96
+ if isinstance(mod, torch.nn.Module):
97
+ try:
98
+ mod.to("cpu")
99
+ except Exception:
100
+ pass
101
+ _flush()
102
+ return self
103
+
104
+ @torch.no_grad()
105
+ def __call__(
106
+ self,
107
+ prompt: str | list[str] = "",
108
+ image: Union[PIL.Image.Image, List[PIL.Image.Image], None] = None,
109
+ height: Optional[int] = None,
110
+ width: Optional[int] = None,
111
+ num_inference_steps: int = 4,
112
+ guidance_scale: float = 1.0,
113
+ negative_prompt: Optional[str] = None,
114
+ num_images_per_prompt: int = 1,
115
+ generator: Optional[torch.Generator] = None,
116
+ seed: Optional[int] = None,
117
+ **kwargs,
118
+ ) -> Flux2PipelineOutput:
119
+ device = self.device
120
+
121
+ if generator is None:
122
+ generator = torch.Generator(device=device)
123
+ if seed is not None:
124
+ generator.manual_seed(seed)
125
+
126
+ t_start = time.time()
127
+
128
+ # ------------------------------------------------------------------
129
+ # STAGE 1: Text Encoding (Qwen3 NVFP4 Text Encoder)
130
+ # ------------------------------------------------------------------
131
+ prompt_embeds = None
132
+ text_ids = None
133
+ try:
134
+ print("[Flux2Klein] Stage 1: Moving Text Encoder to GPU...")
135
+ self.text_encoder.to(device)
136
+ _flush()
137
+
138
+ prompt_embeds, text_ids = self.inner_pipe.encode_prompt(
139
+ prompt=prompt,
140
+ device=device,
141
+ num_images_per_prompt=num_images_per_prompt,
142
+ max_sequence_length=512,
143
+ )
144
+ # Store CPU copies until Stage 3 to minimize VRAM
145
+ prompt_embeds = prompt_embeds.to("cpu")
146
+ text_ids = text_ids.to("cpu")
147
+ finally:
148
+ self.text_encoder.to("cpu")
149
+ _flush()
150
+ print(f"[Flux2Klein] Stage 1 complete. Allocated VRAM: {torch.cuda.memory_allocated() / 1e9:.3f} GB")
151
+
152
+ # ------------------------------------------------------------------
153
+ # STAGE 2: VAE Conditioning (if reference images provided)
154
+ # ------------------------------------------------------------------
155
+ condition_images = None
156
+ if image is not None:
157
+ if not isinstance(image, list):
158
+ image = [image]
159
+ condition_images = []
160
+ for img in image:
161
+ self.image_processor.check_image_input(img)
162
+ img_w, img_h = img.size
163
+ if img_w * img_h > 1024 * 1024:
164
+ img = self.image_processor._resize_to_target_area(img, 1024 * 1024)
165
+ img_w, img_h = img.size
166
+ multiple_of = self.vae_scale_factor * 2
167
+ img_w = (img_w // multiple_of) * multiple_of
168
+ img_h = (img_h // multiple_of) * multiple_of
169
+ img_pre = self.image_processor.preprocess(img, height=img_h, width=img_w, resize_mode="crop")
170
+ condition_images.append(img_pre)
171
+ height = height or img_h
172
+ width = width or img_w
173
+
174
+ height = height or 1024
175
+ width = width or 1024
176
+
177
+ image_latents = None
178
+ image_latent_ids = None
179
+ if condition_images is not None:
180
+ try:
181
+ print(f"[Flux2Klein] Stage 2: Moving VAE to GPU to encode {len(condition_images)} reference image(s)...")
182
+ self.vae.to(device)
183
+ _flush()
184
+
185
+ image_latents, image_latent_ids = self.inner_pipe.prepare_image_latents(
186
+ images=condition_images,
187
+ batch_size=num_images_per_prompt,
188
+ generator=generator,
189
+ device=device,
190
+ dtype=self.vae.dtype,
191
+ )
192
+ image_latents = image_latents.to("cpu")
193
+ image_latent_ids = image_latent_ids.to("cpu")
194
+ finally:
195
+ self.vae.to("cpu")
196
+ _flush()
197
+ print(f"[Flux2Klein] Stage 2 complete. Allocated VRAM: {torch.cuda.memory_allocated() / 1e9:.3f} GB")
198
+
199
+ # ------------------------------------------------------------------
200
+ # STAGE 3: Transformer Denoising Loop (Nunchaku FP4/INT4 KV-Cache)
201
+ # ------------------------------------------------------------------
202
+ num_channels_latents = self.transformer.config.in_channels // 4
203
+ latents, latent_ids = self.inner_pipe.prepare_latents(
204
+ batch_size=num_images_per_prompt,
205
+ num_latents_channels=num_channels_latents,
206
+ height=height,
207
+ width=width,
208
+ dtype=self.transformer.dtype,
209
+ device=device,
210
+ generator=generator,
211
+ )
212
+
213
+ sigmas = np.linspace(1.0, 1.0 / num_inference_steps, num_inference_steps)
214
+ image_seq_len = latents.shape[1]
215
+ mu = compute_empirical_mu(image_seq_len=image_seq_len, num_steps=num_inference_steps)
216
+ timesteps, num_inference_steps = retrieve_timesteps(
217
+ self.scheduler,
218
+ num_inference_steps,
219
+ device,
220
+ sigmas=sigmas,
221
+ mu=mu,
222
+ )
223
+ self.scheduler.set_begin_index(0)
224
+
225
+ kv_cache = None
226
+ try:
227
+ print("[Flux2Klein] Stage 3: Moving Nunchaku Transformer to GPU...")
228
+ self.transformer.to(device)
229
+ _flush()
230
+
231
+ prompt_embeds = prompt_embeds.to(device)
232
+ text_ids = text_ids.to(device)
233
+ latents = latents.to(device)
234
+ latent_ids = latent_ids.to(device)
235
+ if image_latents is not None:
236
+ image_latents = image_latents.to(device)
237
+ image_latent_ids = image_latent_ids.to(device)
238
+
239
+ for i, t in enumerate(timesteps):
240
+ t_step = time.time()
241
+ timestep = t.expand(latents.shape[0]).to(latents.dtype)
242
+
243
+ if i == 0 and image_latents is not None:
244
+ # Step 0: Extract KV cache for reference tokens
245
+ latent_model_input = torch.cat([image_latents, latents], dim=1).to(self.transformer.dtype)
246
+ latent_image_ids = torch.cat([image_latent_ids, latent_ids], dim=1)
247
+ noise_pred, kv_cache = self.transformer(
248
+ hidden_states=latent_model_input,
249
+ timestep=timestep / 1000,
250
+ guidance=None,
251
+ encoder_hidden_states=prompt_embeds,
252
+ txt_ids=text_ids,
253
+ img_ids=latent_image_ids,
254
+ joint_attention_kwargs=None,
255
+ return_dict=False,
256
+ kv_cache_mode="extract",
257
+ num_ref_tokens=image_latents.shape[1],
258
+ )
259
+ elif kv_cache is not None:
260
+ # Steps 1+: Reuse cached reference KV
261
+ noise_pred = self.transformer(
262
+ hidden_states=latents.to(self.transformer.dtype),
263
+ timestep=timestep / 1000,
264
+ guidance=None,
265
+ encoder_hidden_states=prompt_embeds,
266
+ txt_ids=text_ids,
267
+ img_ids=latent_ids,
268
+ joint_attention_kwargs=None,
269
+ return_dict=False,
270
+ kv_cache=kv_cache,
271
+ kv_cache_mode="cached",
272
+ )[0]
273
+ else:
274
+ # Standard text-to-image forward
275
+ noise_pred = self.transformer(
276
+ hidden_states=latents.to(self.transformer.dtype),
277
+ timestep=timestep / 1000,
278
+ guidance=None,
279
+ encoder_hidden_states=prompt_embeds,
280
+ txt_ids=text_ids,
281
+ img_ids=latent_ids,
282
+ joint_attention_kwargs=None,
283
+ return_dict=False,
284
+ )[0]
285
+
286
+ latents = self.scheduler.step(noise_pred, t, latents, return_dict=False)[0]
287
+ print(
288
+ f"[Flux2Klein] Step {i+1}/{len(timesteps)} in {time.time() - t_step:.2f}s | "
289
+ f"Peak VRAM: {torch.cuda.max_memory_allocated() / 1e9:.2f} GB"
290
+ )
291
+
292
+ if "noise_pred" in locals():
293
+ del noise_pred
294
+ finally:
295
+ if kv_cache is not None:
296
+ kv_cache.clear()
297
+ self.transformer.to("cpu")
298
+ del prompt_embeds, text_ids, image_latents, image_latent_ids
299
+ _flush()
300
+ print(f"[Flux2Klein] Stage 3 complete. Allocated VRAM: {torch.cuda.memory_allocated() / 1e9:.3f} GB")
301
+
302
+ # ------------------------------------------------------------------
303
+ # STAGE 4: VAE Decoding
304
+ # ------------------------------------------------------------------
305
+ try:
306
+ print("[Flux2Klein] Stage 4: Moving VAE to GPU to decode latents...")
307
+ self.vae.to(device)
308
+ _flush()
309
+
310
+ latents = self.inner_pipe._unpack_latents_with_ids(latents, latent_ids)
311
+ latents_bn_mean = self.vae.bn.running_mean.view(1, -1, 1, 1).to(latents.device, latents.dtype)
312
+ latents_bn_std = torch.sqrt(self.vae.bn.running_var.view(1, -1, 1, 1) + self.vae.config.batch_norm_eps).to(
313
+ latents.device, latents.dtype
314
+ )
315
+ latents = latents * latents_bn_std + latents_bn_mean
316
+ latents = self.inner_pipe._unpatchify_latents(latents)
317
+ decoded = self.vae.decode(latents, return_dict=False)[0]
318
+ out_images = self.image_processor.postprocess(decoded, output_type="pil")
319
+ finally:
320
+ self.vae.to("cpu")
321
+ del latents, latent_ids
322
+ _flush()
323
+ print(f"[Flux2Klein] Stage 4 complete. Allocated VRAM: {torch.cuda.memory_allocated() / 1e9:.3f} GB")
324
+
325
+ print(f"[Flux2Klein] Total generation finished in {time.time() - t_start:.2f}s!")
326
+ return Flux2PipelineOutput(images=out_images)
327
+
328
+
329
+ class Flux2KleinBackend:
330
+ """Backend factory for FLUX.2 Klein 9B KV Nunchaku."""
331
+
332
+ def __init__(
333
+ self,
334
+ model_id: str,
335
+ optimized_model_path: Optional[str] = None,
336
+ nvfp4_text_encoder_path: Optional[str] = None,
337
+ ):
338
+ self.model_id = model_id
339
+ self.optimized_model_path = optimized_model_path
340
+ self.nvfp4_text_encoder_path = nvfp4_text_encoder_path
341
+ self.pipeline = None
342
+
343
+ def load(self):
344
+ print(f"[Flux2KleinBackend] Initializing backend from base model: {self.model_id}...")
345
+
346
+ # 1. Resolve optimized transformer path
347
+ opt_path = self.optimized_model_path
348
+ if not opt_path:
349
+ precision = get_precision()
350
+ opt_path = os.path.join(
351
+ self.model_id,
352
+ f"svdq-{precision}_r32-FLUX.2-klein-9b-kv-Nunchaku.safetensors",
353
+ )
354
+ if not os.path.exists(opt_path):
355
+ # Fallback to fp4 if not found directly
356
+ opt_path = os.path.join(
357
+ self.model_id,
358
+ "svdq-fp4_r32-FLUX.2-klein-9b-kv-Nunchaku.safetensors",
359
+ )
360
+
361
+ print(f"[Flux2KleinBackend] Loading Nunchaku transformer from {opt_path}...")
362
+ transformer = NunchakuFlux2Transformer2DModel.from_pretrained(
363
+ opt_path,
364
+ torch_dtype=torch.bfloat16,
365
+ )
366
+ transformer.to("cpu")
367
+
368
+ # 2. Resolve NVFP4 text encoder path
369
+ enc_path = self.nvfp4_text_encoder_path
370
+ if not enc_path:
371
+ # Check if running directly from within the text encoder repository (extras/)
372
+ candidate_parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
373
+ if os.path.exists(os.path.join(candidate_parent, "config.json")):
374
+ enc_path = candidate_parent
375
+ elif os.path.exists(os.path.join(self.model_id, "text_encoder")):
376
+ enc_path = os.path.join(self.model_id, "text_encoder")
377
+ else:
378
+ enc_path = "/path/to/FLUX.2-klein-text-encoder-NVFP4"
379
+
380
+ print(f"[Flux2KleinBackend] Loading NVFP4 text encoder from {enc_path}...")
381
+ text_encoder = load_nvfp4_text_encoder(enc_path, device="cpu", dtype=torch.bfloat16)
382
+ tokenizer = AutoTokenizer.from_pretrained(enc_path)
383
+
384
+ # 3. Load VAE and Scheduler
385
+ print(f"[Flux2KleinBackend] Loading VAE and Scheduler from {self.model_id}...")
386
+ vae = AutoencoderKLFlux2.from_pretrained(
387
+ self.model_id,
388
+ subfolder="vae",
389
+ torch_dtype=torch.bfloat16,
390
+ )
391
+ vae.to("cpu")
392
+ scheduler = FlowMatchEulerDiscreteScheduler.from_pretrained(
393
+ self.model_id,
394
+ subfolder="scheduler",
395
+ )
396
+
397
+ # 4. Construct Sequential Pipeline
398
+ self.pipeline = SequentialFlux2KleinPipeline(
399
+ scheduler=scheduler,
400
+ vae=vae,
401
+ text_encoder=text_encoder,
402
+ tokenizer=tokenizer,
403
+ transformer=transformer,
404
+ device="cuda",
405
+ )
406
+
407
+ print("[Flux2KleinBackend] Pipeline successfully loaded and ready on CPU!")
408
+ return self.pipeline, self.pipeline
extras/ImageEditServer.py ADDED
@@ -0,0 +1,505 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import base64
3
+ import io
4
+ import time
5
+ import torch
6
+ import uvicorn
7
+ import gc
8
+ import asyncio
9
+ import traceback
10
+ from typing import List, Optional, Union
11
+ from contextlib import asynccontextmanager
12
+ from fastapi import FastAPI, HTTPException, UploadFile, File, Form
13
+ from pydantic import BaseModel
14
+ from PIL import Image, ImageOps
15
+
16
+ # Argument parsing
17
+ parser = argparse.ArgumentParser(description="Flux Image Edit Server with Nunchaku")
18
+ parser.add_argument("--host", type=str, default="0.0.0.0", help="Host to bind to")
19
+ parser.add_argument("--port", type=int, default=8000, help="Port to bind to")
20
+ parser.add_argument("--model", type=str, default="black-forest-labs/FLUX.1-Kontext-dev", help="Path or Repo ID of the base model")
21
+ parser.add_argument("--optimized-model", type=str, default=None, help="Path to the optimized Nunchaku model safetensors file")
22
+ parser.add_argument("--optimized-edit-model", type=str, default=None, help="Path to the optimized Nunchaku model safetensors file for editing (optional)")
23
+ parser.add_argument("--backend", type=str, default="kontext", choices=["kontext", "flux2", "flux2-klein", "flux2_klein", "qwen", "glm", "zimage"], help="Backend to use: 'kontext', 'flux2', 'flux2-klein', 'qwen', 'glm', or 'zimage'")
24
+ parser.add_argument("--steps", type=int, default=28, help="Default number of inference steps")
25
+ parser.add_argument("--guidance-scale", type=float, default=3.5, help="Default guidance scale")
26
+ parser.add_argument("--qwenimage", action="store_true", help="Use QwenImageBackend (T2I only) instead of full Qwen edit backend")
27
+ parser.add_argument("--uma", action="store_true", help="Enable Unified Memory Architecture mode (load all to GPU, disable offload)")
28
+ parser.add_argument(
29
+ "--nvfp4-text-encoder",
30
+ type=str,
31
+ default=None,
32
+ help=(
33
+ "Path to an NVFP4-pack-quantized HuggingFace text encoder "
34
+ "(compressed-tensors format). Honoured by the zimage and flux2-klein backends; "
35
+ "swaps in vLLM's W4A4 NVFP4 CUTLASS GEMM for ~4x text-encoder VRAM savings."
36
+ ),
37
+ )
38
+ args = parser.parse_args()
39
+
40
+ @asynccontextmanager
41
+ async def lifespan(app: FastAPI):
42
+ # Startup logic
43
+ load_model()
44
+ yield
45
+ # Shutdown logic (if any) could go here
46
+
47
+ app = FastAPI(lifespan=lifespan)
48
+
49
+ # Global components
50
+ IMAGE_DIMENSION_ALIGNMENT = 32
51
+ pipeline = None
52
+ edit_pipeline = None
53
+ request_lock = asyncio.Lock()
54
+ is_sleeping_flag = False
55
+ sleep_requested = False
56
+
57
+ def load_model():
58
+ global pipeline, edit_pipeline
59
+
60
+ try:
61
+ if args.backend == "kontext":
62
+ import KontextBackend
63
+ print(f"Initializing KontextBackend...")
64
+ backend = KontextBackend.KontextBackend(args.model, args.optimized_model)
65
+ pipeline, edit_pipeline = backend.load()
66
+ elif args.backend == "flux2":
67
+ import Flux2Backend
68
+ print(f"Initializing Flux2Backend...")
69
+ backend = Flux2Backend.Flux2Backend(args.model)
70
+ pipeline, edit_pipeline = backend.load()
71
+ elif args.backend == "glm":
72
+ import GlmBackend
73
+ print(f"Initializing GlmBackend...")
74
+ # Use provided model or default to the one in the snippet if args.model is generic
75
+ # The user might pass the specific GLM model via --model, or we default in GlmBackend.
76
+ # Let's pass args.model if it's not the default flux one, otherwise let GlmBackend use its default.
77
+ model_to_use = args.model if args.model != "black-forest-labs/FLUX.1-Kontext-dev" else "Disty0/GLM-Image-SDNQ-4bit-dynamic"
78
+ backend = GlmBackend.GlmBackend(model_to_use)
79
+ pipeline, edit_pipeline = backend.load()
80
+ elif args.backend.startswith("qwen"):
81
+ if args.qwenimage:
82
+ import QwenImageBackend
83
+ print(f"Initializing QwenImageBackend (T2I only)...")
84
+ backend = QwenImageBackend.QwenImageBackend(args.model, args.optimized_model)
85
+ pipeline, edit_pipeline = backend.load()
86
+ else:
87
+ import QwenBackend
88
+ print(f"Initializing QwenBackend...")
89
+ backend = QwenBackend.QwenBackend(args.model, args.optimized_model, optimized_edit_model_path=args.optimized_edit_model, uma=args.uma)
90
+ pipeline, edit_pipeline = backend.load()
91
+ elif args.backend in ["flux2-klein", "flux2_klein"]:
92
+ import Flux2KleinBackend
93
+ print(f"Initializing Flux2KleinBackend...")
94
+ backend = Flux2KleinBackend.Flux2KleinBackend(
95
+ args.model,
96
+ args.optimized_model,
97
+ nvfp4_text_encoder_path=args.nvfp4_text_encoder,
98
+ )
99
+ pipeline, edit_pipeline = backend.load()
100
+ elif args.backend == "zimage":
101
+ import ZImageTurboBackend
102
+ print(f"Initializing ZImageTurboBackend...")
103
+ backend = ZImageTurboBackend.ZImageTurboBackend(
104
+ args.model,
105
+ args.optimized_model,
106
+ uma=args.uma,
107
+ nvfp4_text_encoder_path=args.nvfp4_text_encoder,
108
+ )
109
+ pipeline, edit_pipeline = backend.load()
110
+ else:
111
+ raise ValueError(f"Unknown backend: {args.backend}")
112
+
113
+ except Exception as e:
114
+ print(f"Oh no! The model refused to wake up: {e}")
115
+ raise e
116
+
117
+ # Enable progress bar for diffusers
118
+ import diffusers.utils.logging
119
+ diffusers.utils.logging.enable_progress_bar()
120
+ diffusers.utils.logging.set_verbosity_info()
121
+
122
+ print("Model loaded successfully! Ready for editing quests!")
123
+
124
+ def flush():
125
+ gc.collect()
126
+ torch.cuda.empty_cache()
127
+
128
+
129
+ class ImageGenerationRequest(BaseModel):
130
+ prompt: str
131
+ n: int = 1
132
+ size: str = "1024x1024"
133
+ response_format: str = "b64_json"
134
+ quality: str = "standard"
135
+ style: str = "vivid"
136
+ num_inference_steps: Optional[int] = None
137
+ guidance_scale: Optional[float] = None
138
+ negative_prompt: Optional[str] = None
139
+ seed: Optional[int] = None
140
+
141
+
142
+ @app.post("/v1/sleep")
143
+ async def sleep_endpoint():
144
+ global is_sleeping_flag, sleep_requested
145
+ sleep_requested = True
146
+ try:
147
+ async with request_lock:
148
+ if not is_sleeping_flag and sleep_requested:
149
+ print("Sleep requested, moving models to CPU...")
150
+ for p in [pipeline, edit_pipeline]:
151
+ if not p: continue
152
+ for name, component in p.components.items():
153
+ if isinstance(component, torch.nn.Module):
154
+ # Special handling for Nunchaku which blocks .to() if offload is True
155
+ if hasattr(component, "set_offload") and getattr(component, "offload", False):
156
+ component.set_offload(False)
157
+ component._nunchaku_was_offloaded = True
158
+
159
+ try:
160
+ component.to("cpu")
161
+ except Exception as e:
162
+ pass
163
+ flush()
164
+ is_sleeping_flag = True
165
+ finally:
166
+ sleep_requested = False
167
+ return {"status": "sleep completed", "is_sleeping": is_sleeping_flag}
168
+
169
+ @app.post("/v1/wake_up")
170
+ async def wake_up_endpoint():
171
+ global is_sleeping_flag, sleep_requested
172
+ sleep_requested = False
173
+ async with request_lock:
174
+ if is_sleeping_flag:
175
+ print("Waking up, restoring models to CUDA...")
176
+ for p in [pipeline, edit_pipeline]:
177
+ if not p: continue
178
+ excluded = getattr(p, "_exclude_from_cpu_offload", [])
179
+ for name, component in p.components.items():
180
+ if isinstance(component, torch.nn.Module):
181
+ if getattr(component, "_nunchaku_was_offloaded", False):
182
+ component.set_offload(True, use_pin_memory=True, num_blocks_on_gpu=8)
183
+ for attr in ["img_in", "txt_in", "txt_norm", "time_text_embed", "norm_out", "proj_out"]:
184
+ if hasattr(component, attr):
185
+ try:
186
+ getattr(component, attr).to("cuda")
187
+ except Exception:
188
+ pass
189
+ component._nunchaku_was_offloaded = False
190
+ elif not hasattr(component, "_hf_hook") or name in excluded:
191
+ try:
192
+ component.to("cuda")
193
+ except Exception:
194
+ pass
195
+ is_sleeping_flag = False
196
+ return {"status": "awoken", "is_sleeping": False}
197
+
198
+ @app.get("/v1/is_sleeping")
199
+ async def is_sleeping_endpoint():
200
+ return {"is_sleeping": is_sleeping_flag}
201
+
202
+
203
+ @app.get("/v1/memory_stats")
204
+ async def memory_stats_endpoint():
205
+ """Lightweight introspection endpoint that returns PyTorch's CUDA allocator
206
+ snapshot. Used to diagnose VRAM/UMA bloat without restarting the server."""
207
+ stats = {}
208
+ if torch.cuda.is_available():
209
+ stats["allocated_gb"] = torch.cuda.memory_allocated() / 1e9
210
+ stats["reserved_gb"] = torch.cuda.memory_reserved() / 1e9
211
+ stats["max_allocated_gb"] = torch.cuda.max_memory_allocated() / 1e9
212
+ stats["max_reserved_gb"] = torch.cuda.max_memory_reserved() / 1e9
213
+ # Top allocations by size from the allocator snapshot (>=64 MiB)
214
+ try:
215
+ snap = torch.cuda.memory_snapshot()
216
+ blocks = []
217
+ for seg in snap:
218
+ for b in seg.get("blocks", []):
219
+ if b.get("state") == "active_allocated" and b.get("size", 0) >= 64 * 1024 * 1024:
220
+ blocks.append(b["size"])
221
+ blocks.sort(reverse=True)
222
+ stats["large_active_blocks_gb"] = [round(s / 1e9, 3) for s in blocks[:20]]
223
+ stats["large_active_blocks_total_gb"] = round(sum(blocks) / 1e9, 3)
224
+ stats["large_active_blocks_count"] = len(blocks)
225
+ except Exception as e:
226
+ stats["snapshot_error"] = str(e)
227
+ # Walk Python objects to find big tensors and group them
228
+ try:
229
+ import gc as _gc
230
+ seen = set()
231
+ big = []
232
+ for obj in _gc.get_objects():
233
+ try:
234
+ if isinstance(obj, torch.Tensor) and obj.is_cuda:
235
+ ptr = obj.data_ptr()
236
+ if ptr in seen or ptr == 0:
237
+ continue
238
+ seen.add(ptr)
239
+ sz = obj.element_size() * obj.numel()
240
+ if sz >= 16 * 1024 * 1024:
241
+ big.append((sz, tuple(obj.shape), str(obj.dtype)))
242
+ except Exception:
243
+ continue
244
+ big.sort(reverse=True)
245
+ # Group by (shape, dtype)
246
+ from collections import Counter
247
+ grouped = Counter((shape, dtype) for _, shape, dtype in big)
248
+ stats["big_tensor_groups"] = [
249
+ {"shape": list(shape), "dtype": dtype, "count": cnt,
250
+ "size_gb_each": round(
251
+ (1 if shape == () else (lambda l: __import__('functools').reduce(lambda a, b: a*b, l, 1))(shape)) * (
252
+ 8 if 'int64' in dtype or 'float64' in dtype else
253
+ 4 if 'int32' in dtype or 'float32' in dtype else
254
+ 2 if 'bfloat16' in dtype or 'float16' in dtype else 1
255
+ ) / 1e9, 4)}
256
+ for (shape, dtype), cnt in grouped.most_common(30)
257
+ ]
258
+ stats["big_tensor_count"] = len(big)
259
+ stats["big_tensor_total_gb"] = round(sum(s for s, _, _ in big) / 1e9, 3)
260
+ except Exception as e:
261
+ stats["walk_error"] = str(e)
262
+ return stats
263
+
264
+ @app.post("/v1/images/edits")
265
+ async def edit_image(
266
+ image: Union[List[UploadFile], UploadFile] = File(...),
267
+ prompt: str = Form(...),
268
+ n: int = Form(1),
269
+ size: str = Form("1024x1024"),
270
+ response_format: str = Form("b64_json"), # Default to b64_json
271
+ guidance_scale: Optional[float] = Form(None),
272
+ num_inference_steps: Optional[int] = Form(None),
273
+ negative_prompt: Optional[str] = Form(None),
274
+ seed: Optional[int] = Form(None)
275
+ ):
276
+ # Use CLI defaults if not provided
277
+ steps = num_inference_steps if num_inference_steps is not None else args.steps
278
+ cfg_scale = guidance_scale if guidance_scale is not None else args.guidance_scale
279
+ neg_prompt = negative_prompt if negative_prompt is not None else "" # Default empty for now, or maybe None?
280
+
281
+ generator = None
282
+ import random
283
+ if seed is None:
284
+ seed = random.randint(0, 2**32 - 1)
285
+
286
+ print(f"Using seed: {seed}")
287
+ generator = torch.Generator(device="cuda").manual_seed(seed)
288
+
289
+ if not edit_pipeline:
290
+ raise HTTPException(status_code=500, detail="Model not loaded")
291
+
292
+ if sleep_requested or is_sleeping_flag:
293
+ raise HTTPException(status_code=503, detail="Server is sleeping or trying to sleep.")
294
+
295
+ async with request_lock:
296
+ print(f"Received edit request: {prompt}")
297
+
298
+ # Processing the input image(s)
299
+ input_files = image if isinstance(image, list) else [image]
300
+ init_images = []
301
+
302
+ try:
303
+ for img_file in input_files:
304
+ await img_file.seek(0)
305
+ contents = await img_file.read()
306
+ img = Image.open(io.BytesIO(contents)).convert("RGB")
307
+ init_images.append(img)
308
+ except Exception as e:
309
+ raise HTTPException(status_code=400, detail=f"Invalid image file: {e}")
310
+
311
+ if not init_images:
312
+ raise HTTPException(status_code=400, detail="No images provided")
313
+
314
+ # Parse max target dimensions from requested size
315
+ try:
316
+ target_width, target_height = map(int, size.split("x"))
317
+ except ValueError:
318
+ target_width, target_height = 1024, 1024
319
+
320
+ # Calculate new dimensions preserving aspect ratio based on the first image
321
+ first_image = init_images[0]
322
+ orig_width, orig_height = first_image.size
323
+ scale = min(target_width / orig_width, target_height / orig_height)
324
+ new_width = int(orig_width * scale)
325
+ new_height = int(orig_height * scale)
326
+
327
+ # Ensure dimensions are aligned to 32 for compatibility (e.g. GLM-Image)
328
+ width = (new_width // IMAGE_DIMENSION_ALIGNMENT) * IMAGE_DIMENSION_ALIGNMENT
329
+ height = (new_height // IMAGE_DIMENSION_ALIGNMENT) * IMAGE_DIMENSION_ALIGNMENT
330
+
331
+ # Resize input images to match the calculated target size, padding if necessary
332
+ resized_images = []
333
+ for img in init_images:
334
+ if img.size != (width, height):
335
+ # Use ImageOps.pad to preserve aspect ratio and center in the target size
336
+ # This handles cases where subsequent images might have different ARs
337
+ img = ImageOps.pad(img, (width, height), method=Image.LANCZOS, color=(0, 0, 0))
338
+ resized_images.append(img)
339
+
340
+ # If single image, pass as item, if multiple, pass as list
341
+ # GLM pipeline has a bug where it checks len() on the input, so it must be a list
342
+ if len(resized_images) > 1 or args.backend == "glm":
343
+ image_input = resized_images
344
+ else:
345
+ image_input = resized_images[0]
346
+
347
+ response_images = []
348
+
349
+ try:
350
+ if args.backend.startswith("qwen"):
351
+ # Qwen specific parameters
352
+ # guidance_scale maps to true_cfg_scale
353
+ if args.qwenimage: # QwenImageBackend is T2I only, so it doesn't take an image
354
+ generated_images = edit_pipeline(
355
+ prompt=prompt,
356
+ height=height,
357
+ width=width,
358
+ num_inference_steps=steps,
359
+ true_cfg_scale=cfg_scale,
360
+ num_images_per_prompt=n,
361
+ generator=generator,
362
+ ).images
363
+ else: # Full Qwen edit backend takes an image (or list of images now)
364
+ generated_images = edit_pipeline(
365
+ image=image_input,
366
+ prompt=prompt,
367
+ height=height,
368
+ width=width,
369
+ negative_prompt=neg_prompt,
370
+ num_inference_steps=steps,
371
+ true_cfg_scale=cfg_scale,
372
+ num_images_per_prompt=n,
373
+ generator=generator,
374
+ ).images
375
+ else:
376
+ # Standard Flux/Kontext or GLM
377
+ # GLM I2I Fix: Manually move vision encoder to GPU because get_image_features escapes hooks
378
+ if args.backend == "glm" and hasattr(edit_pipeline, "vision_language_encoder"):
379
+ print("Manually moving GLM Vision Encoder to GPU...")
380
+ edit_pipeline.vision_language_encoder.to("cuda")
381
+
382
+ try:
383
+ generated_images = edit_pipeline(
384
+ image=image_input,
385
+ prompt=prompt,
386
+ height=height,
387
+ width=width,
388
+ num_inference_steps=steps,
389
+ guidance_scale=cfg_scale,
390
+ num_images_per_prompt=n,
391
+ generator=generator,
392
+ ).images
393
+ finally:
394
+ if args.backend == "glm" and hasattr(edit_pipeline, "vision_language_encoder"):
395
+ print("Moving GLM Vision Encoder back to CPU...")
396
+ edit_pipeline.vision_language_encoder.to("cpu")
397
+
398
+ for img in generated_images:
399
+ buffered = io.BytesIO()
400
+ img.save(buffered, format="PNG")
401
+ img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
402
+
403
+ if response_format == "b64_json":
404
+ response_images.append({"b64_json": img_str})
405
+ else:
406
+ # If url is requested we can't really do it without storage, so we fallback or error?
407
+ # For now, let's just assume simple b64_json as per request
408
+ response_images.append({"b64_json": img_str}) # Fallback
409
+
410
+ except Exception as e:
411
+ print(f"Error during editing: {e}")
412
+ print(traceback.format_exc())
413
+ raise HTTPException(status_code=500, detail=str(e))
414
+ finally:
415
+ flush()
416
+
417
+ return {
418
+ "created": int(time.time()),
419
+ "data": response_images
420
+ }
421
+
422
+
423
+
424
+ @app.post("/v1/images/generations")
425
+ async def generate_image(request: ImageGenerationRequest):
426
+ if not pipeline:
427
+ raise HTTPException(status_code=500, detail="Model not loaded")
428
+
429
+ if sleep_requested or is_sleeping_flag:
430
+ raise HTTPException(status_code=503, detail="Server is sleeping or trying to sleep.")
431
+
432
+ async with request_lock:
433
+ #print(f"Received generation request: {request.prompt}")
434
+
435
+ # Parse size
436
+ try:
437
+ width, height = map(int, request.size.split("x"))
438
+ except ValueError:
439
+ width, height = 1024, 1024
440
+
441
+ # Ensure dimensions are aligned to 32
442
+ width = (width // IMAGE_DIMENSION_ALIGNMENT) * IMAGE_DIMENSION_ALIGNMENT
443
+ height = (height // IMAGE_DIMENSION_ALIGNMENT) * IMAGE_DIMENSION_ALIGNMENT
444
+
445
+ response_images = []
446
+
447
+ try:
448
+ # Generate images (no image argument for txt2img!)
449
+ steps = request.num_inference_steps if request.num_inference_steps is not None else args.steps
450
+ cfg_scale = request.guidance_scale if request.guidance_scale is not None else args.guidance_scale
451
+ # negative_prompt not in standard request body in original snippet, but we added it to model
452
+ neg_prompt = request.negative_prompt if request.negative_prompt is not None else ""
453
+
454
+ generator = None
455
+ import random
456
+ seed = request.seed
457
+ if seed is None:
458
+ seed = random.randint(0, 2**32 - 1)
459
+
460
+ print(f"Using seed: {seed}")
461
+ generator = torch.Generator(device="cuda").manual_seed(seed)
462
+
463
+ if args.backend.startswith("qwen"):
464
+ generated_images = pipeline(
465
+ prompt=request.prompt,
466
+ height=height,
467
+ width=width,
468
+ num_inference_steps=steps,
469
+ true_cfg_scale=cfg_scale,
470
+ num_images_per_prompt=request.n,
471
+ negative_prompt=neg_prompt,
472
+ generator=generator,
473
+ ).images
474
+ else:
475
+ generated_images = pipeline(
476
+ prompt=request.prompt,
477
+ height=height,
478
+ width=width,
479
+ num_inference_steps=steps,
480
+ guidance_scale=cfg_scale,
481
+ num_images_per_prompt=request.n,
482
+ generator=generator,
483
+ # Not passing negative_prompt here for generation unless we confirm support in standard Flux pipeline?
484
+ ).images
485
+
486
+ for img in generated_images:
487
+ buffered = io.BytesIO()
488
+ img.save(buffered, format="PNG")
489
+ img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
490
+ response_images.append({"b64_json": img_str})
491
+
492
+ except Exception as e:
493
+ print(f"Error during generation: {e}")
494
+ print(traceback.format_exc())
495
+ raise HTTPException(status_code=500, detail=str(e))
496
+ finally:
497
+ flush()
498
+
499
+ return {
500
+ "created": int(time.time()),
501
+ "data": response_images
502
+ }
503
+
504
+ if __name__ == "__main__":
505
+ uvicorn.run(app, host=args.host, port=args.port)
extras/NVFP4TextEncoder.py ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ NVFP4 text encoder loader for diffusers image pipelines.
3
+
4
+ Loads a compressed-tensors NVFP4-pack-quantized HuggingFace causal LM and wraps
5
+ it so it can be plugged into ``diffusers.ZImagePipeline`` (or any pipeline
6
+ calling ``self.text_encoder(input_ids, attention_mask, output_hidden_states=True)``).
7
+
8
+ Strategy:
9
+ - Instantiate the HF model on the ``meta`` device (no real allocation).
10
+ - Walk every ``torch.nn.Linear`` and swap it for vLLM's ``ReplicatedLinear`` with
11
+ ``CompressedTensorsConfig`` derived from the checkpoint's
12
+ ``quantization_config``. This registers ``weight_packed`` / ``weight_scale`` /
13
+ ``*_global_scale`` parameters in the exact layout vLLM's
14
+ ``CompressedTensorsW4A4Fp4`` scheme expects.
15
+ - Materialise remaining (non-Linear) parameters (embeddings, RMSNorm, k/q norms)
16
+ on the target device & dtype.
17
+ - Stream the safetensors file and dispatch each tensor through the registered
18
+ vLLM ``weight_loader`` (which handles layout swizzling on
19
+ ``process_weights_after_loading``).
20
+ - Tie the LM head to the input embedding when ``config.tie_word_embeddings``.
21
+
22
+ The result is a regular ``nn.Module`` matching the HF model's call signature
23
+ (``forward(input_ids, attention_mask, output_hidden_states)``) -- usable directly
24
+ as ``ZImagePipeline.text_encoder``.
25
+
26
+ vLLM requires a minimal global context (distributed process group + model
27
+ parallel state + active VllmConfig) even at TP=1 because ``ReplicatedLinear``
28
+ queries the TP world size at construction. We bootstrap that lazily once.
29
+
30
+ Forced kernel: we set ``VLLM_NVFP4_GEMM_BACKEND=cutlass`` to skip
31
+ flashinfer-cutlass JIT (which needs the ``ninja`` binary on PATH). The vLLM
32
+ CUTLASS kernel is built into the wheel.
33
+ """
34
+ from __future__ import annotations
35
+
36
+ import json
37
+ import os
38
+ from collections.abc import Iterator
39
+ from typing import Optional
40
+
41
+ import torch
42
+ import torch.nn as nn
43
+
44
+
45
+ # ----------------------------------------------------------------------------
46
+ # One-time vLLM bootstrap (TP=1, no engine, just enough context for ReplicatedLinear)
47
+ # ----------------------------------------------------------------------------
48
+ _VLLM_BOOTSTRAPPED = False
49
+ _VLLM_CONFIG_CTX = None # holds the entered set_current_vllm_config context manager
50
+
51
+
52
+ def _bootstrap_vllm_once() -> None:
53
+ """Initialise the bits of vLLM that ReplicatedLinear needs at TP=1.
54
+
55
+ Idempotent. Uses ``gloo`` so it works without NCCL/CUDA-aware MPI and even
56
+ when CUDA is busy with the diffusion transformer.
57
+ """
58
+ global _VLLM_BOOTSTRAPPED, _VLLM_CONFIG_CTX
59
+ if _VLLM_BOOTSTRAPPED:
60
+ return
61
+
62
+ # Force CUTLASS to avoid flashinfer-cutlass JIT (requires `ninja` on PATH).
63
+ os.environ.setdefault("VLLM_NVFP4_GEMM_BACKEND", "cutlass")
64
+
65
+ from vllm.config import VllmConfig
66
+ from vllm.config.vllm import set_current_vllm_config
67
+ from vllm.distributed import (
68
+ ensure_model_parallel_initialized,
69
+ init_distributed_environment,
70
+ )
71
+
72
+ # Pick a free port; world_size=1.
73
+ import socket
74
+
75
+ s = socket.socket()
76
+ s.bind(("127.0.0.1", 0))
77
+ port = s.getsockname()[1]
78
+ s.close()
79
+
80
+ if not torch.distributed.is_initialized():
81
+ init_distributed_environment(
82
+ world_size=1,
83
+ rank=0,
84
+ local_rank=0,
85
+ distributed_init_method=f"tcp://127.0.0.1:{port}",
86
+ backend="gloo",
87
+ )
88
+
89
+ # Enter a long-lived VllmConfig context. We never exit it -- the encoder
90
+ # may construct submodules lazily and ReplicatedLinear calls
91
+ # get_current_vllm_config() at init.
92
+ vc = VllmConfig()
93
+ _VLLM_CONFIG_CTX = set_current_vllm_config(vc)
94
+ _VLLM_CONFIG_CTX.__enter__()
95
+
96
+ ensure_model_parallel_initialized(1, 1)
97
+ _VLLM_BOOTSTRAPPED = True
98
+
99
+
100
+ # ----------------------------------------------------------------------------
101
+ # Module: linear replacement
102
+ # ----------------------------------------------------------------------------
103
+ def _replace_linears_with_replicated(
104
+ model: nn.Module, quant_config
105
+ ) -> None:
106
+ """Recursively swap every ``nn.Linear`` for vLLM ``ReplicatedLinear``.
107
+
108
+ Carries the ``prefix`` so quant_config's ``ignore`` patterns (e.g. ``lm_head``)
109
+ are correctly applied.
110
+ """
111
+ from vllm.model_executor.layers.linear import ReplicatedLinear
112
+
113
+ def _walk(parent: nn.Module, prefix: str) -> None:
114
+ for child_name, child in list(parent.named_children()):
115
+ qname = f"{prefix}.{child_name}" if prefix else child_name
116
+ if isinstance(child, nn.Linear):
117
+ new = ReplicatedLinear(
118
+ input_size=child.in_features,
119
+ output_size=child.out_features,
120
+ bias=child.bias is not None,
121
+ quant_config=quant_config,
122
+ prefix=qname,
123
+ return_bias=False,
124
+ params_dtype=torch.bfloat16,
125
+ )
126
+ setattr(parent, child_name, new)
127
+ else:
128
+ _walk(child, qname)
129
+
130
+ _walk(model, prefix="")
131
+
132
+
133
+ def _materialize_remaining_meta_params(
134
+ model: nn.Module, dtype: torch.dtype, device: torch.device
135
+ ) -> None:
136
+ """Replace any ``meta`` parameter with empty real storage.
137
+
138
+ Only touches parameters NOT already created on a real device by the
139
+ ReplicatedLinear swap above (i.e. embeddings, layernorms, biases).
140
+ """
141
+ for name, param in list(model.named_parameters(recurse=True)):
142
+ if param.device.type == "meta":
143
+ real = nn.Parameter(
144
+ torch.empty(param.shape, dtype=dtype, device=device),
145
+ requires_grad=False,
146
+ )
147
+ # Replace in the parent module
148
+ parent = model
149
+ *path, leaf = name.split(".")
150
+ for p in path:
151
+ parent = getattr(parent, p)
152
+ setattr(parent, leaf, real)
153
+ # Same for buffers (e.g. rotary inv_freq if registered as buffer on meta)
154
+ for name, buf in list(model.named_buffers(recurse=True)):
155
+ if buf.device.type == "meta":
156
+ real = torch.empty(buf.shape, dtype=buf.dtype, device=device)
157
+ parent = model
158
+ *path, leaf = name.split(".")
159
+ for p in path:
160
+ parent = getattr(parent, p)
161
+ parent.register_buffer(leaf, real, persistent=False)
162
+
163
+
164
+ # ----------------------------------------------------------------------------
165
+ # Weight loading
166
+ # ----------------------------------------------------------------------------
167
+ def _iter_safetensors(model_dir: str) -> Iterator[tuple[str, torch.Tensor]]:
168
+ """Yield (name, tensor) pairs from all *.safetensors shards in ``model_dir``."""
169
+ from safetensors import safe_open
170
+
171
+ # Single-file checkpoint or sharded? Prefer ``model.safetensors.index.json``.
172
+ index_path = os.path.join(model_dir, "model.safetensors.index.json")
173
+ if os.path.exists(index_path):
174
+ with open(index_path) as f:
175
+ index = json.load(f)
176
+ shards = sorted(set(index["weight_map"].values()))
177
+ else:
178
+ # Find all *.safetensors files in dir
179
+ shards = sorted(
180
+ fn for fn in os.listdir(model_dir) if fn.endswith(".safetensors")
181
+ )
182
+ for shard in shards:
183
+ path = os.path.join(model_dir, shard)
184
+ with safe_open(path, framework="pt") as f:
185
+ for key in f.keys():
186
+ yield key, f.get_tensor(key)
187
+
188
+
189
+ def _load_weights_into_model(model: nn.Module, model_dir: str) -> None:
190
+ """Stream safetensors into the (already-structured) model.
191
+
192
+ Uses each ReplicatedLinear's registered ``weight_loader`` for quantised
193
+ params (which handles tensor-parallel sharding, even though TP=1 here it
194
+ keeps casts consistent). Other params (embeddings, layernorms, biases) are
195
+ copied directly.
196
+ """
197
+ # Strip vllm-omni-style "text_encoder." prefix if present; not applicable
198
+ # here since we load the standalone HF Qwen3 checkpoint where keys start
199
+ # with "model.layers..." / "model.embed_tokens..." / "lm_head...".
200
+ name_to_param: dict[str, nn.Parameter] = dict(model.named_parameters(recurse=True))
201
+ name_to_buffer: dict[str, torch.Tensor] = dict(model.named_buffers(recurse=True))
202
+
203
+ missing = set(name_to_param.keys())
204
+ unexpected = []
205
+
206
+ for key, tensor in _iter_safetensors(model_dir):
207
+ # Skip rotary inv_freq etc that aren't params (rare in modern HF saves)
208
+ if key in name_to_param:
209
+ param = name_to_param[key]
210
+ wl = getattr(param, "weight_loader", None)
211
+ if wl is not None:
212
+ wl(param, tensor.to(param.device))
213
+ else:
214
+ with torch.no_grad():
215
+ param.data.copy_(tensor.to(param.device, dtype=param.dtype))
216
+ missing.discard(key)
217
+ elif key in name_to_buffer:
218
+ with torch.no_grad():
219
+ name_to_buffer[key].copy_(tensor.to(name_to_buffer[key].device))
220
+ else:
221
+ unexpected.append(key)
222
+
223
+ # Tied embeddings (lm_head.weight not in checkpoint when tie_word_embeddings=True)
224
+ cfg = getattr(model, "config", None)
225
+ if cfg is not None and getattr(cfg, "tie_word_embeddings", False):
226
+ try:
227
+ inp_emb = model.get_input_embeddings().weight
228
+ model.lm_head.weight = inp_emb # share storage
229
+ missing.discard("lm_head.weight")
230
+ except Exception:
231
+ pass
232
+
233
+ if missing:
234
+ # It's OK if missing entries are *purely* lm_head.weight when tied; we
235
+ # already handled that above. Anything else is fatal-ish.
236
+ leftover = sorted(missing)
237
+ if leftover:
238
+ print(
239
+ f"[NVFP4TextEncoder] WARN: {len(leftover)} params missing from checkpoint; "
240
+ f"first 5: {leftover[:5]}"
241
+ )
242
+ if unexpected:
243
+ print(
244
+ f"[NVFP4TextEncoder] WARN: {len(unexpected)} keys in checkpoint unused; "
245
+ f"first 5: {unexpected[:5]}"
246
+ )
247
+
248
+
249
+ def _process_weights_after_loading(model: nn.Module) -> None:
250
+ """Invoke vLLM's per-layer ``process_weights_after_loading`` for each
251
+ ReplicatedLinear (renames ``weight_packed`` -> ``weight``, computes ``alpha``,
252
+ swizzles scales for the CUTLASS kernel, etc.)."""
253
+ for module in model.modules():
254
+ qm = getattr(module, "quant_method", None)
255
+ if qm is not None and hasattr(qm, "process_weights_after_loading"):
256
+ qm.process_weights_after_loading(module)
257
+
258
+
259
+ # ----------------------------------------------------------------------------
260
+ # Public API
261
+ # ----------------------------------------------------------------------------
262
+ def load_nvfp4_text_encoder(
263
+ model_dir: str,
264
+ device: str | torch.device = "cuda",
265
+ dtype: torch.dtype = torch.bfloat16,
266
+ ) -> nn.Module:
267
+ """Load an NVFP4-quantised HuggingFace causal LM as a plug-in text encoder.
268
+
269
+ Args:
270
+ model_dir: path to the checkpoint directory containing ``config.json``
271
+ and ``model*.safetensors``. The config must carry a
272
+ ``quantization_config`` block with ``"format": "nvfp4-pack-quantized"``.
273
+ device: target CUDA device (forwards to ``model.to(device)``-equivalent
274
+ during materialisation).
275
+ dtype: activation / non-quantised-param dtype.
276
+
277
+ Returns:
278
+ A ``PreTrainedModel`` whose ``Linear`` layers are NVFP4 inside the vLLM
279
+ CUTLASS kernel. Activations flow as ``dtype``.
280
+ """
281
+ _bootstrap_vllm_once()
282
+
283
+ from transformers import AutoConfig, AutoModelForCausalLM
284
+ from vllm.model_executor.layers.quantization.compressed_tensors.compressed_tensors import (
285
+ CompressedTensorsConfig,
286
+ )
287
+ from vllm.model_executor.models.transformers.utils import (
288
+ init_on_device_without_buffers,
289
+ )
290
+
291
+ hf_config = AutoConfig.from_pretrained(model_dir, local_files_only=True)
292
+ if not getattr(hf_config, "quantization_config", None):
293
+ raise ValueError(
294
+ f"{model_dir}/config.json has no `quantization_config`; "
295
+ "this loader only handles NVFP4-quantised checkpoints."
296
+ )
297
+ quant_config = CompressedTensorsConfig.from_config(hf_config.quantization_config)
298
+
299
+ # 1) Build the model skeleton on meta (zero allocation).
300
+ with init_on_device_without_buffers("meta"):
301
+ model = AutoModelForCausalLM.from_config(hf_config)
302
+
303
+ # 2) Swap Linear -> ReplicatedLinear(quant_config) (creates real CUDA params
304
+ # of the quantised shapes).
305
+ target_device = torch.device(device)
306
+ _replace_linears_with_replicated(model, quant_config)
307
+
308
+ # 3) Materialise any leftover meta parameters (embeddings, RMSNorms, ...)
309
+ _materialize_remaining_meta_params(model, dtype=dtype, device=target_device)
310
+
311
+ # 4) Move newly-created quantised params to target device (ReplicatedLinear
312
+ # creates them on the current default device which is usually CPU).
313
+ model.to(target_device)
314
+
315
+ # 5) Load weights via per-param weight_loader.
316
+ _load_weights_into_model(model, model_dir)
317
+
318
+ # 6) Let vLLM swizzle scales / rename weight_packed->weight / compute alpha.
319
+ _process_weights_after_loading(model)
320
+
321
+ # 7) Match HF semantics for downstream pipelines.
322
+ model.eval()
323
+ model.config.use_cache = False
324
+ return model
extras/README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FLUX.2 Klein 9B KV Image Generation & Multi-Reference Edit Server
2
+
3
+ This directory contains the self-contained image generation and editing server integrating **`FLUX.2-klein-9b-kv-Nunchaku`** with this **`FLUX.2-klein-text-encoder-NVFP4`** text encoder.
4
+
5
+ It enables fast, 4-step distilled text-to-image generation and multi-reference image editing (with KV caching) on single consumer GPUs (e.g., 16 GB RTX 5060 Ti / RTX 4080 / RTX 5090) without running out of memory.
6
+
7
+ ---
8
+
9
+ ## 🧪 Quantization Details & Strategy
10
+
11
+ The text encoder was quantized using `llmcompressor` / `compressed-tensors` via [`quantize_flux2_klein_text_encoder_nvfp4.py`](file:///auto/home/amano/olegk/Nikola/src/nvfp4/quantize_flux2_klein_text_encoder_nvfp4.py) based on the recipe in [`recipe.yaml`](../recipe.yaml).
12
+
13
+ ### High-Fidelity Representation Preservation Strategy
14
+
15
+ FLUX.2 Klein conditions its flow transformer on intermediate representations extracted from specific layers of the Qwen3 text encoder (specifically layer indices **9, 18, and 27**). Blanket quantization across all layers degrades prompt adherence and text grounding. To prevent this, the following selective quantization scheme was applied:
16
+
17
+ 1. **Unquantized Self-Attention Projections (`q_proj`, `k_proj`, `v_proj`, `o_proj`)**:
18
+ - Kept in full **bfloat16** across all 36 layers.
19
+ - Preserves semantic query-key routing and relational representations without quantization noise.
20
+
21
+ 2. **Unquantized Root & Near-Tap Layers**:
22
+ - Layer 0 (root) and layers **8, 9, 17, 18, 26, 27** (the critical tap layers and their immediate predecessors) are preserved in full **bfloat16**.
23
+ - Ensures the hidden state outputs at indices 9, 18, and 27 have near-perfect representation fidelity (cosine similarity > 0.999 vs unquantized reference).
24
+
25
+ 3. **Compressed Intermediate MLP Blocks**:
26
+ - The MLP blocks (`gate_proj`, `up_proj`, `down_proj`) of intermediate layers (1–7, 10–16, 19–25, 28–35) are compressed to **NVFP4 (W4A4)** using tensor-group scaling (`format: nvfp4-pack-quantized`).
27
+ - Yields ~4x compression of MLP weights, reducing memory footprint and load times significantly.
28
+
29
+ 4. **Preserved Head & Embeddings**:
30
+ - `lm_head` and `embed_tokens` are kept unquantized in **bfloat16**.
31
+
32
+ ---
33
+
34
+ ## 📦 Required Packages in Python Environment
35
+
36
+ The server runs on Python 3.11 or 3.12 with CUDA 12.8 / 13.0 (e.g. Blackwell sm_120 / Thor sm_110):
37
+
38
+ | Package | Minimum Version | Purpose |
39
+ | :--- | :---: | :--- |
40
+ | `torch` | `2.11.0+` | PyTorch with Blackwell/sm_120 CUDA compute support |
41
+ | `diffusers` | `0.38.0+` | Built with native `Flux2KleinKVPipeline` support |
42
+ | `transformers` | `5.3.0+` | Qwen3 causal language model architecture support |
43
+ | `vllm` | `0.20.0+` | Provides precompiled CUTLASS NVFP4 GEMM kernels |
44
+ | `nunchaku` | `1.2.1+` | SVDQuant FP4/INT4 4-bit transformer execution |
45
+ | `fastapi`, `uvicorn` | Latest | OpenAI-compatible REST server infrastructure |
46
+ | `pillow` | Latest | Image processing and aspect-ratio padding |
47
+
48
+ > [!IMPORTANT]
49
+ > When installing packages in environments with custom CUDA builds, use `--no-deps` to avoid overwriting PyTorch or flash-attention wheels tuned for your compute capability.
50
+
51
+ ---
52
+
53
+ ## ⚡ Architecture & Sequential GPU Memory Management
54
+
55
+ On a 16 GB VRAM GPU, loading both the NVFP4 text encoder (~10.1 GB) and the Nunchaku transformer (~5.8 GB) simultaneously would total ~15.9 GB, exceeding available VRAM and causing an out-of-memory crash.
56
+
57
+ `Flux2KleinBackend.py` solves this using **Sequential GPU Stage Execution**:
58
+
59
+ ```
60
+ [Idle: 0.01 GB VRAM]
61
+ │
62
+ ▼
63
+ Stage 1: Load Text Encoder to CUDA ──> Encode Prompt & IDs ──> Offload to CPU [0.01 GB VRAM]
64
+ │
65
+ ▼ (if reference images passed)
66
+ Stage 2: Load VAE to CUDA ───────────> Encode Image Latents ──> Offload to CPU [0.01 GB VRAM]
67
+ │
68
+ ▼
69
+ Stage 3: Load Transformer to CUDA ───> 4-Step Denoise (KV) ──> Offload to CPU [0.01 GB VRAM]
70
+ │ (Step 0: Extract KV)
71
+ │ (Steps 1-3: Cached KV)
72
+ ▼
73
+ Stage 4: Load VAE to CUDA ───────────> Decode Latents to PIL ─> Offload to CPU [0.01 GB VRAM]
74
+ │
75
+ ▼
76
+ [Idle: 0.01 GB VRAM] (GPU completely freed for other tasks!)
77
+ ```
78
+
79
+ ### Performance & Memory Metrics (RTX 5060 Ti 16 GB)
80
+
81
+ - **Text-to-Image (1024x1024, 4 steps)**: ~9.5s total (~0.5s/step), **10.43 GB** peak VRAM.
82
+ - **1-Image Edit (1024x1024, 4 steps)**: ~12.5s total, **10.46 GB** peak VRAM.
83
+ - **2-Image Multi-Reference Edit (1024x1024, 4 steps)**: ~15.0s total, **13.18 GB** peak VRAM.
84
+ - **Idle Memory Footprint**: **0.010 GB** (10 MB).
85
+ - **Concurrency**: All requests are serialized with an `asyncio.Lock` queue, preventing concurrent memory spikes.
86
+
87
+ ---
88
+
89
+ ## 🚀 Running the Server
90
+
91
+ ### 1. Launch via Helper Script
92
+
93
+ ```bash
94
+ # Set paths (or edit defaults inside the script)
95
+ export MODEL_PATH="/path/to/FLUX.2-klein-9b-kv-Nunchaku"
96
+ export NVFP4_TEXT_ENCODER_PATH="/path/to/FLUX.2-klein-text-encoder-NVFP4"
97
+
98
+ ./imagegen_flux2_klein.sh 4501
99
+ ```
100
+
101
+ ### 2. Launch Manually via Python
102
+
103
+ ```bash
104
+ export VLLM_NVFP4_GEMM_BACKEND=cutlass
105
+
106
+ python ImageEditServer.py \
107
+ --port 4501 \
108
+ --model /path/to/FLUX.2-klein-9b-kv-Nunchaku \
109
+ --optimized-model /path/to/FLUX.2-klein-9b-kv-Nunchaku/svdq-fp4_r32-FLUX.2-klein-9b-kv-Nunchaku.safetensors \
110
+ --nvfp4-text-encoder /path/to/FLUX.2-klein-text-encoder-NVFP4 \
111
+ --backend flux2-klein \
112
+ --steps 4 \
113
+ --guidance-scale 1.0
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 📡 API Usage Examples
119
+
120
+ ### 1. Text-to-Image Generation (`POST /v1/images/generations`)
121
+
122
+ ```bash
123
+ curl -X POST http://localhost:4501/v1/images/generations \
124
+ -H "Content-Type: application/json" \
125
+ -d '{
126
+ "prompt": "A cute cheerful anime girl with a ponytail in a simple village dress smiling, anime style",
127
+ "size": "1024x1024",
128
+ "num_inference_steps": 4,
129
+ "seed": 42
130
+ }' | jq -r '.data[0].b64_json' | base64 -d > generated.png
131
+ ```
132
+
133
+ ### 2. Single-Image Reference Edit (`POST /v1/images/edits`)
134
+
135
+ ```bash
136
+ curl -X POST http://localhost:4501/v1/images/edits \
137
+ -F "image=@generated.png" \
138
+ -F "prompt=The anime girl wearing stylish round glasses and a bright red ribbon in her hair, anime style" \
139
+ -F "num_inference_steps=4" \
140
+ -F "seed": 42 | jq -r '.data[0].b64_json' | base64 -d > edited_1img.png
141
+ ```
142
+
143
+ ### 3. Multi-Reference 2-Image Edit (`POST /v1/images/edits`)
144
+
145
+ Pass multiple `-F "image=@..."` form fields:
146
+
147
+ ```bash
148
+ curl -X POST http://localhost:4501/v1/images/edits \
149
+ -F "image=@girl.png" \
150
+ -F "image=@sofa.png" \
151
+ -F "prompt=The anime girl from image 1 is sitting comfortably on the sofa from image 2 in the living room, anime style" \
152
+ -F "num_inference_steps=4" \
153
+ -F "seed": 42 | jq -r '.data[0].b64_json' | base64 -d > edited_2imgs.png
154
+ ```
155
+
156
+ ### 4. Memory Introspection (`GET /v1/memory_stats`)
157
+
158
+ ```bash
159
+ curl http://localhost:4501/v1/memory_stats | jq .
160
+ ```
161
+ Expected output when idle: `"allocated_gb": 0.01`, `"reserved_gb": 0.02`.
162
+
extras/imagegen_flux2_klein.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Activate your python virtual environment containing torch, vllm, nunchaku, diffusers
3
+ # source /path/to/venv/bin/activate
4
+
5
+ # Force vLLM's built-in CUTLASS NVFP4 kernel
6
+ export VLLM_NVFP4_GEMM_BACKEND=cutlass
7
+
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ cd "$SCRIPT_DIR"
10
+
11
+ PORT=${PORT:-${1:-4501}}
12
+ MODEL_PATH=${MODEL_PATH:-"/path/to/FLUX.2-klein-9b-kv-Nunchaku"}
13
+ OPTIMIZED_MODEL_PATH=${OPTIMIZED_MODEL_PATH:-"$MODEL_PATH/svdq-fp4_r32-FLUX.2-klein-9b-kv-Nunchaku.safetensors"}
14
+ NVFP4_TEXT_ENCODER_PATH=${NVFP4_TEXT_ENCODER_PATH:-"/path/to/FLUX.2-klein-text-encoder-NVFP4"}
15
+
16
+ python ImageEditServer.py \
17
+ --port "$PORT" \
18
+ --model "$MODEL_PATH" \
19
+ --optimized-model "$OPTIMIZED_MODEL_PATH" \
20
+ --nvfp4-text-encoder "$NVFP4_TEXT_ENCODER_PATH" \
21
+ --backend flux2-klein \
22
+ --steps 4 \
23
+ --guidance-scale 1.0
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "pad_token_id": 151643,
9
+ "temperature": 0.6,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "transformers_version": "4.57.1"
13
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model-00001-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37d64ab50a2327706661600993c0984c67d448201f8d348a0a2ff5699cc04596
3
+ size 4950651864
model-00002-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b21bc981a803cc399bc667de72a4f968efdeb062793270e579a18195d51873bc
3
+ size 3891633056
model-00003-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20c2d6366ab85c90786ccdd829cd2b9e7d30ef3b2ebbb998280e7e4014b542ff
3
+ size 1244659840
model.safetensors.index.json ADDED
@@ -0,0 +1,668 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 6274987182,
4
+ "total_size": 10086869688
5
+ },
6
+ "weight_map": {
7
+ "lm_head.weight": "model-00003-of-00003.safetensors",
8
+ "model.embed_tokens.weight": "model-00001-of-00003.safetensors",
9
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00003.safetensors",
10
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
11
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
12
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
13
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
14
+ "model.layers.0.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
15
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
16
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
17
+ "model.layers.0.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
18
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
19
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
20
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00003.safetensors",
21
+ "model.layers.1.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
22
+ "model.layers.1.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
23
+ "model.layers.1.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
24
+ "model.layers.1.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
25
+ "model.layers.1.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
26
+ "model.layers.1.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
27
+ "model.layers.1.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
28
+ "model.layers.1.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
29
+ "model.layers.1.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
30
+ "model.layers.1.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
31
+ "model.layers.1.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
32
+ "model.layers.1.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
33
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
34
+ "model.layers.1.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
35
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
36
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
37
+ "model.layers.1.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
38
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
39
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
40
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00003.safetensors",
41
+ "model.layers.10.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
42
+ "model.layers.10.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
43
+ "model.layers.10.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
44
+ "model.layers.10.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
45
+ "model.layers.10.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
46
+ "model.layers.10.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
47
+ "model.layers.10.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
48
+ "model.layers.10.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
49
+ "model.layers.10.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
50
+ "model.layers.10.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
51
+ "model.layers.10.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
52
+ "model.layers.10.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
53
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
54
+ "model.layers.10.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
55
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
56
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
57
+ "model.layers.10.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
58
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
59
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
60
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00003.safetensors",
61
+ "model.layers.11.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
62
+ "model.layers.11.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
63
+ "model.layers.11.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
64
+ "model.layers.11.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
65
+ "model.layers.11.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
66
+ "model.layers.11.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
67
+ "model.layers.11.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
68
+ "model.layers.11.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
69
+ "model.layers.11.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
70
+ "model.layers.11.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
71
+ "model.layers.11.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
72
+ "model.layers.11.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
73
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
74
+ "model.layers.11.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
75
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
76
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
77
+ "model.layers.11.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
78
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
79
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
80
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00003.safetensors",
81
+ "model.layers.12.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
82
+ "model.layers.12.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
83
+ "model.layers.12.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
84
+ "model.layers.12.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
85
+ "model.layers.12.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
86
+ "model.layers.12.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
87
+ "model.layers.12.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
88
+ "model.layers.12.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
89
+ "model.layers.12.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
90
+ "model.layers.12.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
91
+ "model.layers.12.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
92
+ "model.layers.12.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
93
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
94
+ "model.layers.12.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
95
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
96
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
97
+ "model.layers.12.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
98
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
99
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
100
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00003.safetensors",
101
+ "model.layers.13.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
102
+ "model.layers.13.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
103
+ "model.layers.13.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
104
+ "model.layers.13.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
105
+ "model.layers.13.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
106
+ "model.layers.13.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
107
+ "model.layers.13.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
108
+ "model.layers.13.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
109
+ "model.layers.13.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
110
+ "model.layers.13.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
111
+ "model.layers.13.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
112
+ "model.layers.13.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
113
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
114
+ "model.layers.13.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
115
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
116
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
117
+ "model.layers.13.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
118
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
119
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
120
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00003.safetensors",
121
+ "model.layers.14.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
122
+ "model.layers.14.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
123
+ "model.layers.14.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
124
+ "model.layers.14.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
125
+ "model.layers.14.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
126
+ "model.layers.14.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
127
+ "model.layers.14.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
128
+ "model.layers.14.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
129
+ "model.layers.14.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
130
+ "model.layers.14.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
131
+ "model.layers.14.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
132
+ "model.layers.14.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
133
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
134
+ "model.layers.14.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
135
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
136
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
137
+ "model.layers.14.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
138
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
139
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
140
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00003.safetensors",
141
+ "model.layers.15.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
142
+ "model.layers.15.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
143
+ "model.layers.15.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
144
+ "model.layers.15.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
145
+ "model.layers.15.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
146
+ "model.layers.15.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
147
+ "model.layers.15.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
148
+ "model.layers.15.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
149
+ "model.layers.15.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
150
+ "model.layers.15.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
151
+ "model.layers.15.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
152
+ "model.layers.15.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
153
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
154
+ "model.layers.15.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
155
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
156
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
157
+ "model.layers.15.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
158
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
159
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
160
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00003.safetensors",
161
+ "model.layers.16.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
162
+ "model.layers.16.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
163
+ "model.layers.16.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
164
+ "model.layers.16.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
165
+ "model.layers.16.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
166
+ "model.layers.16.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
167
+ "model.layers.16.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
168
+ "model.layers.16.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
169
+ "model.layers.16.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
170
+ "model.layers.16.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
171
+ "model.layers.16.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
172
+ "model.layers.16.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
173
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
174
+ "model.layers.16.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
175
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
176
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
177
+ "model.layers.16.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
178
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
179
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
180
+ "model.layers.17.input_layernorm.weight": "model-00002-of-00003.safetensors",
181
+ "model.layers.17.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
182
+ "model.layers.17.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
183
+ "model.layers.17.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
184
+ "model.layers.17.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
185
+ "model.layers.17.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
186
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
187
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
188
+ "model.layers.17.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
189
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
190
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
191
+ "model.layers.18.input_layernorm.weight": "model-00002-of-00003.safetensors",
192
+ "model.layers.18.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
193
+ "model.layers.18.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
194
+ "model.layers.18.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
195
+ "model.layers.18.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
196
+ "model.layers.18.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
197
+ "model.layers.18.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
198
+ "model.layers.18.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
199
+ "model.layers.18.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
200
+ "model.layers.18.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
201
+ "model.layers.18.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
202
+ "model.layers.19.input_layernorm.weight": "model-00002-of-00003.safetensors",
203
+ "model.layers.19.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
204
+ "model.layers.19.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
205
+ "model.layers.19.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
206
+ "model.layers.19.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
207
+ "model.layers.19.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
208
+ "model.layers.19.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
209
+ "model.layers.19.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
210
+ "model.layers.19.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
211
+ "model.layers.19.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
212
+ "model.layers.19.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
213
+ "model.layers.19.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
214
+ "model.layers.19.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
215
+ "model.layers.19.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
216
+ "model.layers.19.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
217
+ "model.layers.19.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
218
+ "model.layers.19.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
219
+ "model.layers.19.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
220
+ "model.layers.19.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
221
+ "model.layers.19.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
222
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00003.safetensors",
223
+ "model.layers.2.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
224
+ "model.layers.2.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
225
+ "model.layers.2.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
226
+ "model.layers.2.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
227
+ "model.layers.2.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
228
+ "model.layers.2.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
229
+ "model.layers.2.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
230
+ "model.layers.2.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
231
+ "model.layers.2.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
232
+ "model.layers.2.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
233
+ "model.layers.2.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
234
+ "model.layers.2.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
235
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
236
+ "model.layers.2.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
237
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
238
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
239
+ "model.layers.2.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
240
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
241
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
242
+ "model.layers.20.input_layernorm.weight": "model-00002-of-00003.safetensors",
243
+ "model.layers.20.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
244
+ "model.layers.20.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
245
+ "model.layers.20.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
246
+ "model.layers.20.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
247
+ "model.layers.20.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
248
+ "model.layers.20.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
249
+ "model.layers.20.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
250
+ "model.layers.20.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
251
+ "model.layers.20.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
252
+ "model.layers.20.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
253
+ "model.layers.20.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
254
+ "model.layers.20.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
255
+ "model.layers.20.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
256
+ "model.layers.20.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
257
+ "model.layers.20.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
258
+ "model.layers.20.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
259
+ "model.layers.20.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
260
+ "model.layers.20.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
261
+ "model.layers.20.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
262
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00003.safetensors",
263
+ "model.layers.21.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
264
+ "model.layers.21.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
265
+ "model.layers.21.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
266
+ "model.layers.21.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
267
+ "model.layers.21.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
268
+ "model.layers.21.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
269
+ "model.layers.21.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
270
+ "model.layers.21.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
271
+ "model.layers.21.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
272
+ "model.layers.21.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
273
+ "model.layers.21.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
274
+ "model.layers.21.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
275
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
276
+ "model.layers.21.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
277
+ "model.layers.21.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
278
+ "model.layers.21.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
279
+ "model.layers.21.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
280
+ "model.layers.21.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
281
+ "model.layers.21.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
282
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00003.safetensors",
283
+ "model.layers.22.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
284
+ "model.layers.22.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
285
+ "model.layers.22.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
286
+ "model.layers.22.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
287
+ "model.layers.22.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
288
+ "model.layers.22.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
289
+ "model.layers.22.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
290
+ "model.layers.22.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
291
+ "model.layers.22.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
292
+ "model.layers.22.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
293
+ "model.layers.22.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
294
+ "model.layers.22.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
295
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
296
+ "model.layers.22.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
297
+ "model.layers.22.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
298
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
299
+ "model.layers.22.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
300
+ "model.layers.22.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
301
+ "model.layers.22.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
302
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00003.safetensors",
303
+ "model.layers.23.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
304
+ "model.layers.23.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
305
+ "model.layers.23.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
306
+ "model.layers.23.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
307
+ "model.layers.23.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
308
+ "model.layers.23.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
309
+ "model.layers.23.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
310
+ "model.layers.23.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
311
+ "model.layers.23.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
312
+ "model.layers.23.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
313
+ "model.layers.23.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
314
+ "model.layers.23.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
315
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
316
+ "model.layers.23.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
317
+ "model.layers.23.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
318
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
319
+ "model.layers.23.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
320
+ "model.layers.23.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
321
+ "model.layers.23.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
322
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00003.safetensors",
323
+ "model.layers.24.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
324
+ "model.layers.24.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
325
+ "model.layers.24.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
326
+ "model.layers.24.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
327
+ "model.layers.24.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
328
+ "model.layers.24.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
329
+ "model.layers.24.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
330
+ "model.layers.24.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
331
+ "model.layers.24.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
332
+ "model.layers.24.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
333
+ "model.layers.24.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
334
+ "model.layers.24.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
335
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
336
+ "model.layers.24.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
337
+ "model.layers.24.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
338
+ "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
339
+ "model.layers.24.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
340
+ "model.layers.24.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
341
+ "model.layers.24.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
342
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00003.safetensors",
343
+ "model.layers.25.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
344
+ "model.layers.25.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
345
+ "model.layers.25.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
346
+ "model.layers.25.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
347
+ "model.layers.25.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
348
+ "model.layers.25.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
349
+ "model.layers.25.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
350
+ "model.layers.25.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
351
+ "model.layers.25.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
352
+ "model.layers.25.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
353
+ "model.layers.25.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
354
+ "model.layers.25.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
355
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
356
+ "model.layers.25.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
357
+ "model.layers.25.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
358
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
359
+ "model.layers.25.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
360
+ "model.layers.25.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
361
+ "model.layers.25.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
362
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00003.safetensors",
363
+ "model.layers.26.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
364
+ "model.layers.26.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
365
+ "model.layers.26.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
366
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
367
+ "model.layers.26.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
368
+ "model.layers.26.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
369
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
370
+ "model.layers.26.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
371
+ "model.layers.26.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
372
+ "model.layers.26.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
373
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00003.safetensors",
374
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
375
+ "model.layers.27.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
376
+ "model.layers.27.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
377
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
378
+ "model.layers.27.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
379
+ "model.layers.27.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
380
+ "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
381
+ "model.layers.27.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
382
+ "model.layers.27.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
383
+ "model.layers.27.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
384
+ "model.layers.28.input_layernorm.weight": "model-00002-of-00003.safetensors",
385
+ "model.layers.28.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
386
+ "model.layers.28.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
387
+ "model.layers.28.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
388
+ "model.layers.28.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
389
+ "model.layers.28.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
390
+ "model.layers.28.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
391
+ "model.layers.28.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
392
+ "model.layers.28.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
393
+ "model.layers.28.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
394
+ "model.layers.28.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
395
+ "model.layers.28.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
396
+ "model.layers.28.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
397
+ "model.layers.28.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
398
+ "model.layers.28.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
399
+ "model.layers.28.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
400
+ "model.layers.28.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
401
+ "model.layers.28.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
402
+ "model.layers.28.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
403
+ "model.layers.28.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
404
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00003.safetensors",
405
+ "model.layers.29.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
406
+ "model.layers.29.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
407
+ "model.layers.29.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
408
+ "model.layers.29.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
409
+ "model.layers.29.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
410
+ "model.layers.29.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
411
+ "model.layers.29.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
412
+ "model.layers.29.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
413
+ "model.layers.29.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
414
+ "model.layers.29.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
415
+ "model.layers.29.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
416
+ "model.layers.29.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
417
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
418
+ "model.layers.29.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
419
+ "model.layers.29.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
420
+ "model.layers.29.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
421
+ "model.layers.29.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
422
+ "model.layers.29.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
423
+ "model.layers.29.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
424
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00003.safetensors",
425
+ "model.layers.3.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
426
+ "model.layers.3.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
427
+ "model.layers.3.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
428
+ "model.layers.3.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
429
+ "model.layers.3.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
430
+ "model.layers.3.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
431
+ "model.layers.3.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
432
+ "model.layers.3.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
433
+ "model.layers.3.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
434
+ "model.layers.3.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
435
+ "model.layers.3.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
436
+ "model.layers.3.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
437
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
438
+ "model.layers.3.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
439
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
440
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
441
+ "model.layers.3.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
442
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
443
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
444
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00003.safetensors",
445
+ "model.layers.30.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
446
+ "model.layers.30.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
447
+ "model.layers.30.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
448
+ "model.layers.30.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
449
+ "model.layers.30.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
450
+ "model.layers.30.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
451
+ "model.layers.30.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
452
+ "model.layers.30.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
453
+ "model.layers.30.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
454
+ "model.layers.30.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
455
+ "model.layers.30.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
456
+ "model.layers.30.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
457
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
458
+ "model.layers.30.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
459
+ "model.layers.30.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
460
+ "model.layers.30.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
461
+ "model.layers.30.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
462
+ "model.layers.30.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
463
+ "model.layers.30.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
464
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00003.safetensors",
465
+ "model.layers.31.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
466
+ "model.layers.31.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
467
+ "model.layers.31.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
468
+ "model.layers.31.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
469
+ "model.layers.31.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
470
+ "model.layers.31.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
471
+ "model.layers.31.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
472
+ "model.layers.31.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
473
+ "model.layers.31.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
474
+ "model.layers.31.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
475
+ "model.layers.31.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
476
+ "model.layers.31.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
477
+ "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
478
+ "model.layers.31.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
479
+ "model.layers.31.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
480
+ "model.layers.31.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
481
+ "model.layers.31.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
482
+ "model.layers.31.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
483
+ "model.layers.31.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
484
+ "model.layers.32.input_layernorm.weight": "model-00002-of-00003.safetensors",
485
+ "model.layers.32.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
486
+ "model.layers.32.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
487
+ "model.layers.32.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
488
+ "model.layers.32.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
489
+ "model.layers.32.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
490
+ "model.layers.32.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
491
+ "model.layers.32.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
492
+ "model.layers.32.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
493
+ "model.layers.32.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
494
+ "model.layers.32.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
495
+ "model.layers.32.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
496
+ "model.layers.32.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
497
+ "model.layers.32.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
498
+ "model.layers.32.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
499
+ "model.layers.32.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
500
+ "model.layers.32.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
501
+ "model.layers.32.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
502
+ "model.layers.32.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
503
+ "model.layers.32.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
504
+ "model.layers.33.input_layernorm.weight": "model-00002-of-00003.safetensors",
505
+ "model.layers.33.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
506
+ "model.layers.33.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
507
+ "model.layers.33.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
508
+ "model.layers.33.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
509
+ "model.layers.33.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
510
+ "model.layers.33.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
511
+ "model.layers.33.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
512
+ "model.layers.33.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
513
+ "model.layers.33.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
514
+ "model.layers.33.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
515
+ "model.layers.33.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
516
+ "model.layers.33.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
517
+ "model.layers.33.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
518
+ "model.layers.33.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
519
+ "model.layers.33.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
520
+ "model.layers.33.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
521
+ "model.layers.33.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
522
+ "model.layers.33.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
523
+ "model.layers.33.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
524
+ "model.layers.34.input_layernorm.weight": "model-00002-of-00003.safetensors",
525
+ "model.layers.34.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
526
+ "model.layers.34.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
527
+ "model.layers.34.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
528
+ "model.layers.34.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
529
+ "model.layers.34.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
530
+ "model.layers.34.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
531
+ "model.layers.34.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
532
+ "model.layers.34.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
533
+ "model.layers.34.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
534
+ "model.layers.34.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
535
+ "model.layers.34.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
536
+ "model.layers.34.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
537
+ "model.layers.34.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
538
+ "model.layers.34.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
539
+ "model.layers.34.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
540
+ "model.layers.34.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
541
+ "model.layers.34.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
542
+ "model.layers.34.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
543
+ "model.layers.34.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
544
+ "model.layers.35.input_layernorm.weight": "model-00002-of-00003.safetensors",
545
+ "model.layers.35.mlp.down_proj.input_global_scale": "model-00002-of-00003.safetensors",
546
+ "model.layers.35.mlp.down_proj.weight_global_scale": "model-00002-of-00003.safetensors",
547
+ "model.layers.35.mlp.down_proj.weight_packed": "model-00002-of-00003.safetensors",
548
+ "model.layers.35.mlp.down_proj.weight_scale": "model-00002-of-00003.safetensors",
549
+ "model.layers.35.mlp.gate_proj.input_global_scale": "model-00002-of-00003.safetensors",
550
+ "model.layers.35.mlp.gate_proj.weight_global_scale": "model-00002-of-00003.safetensors",
551
+ "model.layers.35.mlp.gate_proj.weight_packed": "model-00002-of-00003.safetensors",
552
+ "model.layers.35.mlp.gate_proj.weight_scale": "model-00002-of-00003.safetensors",
553
+ "model.layers.35.mlp.up_proj.input_global_scale": "model-00002-of-00003.safetensors",
554
+ "model.layers.35.mlp.up_proj.weight_global_scale": "model-00002-of-00003.safetensors",
555
+ "model.layers.35.mlp.up_proj.weight_packed": "model-00002-of-00003.safetensors",
556
+ "model.layers.35.mlp.up_proj.weight_scale": "model-00002-of-00003.safetensors",
557
+ "model.layers.35.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
558
+ "model.layers.35.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
559
+ "model.layers.35.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
560
+ "model.layers.35.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
561
+ "model.layers.35.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
562
+ "model.layers.35.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
563
+ "model.layers.35.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
564
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00003.safetensors",
565
+ "model.layers.4.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
566
+ "model.layers.4.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
567
+ "model.layers.4.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
568
+ "model.layers.4.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
569
+ "model.layers.4.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
570
+ "model.layers.4.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
571
+ "model.layers.4.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
572
+ "model.layers.4.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
573
+ "model.layers.4.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
574
+ "model.layers.4.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
575
+ "model.layers.4.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
576
+ "model.layers.4.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
577
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
578
+ "model.layers.4.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
579
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
580
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
581
+ "model.layers.4.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
582
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
583
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
584
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00003.safetensors",
585
+ "model.layers.5.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
586
+ "model.layers.5.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
587
+ "model.layers.5.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
588
+ "model.layers.5.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
589
+ "model.layers.5.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
590
+ "model.layers.5.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
591
+ "model.layers.5.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
592
+ "model.layers.5.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
593
+ "model.layers.5.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
594
+ "model.layers.5.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
595
+ "model.layers.5.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
596
+ "model.layers.5.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
597
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
598
+ "model.layers.5.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
599
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
600
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
601
+ "model.layers.5.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
602
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
603
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
604
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00003.safetensors",
605
+ "model.layers.6.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
606
+ "model.layers.6.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
607
+ "model.layers.6.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
608
+ "model.layers.6.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
609
+ "model.layers.6.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
610
+ "model.layers.6.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
611
+ "model.layers.6.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
612
+ "model.layers.6.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
613
+ "model.layers.6.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
614
+ "model.layers.6.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
615
+ "model.layers.6.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
616
+ "model.layers.6.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
617
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
618
+ "model.layers.6.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
619
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
620
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
621
+ "model.layers.6.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
622
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
623
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
624
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00003.safetensors",
625
+ "model.layers.7.mlp.down_proj.input_global_scale": "model-00001-of-00003.safetensors",
626
+ "model.layers.7.mlp.down_proj.weight_global_scale": "model-00001-of-00003.safetensors",
627
+ "model.layers.7.mlp.down_proj.weight_packed": "model-00001-of-00003.safetensors",
628
+ "model.layers.7.mlp.down_proj.weight_scale": "model-00001-of-00003.safetensors",
629
+ "model.layers.7.mlp.gate_proj.input_global_scale": "model-00001-of-00003.safetensors",
630
+ "model.layers.7.mlp.gate_proj.weight_global_scale": "model-00001-of-00003.safetensors",
631
+ "model.layers.7.mlp.gate_proj.weight_packed": "model-00001-of-00003.safetensors",
632
+ "model.layers.7.mlp.gate_proj.weight_scale": "model-00001-of-00003.safetensors",
633
+ "model.layers.7.mlp.up_proj.input_global_scale": "model-00001-of-00003.safetensors",
634
+ "model.layers.7.mlp.up_proj.weight_global_scale": "model-00001-of-00003.safetensors",
635
+ "model.layers.7.mlp.up_proj.weight_packed": "model-00001-of-00003.safetensors",
636
+ "model.layers.7.mlp.up_proj.weight_scale": "model-00001-of-00003.safetensors",
637
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
638
+ "model.layers.7.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
639
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
640
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
641
+ "model.layers.7.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
642
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
643
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
644
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00003.safetensors",
645
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
646
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
647
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
648
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
649
+ "model.layers.8.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
650
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
651
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
652
+ "model.layers.8.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
653
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
654
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
655
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00003.safetensors",
656
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
657
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
658
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
659
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
660
+ "model.layers.9.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
661
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
662
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
663
+ "model.layers.9.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
664
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
665
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
666
+ "model.norm.weight": "model-00002-of-00003.safetensors"
667
+ }
668
+ }
recipe.yaml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ default_stage:
2
+ default_modifiers:
3
+ QuantizationModifier:
4
+ targets: [Linear]
5
+ ignore: [lm_head, 're:.*self_attn.*', 're:.*layers\.(0|8|9|17|18|26|27)\.mlp.*']
6
+ scheme: NVFP4
special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:352a863cd2761388ccc58f1432467ba6a1037bf12df9069889b142fa246471f6
3
+ size 11422752
tokenizer_config.json ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ },
181
+ "151665": {
182
+ "content": "<tool_response>",
183
+ "lstrip": false,
184
+ "normalized": false,
185
+ "rstrip": false,
186
+ "single_word": false,
187
+ "special": false
188
+ },
189
+ "151666": {
190
+ "content": "</tool_response>",
191
+ "lstrip": false,
192
+ "normalized": false,
193
+ "rstrip": false,
194
+ "single_word": false,
195
+ "special": false
196
+ },
197
+ "151667": {
198
+ "content": "<think>",
199
+ "lstrip": false,
200
+ "normalized": false,
201
+ "rstrip": false,
202
+ "single_word": false,
203
+ "special": false
204
+ },
205
+ "151668": {
206
+ "content": "</think>",
207
+ "lstrip": false,
208
+ "normalized": false,
209
+ "rstrip": false,
210
+ "single_word": false,
211
+ "special": false
212
+ }
213
+ },
214
+ "additional_special_tokens": [
215
+ "<|im_start|>",
216
+ "<|im_end|>",
217
+ "<|object_ref_start|>",
218
+ "<|object_ref_end|>",
219
+ "<|box_start|>",
220
+ "<|box_end|>",
221
+ "<|quad_start|>",
222
+ "<|quad_end|>",
223
+ "<|vision_start|>",
224
+ "<|vision_end|>",
225
+ "<|vision_pad|>",
226
+ "<|image_pad|>",
227
+ "<|video_pad|>"
228
+ ],
229
+ "bos_token": null,
230
+ "clean_up_tokenization_spaces": false,
231
+ "eos_token": "<|im_end|>",
232
+ "errors": "replace",
233
+ "extra_special_tokens": {},
234
+ "model_max_length": 131072,
235
+ "pad_token": "<|endoftext|>",
236
+ "split_special_tokens": false,
237
+ "tokenizer_class": "Qwen2Tokenizer",
238
+ "unk_token": null
239
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff