ushakov15 commited on
Commit
35ad87a
·
verified ·
1 Parent(s): ff41259

Initial commit with copied model

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,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "[PAD]": 151669
29
+ }
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151643,
9
+ "head_dim": 128,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 1024,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "max_position_embeddings": 32768,
15
+ "max_window_layers": 28,
16
+ "model_type": "qwen3",
17
+ "num_attention_heads": 16,
18
+ "num_hidden_layers": 28,
19
+ "num_key_value_heads": 8,
20
+ "parallel_config": {
21
+ "parallel_style": "none",
22
+ "pipeline_parallel": 1,
23
+ "tensor_parallel": 1
24
+ },
25
+ "rms_norm_eps": 1e-06,
26
+ "rope_scaling": null,
27
+ "rope_theta": 1000000,
28
+ "sliding_window": null,
29
+ "tie_word_embeddings": true,
30
+ "torch_dtype": "bfloat16",
31
+ "transformers_version": "4.51.3",
32
+ "use_cache": false,
33
+ "use_sliding_window": false,
34
+ "vocab_size": 151936
35
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "eos_token_id": 151643,
4
+ "max_new_tokens": 2048,
5
+ "transformers_version": "4.51.3"
6
+ }
global_step3290/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a624e108def6d9b6e5f79d65e016767c64279fa06340d33ce8c9aaac122b507
3
+ size 894080304
global_step3290/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e07ed15aebd22a73ecc47b886681de6325383497b853fb19bd527d5a8632329
3
+ size 1192188984
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step3290
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf80bd478e6f9fa957d71bd9ffb37f7be681d3aff710158e1e7c65b64e847c34
3
+ size 1503300328
rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92cc13315f24c28015d695b6cde08bb1cd6fea4cbc435998485ed6fbe4c91285
3
+ size 15024
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8594aab587aa802e1e2bcfff77510f83c4ab060c0fa208567fb10200d8e606f9
3
+ size 1064
special_tokens_map.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "<|endoftext|>",
18
+ "pad_token": {
19
+ "content": "[PAD]",
20
+ "lstrip": false,
21
+ "normalized": false,
22
+ "rstrip": false,
23
+ "single_word": false
24
+ }
25
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ea50a7b472ec8fecfd70e281c476f75a704a92a72cbeb4efbb880e1a9e3a67d
3
+ size 11422836
tokenizer_config.json ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "151669": {
214
+ "content": "[PAD]",
215
+ "lstrip": false,
216
+ "normalized": false,
217
+ "rstrip": false,
218
+ "single_word": false,
219
+ "special": true
220
+ }
221
+ },
222
+ "additional_special_tokens": [
223
+ "<|im_start|>",
224
+ "<|im_end|>",
225
+ "<|object_ref_start|>",
226
+ "<|object_ref_end|>",
227
+ "<|box_start|>",
228
+ "<|box_end|>",
229
+ "<|quad_start|>",
230
+ "<|quad_end|>",
231
+ "<|vision_start|>",
232
+ "<|vision_end|>",
233
+ "<|vision_pad|>",
234
+ "<|image_pad|>",
235
+ "<|video_pad|>"
236
+ ],
237
+ "bos_token": null,
238
+ "chat_template": "{% for message in messages %}\n<|im_start|>{{ message.role }}\n{{ message.content }}<|im_end|>\n{% endfor %}\n{% if add_generation_prompt %}\n<|im_start|>assistant\n{% endif %}",
239
+ "clean_up_tokenization_spaces": false,
240
+ "eos_token": "<|endoftext|>",
241
+ "errors": "replace",
242
+ "extra_special_tokens": {},
243
+ "model_max_length": 131072,
244
+ "pad_token": "[PAD]",
245
+ "padding_side": "right",
246
+ "split_special_tokens": false,
247
+ "tokenizer_class": "Qwen2Tokenizer",
248
+ "unk_token": null
249
+ }
trainer_state.json ADDED
@@ -0,0 +1,1222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.9999240179317681,
6
+ "eval_steps": 160,
7
+ "global_step": 3290,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.0003039282729275891,
14
+ "grad_norm": 5.229409217834473,
15
+ "learning_rate": 0.0,
16
+ "loss": 1.2164,
17
+ "mean_token_accuracy": 0.7386507540941238,
18
+ "num_tokens": 87378.0,
19
+ "step": 1
20
+ },
21
+ {
22
+ "epoch": 0.007598206823189727,
23
+ "grad_norm": 4.077776908874512,
24
+ "learning_rate": 1.2121212121212122e-06,
25
+ "loss": 1.3951,
26
+ "mean_token_accuracy": 0.7043480854481459,
27
+ "num_tokens": 2555177.0,
28
+ "step": 25
29
+ },
30
+ {
31
+ "epoch": 0.015196413646379454,
32
+ "grad_norm": 3.2261855602264404,
33
+ "learning_rate": 2.474747474747475e-06,
34
+ "loss": 1.3716,
35
+ "mean_token_accuracy": 0.7009463596343994,
36
+ "num_tokens": 5171296.0,
37
+ "step": 50
38
+ },
39
+ {
40
+ "epoch": 0.02279462046956918,
41
+ "grad_norm": 1.221886396408081,
42
+ "learning_rate": 3.737373737373738e-06,
43
+ "loss": 1.2697,
44
+ "mean_token_accuracy": 0.7165025919675827,
45
+ "num_tokens": 7791520.0,
46
+ "step": 75
47
+ },
48
+ {
49
+ "epoch": 0.030392827292758908,
50
+ "grad_norm": 1.2025024890899658,
51
+ "learning_rate": 5e-06,
52
+ "loss": 1.2611,
53
+ "mean_token_accuracy": 0.7154420650005341,
54
+ "num_tokens": 10428214.0,
55
+ "step": 100
56
+ },
57
+ {
58
+ "epoch": 0.03799103411594864,
59
+ "grad_norm": 1.2315771579742432,
60
+ "learning_rate": 4.960827326856785e-06,
61
+ "loss": 1.2618,
62
+ "mean_token_accuracy": 0.7133645015954971,
63
+ "num_tokens": 13035315.0,
64
+ "step": 125
65
+ },
66
+ {
67
+ "epoch": 0.04558924093913836,
68
+ "grad_norm": 1.1814574003219604,
69
+ "learning_rate": 4.92165465371357e-06,
70
+ "loss": 1.2494,
71
+ "mean_token_accuracy": 0.7152758586406708,
72
+ "num_tokens": 15555229.0,
73
+ "step": 150
74
+ },
75
+ {
76
+ "epoch": 0.05318744776232809,
77
+ "grad_norm": 1.0967789888381958,
78
+ "learning_rate": 4.882481980570354e-06,
79
+ "loss": 1.1929,
80
+ "mean_token_accuracy": 0.7268460893630981,
81
+ "num_tokens": 18110892.0,
82
+ "step": 175
83
+ },
84
+ {
85
+ "epoch": 0.060785654585517816,
86
+ "grad_norm": 1.38316011428833,
87
+ "learning_rate": 4.843309307427139e-06,
88
+ "loss": 1.2274,
89
+ "mean_token_accuracy": 0.7177506709098815,
90
+ "num_tokens": 20638485.0,
91
+ "step": 200
92
+ },
93
+ {
94
+ "epoch": 0.06838386140870754,
95
+ "grad_norm": 1.1938471794128418,
96
+ "learning_rate": 4.804136634283924e-06,
97
+ "loss": 1.2036,
98
+ "mean_token_accuracy": 0.7217154312133789,
99
+ "num_tokens": 23186502.0,
100
+ "step": 225
101
+ },
102
+ {
103
+ "epoch": 0.07598206823189728,
104
+ "grad_norm": 1.2482621669769287,
105
+ "learning_rate": 4.764963961140708e-06,
106
+ "loss": 1.1962,
107
+ "mean_token_accuracy": 0.7237263369560242,
108
+ "num_tokens": 25737398.0,
109
+ "step": 250
110
+ },
111
+ {
112
+ "epoch": 0.083580275055087,
113
+ "grad_norm": 0.9959760308265686,
114
+ "learning_rate": 4.725791287997493e-06,
115
+ "loss": 1.1908,
116
+ "mean_token_accuracy": 0.7237645584344864,
117
+ "num_tokens": 28386635.0,
118
+ "step": 275
119
+ },
120
+ {
121
+ "epoch": 0.09117848187827672,
122
+ "grad_norm": 1.1848807334899902,
123
+ "learning_rate": 4.686618614854278e-06,
124
+ "loss": 1.1968,
125
+ "mean_token_accuracy": 0.7229974180459976,
126
+ "num_tokens": 30963803.0,
127
+ "step": 300
128
+ },
129
+ {
130
+ "epoch": 0.09877668870146646,
131
+ "grad_norm": 1.3056175708770752,
132
+ "learning_rate": 4.647445941711063e-06,
133
+ "loss": 1.1937,
134
+ "mean_token_accuracy": 0.7229531377553939,
135
+ "num_tokens": 33594219.0,
136
+ "step": 325
137
+ },
138
+ {
139
+ "epoch": 0.10637489552465618,
140
+ "grad_norm": 1.135485053062439,
141
+ "learning_rate": 4.608273268567847e-06,
142
+ "loss": 1.1815,
143
+ "mean_token_accuracy": 0.724581116437912,
144
+ "num_tokens": 36131516.0,
145
+ "step": 350
146
+ },
147
+ {
148
+ "epoch": 0.11397310234784591,
149
+ "grad_norm": 0.9885596036911011,
150
+ "learning_rate": 4.569100595424632e-06,
151
+ "loss": 1.1588,
152
+ "mean_token_accuracy": 0.7286039453744888,
153
+ "num_tokens": 38679243.0,
154
+ "step": 375
155
+ },
156
+ {
157
+ "epoch": 0.12157130917103563,
158
+ "grad_norm": 0.9995855093002319,
159
+ "learning_rate": 4.529927922281417e-06,
160
+ "loss": 1.1754,
161
+ "mean_token_accuracy": 0.7271614295244216,
162
+ "num_tokens": 41253914.0,
163
+ "step": 400
164
+ },
165
+ {
166
+ "epoch": 0.12916951599422535,
167
+ "grad_norm": 0.9095941185951233,
168
+ "learning_rate": 4.490755249138202e-06,
169
+ "loss": 1.2398,
170
+ "mean_token_accuracy": 0.7160615402460099,
171
+ "num_tokens": 43939124.0,
172
+ "step": 425
173
+ },
174
+ {
175
+ "epoch": 0.1367677228174151,
176
+ "grad_norm": 1.0696874856948853,
177
+ "learning_rate": 4.451582575994986e-06,
178
+ "loss": 1.183,
179
+ "mean_token_accuracy": 0.7253994250297546,
180
+ "num_tokens": 46572312.0,
181
+ "step": 450
182
+ },
183
+ {
184
+ "epoch": 0.14436592964060482,
185
+ "grad_norm": 1.0358718633651733,
186
+ "learning_rate": 4.41240990285177e-06,
187
+ "loss": 1.1931,
188
+ "mean_token_accuracy": 0.7237947028875351,
189
+ "num_tokens": 49064213.0,
190
+ "step": 475
191
+ },
192
+ {
193
+ "epoch": 0.15196413646379456,
194
+ "grad_norm": 0.9893081784248352,
195
+ "learning_rate": 4.373237229708556e-06,
196
+ "loss": 1.1951,
197
+ "mean_token_accuracy": 0.7238883310556412,
198
+ "num_tokens": 51663643.0,
199
+ "step": 500
200
+ },
201
+ {
202
+ "epoch": 0.15956234328698427,
203
+ "grad_norm": 1.0677660703659058,
204
+ "learning_rate": 4.334064556565341e-06,
205
+ "loss": 1.1721,
206
+ "mean_token_accuracy": 0.7265544033050537,
207
+ "num_tokens": 54161634.0,
208
+ "step": 525
209
+ },
210
+ {
211
+ "epoch": 0.167160550110174,
212
+ "grad_norm": 0.8927258849143982,
213
+ "learning_rate": 4.294891883422124e-06,
214
+ "loss": 1.1685,
215
+ "mean_token_accuracy": 0.7285602086782456,
216
+ "num_tokens": 56784150.0,
217
+ "step": 550
218
+ },
219
+ {
220
+ "epoch": 0.17475875693336373,
221
+ "grad_norm": 0.9111976027488708,
222
+ "learning_rate": 4.25571921027891e-06,
223
+ "loss": 1.1562,
224
+ "mean_token_accuracy": 0.7312729161977768,
225
+ "num_tokens": 59382430.0,
226
+ "step": 575
227
+ },
228
+ {
229
+ "epoch": 0.18235696375655344,
230
+ "grad_norm": 0.8939260244369507,
231
+ "learning_rate": 4.216546537135695e-06,
232
+ "loss": 1.1818,
233
+ "mean_token_accuracy": 0.7256826394796372,
234
+ "num_tokens": 61928694.0,
235
+ "step": 600
236
+ },
237
+ {
238
+ "epoch": 0.18995517057974318,
239
+ "grad_norm": 0.9611142873764038,
240
+ "learning_rate": 4.177373863992479e-06,
241
+ "loss": 1.1793,
242
+ "mean_token_accuracy": 0.7260627967119216,
243
+ "num_tokens": 64496365.0,
244
+ "step": 625
245
+ },
246
+ {
247
+ "epoch": 0.1975533774029329,
248
+ "grad_norm": 0.9116730690002441,
249
+ "learning_rate": 4.138201190849264e-06,
250
+ "loss": 1.149,
251
+ "mean_token_accuracy": 0.7322022247314454,
252
+ "num_tokens": 67108712.0,
253
+ "step": 650
254
+ },
255
+ {
256
+ "epoch": 0.20515158422612265,
257
+ "grad_norm": 0.9878592491149902,
258
+ "learning_rate": 4.099028517706049e-06,
259
+ "loss": 1.1509,
260
+ "mean_token_accuracy": 0.7325534474849701,
261
+ "num_tokens": 69702021.0,
262
+ "step": 675
263
+ },
264
+ {
265
+ "epoch": 0.21274979104931235,
266
+ "grad_norm": 0.9378741979598999,
267
+ "learning_rate": 4.059855844562833e-06,
268
+ "loss": 1.1801,
269
+ "mean_token_accuracy": 0.727109580039978,
270
+ "num_tokens": 72301699.0,
271
+ "step": 700
272
+ },
273
+ {
274
+ "epoch": 0.2203479978725021,
275
+ "grad_norm": 1.0023488998413086,
276
+ "learning_rate": 4.020683171419618e-06,
277
+ "loss": 1.1814,
278
+ "mean_token_accuracy": 0.7265605771541596,
279
+ "num_tokens": 74824515.0,
280
+ "step": 725
281
+ },
282
+ {
283
+ "epoch": 0.22794620469569182,
284
+ "grad_norm": 0.9925772547721863,
285
+ "learning_rate": 3.981510498276403e-06,
286
+ "loss": 1.1932,
287
+ "mean_token_accuracy": 0.7241325139999389,
288
+ "num_tokens": 77468439.0,
289
+ "step": 750
290
+ },
291
+ {
292
+ "epoch": 0.23554441151888153,
293
+ "grad_norm": 1.0404661893844604,
294
+ "learning_rate": 3.942337825133187e-06,
295
+ "loss": 1.1525,
296
+ "mean_token_accuracy": 0.7301458239555358,
297
+ "num_tokens": 80143332.0,
298
+ "step": 775
299
+ },
300
+ {
301
+ "epoch": 0.24314261834207127,
302
+ "grad_norm": 0.9634000062942505,
303
+ "learning_rate": 3.903165151989972e-06,
304
+ "loss": 1.1691,
305
+ "mean_token_accuracy": 0.7280007082223893,
306
+ "num_tokens": 82731678.0,
307
+ "step": 800
308
+ },
309
+ {
310
+ "epoch": 0.25074082516526097,
311
+ "grad_norm": 0.9083330631256104,
312
+ "learning_rate": 3.863992478846757e-06,
313
+ "loss": 1.1272,
314
+ "mean_token_accuracy": 0.7353595513105392,
315
+ "num_tokens": 85345821.0,
316
+ "step": 825
317
+ },
318
+ {
319
+ "epoch": 0.2583390319884507,
320
+ "grad_norm": 0.9275352358818054,
321
+ "learning_rate": 3.824819805703541e-06,
322
+ "loss": 1.1558,
323
+ "mean_token_accuracy": 0.7300055593252182,
324
+ "num_tokens": 87948235.0,
325
+ "step": 850
326
+ },
327
+ {
328
+ "epoch": 0.26593723881164044,
329
+ "grad_norm": 0.9232833385467529,
330
+ "learning_rate": 3.785647132560326e-06,
331
+ "loss": 1.162,
332
+ "mean_token_accuracy": 0.7284415501356125,
333
+ "num_tokens": 90574681.0,
334
+ "step": 875
335
+ },
336
+ {
337
+ "epoch": 0.2735354456348302,
338
+ "grad_norm": 1.131739854812622,
339
+ "learning_rate": 3.746474459417111e-06,
340
+ "loss": 1.1697,
341
+ "mean_token_accuracy": 0.7278369426727295,
342
+ "num_tokens": 93215297.0,
343
+ "step": 900
344
+ },
345
+ {
346
+ "epoch": 0.2811336524580199,
347
+ "grad_norm": 0.9522098898887634,
348
+ "learning_rate": 3.7073017862738957e-06,
349
+ "loss": 1.1846,
350
+ "mean_token_accuracy": 0.7259439510107041,
351
+ "num_tokens": 95791861.0,
352
+ "step": 925
353
+ },
354
+ {
355
+ "epoch": 0.28873185928120965,
356
+ "grad_norm": 1.0696117877960205,
357
+ "learning_rate": 3.66812911313068e-06,
358
+ "loss": 1.1394,
359
+ "mean_token_accuracy": 0.733702262043953,
360
+ "num_tokens": 98410562.0,
361
+ "step": 950
362
+ },
363
+ {
364
+ "epoch": 0.2963300661043994,
365
+ "grad_norm": 0.9875262379646301,
366
+ "learning_rate": 3.628956439987465e-06,
367
+ "loss": 1.1214,
368
+ "mean_token_accuracy": 0.7367280977964401,
369
+ "num_tokens": 101018834.0,
370
+ "step": 975
371
+ },
372
+ {
373
+ "epoch": 0.3039282729275891,
374
+ "grad_norm": 1.0046495199203491,
375
+ "learning_rate": 3.5897837668442497e-06,
376
+ "loss": 1.1471,
377
+ "mean_token_accuracy": 0.7323124688863755,
378
+ "num_tokens": 103548660.0,
379
+ "step": 1000
380
+ },
381
+ {
382
+ "epoch": 0.3115264797507788,
383
+ "grad_norm": 0.9220812320709229,
384
+ "learning_rate": 3.550611093701035e-06,
385
+ "loss": 1.1144,
386
+ "mean_token_accuracy": 0.7385808283090591,
387
+ "num_tokens": 106144886.0,
388
+ "step": 1025
389
+ },
390
+ {
391
+ "epoch": 0.31912468657396853,
392
+ "grad_norm": 0.84840327501297,
393
+ "learning_rate": 3.511438420557819e-06,
394
+ "loss": 1.1292,
395
+ "mean_token_accuracy": 0.7352547180652619,
396
+ "num_tokens": 108737841.0,
397
+ "step": 1050
398
+ },
399
+ {
400
+ "epoch": 0.32672289339715826,
401
+ "grad_norm": 0.9784463047981262,
402
+ "learning_rate": 3.4722657474146037e-06,
403
+ "loss": 1.1397,
404
+ "mean_token_accuracy": 0.7329702425003052,
405
+ "num_tokens": 111263726.0,
406
+ "step": 1075
407
+ },
408
+ {
409
+ "epoch": 0.334321100220348,
410
+ "grad_norm": 0.9851428270339966,
411
+ "learning_rate": 3.433093074271389e-06,
412
+ "loss": 1.1522,
413
+ "mean_token_accuracy": 0.7319200646877289,
414
+ "num_tokens": 113862710.0,
415
+ "step": 1100
416
+ },
417
+ {
418
+ "epoch": 0.34191930704353773,
419
+ "grad_norm": 1.0207332372665405,
420
+ "learning_rate": 3.3939204011281735e-06,
421
+ "loss": 1.1596,
422
+ "mean_token_accuracy": 0.7311873000860214,
423
+ "num_tokens": 116455029.0,
424
+ "step": 1125
425
+ },
426
+ {
427
+ "epoch": 0.34951751386672747,
428
+ "grad_norm": 1.057591199874878,
429
+ "learning_rate": 3.3547477279849577e-06,
430
+ "loss": 1.1469,
431
+ "mean_token_accuracy": 0.7317946165800094,
432
+ "num_tokens": 119016227.0,
433
+ "step": 1150
434
+ },
435
+ {
436
+ "epoch": 0.3571157206899172,
437
+ "grad_norm": 0.8993873596191406,
438
+ "learning_rate": 3.3155750548417424e-06,
439
+ "loss": 1.166,
440
+ "mean_token_accuracy": 0.7290427106618881,
441
+ "num_tokens": 121623537.0,
442
+ "step": 1175
443
+ },
444
+ {
445
+ "epoch": 0.3647139275131069,
446
+ "grad_norm": 0.9834045171737671,
447
+ "learning_rate": 3.2764023816985275e-06,
448
+ "loss": 1.1433,
449
+ "mean_token_accuracy": 0.7334721457958221,
450
+ "num_tokens": 124161994.0,
451
+ "step": 1200
452
+ },
453
+ {
454
+ "epoch": 0.3723121343362966,
455
+ "grad_norm": 0.9397407174110413,
456
+ "learning_rate": 3.237229708555312e-06,
457
+ "loss": 1.1613,
458
+ "mean_token_accuracy": 0.7288734668493271,
459
+ "num_tokens": 126771313.0,
460
+ "step": 1225
461
+ },
462
+ {
463
+ "epoch": 0.37991034115948635,
464
+ "grad_norm": 0.8688826560974121,
465
+ "learning_rate": 3.1980570354120964e-06,
466
+ "loss": 1.1314,
467
+ "mean_token_accuracy": 0.7348222607374191,
468
+ "num_tokens": 129372256.0,
469
+ "step": 1250
470
+ },
471
+ {
472
+ "epoch": 0.3875085479826761,
473
+ "grad_norm": 0.9596332311630249,
474
+ "learning_rate": 3.1588843622688815e-06,
475
+ "loss": 1.1771,
476
+ "mean_token_accuracy": 0.7289222145080566,
477
+ "num_tokens": 132004952.0,
478
+ "step": 1275
479
+ },
480
+ {
481
+ "epoch": 0.3951067548058658,
482
+ "grad_norm": 0.8962276577949524,
483
+ "learning_rate": 3.119711689125666e-06,
484
+ "loss": 1.13,
485
+ "mean_token_accuracy": 0.7361785328388214,
486
+ "num_tokens": 134597308.0,
487
+ "step": 1300
488
+ },
489
+ {
490
+ "epoch": 0.40270496162905556,
491
+ "grad_norm": 0.9526214599609375,
492
+ "learning_rate": 3.0805390159824512e-06,
493
+ "loss": 1.1279,
494
+ "mean_token_accuracy": 0.7370401775836944,
495
+ "num_tokens": 137154477.0,
496
+ "step": 1325
497
+ },
498
+ {
499
+ "epoch": 0.4103031684522453,
500
+ "grad_norm": 0.9959564208984375,
501
+ "learning_rate": 3.0413663428392355e-06,
502
+ "loss": 1.1501,
503
+ "mean_token_accuracy": 0.7321191453933715,
504
+ "num_tokens": 139811600.0,
505
+ "step": 1350
506
+ },
507
+ {
508
+ "epoch": 0.41790137527543497,
509
+ "grad_norm": 0.8501905798912048,
510
+ "learning_rate": 3.00219366969602e-06,
511
+ "loss": 1.1509,
512
+ "mean_token_accuracy": 0.7308077716827392,
513
+ "num_tokens": 142453993.0,
514
+ "step": 1375
515
+ },
516
+ {
517
+ "epoch": 0.4254995820986247,
518
+ "grad_norm": 0.913529098033905,
519
+ "learning_rate": 2.9630209965528052e-06,
520
+ "loss": 1.1338,
521
+ "mean_token_accuracy": 0.7351639837026596,
522
+ "num_tokens": 144957196.0,
523
+ "step": 1400
524
+ },
525
+ {
526
+ "epoch": 0.43309778892181444,
527
+ "grad_norm": 0.9400737285614014,
528
+ "learning_rate": 2.92384832340959e-06,
529
+ "loss": 1.1322,
530
+ "mean_token_accuracy": 0.7360527998209,
531
+ "num_tokens": 147574322.0,
532
+ "step": 1425
533
+ },
534
+ {
535
+ "epoch": 0.4406959957450042,
536
+ "grad_norm": 0.9140069484710693,
537
+ "learning_rate": 2.884675650266374e-06,
538
+ "loss": 1.1359,
539
+ "mean_token_accuracy": 0.7348436897993088,
540
+ "num_tokens": 150085697.0,
541
+ "step": 1450
542
+ },
543
+ {
544
+ "epoch": 0.4482942025681939,
545
+ "grad_norm": 0.9307470321655273,
546
+ "learning_rate": 2.8455029771231592e-06,
547
+ "loss": 1.1537,
548
+ "mean_token_accuracy": 0.7332108038663864,
549
+ "num_tokens": 152693678.0,
550
+ "step": 1475
551
+ },
552
+ {
553
+ "epoch": 0.45589240939138365,
554
+ "grad_norm": 0.9836713671684265,
555
+ "learning_rate": 2.806330303979944e-06,
556
+ "loss": 1.1398,
557
+ "mean_token_accuracy": 0.7350041055679322,
558
+ "num_tokens": 155307631.0,
559
+ "step": 1500
560
+ },
561
+ {
562
+ "epoch": 0.4634906162145734,
563
+ "grad_norm": 0.9581474661827087,
564
+ "learning_rate": 2.7671576308367286e-06,
565
+ "loss": 1.1213,
566
+ "mean_token_accuracy": 0.7367819517850875,
567
+ "num_tokens": 157931564.0,
568
+ "step": 1525
569
+ },
570
+ {
571
+ "epoch": 0.47108882303776306,
572
+ "grad_norm": 0.9196196794509888,
573
+ "learning_rate": 2.727984957693513e-06,
574
+ "loss": 1.1416,
575
+ "mean_token_accuracy": 0.7337223035097122,
576
+ "num_tokens": 160523557.0,
577
+ "step": 1550
578
+ },
579
+ {
580
+ "epoch": 0.4786870298609528,
581
+ "grad_norm": 1.0535234212875366,
582
+ "learning_rate": 2.688812284550298e-06,
583
+ "loss": 1.1376,
584
+ "mean_token_accuracy": 0.7336768537759781,
585
+ "num_tokens": 163117027.0,
586
+ "step": 1575
587
+ },
588
+ {
589
+ "epoch": 0.48628523668414253,
590
+ "grad_norm": 0.9108763337135315,
591
+ "learning_rate": 2.6496396114070826e-06,
592
+ "loss": 1.1186,
593
+ "mean_token_accuracy": 0.7363489520549774,
594
+ "num_tokens": 165577284.0,
595
+ "step": 1600
596
+ },
597
+ {
598
+ "epoch": 0.49388344350733226,
599
+ "grad_norm": 0.914046585559845,
600
+ "learning_rate": 2.6104669382638677e-06,
601
+ "loss": 1.1193,
602
+ "mean_token_accuracy": 0.7358357053995133,
603
+ "num_tokens": 168176206.0,
604
+ "step": 1625
605
+ },
606
+ {
607
+ "epoch": 0.5014816503305219,
608
+ "grad_norm": 0.9301220774650574,
609
+ "learning_rate": 2.571294265120652e-06,
610
+ "loss": 1.1359,
611
+ "mean_token_accuracy": 0.7337970972061157,
612
+ "num_tokens": 170860276.0,
613
+ "step": 1650
614
+ },
615
+ {
616
+ "epoch": 0.5090798571537117,
617
+ "grad_norm": 1.1479674577713013,
618
+ "learning_rate": 2.5321215919774366e-06,
619
+ "loss": 1.1339,
620
+ "mean_token_accuracy": 0.7356235873699188,
621
+ "num_tokens": 173397712.0,
622
+ "step": 1675
623
+ },
624
+ {
625
+ "epoch": 0.5166780639769014,
626
+ "grad_norm": 0.9349409937858582,
627
+ "learning_rate": 2.4929489188342217e-06,
628
+ "loss": 1.1381,
629
+ "mean_token_accuracy": 0.7338095015287399,
630
+ "num_tokens": 175907043.0,
631
+ "step": 1700
632
+ },
633
+ {
634
+ "epoch": 0.5242762708000912,
635
+ "grad_norm": 0.9135065078735352,
636
+ "learning_rate": 2.453776245691006e-06,
637
+ "loss": 1.1424,
638
+ "mean_token_accuracy": 0.7341409718990326,
639
+ "num_tokens": 178454221.0,
640
+ "step": 1725
641
+ },
642
+ {
643
+ "epoch": 0.5318744776232809,
644
+ "grad_norm": 0.8928455710411072,
645
+ "learning_rate": 2.414603572547791e-06,
646
+ "loss": 1.1486,
647
+ "mean_token_accuracy": 0.7311108547449112,
648
+ "num_tokens": 181045005.0,
649
+ "step": 1750
650
+ },
651
+ {
652
+ "epoch": 0.5394726844464707,
653
+ "grad_norm": 0.980609118938446,
654
+ "learning_rate": 2.3754308994045757e-06,
655
+ "loss": 1.1368,
656
+ "mean_token_accuracy": 0.7330597722530365,
657
+ "num_tokens": 183666329.0,
658
+ "step": 1775
659
+ },
660
+ {
661
+ "epoch": 0.5470708912696604,
662
+ "grad_norm": 0.9772244691848755,
663
+ "learning_rate": 2.3362582262613603e-06,
664
+ "loss": 1.1105,
665
+ "mean_token_accuracy": 0.7395724445581436,
666
+ "num_tokens": 186221096.0,
667
+ "step": 1800
668
+ },
669
+ {
670
+ "epoch": 0.55466909809285,
671
+ "grad_norm": 0.9453775882720947,
672
+ "learning_rate": 2.297085553118145e-06,
673
+ "loss": 1.1207,
674
+ "mean_token_accuracy": 0.737914999127388,
675
+ "num_tokens": 188781580.0,
676
+ "step": 1825
677
+ },
678
+ {
679
+ "epoch": 0.5622673049160398,
680
+ "grad_norm": 0.9014413952827454,
681
+ "learning_rate": 2.2579128799749297e-06,
682
+ "loss": 1.1436,
683
+ "mean_token_accuracy": 0.7317037135362625,
684
+ "num_tokens": 191380677.0,
685
+ "step": 1850
686
+ },
687
+ {
688
+ "epoch": 0.5698655117392295,
689
+ "grad_norm": 0.8946366310119629,
690
+ "learning_rate": 2.2187402068317143e-06,
691
+ "loss": 1.1548,
692
+ "mean_token_accuracy": 0.7314022815227509,
693
+ "num_tokens": 193996266.0,
694
+ "step": 1875
695
+ },
696
+ {
697
+ "epoch": 0.5774637185624193,
698
+ "grad_norm": 0.9767251014709473,
699
+ "learning_rate": 2.179567533688499e-06,
700
+ "loss": 1.1258,
701
+ "mean_token_accuracy": 0.737195520401001,
702
+ "num_tokens": 196548577.0,
703
+ "step": 1900
704
+ },
705
+ {
706
+ "epoch": 0.585061925385609,
707
+ "grad_norm": 1.0095189809799194,
708
+ "learning_rate": 2.1403948605452837e-06,
709
+ "loss": 1.1481,
710
+ "mean_token_accuracy": 0.7341015815734864,
711
+ "num_tokens": 199121126.0,
712
+ "step": 1925
713
+ },
714
+ {
715
+ "epoch": 0.5926601322087988,
716
+ "grad_norm": 0.9052937030792236,
717
+ "learning_rate": 2.1012221874020688e-06,
718
+ "loss": 1.1309,
719
+ "mean_token_accuracy": 0.7348120081424713,
720
+ "num_tokens": 201731098.0,
721
+ "step": 1950
722
+ },
723
+ {
724
+ "epoch": 0.6002583390319884,
725
+ "grad_norm": 0.9695770144462585,
726
+ "learning_rate": 2.062049514258853e-06,
727
+ "loss": 1.1248,
728
+ "mean_token_accuracy": 0.7372716355323792,
729
+ "num_tokens": 204324674.0,
730
+ "step": 1975
731
+ },
732
+ {
733
+ "epoch": 0.6078565458551782,
734
+ "grad_norm": 0.9187005758285522,
735
+ "learning_rate": 2.022876841115638e-06,
736
+ "loss": 1.1275,
737
+ "mean_token_accuracy": 0.7356339997053146,
738
+ "num_tokens": 206937271.0,
739
+ "step": 2000
740
+ },
741
+ {
742
+ "epoch": 0.6154547526783679,
743
+ "grad_norm": 0.9396357536315918,
744
+ "learning_rate": 1.9837041679724223e-06,
745
+ "loss": 1.1475,
746
+ "mean_token_accuracy": 0.7320456486940384,
747
+ "num_tokens": 209530276.0,
748
+ "step": 2025
749
+ },
750
+ {
751
+ "epoch": 0.6230529595015576,
752
+ "grad_norm": 0.9308034181594849,
753
+ "learning_rate": 1.9445314948292074e-06,
754
+ "loss": 1.107,
755
+ "mean_token_accuracy": 0.7407030069828033,
756
+ "num_tokens": 212127023.0,
757
+ "step": 2050
758
+ },
759
+ {
760
+ "epoch": 0.6306511663247474,
761
+ "grad_norm": 0.9127600193023682,
762
+ "learning_rate": 1.9053588216859919e-06,
763
+ "loss": 1.117,
764
+ "mean_token_accuracy": 0.7379663151502609,
765
+ "num_tokens": 214698253.0,
766
+ "step": 2075
767
+ },
768
+ {
769
+ "epoch": 0.6382493731479371,
770
+ "grad_norm": 1.0522152185440063,
771
+ "learning_rate": 1.8661861485427768e-06,
772
+ "loss": 1.1134,
773
+ "mean_token_accuracy": 0.738114013671875,
774
+ "num_tokens": 217256660.0,
775
+ "step": 2100
776
+ },
777
+ {
778
+ "epoch": 0.6458475799711269,
779
+ "grad_norm": 1.1676892042160034,
780
+ "learning_rate": 1.8270134753995614e-06,
781
+ "loss": 1.1501,
782
+ "mean_token_accuracy": 0.7336319923400879,
783
+ "num_tokens": 219876024.0,
784
+ "step": 2125
785
+ },
786
+ {
787
+ "epoch": 0.6534457867943165,
788
+ "grad_norm": 0.950326144695282,
789
+ "learning_rate": 1.7878408022563463e-06,
790
+ "loss": 1.1027,
791
+ "mean_token_accuracy": 0.7408947384357453,
792
+ "num_tokens": 222494174.0,
793
+ "step": 2150
794
+ },
795
+ {
796
+ "epoch": 0.6610439936175063,
797
+ "grad_norm": 0.9229258298873901,
798
+ "learning_rate": 1.7486681291131308e-06,
799
+ "loss": 1.149,
800
+ "mean_token_accuracy": 0.7321878397464752,
801
+ "num_tokens": 225084016.0,
802
+ "step": 2175
803
+ },
804
+ {
805
+ "epoch": 0.668642200440696,
806
+ "grad_norm": 0.8653574585914612,
807
+ "learning_rate": 1.7094954559699156e-06,
808
+ "loss": 1.1264,
809
+ "mean_token_accuracy": 0.7363163530826569,
810
+ "num_tokens": 227745579.0,
811
+ "step": 2200
812
+ },
813
+ {
814
+ "epoch": 0.6762404072638857,
815
+ "grad_norm": 0.8321031332015991,
816
+ "learning_rate": 1.6703227828267e-06,
817
+ "loss": 1.1262,
818
+ "mean_token_accuracy": 0.7373967486619949,
819
+ "num_tokens": 230365604.0,
820
+ "step": 2225
821
+ },
822
+ {
823
+ "epoch": 0.6838386140870755,
824
+ "grad_norm": 0.9620904326438904,
825
+ "learning_rate": 1.631150109683485e-06,
826
+ "loss": 1.104,
827
+ "mean_token_accuracy": 0.7394238811731338,
828
+ "num_tokens": 232943997.0,
829
+ "step": 2250
830
+ },
831
+ {
832
+ "epoch": 0.6914368209102651,
833
+ "grad_norm": 0.9633401036262512,
834
+ "learning_rate": 1.5919774365402697e-06,
835
+ "loss": 1.1312,
836
+ "mean_token_accuracy": 0.7345698297023773,
837
+ "num_tokens": 235514397.0,
838
+ "step": 2275
839
+ },
840
+ {
841
+ "epoch": 0.6990350277334549,
842
+ "grad_norm": 1.049621343612671,
843
+ "learning_rate": 1.5528047633970545e-06,
844
+ "loss": 1.1038,
845
+ "mean_token_accuracy": 0.7410222667455674,
846
+ "num_tokens": 237958000.0,
847
+ "step": 2300
848
+ },
849
+ {
850
+ "epoch": 0.7066332345566446,
851
+ "grad_norm": 0.8942002654075623,
852
+ "learning_rate": 1.513632090253839e-06,
853
+ "loss": 1.128,
854
+ "mean_token_accuracy": 0.7355525487661362,
855
+ "num_tokens": 240563561.0,
856
+ "step": 2325
857
+ },
858
+ {
859
+ "epoch": 0.7142314413798344,
860
+ "grad_norm": 1.0083601474761963,
861
+ "learning_rate": 1.4744594171106239e-06,
862
+ "loss": 1.1763,
863
+ "mean_token_accuracy": 0.7265212672948838,
864
+ "num_tokens": 243194983.0,
865
+ "step": 2350
866
+ },
867
+ {
868
+ "epoch": 0.7218296482030241,
869
+ "grad_norm": 0.8960743546485901,
870
+ "learning_rate": 1.4352867439674083e-06,
871
+ "loss": 1.1586,
872
+ "mean_token_accuracy": 0.7288067770004273,
873
+ "num_tokens": 245824173.0,
874
+ "step": 2375
875
+ },
876
+ {
877
+ "epoch": 0.7294278550262138,
878
+ "grad_norm": 0.9686855673789978,
879
+ "learning_rate": 1.3961140708241932e-06,
880
+ "loss": 1.1404,
881
+ "mean_token_accuracy": 0.732091948390007,
882
+ "num_tokens": 248428880.0,
883
+ "step": 2400
884
+ },
885
+ {
886
+ "epoch": 0.7370260618494036,
887
+ "grad_norm": 0.8258799910545349,
888
+ "learning_rate": 1.3569413976809779e-06,
889
+ "loss": 1.1119,
890
+ "mean_token_accuracy": 0.7375982666015625,
891
+ "num_tokens": 251034901.0,
892
+ "step": 2425
893
+ },
894
+ {
895
+ "epoch": 0.7446242686725932,
896
+ "grad_norm": 0.9364578127861023,
897
+ "learning_rate": 1.3177687245377627e-06,
898
+ "loss": 1.162,
899
+ "mean_token_accuracy": 0.7280535787343979,
900
+ "num_tokens": 253656324.0,
901
+ "step": 2450
902
+ },
903
+ {
904
+ "epoch": 0.752222475495783,
905
+ "grad_norm": 0.8600585460662842,
906
+ "learning_rate": 1.2785960513945472e-06,
907
+ "loss": 1.0984,
908
+ "mean_token_accuracy": 0.7421051144599915,
909
+ "num_tokens": 256255282.0,
910
+ "step": 2475
911
+ },
912
+ {
913
+ "epoch": 0.7598206823189727,
914
+ "grad_norm": 0.955594003200531,
915
+ "learning_rate": 1.2394233782513319e-06,
916
+ "loss": 1.1248,
917
+ "mean_token_accuracy": 0.7350970155000687,
918
+ "num_tokens": 258805575.0,
919
+ "step": 2500
920
+ },
921
+ {
922
+ "epoch": 0.7674188891421625,
923
+ "grad_norm": 0.8654617667198181,
924
+ "learning_rate": 1.2002507051081167e-06,
925
+ "loss": 1.139,
926
+ "mean_token_accuracy": 0.7342792183160782,
927
+ "num_tokens": 261394940.0,
928
+ "step": 2525
929
+ },
930
+ {
931
+ "epoch": 0.7750170959653522,
932
+ "grad_norm": 0.9037804007530212,
933
+ "learning_rate": 1.1610780319649014e-06,
934
+ "loss": 1.1507,
935
+ "mean_token_accuracy": 0.731409004330635,
936
+ "num_tokens": 264013243.0,
937
+ "step": 2550
938
+ },
939
+ {
940
+ "epoch": 0.7826153027885419,
941
+ "grad_norm": 0.9133325815200806,
942
+ "learning_rate": 1.121905358821686e-06,
943
+ "loss": 1.097,
944
+ "mean_token_accuracy": 0.7419029778242111,
945
+ "num_tokens": 266628788.0,
946
+ "step": 2575
947
+ },
948
+ {
949
+ "epoch": 0.7902135096117316,
950
+ "grad_norm": 0.960132360458374,
951
+ "learning_rate": 1.0827326856784708e-06,
952
+ "loss": 1.1012,
953
+ "mean_token_accuracy": 0.7402530944347382,
954
+ "num_tokens": 269174466.0,
955
+ "step": 2600
956
+ },
957
+ {
958
+ "epoch": 0.7978117164349213,
959
+ "grad_norm": 1.2616750001907349,
960
+ "learning_rate": 1.0435600125352554e-06,
961
+ "loss": 1.1035,
962
+ "mean_token_accuracy": 0.7417422020435334,
963
+ "num_tokens": 271735962.0,
964
+ "step": 2625
965
+ },
966
+ {
967
+ "epoch": 0.8054099232581111,
968
+ "grad_norm": 0.9597173929214478,
969
+ "learning_rate": 1.00438733939204e-06,
970
+ "loss": 1.0966,
971
+ "mean_token_accuracy": 0.7435225594043732,
972
+ "num_tokens": 274392874.0,
973
+ "step": 2650
974
+ },
975
+ {
976
+ "epoch": 0.8130081300813008,
977
+ "grad_norm": 0.8417394161224365,
978
+ "learning_rate": 9.65214666248825e-07,
979
+ "loss": 1.1347,
980
+ "mean_token_accuracy": 0.7362286591529846,
981
+ "num_tokens": 276982423.0,
982
+ "step": 2675
983
+ },
984
+ {
985
+ "epoch": 0.8206063369044906,
986
+ "grad_norm": 0.8907487392425537,
987
+ "learning_rate": 9.260419931056095e-07,
988
+ "loss": 1.1112,
989
+ "mean_token_accuracy": 0.7379048210382462,
990
+ "num_tokens": 279629729.0,
991
+ "step": 2700
992
+ },
993
+ {
994
+ "epoch": 0.8282045437276803,
995
+ "grad_norm": 0.9732270240783691,
996
+ "learning_rate": 8.868693199623943e-07,
997
+ "loss": 1.1219,
998
+ "mean_token_accuracy": 0.7383491581678391,
999
+ "num_tokens": 282200981.0,
1000
+ "step": 2725
1001
+ },
1002
+ {
1003
+ "epoch": 0.8358027505508699,
1004
+ "grad_norm": 0.8799415230751038,
1005
+ "learning_rate": 8.47696646819179e-07,
1006
+ "loss": 1.1059,
1007
+ "mean_token_accuracy": 0.7389830541610718,
1008
+ "num_tokens": 284699697.0,
1009
+ "step": 2750
1010
+ },
1011
+ {
1012
+ "epoch": 0.8434009573740597,
1013
+ "grad_norm": 0.8372652530670166,
1014
+ "learning_rate": 8.085239736759637e-07,
1015
+ "loss": 1.123,
1016
+ "mean_token_accuracy": 0.7350180590152741,
1017
+ "num_tokens": 287274170.0,
1018
+ "step": 2775
1019
+ },
1020
+ {
1021
+ "epoch": 0.8509991641972494,
1022
+ "grad_norm": 0.8474750518798828,
1023
+ "learning_rate": 7.693513005327484e-07,
1024
+ "loss": 1.1316,
1025
+ "mean_token_accuracy": 0.735204011797905,
1026
+ "num_tokens": 289905267.0,
1027
+ "step": 2800
1028
+ },
1029
+ {
1030
+ "epoch": 0.8585973710204392,
1031
+ "grad_norm": 0.9228349924087524,
1032
+ "learning_rate": 7.301786273895331e-07,
1033
+ "loss": 1.1276,
1034
+ "mean_token_accuracy": 0.7360332900285721,
1035
+ "num_tokens": 292531690.0,
1036
+ "step": 2825
1037
+ },
1038
+ {
1039
+ "epoch": 0.8661955778436289,
1040
+ "grad_norm": 0.9425334334373474,
1041
+ "learning_rate": 6.910059542463178e-07,
1042
+ "loss": 1.1446,
1043
+ "mean_token_accuracy": 0.7327738231420518,
1044
+ "num_tokens": 295102204.0,
1045
+ "step": 2850
1046
+ },
1047
+ {
1048
+ "epoch": 0.8737937846668187,
1049
+ "grad_norm": 0.8812386393547058,
1050
+ "learning_rate": 6.518332811031025e-07,
1051
+ "loss": 1.1197,
1052
+ "mean_token_accuracy": 0.7385855436325073,
1053
+ "num_tokens": 297696866.0,
1054
+ "step": 2875
1055
+ },
1056
+ {
1057
+ "epoch": 0.8813919914900084,
1058
+ "grad_norm": 0.8696539998054504,
1059
+ "learning_rate": 6.126606079598872e-07,
1060
+ "loss": 1.1084,
1061
+ "mean_token_accuracy": 0.740631007552147,
1062
+ "num_tokens": 300294510.0,
1063
+ "step": 2900
1064
+ },
1065
+ {
1066
+ "epoch": 0.888990198313198,
1067
+ "grad_norm": 0.9522122144699097,
1068
+ "learning_rate": 5.73487934816672e-07,
1069
+ "loss": 1.1582,
1070
+ "mean_token_accuracy": 0.7323483002185821,
1071
+ "num_tokens": 302898731.0,
1072
+ "step": 2925
1073
+ },
1074
+ {
1075
+ "epoch": 0.8965884051363878,
1076
+ "grad_norm": 0.9082636833190918,
1077
+ "learning_rate": 5.343152616734566e-07,
1078
+ "loss": 1.1264,
1079
+ "mean_token_accuracy": 0.7359338957071304,
1080
+ "num_tokens": 305410011.0,
1081
+ "step": 2950
1082
+ },
1083
+ {
1084
+ "epoch": 0.9041866119595775,
1085
+ "grad_norm": 0.9275860786437988,
1086
+ "learning_rate": 4.951425885302413e-07,
1087
+ "loss": 1.1528,
1088
+ "mean_token_accuracy": 0.7339082890748978,
1089
+ "num_tokens": 308110984.0,
1090
+ "step": 2975
1091
+ },
1092
+ {
1093
+ "epoch": 0.9117848187827673,
1094
+ "grad_norm": 1.0664831399917603,
1095
+ "learning_rate": 4.55969915387026e-07,
1096
+ "loss": 1.1404,
1097
+ "mean_token_accuracy": 0.7343163812160491,
1098
+ "num_tokens": 310767815.0,
1099
+ "step": 3000
1100
+ },
1101
+ {
1102
+ "epoch": 0.919383025605957,
1103
+ "grad_norm": 0.9530277252197266,
1104
+ "learning_rate": 4.1679724224381073e-07,
1105
+ "loss": 1.1293,
1106
+ "mean_token_accuracy": 0.7350982189178467,
1107
+ "num_tokens": 313289189.0,
1108
+ "step": 3025
1109
+ },
1110
+ {
1111
+ "epoch": 0.9269812324291468,
1112
+ "grad_norm": 0.8777811527252197,
1113
+ "learning_rate": 3.7762456910059545e-07,
1114
+ "loss": 1.1222,
1115
+ "mean_token_accuracy": 0.7371740919351578,
1116
+ "num_tokens": 315885578.0,
1117
+ "step": 3050
1118
+ },
1119
+ {
1120
+ "epoch": 0.9345794392523364,
1121
+ "grad_norm": 0.9783887267112732,
1122
+ "learning_rate": 3.3845189595738017e-07,
1123
+ "loss": 1.1018,
1124
+ "mean_token_accuracy": 0.7426222825050354,
1125
+ "num_tokens": 318443917.0,
1126
+ "step": 3075
1127
+ },
1128
+ {
1129
+ "epoch": 0.9421776460755261,
1130
+ "grad_norm": 0.8978294730186462,
1131
+ "learning_rate": 2.9927922281416484e-07,
1132
+ "loss": 1.1463,
1133
+ "mean_token_accuracy": 0.7316457951068878,
1134
+ "num_tokens": 321002620.0,
1135
+ "step": 3100
1136
+ },
1137
+ {
1138
+ "epoch": 0.9497758528987159,
1139
+ "grad_norm": 0.9735873937606812,
1140
+ "learning_rate": 2.6010654967094956e-07,
1141
+ "loss": 1.1119,
1142
+ "mean_token_accuracy": 0.7383992117643357,
1143
+ "num_tokens": 323561038.0,
1144
+ "step": 3125
1145
+ },
1146
+ {
1147
+ "epoch": 0.9573740597219056,
1148
+ "grad_norm": 0.8766360282897949,
1149
+ "learning_rate": 2.2093387652773425e-07,
1150
+ "loss": 1.0943,
1151
+ "mean_token_accuracy": 0.7416167676448822,
1152
+ "num_tokens": 326152504.0,
1153
+ "step": 3150
1154
+ },
1155
+ {
1156
+ "epoch": 0.9649722665450954,
1157
+ "grad_norm": 0.8869988322257996,
1158
+ "learning_rate": 1.8176120338451897e-07,
1159
+ "loss": 1.1099,
1160
+ "mean_token_accuracy": 0.7376412642002106,
1161
+ "num_tokens": 328738142.0,
1162
+ "step": 3175
1163
+ },
1164
+ {
1165
+ "epoch": 0.9725704733682851,
1166
+ "grad_norm": 0.9266097545623779,
1167
+ "learning_rate": 1.4258853024130367e-07,
1168
+ "loss": 1.1165,
1169
+ "mean_token_accuracy": 0.7394632256031036,
1170
+ "num_tokens": 331295732.0,
1171
+ "step": 3200
1172
+ },
1173
+ {
1174
+ "epoch": 0.9801686801914749,
1175
+ "grad_norm": 0.9964390993118286,
1176
+ "learning_rate": 1.0341585709808838e-07,
1177
+ "loss": 1.1191,
1178
+ "mean_token_accuracy": 0.7373811560869217,
1179
+ "num_tokens": 333891414.0,
1180
+ "step": 3225
1181
+ },
1182
+ {
1183
+ "epoch": 0.9877668870146645,
1184
+ "grad_norm": 0.9817653298377991,
1185
+ "learning_rate": 6.424318395487308e-08,
1186
+ "loss": 1.1356,
1187
+ "mean_token_accuracy": 0.7354251599311828,
1188
+ "num_tokens": 336538563.0,
1189
+ "step": 3250
1190
+ },
1191
+ {
1192
+ "epoch": 0.9953650938378543,
1193
+ "grad_norm": 0.8675805330276489,
1194
+ "learning_rate": 2.507051081165779e-08,
1195
+ "loss": 1.1482,
1196
+ "mean_token_accuracy": 0.7319550043344498,
1197
+ "num_tokens": 339216210.0,
1198
+ "step": 3275
1199
+ }
1200
+ ],
1201
+ "logging_steps": 25,
1202
+ "max_steps": 3290,
1203
+ "num_input_tokens_seen": 0,
1204
+ "num_train_epochs": 1,
1205
+ "save_steps": 1000,
1206
+ "stateful_callbacks": {
1207
+ "TrainerControl": {
1208
+ "args": {
1209
+ "should_epoch_stop": false,
1210
+ "should_evaluate": false,
1211
+ "should_log": false,
1212
+ "should_save": true,
1213
+ "should_training_stop": true
1214
+ },
1215
+ "attributes": {}
1216
+ }
1217
+ },
1218
+ "total_flos": 1.8698621709430292e+18,
1219
+ "train_batch_size": 4,
1220
+ "trial_name": null,
1221
+ "trial_params": null
1222
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56ed8a20d75838e68b4b9c64cec17c2d7ad2d9597671b5bf4a16124c4f707494
3
+ size 7352
vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)