Training in progress, step 2000
Browse files- checkpoint-2000/config.json +41 -0
- checkpoint-2000/global_step2000/mp_rank_00_model_states.pt +3 -0
- checkpoint-2000/global_step2000/zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
- checkpoint-2000/latest +1 -0
- checkpoint-2000/preprocessor_config.json +0 -0
- checkpoint-2000/pytorch_model.bin +3 -0
- checkpoint-2000/rng_state.pth +3 -0
- checkpoint-2000/trainer_state.json +514 -0
- checkpoint-2000/training_args.bin +3 -0
- checkpoint-2000/zero_to_fp32.py +482 -0
- pytorch_model.bin +1 -1
- runs/Dec22_17-47-55_129-146-176-120/events.out.tfevents.1671731318.129-146-176-120.842798.0 +2 -2
checkpoint-2000/config.json
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "emilios/whisper-medium-el-n2",
|
3 |
+
"activation_dropout": 0.0,
|
4 |
+
"activation_function": "gelu",
|
5 |
+
"architectures": [
|
6 |
+
"WhisperForConditionalGeneration"
|
7 |
+
],
|
8 |
+
"attention_dropout": 0.1,
|
9 |
+
"begin_suppress_tokens": [
|
10 |
+
220,
|
11 |
+
50257
|
12 |
+
],
|
13 |
+
"bos_token_id": 50257,
|
14 |
+
"d_model": 1024,
|
15 |
+
"decoder_attention_heads": 16,
|
16 |
+
"decoder_ffn_dim": 4096,
|
17 |
+
"decoder_layerdrop": 0.0,
|
18 |
+
"decoder_layers": 24,
|
19 |
+
"decoder_start_token_id": 50258,
|
20 |
+
"dropout": 0.1,
|
21 |
+
"encoder_attention_heads": 16,
|
22 |
+
"encoder_ffn_dim": 4096,
|
23 |
+
"encoder_layerdrop": 0.0,
|
24 |
+
"encoder_layers": 24,
|
25 |
+
"eos_token_id": 50257,
|
26 |
+
"forced_decoder_ids": null,
|
27 |
+
"init_std": 0.02,
|
28 |
+
"is_encoder_decoder": true,
|
29 |
+
"max_length": 448,
|
30 |
+
"max_source_positions": 1500,
|
31 |
+
"max_target_positions": 448,
|
32 |
+
"model_type": "whisper",
|
33 |
+
"num_hidden_layers": 24,
|
34 |
+
"num_mel_bins": 80,
|
35 |
+
"pad_token_id": 50257,
|
36 |
+
"scale_embedding": false,
|
37 |
+
"torch_dtype": "float16",
|
38 |
+
"transformers_version": "4.26.0.dev0",
|
39 |
+
"use_cache": false,
|
40 |
+
"vocab_size": 51865
|
41 |
+
}
|
checkpoint-2000/global_step2000/mp_rank_00_model_states.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:09147113f409edbd3320ffe6566a545e03155fcc97b5f58b1489e760988fff64
|
3 |
+
size 1527967899
|
checkpoint-2000/global_step2000/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:d1738ed1e00d898c05e08689072ee5acc751eafd96506f2c621c91440676d48e
|
3 |
+
size 9166378846
|
checkpoint-2000/latest
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
global_step2000
|
checkpoint-2000/preprocessor_config.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
checkpoint-2000/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:05cc466e70f2ceed7e53361d15918882e5610e783f0af6aed4bb9bc097ecab2c
|
3 |
+
size 1527847357
|
checkpoint-2000/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": 10.27117384843982,
|
3 |
+
"best_model_checkpoint": "./checkpoint-2000",
|
4 |
+
"epoch": 117.6470588235294,
|
5 |
+
"global_step": 2000,
|
6 |
+
"is_hyper_param_search": false,
|
7 |
+
"is_local_process_zero": true,
|
8 |
+
"is_world_process_zero": true,
|
9 |
+
"log_history": [
|
10 |
+
{
|
11 |
+
"epoch": 1.47,
|
12 |
+
"learning_rate": 1.5136083400296205e-06,
|
13 |
+
"loss": 0.0024,
|
14 |
+
"step": 25
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"epoch": 2.94,
|
18 |
+
"learning_rate": 1.8687587131475301e-06,
|
19 |
+
"loss": 0.0024,
|
20 |
+
"step": 50
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"epoch": 4.41,
|
24 |
+
"learning_rate": 2.0711488350670174e-06,
|
25 |
+
"loss": 0.0023,
|
26 |
+
"step": 75
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"epoch": 5.88,
|
30 |
+
"learning_rate": 2.213317753617305e-06,
|
31 |
+
"loss": 0.0023,
|
32 |
+
"step": 100
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"epoch": 7.35,
|
36 |
+
"learning_rate": 2.3230029693718747e-06,
|
37 |
+
"loss": 0.002,
|
38 |
+
"step": 125
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"epoch": 8.82,
|
42 |
+
"learning_rate": 2.412322158351148e-06,
|
43 |
+
"loss": 0.002,
|
44 |
+
"step": 150
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"epoch": 10.29,
|
48 |
+
"learning_rate": 2.4876668872198717e-06,
|
49 |
+
"loss": 0.0022,
|
50 |
+
"step": 175
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"epoch": 11.76,
|
54 |
+
"learning_rate": 2.552824062407326e-06,
|
55 |
+
"loss": 0.0021,
|
56 |
+
"step": 200
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"epoch": 13.24,
|
60 |
+
"learning_rate": 2.610223373296667e-06,
|
61 |
+
"loss": 0.0034,
|
62 |
+
"step": 225
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"epoch": 14.71,
|
66 |
+
"learning_rate": 2.661517182828361e-06,
|
67 |
+
"loss": 0.0019,
|
68 |
+
"step": 250
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"epoch": 16.18,
|
72 |
+
"learning_rate": 2.7078803874740543e-06,
|
73 |
+
"loss": 0.0018,
|
74 |
+
"step": 275
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"epoch": 17.65,
|
78 |
+
"learning_rate": 2.750178319990197e-06,
|
79 |
+
"loss": 0.0023,
|
80 |
+
"step": 300
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"epoch": 19.12,
|
84 |
+
"learning_rate": 2.7890667754365044e-06,
|
85 |
+
"loss": 0.0019,
|
86 |
+
"step": 325
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"epoch": 20.59,
|
90 |
+
"learning_rate": 2.8250546392106077e-06,
|
91 |
+
"loss": 0.0021,
|
92 |
+
"step": 350
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"epoch": 22.06,
|
96 |
+
"learning_rate": 2.8585447348549113e-06,
|
97 |
+
"loss": 0.0023,
|
98 |
+
"step": 375
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"epoch": 23.53,
|
102 |
+
"learning_rate": 2.889861392935294e-06,
|
103 |
+
"loss": 0.0021,
|
104 |
+
"step": 400
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"epoch": 25.0,
|
108 |
+
"learning_rate": 2.9192696063561725e-06,
|
109 |
+
"loss": 0.0016,
|
110 |
+
"step": 425
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"epoch": 26.47,
|
114 |
+
"learning_rate": 2.946988676871634e-06,
|
115 |
+
"loss": 0.0018,
|
116 |
+
"step": 450
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"epoch": 27.94,
|
120 |
+
"learning_rate": 2.973202150939645e-06,
|
121 |
+
"loss": 0.0022,
|
122 |
+
"step": 475
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"epoch": 29.41,
|
126 |
+
"learning_rate": 2.998065193492142e-06,
|
127 |
+
"loss": 0.0018,
|
128 |
+
"step": 500
|
129 |
+
},
|
130 |
+
{
|
131 |
+
"epoch": 30.88,
|
132 |
+
"learning_rate": 2.9559999999999997e-06,
|
133 |
+
"loss": 0.0018,
|
134 |
+
"step": 525
|
135 |
+
},
|
136 |
+
{
|
137 |
+
"epoch": 32.35,
|
138 |
+
"learning_rate": 2.9060000000000002e-06,
|
139 |
+
"loss": 0.0021,
|
140 |
+
"step": 550
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"epoch": 33.82,
|
144 |
+
"learning_rate": 2.856e-06,
|
145 |
+
"loss": 0.0017,
|
146 |
+
"step": 575
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"epoch": 35.29,
|
150 |
+
"learning_rate": 2.8060000000000003e-06,
|
151 |
+
"loss": 0.0018,
|
152 |
+
"step": 600
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"epoch": 36.76,
|
156 |
+
"learning_rate": 2.756e-06,
|
157 |
+
"loss": 0.0016,
|
158 |
+
"step": 625
|
159 |
+
},
|
160 |
+
{
|
161 |
+
"epoch": 38.24,
|
162 |
+
"learning_rate": 2.706e-06,
|
163 |
+
"loss": 0.0017,
|
164 |
+
"step": 650
|
165 |
+
},
|
166 |
+
{
|
167 |
+
"epoch": 39.71,
|
168 |
+
"learning_rate": 2.656e-06,
|
169 |
+
"loss": 0.0016,
|
170 |
+
"step": 675
|
171 |
+
},
|
172 |
+
{
|
173 |
+
"epoch": 41.18,
|
174 |
+
"learning_rate": 2.606e-06,
|
175 |
+
"loss": 0.0013,
|
176 |
+
"step": 700
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"epoch": 42.65,
|
180 |
+
"learning_rate": 2.556e-06,
|
181 |
+
"loss": 0.0013,
|
182 |
+
"step": 725
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"epoch": 44.12,
|
186 |
+
"learning_rate": 2.5060000000000002e-06,
|
187 |
+
"loss": 0.0012,
|
188 |
+
"step": 750
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"epoch": 45.59,
|
192 |
+
"learning_rate": 2.456e-06,
|
193 |
+
"loss": 0.0013,
|
194 |
+
"step": 775
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"epoch": 47.06,
|
198 |
+
"learning_rate": 2.4060000000000003e-06,
|
199 |
+
"loss": 0.0013,
|
200 |
+
"step": 800
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"epoch": 48.53,
|
204 |
+
"learning_rate": 2.356e-06,
|
205 |
+
"loss": 0.0013,
|
206 |
+
"step": 825
|
207 |
+
},
|
208 |
+
{
|
209 |
+
"epoch": 50.0,
|
210 |
+
"learning_rate": 2.306e-06,
|
211 |
+
"loss": 0.0011,
|
212 |
+
"step": 850
|
213 |
+
},
|
214 |
+
{
|
215 |
+
"epoch": 51.47,
|
216 |
+
"learning_rate": 2.256e-06,
|
217 |
+
"loss": 0.0013,
|
218 |
+
"step": 875
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"epoch": 52.94,
|
222 |
+
"learning_rate": 2.2059999999999997e-06,
|
223 |
+
"loss": 0.0014,
|
224 |
+
"step": 900
|
225 |
+
},
|
226 |
+
{
|
227 |
+
"epoch": 54.41,
|
228 |
+
"learning_rate": 2.156e-06,
|
229 |
+
"loss": 0.0011,
|
230 |
+
"step": 925
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"epoch": 55.88,
|
234 |
+
"learning_rate": 2.106e-06,
|
235 |
+
"loss": 0.0024,
|
236 |
+
"step": 950
|
237 |
+
},
|
238 |
+
{
|
239 |
+
"epoch": 57.35,
|
240 |
+
"learning_rate": 2.0560000000000003e-06,
|
241 |
+
"loss": 0.0014,
|
242 |
+
"step": 975
|
243 |
+
},
|
244 |
+
{
|
245 |
+
"epoch": 58.82,
|
246 |
+
"learning_rate": 2.006e-06,
|
247 |
+
"loss": 0.0014,
|
248 |
+
"step": 1000
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"epoch": 58.82,
|
252 |
+
"eval_loss": 0.494384765625,
|
253 |
+
"eval_runtime": 154.3699,
|
254 |
+
"eval_samples_per_second": 1.762,
|
255 |
+
"eval_steps_per_second": 0.11,
|
256 |
+
"eval_wer": 10.36404160475483,
|
257 |
+
"step": 1000
|
258 |
+
},
|
259 |
+
{
|
260 |
+
"epoch": 60.29,
|
261 |
+
"learning_rate": 1.96e-06,
|
262 |
+
"loss": 0.0012,
|
263 |
+
"step": 1025
|
264 |
+
},
|
265 |
+
{
|
266 |
+
"epoch": 61.76,
|
267 |
+
"learning_rate": 1.9100000000000003e-06,
|
268 |
+
"loss": 0.0009,
|
269 |
+
"step": 1050
|
270 |
+
},
|
271 |
+
{
|
272 |
+
"epoch": 63.24,
|
273 |
+
"learning_rate": 1.86e-06,
|
274 |
+
"loss": 0.0012,
|
275 |
+
"step": 1075
|
276 |
+
},
|
277 |
+
{
|
278 |
+
"epoch": 64.71,
|
279 |
+
"learning_rate": 1.8100000000000002e-06,
|
280 |
+
"loss": 0.0009,
|
281 |
+
"step": 1100
|
282 |
+
},
|
283 |
+
{
|
284 |
+
"epoch": 66.18,
|
285 |
+
"learning_rate": 1.76e-06,
|
286 |
+
"loss": 0.0012,
|
287 |
+
"step": 1125
|
288 |
+
},
|
289 |
+
{
|
290 |
+
"epoch": 67.65,
|
291 |
+
"learning_rate": 1.71e-06,
|
292 |
+
"loss": 0.0012,
|
293 |
+
"step": 1150
|
294 |
+
},
|
295 |
+
{
|
296 |
+
"epoch": 69.12,
|
297 |
+
"learning_rate": 1.66e-06,
|
298 |
+
"loss": 0.0009,
|
299 |
+
"step": 1175
|
300 |
+
},
|
301 |
+
{
|
302 |
+
"epoch": 70.59,
|
303 |
+
"learning_rate": 1.6099999999999998e-06,
|
304 |
+
"loss": 0.0007,
|
305 |
+
"step": 1200
|
306 |
+
},
|
307 |
+
{
|
308 |
+
"epoch": 72.06,
|
309 |
+
"learning_rate": 1.56e-06,
|
310 |
+
"loss": 0.0011,
|
311 |
+
"step": 1225
|
312 |
+
},
|
313 |
+
{
|
314 |
+
"epoch": 73.53,
|
315 |
+
"learning_rate": 1.51e-06,
|
316 |
+
"loss": 0.0014,
|
317 |
+
"step": 1250
|
318 |
+
},
|
319 |
+
{
|
320 |
+
"epoch": 75.0,
|
321 |
+
"learning_rate": 1.4600000000000002e-06,
|
322 |
+
"loss": 0.0008,
|
323 |
+
"step": 1275
|
324 |
+
},
|
325 |
+
{
|
326 |
+
"epoch": 76.47,
|
327 |
+
"learning_rate": 1.41e-06,
|
328 |
+
"loss": 0.0009,
|
329 |
+
"step": 1300
|
330 |
+
},
|
331 |
+
{
|
332 |
+
"epoch": 77.94,
|
333 |
+
"learning_rate": 1.36e-06,
|
334 |
+
"loss": 0.0008,
|
335 |
+
"step": 1325
|
336 |
+
},
|
337 |
+
{
|
338 |
+
"epoch": 79.41,
|
339 |
+
"learning_rate": 1.31e-06,
|
340 |
+
"loss": 0.0009,
|
341 |
+
"step": 1350
|
342 |
+
},
|
343 |
+
{
|
344 |
+
"epoch": 80.88,
|
345 |
+
"learning_rate": 1.26e-06,
|
346 |
+
"loss": 0.0011,
|
347 |
+
"step": 1375
|
348 |
+
},
|
349 |
+
{
|
350 |
+
"epoch": 82.35,
|
351 |
+
"learning_rate": 1.21e-06,
|
352 |
+
"loss": 0.0007,
|
353 |
+
"step": 1400
|
354 |
+
},
|
355 |
+
{
|
356 |
+
"epoch": 83.82,
|
357 |
+
"learning_rate": 1.16e-06,
|
358 |
+
"loss": 0.0011,
|
359 |
+
"step": 1425
|
360 |
+
},
|
361 |
+
{
|
362 |
+
"epoch": 85.29,
|
363 |
+
"learning_rate": 1.11e-06,
|
364 |
+
"loss": 0.001,
|
365 |
+
"step": 1450
|
366 |
+
},
|
367 |
+
{
|
368 |
+
"epoch": 86.76,
|
369 |
+
"learning_rate": 1.06e-06,
|
370 |
+
"loss": 0.0008,
|
371 |
+
"step": 1475
|
372 |
+
},
|
373 |
+
{
|
374 |
+
"epoch": 88.24,
|
375 |
+
"learning_rate": 1.01e-06,
|
376 |
+
"loss": 0.0007,
|
377 |
+
"step": 1500
|
378 |
+
},
|
379 |
+
{
|
380 |
+
"epoch": 89.71,
|
381 |
+
"learning_rate": 9.600000000000001e-07,
|
382 |
+
"loss": 0.0006,
|
383 |
+
"step": 1525
|
384 |
+
},
|
385 |
+
{
|
386 |
+
"epoch": 91.18,
|
387 |
+
"learning_rate": 9.100000000000001e-07,
|
388 |
+
"loss": 0.0007,
|
389 |
+
"step": 1550
|
390 |
+
},
|
391 |
+
{
|
392 |
+
"epoch": 92.65,
|
393 |
+
"learning_rate": 8.6e-07,
|
394 |
+
"loss": 0.0006,
|
395 |
+
"step": 1575
|
396 |
+
},
|
397 |
+
{
|
398 |
+
"epoch": 94.12,
|
399 |
+
"learning_rate": 8.100000000000001e-07,
|
400 |
+
"loss": 0.0008,
|
401 |
+
"step": 1600
|
402 |
+
},
|
403 |
+
{
|
404 |
+
"epoch": 95.59,
|
405 |
+
"learning_rate": 7.600000000000001e-07,
|
406 |
+
"loss": 0.0009,
|
407 |
+
"step": 1625
|
408 |
+
},
|
409 |
+
{
|
410 |
+
"epoch": 97.06,
|
411 |
+
"learning_rate": 7.1e-07,
|
412 |
+
"loss": 0.0006,
|
413 |
+
"step": 1650
|
414 |
+
},
|
415 |
+
{
|
416 |
+
"epoch": 98.53,
|
417 |
+
"learning_rate": 6.6e-07,
|
418 |
+
"loss": 0.0006,
|
419 |
+
"step": 1675
|
420 |
+
},
|
421 |
+
{
|
422 |
+
"epoch": 100.0,
|
423 |
+
"learning_rate": 6.1e-07,
|
424 |
+
"loss": 0.0008,
|
425 |
+
"step": 1700
|
426 |
+
},
|
427 |
+
{
|
428 |
+
"epoch": 101.47,
|
429 |
+
"learning_rate": 5.6e-07,
|
430 |
+
"loss": 0.0006,
|
431 |
+
"step": 1725
|
432 |
+
},
|
433 |
+
{
|
434 |
+
"epoch": 102.94,
|
435 |
+
"learning_rate": 5.100000000000001e-07,
|
436 |
+
"loss": 0.0008,
|
437 |
+
"step": 1750
|
438 |
+
},
|
439 |
+
{
|
440 |
+
"epoch": 104.41,
|
441 |
+
"learning_rate": 4.6e-07,
|
442 |
+
"loss": 0.0006,
|
443 |
+
"step": 1775
|
444 |
+
},
|
445 |
+
{
|
446 |
+
"epoch": 105.88,
|
447 |
+
"learning_rate": 4.1e-07,
|
448 |
+
"loss": 0.0006,
|
449 |
+
"step": 1800
|
450 |
+
},
|
451 |
+
{
|
452 |
+
"epoch": 107.35,
|
453 |
+
"learning_rate": 3.6e-07,
|
454 |
+
"loss": 0.0007,
|
455 |
+
"step": 1825
|
456 |
+
},
|
457 |
+
{
|
458 |
+
"epoch": 108.82,
|
459 |
+
"learning_rate": 3.1e-07,
|
460 |
+
"loss": 0.0007,
|
461 |
+
"step": 1850
|
462 |
+
},
|
463 |
+
{
|
464 |
+
"epoch": 110.29,
|
465 |
+
"learning_rate": 2.6e-07,
|
466 |
+
"loss": 0.0007,
|
467 |
+
"step": 1875
|
468 |
+
},
|
469 |
+
{
|
470 |
+
"epoch": 111.76,
|
471 |
+
"learning_rate": 2.1000000000000003e-07,
|
472 |
+
"loss": 0.0005,
|
473 |
+
"step": 1900
|
474 |
+
},
|
475 |
+
{
|
476 |
+
"epoch": 113.24,
|
477 |
+
"learning_rate": 1.6e-07,
|
478 |
+
"loss": 0.0008,
|
479 |
+
"step": 1925
|
480 |
+
},
|
481 |
+
{
|
482 |
+
"epoch": 114.71,
|
483 |
+
"learning_rate": 1.1e-07,
|
484 |
+
"loss": 0.0006,
|
485 |
+
"step": 1950
|
486 |
+
},
|
487 |
+
{
|
488 |
+
"epoch": 116.18,
|
489 |
+
"learning_rate": 6.000000000000001e-08,
|
490 |
+
"loss": 0.0006,
|
491 |
+
"step": 1975
|
492 |
+
},
|
493 |
+
{
|
494 |
+
"epoch": 117.65,
|
495 |
+
"learning_rate": 1e-08,
|
496 |
+
"loss": 0.0007,
|
497 |
+
"step": 2000
|
498 |
+
},
|
499 |
+
{
|
500 |
+
"epoch": 117.65,
|
501 |
+
"eval_loss": 0.50830078125,
|
502 |
+
"eval_runtime": 170.147,
|
503 |
+
"eval_samples_per_second": 1.599,
|
504 |
+
"eval_steps_per_second": 0.1,
|
505 |
+
"eval_wer": 10.27117384843982,
|
506 |
+
"step": 2000
|
507 |
+
}
|
508 |
+
],
|
509 |
+
"max_steps": 2000,
|
510 |
+
"num_train_epochs": 118,
|
511 |
+
"total_flos": 6.161697879136351e+19,
|
512 |
+
"trial_name": null,
|
513 |
+
"trial_params": null
|
514 |
+
}
|
checkpoint-2000/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ed73d2b317cd1e368b1f5f7eb5b1eb41b01338f297addbfd473d2f8fb949e5d
|
3 |
+
size 4731
|
checkpoint-2000/zero_to_fp32.py
ADDED
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 1527847357
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:05cc466e70f2ceed7e53361d15918882e5610e783f0af6aed4bb9bc097ecab2c
|
3 |
size 1527847357
|
runs/Dec22_17-47-55_129-146-176-120/events.out.tfevents.1671731318.129-146-176-120.842798.0
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a4d49f22ddfd6d01ad8c521f956c799732c5bcee1ed342d63cd8d6566319773c
|
3 |
+
size 17483
|