schnell commited on
Commit
1f3adb9
1 Parent(s): ef22338

Training in progress, epoch 1

Browse files
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ checkpoint-*/
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 512,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 2048,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "bert",
15
+ "num_attention_heads": 8,
16
+ "num_hidden_layers": 4,
17
+ "pad_token_id": 0,
18
+ "position_embedding_type": "absolute",
19
+ "torch_dtype": "float16",
20
+ "transformers_version": "4.19.2",
21
+ "type_vocab_size": 2,
22
+ "use_cache": true,
23
+ "vocab_size": 32000
24
+ }
last-checkpoint/config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 512,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 2048,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "bert",
15
+ "num_attention_heads": 8,
16
+ "num_hidden_layers": 4,
17
+ "pad_token_id": 0,
18
+ "position_embedding_type": "absolute",
19
+ "torch_dtype": "float16",
20
+ "transformers_version": "4.19.2",
21
+ "type_vocab_size": 2,
22
+ "use_cache": true,
23
+ "vocab_size": 32000
24
+ }
last-checkpoint/global_step69473/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e0050713b381dc3ba13434465c1d278d0ab5cadc86d4b70311ef30a660d2275
3
+ size 59134503
last-checkpoint/global_step69473/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:cd6363f2eea53b7241ae383f12fb281c2963ee7c89a67d88e11acee9e9724fec
3
+ size 118216675
last-checkpoint/global_step69473/zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4037d0ac9c29daf2f01103e710e3a7c88a7a367ae8d382d498157ed65496fba0
3
+ size 118217955
last-checkpoint/global_step69473/zero_pp_rank_2_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1bc5b79dabb04bd744c6dc6035eb6f76051655e5732b24ecb018e0c9a68202d3
3
+ size 118221091
last-checkpoint/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step69473
last-checkpoint/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ea8f19b9cfae5ac1f4aea53be2d9bc355af72960cde88e7effe294d0e4c658a
3
+ size 59121639
last-checkpoint/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a80824c9c80bca9b568638795ecb7ff1fafcdbd4e21352551ee3d13f947d45ef
3
+ size 14503
last-checkpoint/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb80857bf4eca9a59ff8597441b8c91a7ea9b5632f862c81cad8c50b6099f5f8
3
+ size 14503
last-checkpoint/rng_state_2.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1593b05733d15d785bb94bec329a81cf0c61504cea8453fd684516fb9b5dbf83
3
+ size 14503
last-checkpoint/special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
last-checkpoint/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
last-checkpoint/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cls_token": "[CLS]", "mask_token": "[MASK]", "model_max_length": 128, "pad_token": "[PAD]", "padding_side": "right", "sep_token": "[SEP]", "truncation_side": "right", "unk_token": "[UNK]", "special_tokens_map_file": "pretrained_tokenizers/UnidicBpe2/special_tokens_map.json", "name_or_path": "pretrained_tokenizers/UnidicBpe2", "tokenizer_class": "PreTrainedTokenizerFast"}
last-checkpoint/trainer_state.json ADDED
@@ -0,0 +1,853 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 1.0,
5
+ "global_step": 69473,
6
+ "is_hyper_param_search": false,
7
+ "is_local_process_zero": true,
8
+ "is_world_process_zero": true,
9
+ "log_history": [
10
+ {
11
+ "epoch": 0.01,
12
+ "learning_rate": 6.763399204600845e-05,
13
+ "loss": 6.9832,
14
+ "step": 500
15
+ },
16
+ {
17
+ "epoch": 0.01,
18
+ "learning_rate": 7.520427275451058e-05,
19
+ "loss": 5.5271,
20
+ "step": 1000
21
+ },
22
+ {
23
+ "epoch": 0.02,
24
+ "learning_rate": 7.961254711978457e-05,
25
+ "loss": 4.6913,
26
+ "step": 1500
27
+ },
28
+ {
29
+ "epoch": 0.03,
30
+ "learning_rate": 8.275270773909965e-05,
31
+ "loss": 4.2907,
32
+ "step": 2000
33
+ },
34
+ {
35
+ "epoch": 0.04,
36
+ "learning_rate": 8.517839539271491e-05,
37
+ "loss": 4.0302,
38
+ "step": 2500
39
+ },
40
+ {
41
+ "epoch": 0.04,
42
+ "learning_rate": 8.716825914421595e-05,
43
+ "loss": 3.8379,
44
+ "step": 3000
45
+ },
46
+ {
47
+ "epoch": 0.05,
48
+ "learning_rate": 8.884385574179297e-05,
49
+ "loss": 3.6906,
50
+ "step": 3500
51
+ },
52
+ {
53
+ "epoch": 0.06,
54
+ "learning_rate": 9.030114272368873e-05,
55
+ "loss": 3.5642,
56
+ "step": 4000
57
+ },
58
+ {
59
+ "epoch": 0.06,
60
+ "learning_rate": 9.158138540964539e-05,
61
+ "loss": 3.4704,
62
+ "step": 4500
63
+ },
64
+ {
65
+ "epoch": 0.07,
66
+ "learning_rate": 9.273119601765861e-05,
67
+ "loss": 3.3821,
68
+ "step": 5000
69
+ },
70
+ {
71
+ "epoch": 0.08,
72
+ "learning_rate": 9.376714826181023e-05,
73
+ "loss": 3.3064,
74
+ "step": 5500
75
+ },
76
+ {
77
+ "epoch": 0.09,
78
+ "learning_rate": 9.471669412880503e-05,
79
+ "loss": 3.2476,
80
+ "step": 6000
81
+ },
82
+ {
83
+ "epoch": 0.09,
84
+ "learning_rate": 9.558668751136338e-05,
85
+ "loss": 3.1892,
86
+ "step": 6500
87
+ },
88
+ {
89
+ "epoch": 0.1,
90
+ "learning_rate": 9.639540886232853e-05,
91
+ "loss": 3.1299,
92
+ "step": 7000
93
+ },
94
+ {
95
+ "epoch": 0.11,
96
+ "learning_rate": 9.714529240377096e-05,
97
+ "loss": 3.0869,
98
+ "step": 7500
99
+ },
100
+ {
101
+ "epoch": 0.12,
102
+ "learning_rate": 9.784957770827781e-05,
103
+ "loss": 3.0405,
104
+ "step": 8000
105
+ },
106
+ {
107
+ "epoch": 0.12,
108
+ "learning_rate": 9.850850144881638e-05,
109
+ "loss": 2.9989,
110
+ "step": 8500
111
+ },
112
+ {
113
+ "epoch": 0.13,
114
+ "learning_rate": 9.91322455339213e-05,
115
+ "loss": 2.9583,
116
+ "step": 9000
117
+ },
118
+ {
119
+ "epoch": 0.14,
120
+ "learning_rate": 9.97198937413398e-05,
121
+ "loss": 2.923,
122
+ "step": 9500
123
+ },
124
+ {
125
+ "epoch": 0.14,
126
+ "learning_rate": 9.997382892215664e-05,
127
+ "loss": 2.8859,
128
+ "step": 10000
129
+ },
130
+ {
131
+ "epoch": 0.15,
132
+ "learning_rate": 9.99221098873709e-05,
133
+ "loss": 2.8536,
134
+ "step": 10500
135
+ },
136
+ {
137
+ "epoch": 0.16,
138
+ "learning_rate": 9.987018314561817e-05,
139
+ "loss": 2.8222,
140
+ "step": 11000
141
+ },
142
+ {
143
+ "epoch": 0.17,
144
+ "learning_rate": 9.981846411083245e-05,
145
+ "loss": 2.7972,
146
+ "step": 11500
147
+ },
148
+ {
149
+ "epoch": 0.17,
150
+ "learning_rate": 9.97665373690797e-05,
151
+ "loss": 2.7657,
152
+ "step": 12000
153
+ },
154
+ {
155
+ "epoch": 0.18,
156
+ "learning_rate": 9.971481833429398e-05,
157
+ "loss": 2.7461,
158
+ "step": 12500
159
+ },
160
+ {
161
+ "epoch": 0.19,
162
+ "learning_rate": 9.966289159254125e-05,
163
+ "loss": 2.721,
164
+ "step": 13000
165
+ },
166
+ {
167
+ "epoch": 0.19,
168
+ "learning_rate": 9.961117255775553e-05,
169
+ "loss": 2.7012,
170
+ "step": 13500
171
+ },
172
+ {
173
+ "epoch": 0.2,
174
+ "learning_rate": 9.95592458160028e-05,
175
+ "loss": 2.6758,
176
+ "step": 14000
177
+ },
178
+ {
179
+ "epoch": 0.21,
180
+ "learning_rate": 9.950752678121706e-05,
181
+ "loss": 2.666,
182
+ "step": 14500
183
+ },
184
+ {
185
+ "epoch": 0.22,
186
+ "learning_rate": 9.945560003946433e-05,
187
+ "loss": 2.6412,
188
+ "step": 15000
189
+ },
190
+ {
191
+ "epoch": 0.22,
192
+ "learning_rate": 9.94038810046786e-05,
193
+ "loss": 2.6264,
194
+ "step": 15500
195
+ },
196
+ {
197
+ "epoch": 0.23,
198
+ "learning_rate": 9.935195426292587e-05,
199
+ "loss": 2.6089,
200
+ "step": 16000
201
+ },
202
+ {
203
+ "epoch": 0.24,
204
+ "learning_rate": 9.930023522814015e-05,
205
+ "loss": 2.5915,
206
+ "step": 16500
207
+ },
208
+ {
209
+ "epoch": 0.24,
210
+ "learning_rate": 9.92483084863874e-05,
211
+ "loss": 2.5783,
212
+ "step": 17000
213
+ },
214
+ {
215
+ "epoch": 0.25,
216
+ "learning_rate": 9.919658945160168e-05,
217
+ "loss": 2.558,
218
+ "step": 17500
219
+ },
220
+ {
221
+ "epoch": 0.26,
222
+ "learning_rate": 9.914466270984895e-05,
223
+ "loss": 2.5481,
224
+ "step": 18000
225
+ },
226
+ {
227
+ "epoch": 0.27,
228
+ "learning_rate": 9.909294367506321e-05,
229
+ "loss": 2.5376,
230
+ "step": 18500
231
+ },
232
+ {
233
+ "epoch": 0.27,
234
+ "learning_rate": 9.90410169333105e-05,
235
+ "loss": 2.5236,
236
+ "step": 19000
237
+ },
238
+ {
239
+ "epoch": 0.28,
240
+ "learning_rate": 9.898929789852477e-05,
241
+ "loss": 2.5129,
242
+ "step": 19500
243
+ },
244
+ {
245
+ "epoch": 0.29,
246
+ "learning_rate": 9.893737115677203e-05,
247
+ "loss": 2.5024,
248
+ "step": 20000
249
+ },
250
+ {
251
+ "epoch": 0.3,
252
+ "learning_rate": 9.88856521219863e-05,
253
+ "loss": 2.4841,
254
+ "step": 20500
255
+ },
256
+ {
257
+ "epoch": 0.3,
258
+ "learning_rate": 9.883372538023356e-05,
259
+ "loss": 2.4802,
260
+ "step": 21000
261
+ },
262
+ {
263
+ "epoch": 0.31,
264
+ "learning_rate": 9.878200634544784e-05,
265
+ "loss": 2.4725,
266
+ "step": 21500
267
+ },
268
+ {
269
+ "epoch": 0.32,
270
+ "learning_rate": 9.873007960369511e-05,
271
+ "loss": 2.4581,
272
+ "step": 22000
273
+ },
274
+ {
275
+ "epoch": 0.32,
276
+ "learning_rate": 9.867836056890939e-05,
277
+ "loss": 2.4493,
278
+ "step": 22500
279
+ },
280
+ {
281
+ "epoch": 0.33,
282
+ "learning_rate": 9.862643382715665e-05,
283
+ "loss": 2.4399,
284
+ "step": 23000
285
+ },
286
+ {
287
+ "epoch": 0.34,
288
+ "learning_rate": 9.857471479237093e-05,
289
+ "loss": 2.4297,
290
+ "step": 23500
291
+ },
292
+ {
293
+ "epoch": 0.35,
294
+ "learning_rate": 9.85227880506182e-05,
295
+ "loss": 2.4259,
296
+ "step": 24000
297
+ },
298
+ {
299
+ "epoch": 0.35,
300
+ "learning_rate": 9.847106901583248e-05,
301
+ "loss": 2.4199,
302
+ "step": 24500
303
+ },
304
+ {
305
+ "epoch": 0.36,
306
+ "learning_rate": 9.841914227407973e-05,
307
+ "loss": 2.4068,
308
+ "step": 25000
309
+ },
310
+ {
311
+ "epoch": 0.37,
312
+ "learning_rate": 9.836742323929401e-05,
313
+ "loss": 2.4023,
314
+ "step": 25500
315
+ },
316
+ {
317
+ "epoch": 0.37,
318
+ "learning_rate": 9.831549649754126e-05,
319
+ "loss": 2.3903,
320
+ "step": 26000
321
+ },
322
+ {
323
+ "epoch": 0.38,
324
+ "learning_rate": 9.826377746275554e-05,
325
+ "loss": 2.3849,
326
+ "step": 26500
327
+ },
328
+ {
329
+ "epoch": 0.39,
330
+ "learning_rate": 9.821185072100282e-05,
331
+ "loss": 2.3787,
332
+ "step": 27000
333
+ },
334
+ {
335
+ "epoch": 0.4,
336
+ "learning_rate": 9.816013168621709e-05,
337
+ "loss": 2.3722,
338
+ "step": 27500
339
+ },
340
+ {
341
+ "epoch": 0.4,
342
+ "learning_rate": 9.810820494446436e-05,
343
+ "loss": 2.3646,
344
+ "step": 28000
345
+ },
346
+ {
347
+ "epoch": 0.41,
348
+ "learning_rate": 9.805648590967863e-05,
349
+ "loss": 2.3537,
350
+ "step": 28500
351
+ },
352
+ {
353
+ "epoch": 0.42,
354
+ "learning_rate": 9.800455916792589e-05,
355
+ "loss": 2.353,
356
+ "step": 29000
357
+ },
358
+ {
359
+ "epoch": 0.42,
360
+ "learning_rate": 9.795284013314017e-05,
361
+ "loss": 2.3468,
362
+ "step": 29500
363
+ },
364
+ {
365
+ "epoch": 0.43,
366
+ "learning_rate": 9.790091339138744e-05,
367
+ "loss": 2.3371,
368
+ "step": 30000
369
+ },
370
+ {
371
+ "epoch": 0.44,
372
+ "learning_rate": 9.784919435660171e-05,
373
+ "loss": 2.3346,
374
+ "step": 30500
375
+ },
376
+ {
377
+ "epoch": 0.45,
378
+ "learning_rate": 9.779726761484898e-05,
379
+ "loss": 2.3244,
380
+ "step": 31000
381
+ },
382
+ {
383
+ "epoch": 0.45,
384
+ "learning_rate": 9.774554858006325e-05,
385
+ "loss": 2.3233,
386
+ "step": 31500
387
+ },
388
+ {
389
+ "epoch": 0.46,
390
+ "learning_rate": 9.769362183831051e-05,
391
+ "loss": 2.3214,
392
+ "step": 32000
393
+ },
394
+ {
395
+ "epoch": 0.47,
396
+ "learning_rate": 9.764190280352479e-05,
397
+ "loss": 2.312,
398
+ "step": 32500
399
+ },
400
+ {
401
+ "epoch": 0.48,
402
+ "learning_rate": 9.758997606177206e-05,
403
+ "loss": 2.3099,
404
+ "step": 33000
405
+ },
406
+ {
407
+ "epoch": 0.48,
408
+ "learning_rate": 9.753825702698634e-05,
409
+ "loss": 2.3025,
410
+ "step": 33500
411
+ },
412
+ {
413
+ "epoch": 0.49,
414
+ "learning_rate": 9.748633028523359e-05,
415
+ "loss": 2.2935,
416
+ "step": 34000
417
+ },
418
+ {
419
+ "epoch": 0.5,
420
+ "learning_rate": 9.743461125044787e-05,
421
+ "loss": 2.2924,
422
+ "step": 34500
423
+ },
424
+ {
425
+ "epoch": 0.5,
426
+ "learning_rate": 9.738268450869514e-05,
427
+ "loss": 2.2895,
428
+ "step": 35000
429
+ },
430
+ {
431
+ "epoch": 0.51,
432
+ "learning_rate": 9.73309654739094e-05,
433
+ "loss": 2.2806,
434
+ "step": 35500
435
+ },
436
+ {
437
+ "epoch": 0.52,
438
+ "learning_rate": 9.727903873215668e-05,
439
+ "loss": 2.2815,
440
+ "step": 36000
441
+ },
442
+ {
443
+ "epoch": 0.53,
444
+ "learning_rate": 9.722731969737096e-05,
445
+ "loss": 2.2735,
446
+ "step": 36500
447
+ },
448
+ {
449
+ "epoch": 0.53,
450
+ "learning_rate": 9.717539295561822e-05,
451
+ "loss": 2.2697,
452
+ "step": 37000
453
+ },
454
+ {
455
+ "epoch": 0.54,
456
+ "learning_rate": 9.71236739208325e-05,
457
+ "loss": 2.2686,
458
+ "step": 37500
459
+ },
460
+ {
461
+ "epoch": 0.55,
462
+ "learning_rate": 9.707174717907976e-05,
463
+ "loss": 2.2617,
464
+ "step": 38000
465
+ },
466
+ {
467
+ "epoch": 0.55,
468
+ "learning_rate": 9.702002814429404e-05,
469
+ "loss": 2.2561,
470
+ "step": 38500
471
+ },
472
+ {
473
+ "epoch": 0.56,
474
+ "learning_rate": 9.69681014025413e-05,
475
+ "loss": 2.2533,
476
+ "step": 39000
477
+ },
478
+ {
479
+ "epoch": 0.57,
480
+ "learning_rate": 9.691638236775557e-05,
481
+ "loss": 2.2484,
482
+ "step": 39500
483
+ },
484
+ {
485
+ "epoch": 0.58,
486
+ "learning_rate": 9.686445562600284e-05,
487
+ "loss": 2.2471,
488
+ "step": 40000
489
+ },
490
+ {
491
+ "epoch": 0.58,
492
+ "learning_rate": 9.681273659121712e-05,
493
+ "loss": 2.2443,
494
+ "step": 40500
495
+ },
496
+ {
497
+ "epoch": 0.59,
498
+ "learning_rate": 9.676080984946439e-05,
499
+ "loss": 2.2331,
500
+ "step": 41000
501
+ },
502
+ {
503
+ "epoch": 0.6,
504
+ "learning_rate": 9.670909081467867e-05,
505
+ "loss": 2.2349,
506
+ "step": 41500
507
+ },
508
+ {
509
+ "epoch": 0.6,
510
+ "learning_rate": 9.665716407292592e-05,
511
+ "loss": 2.2296,
512
+ "step": 42000
513
+ },
514
+ {
515
+ "epoch": 0.61,
516
+ "learning_rate": 9.66054450381402e-05,
517
+ "loss": 2.2296,
518
+ "step": 42500
519
+ },
520
+ {
521
+ "epoch": 0.62,
522
+ "learning_rate": 9.655351829638745e-05,
523
+ "loss": 2.2238,
524
+ "step": 43000
525
+ },
526
+ {
527
+ "epoch": 0.63,
528
+ "learning_rate": 9.650179926160173e-05,
529
+ "loss": 2.2193,
530
+ "step": 43500
531
+ },
532
+ {
533
+ "epoch": 0.63,
534
+ "learning_rate": 9.6449872519849e-05,
535
+ "loss": 2.2185,
536
+ "step": 44000
537
+ },
538
+ {
539
+ "epoch": 0.64,
540
+ "learning_rate": 9.639815348506328e-05,
541
+ "loss": 2.2157,
542
+ "step": 44500
543
+ },
544
+ {
545
+ "epoch": 0.65,
546
+ "learning_rate": 9.634622674331054e-05,
547
+ "loss": 2.2092,
548
+ "step": 45000
549
+ },
550
+ {
551
+ "epoch": 0.65,
552
+ "learning_rate": 9.629450770852482e-05,
553
+ "loss": 2.2096,
554
+ "step": 45500
555
+ },
556
+ {
557
+ "epoch": 0.66,
558
+ "learning_rate": 9.624258096677208e-05,
559
+ "loss": 2.2026,
560
+ "step": 46000
561
+ },
562
+ {
563
+ "epoch": 0.67,
564
+ "learning_rate": 9.619086193198635e-05,
565
+ "loss": 2.1971,
566
+ "step": 46500
567
+ },
568
+ {
569
+ "epoch": 0.68,
570
+ "learning_rate": 9.613893519023362e-05,
571
+ "loss": 2.1962,
572
+ "step": 47000
573
+ },
574
+ {
575
+ "epoch": 0.68,
576
+ "learning_rate": 9.60872161554479e-05,
577
+ "loss": 2.1918,
578
+ "step": 47500
579
+ },
580
+ {
581
+ "epoch": 0.69,
582
+ "learning_rate": 9.603528941369516e-05,
583
+ "loss": 2.1932,
584
+ "step": 48000
585
+ },
586
+ {
587
+ "epoch": 0.7,
588
+ "learning_rate": 9.598357037890943e-05,
589
+ "loss": 2.1844,
590
+ "step": 48500
591
+ },
592
+ {
593
+ "epoch": 0.71,
594
+ "learning_rate": 9.59316436371567e-05,
595
+ "loss": 2.1872,
596
+ "step": 49000
597
+ },
598
+ {
599
+ "epoch": 0.71,
600
+ "learning_rate": 9.587992460237098e-05,
601
+ "loss": 2.1781,
602
+ "step": 49500
603
+ },
604
+ {
605
+ "epoch": 0.72,
606
+ "learning_rate": 9.582799786061825e-05,
607
+ "loss": 2.1797,
608
+ "step": 50000
609
+ },
610
+ {
611
+ "epoch": 0.73,
612
+ "learning_rate": 9.577627882583253e-05,
613
+ "loss": 2.1793,
614
+ "step": 50500
615
+ },
616
+ {
617
+ "epoch": 0.73,
618
+ "learning_rate": 9.572435208407978e-05,
619
+ "loss": 2.1736,
620
+ "step": 51000
621
+ },
622
+ {
623
+ "epoch": 0.74,
624
+ "learning_rate": 9.567263304929406e-05,
625
+ "loss": 2.1723,
626
+ "step": 51500
627
+ },
628
+ {
629
+ "epoch": 0.75,
630
+ "learning_rate": 9.562070630754133e-05,
631
+ "loss": 2.1732,
632
+ "step": 52000
633
+ },
634
+ {
635
+ "epoch": 0.76,
636
+ "learning_rate": 9.55689872727556e-05,
637
+ "loss": 2.1654,
638
+ "step": 52500
639
+ },
640
+ {
641
+ "epoch": 0.76,
642
+ "learning_rate": 9.551706053100287e-05,
643
+ "loss": 2.1678,
644
+ "step": 53000
645
+ },
646
+ {
647
+ "epoch": 0.77,
648
+ "learning_rate": 9.546534149621714e-05,
649
+ "loss": 2.1632,
650
+ "step": 53500
651
+ },
652
+ {
653
+ "epoch": 0.78,
654
+ "learning_rate": 9.54134147544644e-05,
655
+ "loss": 2.158,
656
+ "step": 54000
657
+ },
658
+ {
659
+ "epoch": 0.78,
660
+ "learning_rate": 9.536169571967868e-05,
661
+ "loss": 2.1551,
662
+ "step": 54500
663
+ },
664
+ {
665
+ "epoch": 0.79,
666
+ "learning_rate": 9.530976897792595e-05,
667
+ "loss": 2.1553,
668
+ "step": 55000
669
+ },
670
+ {
671
+ "epoch": 0.8,
672
+ "learning_rate": 9.525804994314023e-05,
673
+ "loss": 2.1469,
674
+ "step": 55500
675
+ },
676
+ {
677
+ "epoch": 0.81,
678
+ "learning_rate": 9.520612320138748e-05,
679
+ "loss": 2.1517,
680
+ "step": 56000
681
+ },
682
+ {
683
+ "epoch": 0.81,
684
+ "learning_rate": 9.515440416660176e-05,
685
+ "loss": 2.1499,
686
+ "step": 56500
687
+ },
688
+ {
689
+ "epoch": 0.82,
690
+ "learning_rate": 9.510247742484903e-05,
691
+ "loss": 2.144,
692
+ "step": 57000
693
+ },
694
+ {
695
+ "epoch": 0.83,
696
+ "learning_rate": 9.50507583900633e-05,
697
+ "loss": 2.1478,
698
+ "step": 57500
699
+ },
700
+ {
701
+ "epoch": 0.83,
702
+ "learning_rate": 9.499883164831058e-05,
703
+ "loss": 2.1369,
704
+ "step": 58000
705
+ },
706
+ {
707
+ "epoch": 0.84,
708
+ "learning_rate": 9.494711261352485e-05,
709
+ "loss": 2.1394,
710
+ "step": 58500
711
+ },
712
+ {
713
+ "epoch": 0.85,
714
+ "learning_rate": 9.489518587177211e-05,
715
+ "loss": 2.1391,
716
+ "step": 59000
717
+ },
718
+ {
719
+ "epoch": 0.86,
720
+ "learning_rate": 9.484346683698639e-05,
721
+ "loss": 2.1344,
722
+ "step": 59500
723
+ },
724
+ {
725
+ "epoch": 0.86,
726
+ "learning_rate": 9.479154009523364e-05,
727
+ "loss": 2.1371,
728
+ "step": 60000
729
+ },
730
+ {
731
+ "epoch": 0.87,
732
+ "learning_rate": 9.473982106044792e-05,
733
+ "loss": 2.1289,
734
+ "step": 60500
735
+ },
736
+ {
737
+ "epoch": 0.88,
738
+ "learning_rate": 9.468789431869519e-05,
739
+ "loss": 2.1271,
740
+ "step": 61000
741
+ },
742
+ {
743
+ "epoch": 0.89,
744
+ "learning_rate": 9.463617528390946e-05,
745
+ "loss": 2.1276,
746
+ "step": 61500
747
+ },
748
+ {
749
+ "epoch": 0.89,
750
+ "learning_rate": 9.458424854215673e-05,
751
+ "loss": 2.1255,
752
+ "step": 62000
753
+ },
754
+ {
755
+ "epoch": 0.9,
756
+ "learning_rate": 9.453252950737101e-05,
757
+ "loss": 2.1192,
758
+ "step": 62500
759
+ },
760
+ {
761
+ "epoch": 0.91,
762
+ "learning_rate": 9.448060276561828e-05,
763
+ "loss": 2.1166,
764
+ "step": 63000
765
+ },
766
+ {
767
+ "epoch": 0.91,
768
+ "learning_rate": 9.442888373083256e-05,
769
+ "loss": 2.1171,
770
+ "step": 63500
771
+ },
772
+ {
773
+ "epoch": 0.92,
774
+ "learning_rate": 9.437695698907981e-05,
775
+ "loss": 2.1127,
776
+ "step": 64000
777
+ },
778
+ {
779
+ "epoch": 0.93,
780
+ "learning_rate": 9.432523795429409e-05,
781
+ "loss": 2.1116,
782
+ "step": 64500
783
+ },
784
+ {
785
+ "epoch": 0.94,
786
+ "learning_rate": 9.427331121254134e-05,
787
+ "loss": 2.1121,
788
+ "step": 65000
789
+ },
790
+ {
791
+ "epoch": 0.94,
792
+ "learning_rate": 9.422159217775562e-05,
793
+ "loss": 2.1093,
794
+ "step": 65500
795
+ },
796
+ {
797
+ "epoch": 0.95,
798
+ "learning_rate": 9.41696654360029e-05,
799
+ "loss": 2.1103,
800
+ "step": 66000
801
+ },
802
+ {
803
+ "epoch": 0.96,
804
+ "learning_rate": 9.411794640121717e-05,
805
+ "loss": 2.1073,
806
+ "step": 66500
807
+ },
808
+ {
809
+ "epoch": 0.96,
810
+ "learning_rate": 9.406601965946444e-05,
811
+ "loss": 2.1057,
812
+ "step": 67000
813
+ },
814
+ {
815
+ "epoch": 0.97,
816
+ "learning_rate": 9.401430062467871e-05,
817
+ "loss": 2.1012,
818
+ "step": 67500
819
+ },
820
+ {
821
+ "epoch": 0.98,
822
+ "learning_rate": 9.396237388292597e-05,
823
+ "loss": 2.1012,
824
+ "step": 68000
825
+ },
826
+ {
827
+ "epoch": 0.99,
828
+ "learning_rate": 9.391065484814025e-05,
829
+ "loss": 2.1041,
830
+ "step": 68500
831
+ },
832
+ {
833
+ "epoch": 0.99,
834
+ "learning_rate": 9.385872810638751e-05,
835
+ "loss": 2.0974,
836
+ "step": 69000
837
+ },
838
+ {
839
+ "epoch": 1.0,
840
+ "eval_accuracy": 0.6071486253641302,
841
+ "eval_loss": 1.974609375,
842
+ "eval_runtime": 652.8749,
843
+ "eval_samples_per_second": 825.483,
844
+ "eval_steps_per_second": 34.396,
845
+ "step": 69473
846
+ }
847
+ ],
848
+ "max_steps": 972622,
849
+ "num_train_epochs": 14,
850
+ "total_flos": 4.979851725289554e+17,
851
+ "trial_name": null,
852
+ "trial_params": null
853
+ }
last-checkpoint/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd54042cd89784f24506b5912f250d73ea83faa93bfe5b987bbcaed0572116e8
3
+ size 4335
last-checkpoint/zero_to_fp32.py ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # This script extracts fp32 consolidated weights from a zero 2 and 3 DeepSpeed checkpoints. It gets
4
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
5
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
6
+ # application.
7
+ #
8
+ # example: python zero_to_fp32.py . pytorch_model.bin
9
+
10
+ import argparse
11
+ import torch
12
+ import glob
13
+ import math
14
+ import os
15
+ import re
16
+ from collections import OrderedDict
17
+
18
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
19
+ # DeepSpeed data structures it has to be available in the current python environment.
20
+ from deepspeed.utils import logger
21
+ from deepspeed.checkpoint.constants import (DS_VERSION,
22
+ OPTIMIZER_STATE_DICT,
23
+ SINGLE_PARTITION_OF_FP32_GROUPS,
24
+ FP32_FLAT_GROUPS,
25
+ ZERO_STAGE,
26
+ PARTITION_COUNT,
27
+ PARAM_SHAPES,
28
+ BUFFER_NAMES)
29
+
30
+ debug = 0
31
+
32
+ # load to cpu
33
+ device = torch.device('cpu')
34
+
35
+
36
+ def atoi(text):
37
+ return int(text) if text.isdigit() else text
38
+
39
+
40
+ def natural_keys(text):
41
+ '''
42
+ alist.sort(key=natural_keys) sorts in human order
43
+ http://nedbatchelder.com/blog/200712/human_sorting.html
44
+ (See Toothy's implementation in the comments)
45
+ '''
46
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
47
+
48
+
49
+ def get_model_state_file(checkpoint_dir, zero_stage):
50
+ if not os.path.isdir(checkpoint_dir):
51
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
52
+
53
+ # there should be only one file
54
+ if zero_stage == 2:
55
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
56
+ elif zero_stage == 3:
57
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
58
+
59
+ if not os.path.exists(file):
60
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
61
+
62
+ return file
63
+
64
+
65
+ def get_optim_files(checkpoint_dir):
66
+ # XXX: need to test that this simple glob rule works for multi-node setup too
67
+ optim_files = sorted(glob.glob(os.path.join(checkpoint_dir,
68
+ "*_optim_states.pt")),
69
+ key=natural_keys)
70
+
71
+ if len(optim_files) == 0:
72
+ raise FileNotFoundError(
73
+ f"can't find '*_optim_states.pt' files in directory '{checkpoint_dir}'")
74
+
75
+ return optim_files
76
+
77
+
78
+ def parse_model_state(file):
79
+ state_dict = torch.load(file, map_location=device)
80
+
81
+ if BUFFER_NAMES not in state_dict:
82
+ raise ValueError(f"{file} is not a model state checkpoint")
83
+ buffer_names = state_dict[BUFFER_NAMES]
84
+ if debug:
85
+ print("Found buffers:", buffer_names)
86
+
87
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
88
+ buffers = {
89
+ k: v.float()
90
+ for k,
91
+ v in state_dict["module"].items() if k in buffer_names
92
+ }
93
+ param_shapes = state_dict[PARAM_SHAPES]
94
+
95
+ ds_version = state_dict.get(DS_VERSION, None)
96
+
97
+ return buffers, param_shapes, ds_version
98
+
99
+
100
+ def parse_optim_states(files, ds_checkpoint_dir):
101
+
102
+ total_files = len(files)
103
+ state_dicts = []
104
+ for f in files:
105
+ state_dicts.append(torch.load(f, map_location=device))
106
+
107
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
108
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
109
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
110
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
111
+
112
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
113
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
114
+ # use the max of the partition_count to get the dp world_size.
115
+
116
+ if type(world_size) is list:
117
+ world_size = max(world_size)
118
+
119
+ if world_size != total_files:
120
+ raise ValueError(
121
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
122
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
123
+ )
124
+
125
+ # the groups are named differently in each stage
126
+ if zero_stage == 2:
127
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
128
+ elif zero_stage == 3:
129
+ fp32_groups_key = FP32_FLAT_GROUPS
130
+ else:
131
+ raise ValueError(f"unknown zero stage {zero_stage}")
132
+
133
+ if zero_stage == 2:
134
+ fp32_flat_groups = [
135
+ state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key]
136
+ for i in range(len(state_dicts))
137
+ ]
138
+ elif zero_stage == 3:
139
+ # if there is more than one param group, there will be multiple flattened tensors - one
140
+ # flattened tensor per group - for simplicity merge them into a single tensor
141
+ #
142
+ # XXX: could make the script more memory efficient for when there are multiple groups - it
143
+ # will require matching the sub-lists of param_shapes for each param group flattened tensor
144
+
145
+ fp32_flat_groups = [
146
+ torch.cat(state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key],
147
+ 0) for i in range(len(state_dicts))
148
+ ]
149
+
150
+ return zero_stage, world_size, fp32_flat_groups
151
+
152
+
153
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir):
154
+ """
155
+ Returns fp32 state_dict reconstructed from ds checkpoint
156
+
157
+ Args:
158
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
159
+
160
+ """
161
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
162
+
163
+ optim_files = get_optim_files(ds_checkpoint_dir)
164
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
165
+ print(
166
+ f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
167
+
168
+ model_file = get_model_state_file(ds_checkpoint_dir, zero_stage)
169
+ buffers, param_shapes, ds_version = parse_model_state(model_file)
170
+ print(f'Parsing checkpoint created by deepspeed=={ds_version}')
171
+
172
+ if zero_stage == 2:
173
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size,
174
+ param_shapes,
175
+ fp32_flat_groups,
176
+ buffers)
177
+ elif zero_stage == 3:
178
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size,
179
+ param_shapes,
180
+ fp32_flat_groups,
181
+ buffers)
182
+
183
+
184
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size,
185
+ param_shapes,
186
+ fp32_flat_groups,
187
+ buffers):
188
+
189
+ # Reconstruction protocol:
190
+ #
191
+ # XXX: document this
192
+
193
+ if debug:
194
+ for i in range(world_size):
195
+ for j in range(len(fp32_flat_groups[0])):
196
+ print(
197
+ f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
198
+
199
+ # XXX: memory usage doubles here (zero2)
200
+ num_param_groups = len(fp32_flat_groups[0])
201
+ merged_single_partition_of_fp32_groups = []
202
+ for i in range(num_param_groups):
203
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
204
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
205
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
206
+ avail_numel = sum([
207
+ full_single_fp32_vector.numel()
208
+ for full_single_fp32_vector in merged_single_partition_of_fp32_groups
209
+ ])
210
+
211
+ if debug:
212
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
213
+ wanted_numel = sum(
214
+ [sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
215
+ # not asserting if there is a mismatch due to possible padding
216
+ print(f"Have {avail_numel} numels to process.")
217
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
218
+
219
+ state_dict = OrderedDict()
220
+
221
+ # buffers
222
+ state_dict.update(buffers)
223
+ if debug:
224
+ print(f"added {len(buffers)} buffers")
225
+
226
+ # params
227
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
228
+ # out-of-core computing solution
229
+ total_numel = 0
230
+ total_params = 0
231
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
232
+ offset = 0
233
+ avail_numel = full_single_fp32_vector.numel()
234
+ for name, shape in shapes.items():
235
+
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+ total_params += 1
239
+
240
+ if debug:
241
+ print(
242
+ f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} "
243
+ )
244
+ state_dict[name] = full_single_fp32_vector.narrow(
245
+ 0,
246
+ offset,
247
+ unpartitioned_numel).view(shape)
248
+ offset += unpartitioned_numel
249
+
250
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
251
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
252
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
253
+ # live optimizer object, so we are checking that the numbers are within the right range
254
+ align_to = 2 * world_size
255
+
256
+ def zero2_align(x):
257
+ return align_to * math.ceil(x / align_to)
258
+
259
+ if debug:
260
+ print(f"original offset={offset}, avail_numel={avail_numel}")
261
+
262
+ offset = zero2_align(offset)
263
+ avail_numel = zero2_align(avail_numel)
264
+
265
+ if debug:
266
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
267
+
268
+ # Sanity check
269
+ if offset != avail_numel:
270
+ raise ValueError(
271
+ f"consumed {offset} numels out of {avail_numel} - something is wrong")
272
+
273
+ print(
274
+ f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements"
275
+ )
276
+
277
+ return state_dict
278
+
279
+
280
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
281
+ remainder = unpartitioned_numel % world_size
282
+ padding_numel = (world_size - remainder) if remainder else 0
283
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
284
+ return partitioned_numel, padding_numel
285
+
286
+
287
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size,
288
+ param_shapes,
289
+ fp32_flat_groups,
290
+ buffers):
291
+
292
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
293
+ # param, re-consolidating each param, while dealing with padding if any
294
+
295
+ avail_numel = fp32_flat_groups[0].numel() * world_size
296
+ # merge list of dicts, preserving order
297
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
298
+
299
+ if debug:
300
+ for i in range(world_size):
301
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
302
+
303
+ wanted_params = len(param_shapes)
304
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
305
+ # not asserting if there is a mismatch due to possible padding
306
+ print(f"Have {avail_numel} numels to process.")
307
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
308
+
309
+ state_dict = OrderedDict()
310
+
311
+ # buffers
312
+ state_dict.update(buffers)
313
+ if debug:
314
+ print(f"added {len(buffers)} buffers")
315
+
316
+ # params
317
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
318
+ # out-of-core computing solution
319
+ offset = 0
320
+ total_numel = 0
321
+ total_params = 0
322
+ for name, shape in param_shapes.items():
323
+
324
+ unpartitioned_numel = shape.numel()
325
+ total_numel += unpartitioned_numel
326
+ total_params += 1
327
+
328
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
329
+
330
+ if debug:
331
+ print(
332
+ f"{total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
333
+ )
334
+
335
+ # XXX: memory usage doubles here
336
+ state_dict[name] = torch.cat(
337
+ tuple(fp32_flat_groups[i].narrow(0,
338
+ offset,
339
+ partitioned_numel)
340
+ for i in range(world_size)),
341
+ 0).narrow(0,
342
+ 0,
343
+ unpartitioned_numel).view(shape)
344
+ offset += partitioned_numel
345
+
346
+ offset *= world_size
347
+
348
+ # Sanity check
349
+ if offset != avail_numel:
350
+ raise ValueError(
351
+ f"consumed {offset} numels out of {avail_numel} - something is wrong")
352
+
353
+ print(
354
+ f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements"
355
+ )
356
+
357
+ return state_dict
358
+
359
+
360
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag=None):
361
+ """
362
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
363
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
364
+ via a model hub.
365
+
366
+ Args:
367
+ - ``checkpoint_dir``: path to the desired checkpoint folder
368
+ - ``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``
369
+
370
+ Returns:
371
+ - pytorch ``state_dict``
372
+
373
+ Note: this approach may not work if your application doesn't have sufficient free CPU memory and
374
+ you may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
375
+ the checkpoint.
376
+
377
+ A typical usage might be ::
378
+
379
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
380
+ # do the training and checkpoint saving
381
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
382
+ model = model.cpu() # move to cpu
383
+ model.load_state_dict(state_dict)
384
+ # submit to model hub or save the model to share with others
385
+
386
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
387
+ application. i.e. you will need to re-initialize the deepspeed engine, since
388
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
389
+
390
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
391
+
392
+ """
393
+ if tag is None:
394
+ latest_path = os.path.join(checkpoint_dir, 'latest')
395
+ if os.path.isfile(latest_path):
396
+ with open(latest_path, 'r') as fd:
397
+ tag = fd.read().strip()
398
+ else:
399
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
400
+
401
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
402
+
403
+ if not os.path.isdir(ds_checkpoint_dir):
404
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
405
+
406
+ return _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir)
407
+
408
+
409
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir, output_file, tag=None):
410
+ """
411
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
412
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
413
+
414
+ Args:
415
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
416
+ - ``output_file``: path to the pytorch fp32 state_dict output file (e.g. path/pytorch_model.bin)
417
+ - ``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``
418
+ """
419
+
420
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
421
+ print(f"Saving fp32 state dict to {output_file}")
422
+ torch.save(state_dict, output_file)
423
+
424
+
425
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
426
+ """
427
+ 1. Put the provided model to cpu
428
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
429
+ 3. Load it into the provided model
430
+
431
+ Args:
432
+ - ``model``: the model object to update
433
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
434
+ - ``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``
435
+
436
+ Returns:
437
+ - ``model`: modified model
438
+
439
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
440
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
441
+ conveniently placed for you in the checkpoint folder.
442
+
443
+ A typical usage might be ::
444
+
445
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
446
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
447
+ # submit to model hub or save the model to share with others
448
+
449
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
450
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
451
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
452
+
453
+ """
454
+ logger.info(f"Extracting fp32 weights")
455
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
456
+
457
+ logger.info(f"Overwriting model with fp32 weights")
458
+ model = model.cpu()
459
+ model.load_state_dict(state_dict, strict=False)
460
+
461
+ return model
462
+
463
+
464
+ if __name__ == "__main__":
465
+
466
+ parser = argparse.ArgumentParser()
467
+ parser.add_argument(
468
+ "checkpoint_dir",
469
+ type=str,
470
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
471
+ parser.add_argument(
472
+ "output_file",
473
+ type=str,
474
+ help=
475
+ "path to the pytorch fp32 state_dict output file (e.g. path/checkpoint-12/pytorch_model.bin)"
476
+ )
477
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
478
+ args = parser.parse_args()
479
+
480
+ debug = args.debug
481
+
482
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir, args.output_file)
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ea8f19b9cfae5ac1f4aea53be2d9bc355af72960cde88e7effe294d0e4c658a
3
+ size 59121639
runs/Feb22_11-16-27_user-SYS-5049A-TR/1677032209.4666054/events.out.tfevents.1677032209.user-SYS-5049A-TR.55703.1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41cbcb6bee5dad543a261dde1389d4ce02265542aab50a2d33ea2155f5d50a01
3
+ size 5216
runs/Feb22_11-16-27_user-SYS-5049A-TR/events.out.tfevents.1677032209.user-SYS-5049A-TR.55703.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b5e6ec22f6237d4a73cb5a4cb804a2c4a4a8a5a9b3bee19852fac349088ab1e
3
+ size 25754
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cls_token": "[CLS]", "mask_token": "[MASK]", "model_max_length": 128, "pad_token": "[PAD]", "padding_side": "right", "sep_token": "[SEP]", "truncation_side": "right", "unk_token": "[UNK]", "special_tokens_map_file": "pretrained_tokenizers/UnidicBpe2/special_tokens_map.json", "name_or_path": "pretrained_tokenizers/UnidicBpe2", "tokenizer_class": "PreTrainedTokenizerFast"}
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd54042cd89784f24506b5912f250d73ea83faa93bfe5b987bbcaed0572116e8
3
+ size 4335