tvkain commited on
Commit
f033d87
·
verified ·
1 Parent(s): e70c5f3

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. l2-13b-ga/checkpoint-2800/special_tokens_map.json +23 -0
  2. l2-13b-ga/checkpoint-2800/tokenizer_config.json +42 -0
  3. l2-13b-ga/checkpoint-3100/config.json +30 -0
  4. l2-13b-ga/checkpoint-3100/generation_config.json +10 -0
  5. l2-13b-ga/checkpoint-3100/latest +1 -0
  6. l2-13b-ga/checkpoint-3100/model.safetensors.index.json +370 -0
  7. l2-13b-ga/checkpoint-3100/special_tokens_map.json +23 -0
  8. l2-13b-ga/checkpoint-3100/tokenizer.json +0 -0
  9. l2-13b-ga/checkpoint-3100/tokenizer_config.json +42 -0
  10. l2-13b-ga/checkpoint-3100/trainer_state.json +2210 -0
  11. l2-13b-ga/checkpoint-3100/zero_to_fp32.py +592 -0
  12. q2.5-eu-en/checkpoint-1800/trainer_state.json +0 -0
  13. q2.5-eu-en/checkpoint-2400/added_tokens.json +24 -0
  14. q2.5-eu-en/checkpoint-2400/chat_template.jinja +54 -0
  15. q2.5-eu-en/checkpoint-2400/config.json +29 -0
  16. q2.5-eu-en/checkpoint-2400/generation_config.json +6 -0
  17. q2.5-eu-en/checkpoint-2400/latest +1 -0
  18. q2.5-eu-en/checkpoint-2400/merges.txt +0 -0
  19. q2.5-eu-en/checkpoint-2400/special_tokens_map.json +31 -0
  20. q2.5-eu-en/checkpoint-2400/tokenizer_config.json +207 -0
  21. q2.5-eu-en/checkpoint-2400/trainer_state.json +0 -0
  22. q2.5-eu-en/checkpoint-2400/vocab.json +0 -0
  23. q2.5-eu-en/checkpoint-2400/zero_to_fp32.py +760 -0
  24. q2.5-eu-en/checkpoint-2700/added_tokens.json +24 -0
  25. q2.5-eu-en/checkpoint-2700/chat_template.jinja +54 -0
  26. q2.5-eu-en/checkpoint-2700/config.json +29 -0
  27. q2.5-eu-en/checkpoint-2700/generation_config.json +6 -0
  28. q2.5-eu-en/checkpoint-2700/latest +1 -0
  29. q2.5-eu-en/checkpoint-2700/merges.txt +0 -0
  30. q2.5-eu-en/checkpoint-2700/special_tokens_map.json +31 -0
  31. q2.5-eu-en/checkpoint-2700/tokenizer_config.json +207 -0
  32. q2.5-eu-en/checkpoint-2700/trainer_state.json +0 -0
  33. q2.5-eu-en/checkpoint-2700/vocab.json +0 -0
  34. q2.5-eu-en/checkpoint-2700/zero_to_fp32.py +760 -0
  35. q2.5-eu-en/checkpoint-300/added_tokens.json +24 -0
  36. q2.5-eu-en/checkpoint-300/chat_template.jinja +54 -0
  37. q2.5-eu-en/checkpoint-300/config.json +29 -0
  38. q2.5-eu-en/checkpoint-300/generation_config.json +6 -0
  39. q2.5-eu-en/checkpoint-300/latest +1 -0
  40. q2.5-eu-en/checkpoint-300/merges.txt +0 -0
  41. q2.5-eu-en/checkpoint-300/special_tokens_map.json +31 -0
  42. q2.5-eu-en/checkpoint-300/tokenizer_config.json +207 -0
  43. q2.5-eu-en/checkpoint-300/trainer_state.json +1091 -0
  44. q2.5-eu-en/checkpoint-300/vocab.json +0 -0
  45. q2.5-eu-en/checkpoint-300/zero_to_fp32.py +760 -0
  46. q2.5/checkpoint-12000/added_tokens.json +24 -0
  47. q2.5/checkpoint-12000/chat_template.jinja +54 -0
  48. q2.5/checkpoint-12000/config.json +29 -0
  49. q2.5/checkpoint-12000/generation_config.json +6 -0
  50. q2.5/checkpoint-12000/latest +1 -0
l2-13b-ga/checkpoint-2800/special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
l2-13b-ga/checkpoint-2800/tokenizer_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": true,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "bos_token": "<s>",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "</s>",
34
+ "legacy": true,
35
+ "model_max_length": 1000000000000000019884624838656,
36
+ "pad_token": null,
37
+ "sp_model_kwargs": {},
38
+ "spaces_between_special_tokens": false,
39
+ "tokenizer_class": "LlamaTokenizer",
40
+ "unk_token": "<unk>",
41
+ "use_default_system_prompt": false
42
+ }
l2-13b-ga/checkpoint-3100/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "meta-llama/Llama-2-13b-hf",
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "bos_token_id": 1,
9
+ "eos_token_id": 2,
10
+ "head_dim": 128,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 5120,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 13824,
15
+ "max_position_embeddings": 4096,
16
+ "mlp_bias": false,
17
+ "model_type": "llama",
18
+ "num_attention_heads": 40,
19
+ "num_hidden_layers": 40,
20
+ "num_key_value_heads": 40,
21
+ "pretraining_tp": 1,
22
+ "rms_norm_eps": 1e-05,
23
+ "rope_scaling": null,
24
+ "rope_theta": 10000.0,
25
+ "tie_word_embeddings": false,
26
+ "torch_dtype": "bfloat16",
27
+ "transformers_version": "4.46.3",
28
+ "use_cache": true,
29
+ "vocab_size": 35483
30
+ }
l2-13b-ga/checkpoint-3100/generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 1,
3
+ "do_sample": true,
4
+ "eos_token_id": 2,
5
+ "max_length": 4096,
6
+ "pad_token_id": 0,
7
+ "temperature": 0.6,
8
+ "top_p": 0.9,
9
+ "transformers_version": "4.46.3"
10
+ }
l2-13b-ga/checkpoint-3100/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step3100
l2-13b-ga/checkpoint-3100/model.safetensors.index.json ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 26103060480
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00006-of-00006.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00006.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00006.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
13
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
14
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
15
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
16
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
17
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00006.safetensors",
18
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
19
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
20
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
21
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
22
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
23
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
24
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
25
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
26
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00006.safetensors",
27
+ "model.layers.10.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
28
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
29
+ "model.layers.10.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
30
+ "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
31
+ "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
32
+ "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
33
+ "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
34
+ "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
35
+ "model.layers.11.input_layernorm.weight": "model-00002-of-00006.safetensors",
36
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
37
+ "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
38
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
39
+ "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
40
+ "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
41
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
42
+ "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
43
+ "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
44
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00006.safetensors",
45
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
46
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
47
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
48
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
49
+ "model.layers.12.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
50
+ "model.layers.12.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
51
+ "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
52
+ "model.layers.12.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
53
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00006.safetensors",
54
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
55
+ "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
56
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
57
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
58
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
59
+ "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
60
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
61
+ "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
62
+ "model.layers.14.input_layernorm.weight": "model-00002-of-00006.safetensors",
63
+ "model.layers.14.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
64
+ "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
65
+ "model.layers.14.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
66
+ "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
67
+ "model.layers.14.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
68
+ "model.layers.14.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
69
+ "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
70
+ "model.layers.14.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
71
+ "model.layers.15.input_layernorm.weight": "model-00003-of-00006.safetensors",
72
+ "model.layers.15.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
73
+ "model.layers.15.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
74
+ "model.layers.15.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
75
+ "model.layers.15.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
76
+ "model.layers.15.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
77
+ "model.layers.15.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
78
+ "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
79
+ "model.layers.15.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
80
+ "model.layers.16.input_layernorm.weight": "model-00003-of-00006.safetensors",
81
+ "model.layers.16.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
82
+ "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
83
+ "model.layers.16.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
84
+ "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
85
+ "model.layers.16.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
86
+ "model.layers.16.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
87
+ "model.layers.16.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
88
+ "model.layers.16.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
89
+ "model.layers.17.input_layernorm.weight": "model-00003-of-00006.safetensors",
90
+ "model.layers.17.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
91
+ "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
92
+ "model.layers.17.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
93
+ "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
94
+ "model.layers.17.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
95
+ "model.layers.17.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
96
+ "model.layers.17.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
97
+ "model.layers.17.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
98
+ "model.layers.18.input_layernorm.weight": "model-00003-of-00006.safetensors",
99
+ "model.layers.18.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
100
+ "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
101
+ "model.layers.18.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
102
+ "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
103
+ "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
104
+ "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
105
+ "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
106
+ "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
107
+ "model.layers.19.input_layernorm.weight": "model-00003-of-00006.safetensors",
108
+ "model.layers.19.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
109
+ "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
110
+ "model.layers.19.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
111
+ "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
112
+ "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
113
+ "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
114
+ "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
115
+ "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
116
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00006.safetensors",
117
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
118
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
119
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
120
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
121
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
122
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
123
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
124
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
125
+ "model.layers.20.input_layernorm.weight": "model-00003-of-00006.safetensors",
126
+ "model.layers.20.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
127
+ "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
128
+ "model.layers.20.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
129
+ "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
130
+ "model.layers.20.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
131
+ "model.layers.20.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
132
+ "model.layers.20.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
133
+ "model.layers.20.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
134
+ "model.layers.21.input_layernorm.weight": "model-00003-of-00006.safetensors",
135
+ "model.layers.21.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
136
+ "model.layers.21.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
137
+ "model.layers.21.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
138
+ "model.layers.21.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
139
+ "model.layers.21.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
140
+ "model.layers.21.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
141
+ "model.layers.21.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
142
+ "model.layers.21.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
143
+ "model.layers.22.input_layernorm.weight": "model-00004-of-00006.safetensors",
144
+ "model.layers.22.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
145
+ "model.layers.22.mlp.gate_proj.weight": "model-00003-of-00006.safetensors",
146
+ "model.layers.22.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
147
+ "model.layers.22.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
148
+ "model.layers.22.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
149
+ "model.layers.22.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
150
+ "model.layers.22.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
151
+ "model.layers.22.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
152
+ "model.layers.23.input_layernorm.weight": "model-00004-of-00006.safetensors",
153
+ "model.layers.23.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
154
+ "model.layers.23.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
155
+ "model.layers.23.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
156
+ "model.layers.23.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
157
+ "model.layers.23.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
158
+ "model.layers.23.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
159
+ "model.layers.23.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
160
+ "model.layers.23.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
161
+ "model.layers.24.input_layernorm.weight": "model-00004-of-00006.safetensors",
162
+ "model.layers.24.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
163
+ "model.layers.24.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
164
+ "model.layers.24.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
165
+ "model.layers.24.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
166
+ "model.layers.24.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
167
+ "model.layers.24.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
168
+ "model.layers.24.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
169
+ "model.layers.24.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
170
+ "model.layers.25.input_layernorm.weight": "model-00004-of-00006.safetensors",
171
+ "model.layers.25.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
172
+ "model.layers.25.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
173
+ "model.layers.25.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
174
+ "model.layers.25.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
175
+ "model.layers.25.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
176
+ "model.layers.25.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
177
+ "model.layers.25.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
178
+ "model.layers.25.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
179
+ "model.layers.26.input_layernorm.weight": "model-00004-of-00006.safetensors",
180
+ "model.layers.26.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
181
+ "model.layers.26.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
182
+ "model.layers.26.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
183
+ "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
184
+ "model.layers.26.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
185
+ "model.layers.26.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
186
+ "model.layers.26.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
187
+ "model.layers.26.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
188
+ "model.layers.27.input_layernorm.weight": "model-00004-of-00006.safetensors",
189
+ "model.layers.27.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
190
+ "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
191
+ "model.layers.27.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
192
+ "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
193
+ "model.layers.27.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
194
+ "model.layers.27.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
195
+ "model.layers.27.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
196
+ "model.layers.27.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
197
+ "model.layers.28.input_layernorm.weight": "model-00004-of-00006.safetensors",
198
+ "model.layers.28.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
199
+ "model.layers.28.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
200
+ "model.layers.28.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
201
+ "model.layers.28.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
202
+ "model.layers.28.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
203
+ "model.layers.28.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
204
+ "model.layers.28.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
205
+ "model.layers.28.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
206
+ "model.layers.29.input_layernorm.weight": "model-00004-of-00006.safetensors",
207
+ "model.layers.29.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
208
+ "model.layers.29.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
209
+ "model.layers.29.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
210
+ "model.layers.29.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
211
+ "model.layers.29.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
212
+ "model.layers.29.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
213
+ "model.layers.29.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
214
+ "model.layers.29.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
215
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00006.safetensors",
216
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
217
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
218
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
219
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
220
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
221
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
222
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
223
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
224
+ "model.layers.30.input_layernorm.weight": "model-00005-of-00006.safetensors",
225
+ "model.layers.30.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
226
+ "model.layers.30.mlp.gate_proj.weight": "model-00004-of-00006.safetensors",
227
+ "model.layers.30.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
228
+ "model.layers.30.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
229
+ "model.layers.30.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
230
+ "model.layers.30.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
231
+ "model.layers.30.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
232
+ "model.layers.30.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
233
+ "model.layers.31.input_layernorm.weight": "model-00005-of-00006.safetensors",
234
+ "model.layers.31.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
235
+ "model.layers.31.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
236
+ "model.layers.31.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
237
+ "model.layers.31.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
238
+ "model.layers.31.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
239
+ "model.layers.31.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
240
+ "model.layers.31.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
241
+ "model.layers.31.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
242
+ "model.layers.32.input_layernorm.weight": "model-00005-of-00006.safetensors",
243
+ "model.layers.32.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
244
+ "model.layers.32.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
245
+ "model.layers.32.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
246
+ "model.layers.32.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
247
+ "model.layers.32.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
248
+ "model.layers.32.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
249
+ "model.layers.32.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
250
+ "model.layers.32.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
251
+ "model.layers.33.input_layernorm.weight": "model-00005-of-00006.safetensors",
252
+ "model.layers.33.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
253
+ "model.layers.33.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
254
+ "model.layers.33.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
255
+ "model.layers.33.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
256
+ "model.layers.33.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
257
+ "model.layers.33.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
258
+ "model.layers.33.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
259
+ "model.layers.33.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
260
+ "model.layers.34.input_layernorm.weight": "model-00005-of-00006.safetensors",
261
+ "model.layers.34.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
262
+ "model.layers.34.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
263
+ "model.layers.34.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
264
+ "model.layers.34.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
265
+ "model.layers.34.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
266
+ "model.layers.34.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
267
+ "model.layers.34.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
268
+ "model.layers.34.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
269
+ "model.layers.35.input_layernorm.weight": "model-00005-of-00006.safetensors",
270
+ "model.layers.35.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
271
+ "model.layers.35.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
272
+ "model.layers.35.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
273
+ "model.layers.35.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
274
+ "model.layers.35.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
275
+ "model.layers.35.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
276
+ "model.layers.35.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
277
+ "model.layers.35.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
278
+ "model.layers.36.input_layernorm.weight": "model-00005-of-00006.safetensors",
279
+ "model.layers.36.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
280
+ "model.layers.36.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
281
+ "model.layers.36.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
282
+ "model.layers.36.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
283
+ "model.layers.36.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
284
+ "model.layers.36.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
285
+ "model.layers.36.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
286
+ "model.layers.36.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
287
+ "model.layers.37.input_layernorm.weight": "model-00005-of-00006.safetensors",
288
+ "model.layers.37.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
289
+ "model.layers.37.mlp.gate_proj.weight": "model-00005-of-00006.safetensors",
290
+ "model.layers.37.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
291
+ "model.layers.37.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
292
+ "model.layers.37.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
293
+ "model.layers.37.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
294
+ "model.layers.37.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
295
+ "model.layers.37.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
296
+ "model.layers.38.input_layernorm.weight": "model-00006-of-00006.safetensors",
297
+ "model.layers.38.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
298
+ "model.layers.38.mlp.gate_proj.weight": "model-00006-of-00006.safetensors",
299
+ "model.layers.38.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
300
+ "model.layers.38.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
301
+ "model.layers.38.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
302
+ "model.layers.38.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
303
+ "model.layers.38.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
304
+ "model.layers.38.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
305
+ "model.layers.39.input_layernorm.weight": "model-00006-of-00006.safetensors",
306
+ "model.layers.39.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
307
+ "model.layers.39.mlp.gate_proj.weight": "model-00006-of-00006.safetensors",
308
+ "model.layers.39.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
309
+ "model.layers.39.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
310
+ "model.layers.39.self_attn.k_proj.weight": "model-00006-of-00006.safetensors",
311
+ "model.layers.39.self_attn.o_proj.weight": "model-00006-of-00006.safetensors",
312
+ "model.layers.39.self_attn.q_proj.weight": "model-00006-of-00006.safetensors",
313
+ "model.layers.39.self_attn.v_proj.weight": "model-00006-of-00006.safetensors",
314
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00006.safetensors",
315
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
316
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
317
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
318
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
319
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
320
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
321
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
322
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
323
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00006.safetensors",
324
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
325
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
326
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
327
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
328
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
329
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
330
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
331
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
332
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00006.safetensors",
333
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
334
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00006.safetensors",
335
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
336
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
337
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
338
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
339
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
340
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
341
+ "model.layers.7.input_layernorm.weight": "model-00002-of-00006.safetensors",
342
+ "model.layers.7.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
343
+ "model.layers.7.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
344
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
345
+ "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
346
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
347
+ "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
348
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
349
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
350
+ "model.layers.8.input_layernorm.weight": "model-00002-of-00006.safetensors",
351
+ "model.layers.8.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
352
+ "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
353
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
354
+ "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
355
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
356
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
357
+ "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
358
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
359
+ "model.layers.9.input_layernorm.weight": "model-00002-of-00006.safetensors",
360
+ "model.layers.9.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
361
+ "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00006.safetensors",
362
+ "model.layers.9.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
363
+ "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
364
+ "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
365
+ "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
366
+ "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
367
+ "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
368
+ "model.norm.weight": "model-00006-of-00006.safetensors"
369
+ }
370
+ }
l2-13b-ga/checkpoint-3100/special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
l2-13b-ga/checkpoint-3100/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
l2-13b-ga/checkpoint-3100/tokenizer_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": true,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "bos_token": "<s>",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "</s>",
34
+ "legacy": true,
35
+ "model_max_length": 1000000000000000019884624838656,
36
+ "pad_token": null,
37
+ "sp_model_kwargs": {},
38
+ "spaces_between_special_tokens": false,
39
+ "tokenizer_class": "LlamaTokenizer",
40
+ "unk_token": "<unk>",
41
+ "use_default_system_prompt": false
42
+ }
l2-13b-ga/checkpoint-3100/trainer_state.json ADDED
@@ -0,0 +1,2210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 2.8954004202661685,
5
+ "eval_steps": 500,
6
+ "global_step": 3100,
7
+ "is_hyper_param_search": false,
8
+ "is_local_process_zero": true,
9
+ "is_world_process_zero": true,
10
+ "log_history": [
11
+ {
12
+ "epoch": 0.0009339248190520663,
13
+ "grad_norm": 6.638877692627699,
14
+ "learning_rate": 9.345794392523364e-07,
15
+ "loss": 9.2917,
16
+ "step": 1
17
+ },
18
+ {
19
+ "epoch": 0.009339248190520663,
20
+ "grad_norm": 1.1560921335705272,
21
+ "learning_rate": 9.345794392523365e-06,
22
+ "loss": 9.0876,
23
+ "step": 10
24
+ },
25
+ {
26
+ "epoch": 0.018678496381041326,
27
+ "grad_norm": 0.8415132296956432,
28
+ "learning_rate": 1.869158878504673e-05,
29
+ "loss": 8.2164,
30
+ "step": 20
31
+ },
32
+ {
33
+ "epoch": 0.02801774457156199,
34
+ "grad_norm": 0.45381630992958155,
35
+ "learning_rate": 2.8037383177570094e-05,
36
+ "loss": 7.5184,
37
+ "step": 30
38
+ },
39
+ {
40
+ "epoch": 0.03735699276208265,
41
+ "grad_norm": 0.8400636107958425,
42
+ "learning_rate": 3.738317757009346e-05,
43
+ "loss": 6.6507,
44
+ "step": 40
45
+ },
46
+ {
47
+ "epoch": 0.046696240952603316,
48
+ "grad_norm": 0.557696240829066,
49
+ "learning_rate": 4.672897196261683e-05,
50
+ "loss": 5.8909,
51
+ "step": 50
52
+ },
53
+ {
54
+ "epoch": 0.05603548914312398,
55
+ "grad_norm": 0.3971996057467842,
56
+ "learning_rate": 5.607476635514019e-05,
57
+ "loss": 5.4127,
58
+ "step": 60
59
+ },
60
+ {
61
+ "epoch": 0.06537473733364464,
62
+ "grad_norm": 0.2932710540265688,
63
+ "learning_rate": 6.542056074766355e-05,
64
+ "loss": 5.0106,
65
+ "step": 70
66
+ },
67
+ {
68
+ "epoch": 0.0747139855241653,
69
+ "grad_norm": 0.3682690443551033,
70
+ "learning_rate": 7.476635514018692e-05,
71
+ "loss": 4.6042,
72
+ "step": 80
73
+ },
74
+ {
75
+ "epoch": 0.08405323371468597,
76
+ "grad_norm": 0.3132971920011515,
77
+ "learning_rate": 8.411214953271028e-05,
78
+ "loss": 4.2031,
79
+ "step": 90
80
+ },
81
+ {
82
+ "epoch": 0.09339248190520663,
83
+ "grad_norm": 0.6731868159213446,
84
+ "learning_rate": 9.345794392523365e-05,
85
+ "loss": 3.9423,
86
+ "step": 100
87
+ },
88
+ {
89
+ "epoch": 0.1027317300957273,
90
+ "grad_norm": 0.27848867836763197,
91
+ "learning_rate": 0.000102803738317757,
92
+ "loss": 3.7157,
93
+ "step": 110
94
+ },
95
+ {
96
+ "epoch": 0.11207097828624796,
97
+ "grad_norm": 0.24642109032991807,
98
+ "learning_rate": 0.00011214953271028037,
99
+ "loss": 3.4516,
100
+ "step": 120
101
+ },
102
+ {
103
+ "epoch": 0.12141022647676862,
104
+ "grad_norm": 0.25717384664029797,
105
+ "learning_rate": 0.00012149532710280373,
106
+ "loss": 3.2167,
107
+ "step": 130
108
+ },
109
+ {
110
+ "epoch": 0.13074947466728928,
111
+ "grad_norm": 0.20912922668565637,
112
+ "learning_rate": 0.0001308411214953271,
113
+ "loss": 3.0237,
114
+ "step": 140
115
+ },
116
+ {
117
+ "epoch": 0.14008872285780993,
118
+ "grad_norm": 0.15805888388706113,
119
+ "learning_rate": 0.00014018691588785047,
120
+ "loss": 2.8529,
121
+ "step": 150
122
+ },
123
+ {
124
+ "epoch": 0.1494279710483306,
125
+ "grad_norm": 0.23370349497479534,
126
+ "learning_rate": 0.00014953271028037384,
127
+ "loss": 2.7078,
128
+ "step": 160
129
+ },
130
+ {
131
+ "epoch": 0.15876721923885126,
132
+ "grad_norm": 0.1802138633012483,
133
+ "learning_rate": 0.0001588785046728972,
134
+ "loss": 2.6115,
135
+ "step": 170
136
+ },
137
+ {
138
+ "epoch": 0.16810646742937194,
139
+ "grad_norm": 0.13354347610039718,
140
+ "learning_rate": 0.00016822429906542056,
141
+ "loss": 2.5309,
142
+ "step": 180
143
+ },
144
+ {
145
+ "epoch": 0.17744571561989259,
146
+ "grad_norm": 0.09414865188086892,
147
+ "learning_rate": 0.00017757009345794393,
148
+ "loss": 2.4452,
149
+ "step": 190
150
+ },
151
+ {
152
+ "epoch": 0.18678496381041326,
153
+ "grad_norm": 0.08333601554768896,
154
+ "learning_rate": 0.0001869158878504673,
155
+ "loss": 2.3832,
156
+ "step": 200
157
+ },
158
+ {
159
+ "epoch": 0.1961242120009339,
160
+ "grad_norm": 0.15926414699806835,
161
+ "learning_rate": 0.00019626168224299065,
162
+ "loss": 2.3492,
163
+ "step": 210
164
+ },
165
+ {
166
+ "epoch": 0.2054634601914546,
167
+ "grad_norm": 0.09492820761057012,
168
+ "learning_rate": 0.0001999989254250208,
169
+ "loss": 2.323,
170
+ "step": 220
171
+ },
172
+ {
173
+ "epoch": 0.21480270838197524,
174
+ "grad_norm": 0.0801349259356147,
175
+ "learning_rate": 0.00019999235866155886,
176
+ "loss": 2.2731,
177
+ "step": 230
178
+ },
179
+ {
180
+ "epoch": 0.22414195657249592,
181
+ "grad_norm": 0.12210960524693895,
182
+ "learning_rate": 0.00019997982251228469,
183
+ "loss": 2.2433,
184
+ "step": 240
185
+ },
186
+ {
187
+ "epoch": 0.23348120476301656,
188
+ "grad_norm": 3.14289498732125,
189
+ "learning_rate": 0.00019996131772558666,
190
+ "loss": 3.2769,
191
+ "step": 250
192
+ },
193
+ {
194
+ "epoch": 0.24282045295353724,
195
+ "grad_norm": 1.632940983166179,
196
+ "learning_rate": 0.00019993684540617132,
197
+ "loss": 4.9343,
198
+ "step": 260
199
+ },
200
+ {
201
+ "epoch": 0.2521597011440579,
202
+ "grad_norm": 3.4831252230225416,
203
+ "learning_rate": 0.00019990640701499736,
204
+ "loss": 4.2768,
205
+ "step": 270
206
+ },
207
+ {
208
+ "epoch": 0.26149894933457857,
209
+ "grad_norm": 1.6069045920523788,
210
+ "learning_rate": 0.00019987000436918874,
211
+ "loss": 5.9581,
212
+ "step": 280
213
+ },
214
+ {
215
+ "epoch": 0.27083819752509924,
216
+ "grad_norm": 0.2220907936615993,
217
+ "learning_rate": 0.00019982763964192585,
218
+ "loss": 3.8228,
219
+ "step": 290
220
+ },
221
+ {
222
+ "epoch": 0.28017744571561987,
223
+ "grad_norm": 0.24737284913291765,
224
+ "learning_rate": 0.00019977931536231596,
225
+ "loss": 3.1413,
226
+ "step": 300
227
+ },
228
+ {
229
+ "epoch": 0.28951669390614054,
230
+ "grad_norm": 4.010404518241152,
231
+ "learning_rate": 0.00019972503441524224,
232
+ "loss": 2.8432,
233
+ "step": 310
234
+ },
235
+ {
236
+ "epoch": 0.2988559420966612,
237
+ "grad_norm": 0.1515583580811596,
238
+ "learning_rate": 0.00019966480004119142,
239
+ "loss": 2.7859,
240
+ "step": 320
241
+ },
242
+ {
243
+ "epoch": 0.3081951902871819,
244
+ "grad_norm": 0.11259395750650594,
245
+ "learning_rate": 0.00019959861583606045,
246
+ "loss": 2.5821,
247
+ "step": 330
248
+ },
249
+ {
250
+ "epoch": 0.3175344384777025,
251
+ "grad_norm": 0.22514797814956813,
252
+ "learning_rate": 0.00019952648575094183,
253
+ "loss": 2.4517,
254
+ "step": 340
255
+ },
256
+ {
257
+ "epoch": 0.3268736866682232,
258
+ "grad_norm": 0.08040136172033542,
259
+ "learning_rate": 0.00019944841409188767,
260
+ "loss": 2.3794,
261
+ "step": 350
262
+ },
263
+ {
264
+ "epoch": 0.3362129348587439,
265
+ "grad_norm": 0.054758073593565354,
266
+ "learning_rate": 0.00019936440551965263,
267
+ "loss": 2.3232,
268
+ "step": 360
269
+ },
270
+ {
271
+ "epoch": 0.34555218304926455,
272
+ "grad_norm": 0.06742998909645591,
273
+ "learning_rate": 0.00019927446504941577,
274
+ "loss": 2.2776,
275
+ "step": 370
276
+ },
277
+ {
278
+ "epoch": 0.35489143123978517,
279
+ "grad_norm": 0.048780907584876736,
280
+ "learning_rate": 0.00019917859805048096,
281
+ "loss": 2.2376,
282
+ "step": 380
283
+ },
284
+ {
285
+ "epoch": 0.36423067943030585,
286
+ "grad_norm": 0.0475325963052214,
287
+ "learning_rate": 0.00019907681024595663,
288
+ "loss": 2.2191,
289
+ "step": 390
290
+ },
291
+ {
292
+ "epoch": 0.3735699276208265,
293
+ "grad_norm": 0.054089563211590065,
294
+ "learning_rate": 0.00019896910771241387,
295
+ "loss": 2.1961,
296
+ "step": 400
297
+ },
298
+ {
299
+ "epoch": 0.3829091758113472,
300
+ "grad_norm": 0.21798406131864823,
301
+ "learning_rate": 0.00019885549687952372,
302
+ "loss": 2.2078,
303
+ "step": 410
304
+ },
305
+ {
306
+ "epoch": 0.3922484240018678,
307
+ "grad_norm": 0.8673185709111124,
308
+ "learning_rate": 0.00019873598452967338,
309
+ "loss": 2.3731,
310
+ "step": 420
311
+ },
312
+ {
313
+ "epoch": 0.4015876721923885,
314
+ "grad_norm": 0.22424350669971718,
315
+ "learning_rate": 0.0001986105777975613,
316
+ "loss": 2.6195,
317
+ "step": 430
318
+ },
319
+ {
320
+ "epoch": 0.4109269203829092,
321
+ "grad_norm": 0.307418135168262,
322
+ "learning_rate": 0.00019847928416977126,
323
+ "loss": 2.3624,
324
+ "step": 440
325
+ },
326
+ {
327
+ "epoch": 0.42026616857342985,
328
+ "grad_norm": 0.07944722668080402,
329
+ "learning_rate": 0.00019834211148432536,
330
+ "loss": 2.2799,
331
+ "step": 450
332
+ },
333
+ {
334
+ "epoch": 0.4296054167639505,
335
+ "grad_norm": 0.18146933758664588,
336
+ "learning_rate": 0.00019819906793021614,
337
+ "loss": 2.2177,
338
+ "step": 460
339
+ },
340
+ {
341
+ "epoch": 0.43894466495447115,
342
+ "grad_norm": 0.07035825837333018,
343
+ "learning_rate": 0.0001980501620469178,
344
+ "loss": 2.1767,
345
+ "step": 470
346
+ },
347
+ {
348
+ "epoch": 0.44828391314499183,
349
+ "grad_norm": 0.04596186944454228,
350
+ "learning_rate": 0.0001978954027238763,
351
+ "loss": 2.1598,
352
+ "step": 480
353
+ },
354
+ {
355
+ "epoch": 0.4576231613355125,
356
+ "grad_norm": 0.041342347745088055,
357
+ "learning_rate": 0.0001977347991999786,
358
+ "loss": 2.131,
359
+ "step": 490
360
+ },
361
+ {
362
+ "epoch": 0.46696240952603313,
363
+ "grad_norm": 0.04172063219841485,
364
+ "learning_rate": 0.00019756836106300137,
365
+ "loss": 2.1231,
366
+ "step": 500
367
+ },
368
+ {
369
+ "epoch": 0.4763016577165538,
370
+ "grad_norm": 0.03373646457711144,
371
+ "learning_rate": 0.00019739609824903843,
372
+ "loss": 2.1146,
373
+ "step": 510
374
+ },
375
+ {
376
+ "epoch": 0.4856409059070745,
377
+ "grad_norm": 0.03736871030676605,
378
+ "learning_rate": 0.00019721802104190748,
379
+ "loss": 2.1003,
380
+ "step": 520
381
+ },
382
+ {
383
+ "epoch": 0.49498015409759516,
384
+ "grad_norm": 0.033931028038211034,
385
+ "learning_rate": 0.00019703414007253645,
386
+ "loss": 2.0983,
387
+ "step": 530
388
+ },
389
+ {
390
+ "epoch": 0.5043194022881158,
391
+ "grad_norm": 0.03790055446070549,
392
+ "learning_rate": 0.00019684446631832868,
393
+ "loss": 2.092,
394
+ "step": 540
395
+ },
396
+ {
397
+ "epoch": 0.5136586504786365,
398
+ "grad_norm": 0.030956192803893078,
399
+ "learning_rate": 0.00019664901110250758,
400
+ "loss": 2.0807,
401
+ "step": 550
402
+ },
403
+ {
404
+ "epoch": 0.5229978986691571,
405
+ "grad_norm": 0.03542530209935129,
406
+ "learning_rate": 0.00019644778609344068,
407
+ "loss": 2.0773,
408
+ "step": 560
409
+ },
410
+ {
411
+ "epoch": 0.5323371468596778,
412
+ "grad_norm": 0.040947757568902336,
413
+ "learning_rate": 0.00019624080330394306,
414
+ "loss": 2.0649,
415
+ "step": 570
416
+ },
417
+ {
418
+ "epoch": 0.5416763950501985,
419
+ "grad_norm": 0.034273415973688146,
420
+ "learning_rate": 0.00019602807509056018,
421
+ "loss": 2.0479,
422
+ "step": 580
423
+ },
424
+ {
425
+ "epoch": 0.5510156432407192,
426
+ "grad_norm": 0.031427481498873144,
427
+ "learning_rate": 0.00019580961415283028,
428
+ "loss": 2.0563,
429
+ "step": 590
430
+ },
431
+ {
432
+ "epoch": 0.5603548914312397,
433
+ "grad_norm": 0.03141549752041532,
434
+ "learning_rate": 0.00019558543353252611,
435
+ "loss": 2.0503,
436
+ "step": 600
437
+ },
438
+ {
439
+ "epoch": 0.5696941396217604,
440
+ "grad_norm": 0.033012392726428204,
441
+ "learning_rate": 0.00019535554661287652,
442
+ "loss": 2.0389,
443
+ "step": 610
444
+ },
445
+ {
446
+ "epoch": 0.5790333878122811,
447
+ "grad_norm": 0.02913261992661444,
448
+ "learning_rate": 0.0001951199671177673,
449
+ "loss": 2.036,
450
+ "step": 620
451
+ },
452
+ {
453
+ "epoch": 0.5883726360028018,
454
+ "grad_norm": 0.030543903708435332,
455
+ "learning_rate": 0.00019487870911092214,
456
+ "loss": 2.0326,
457
+ "step": 630
458
+ },
459
+ {
460
+ "epoch": 0.5977118841933224,
461
+ "grad_norm": 0.03215005545393897,
462
+ "learning_rate": 0.00019463178699506277,
463
+ "loss": 2.0231,
464
+ "step": 640
465
+ },
466
+ {
467
+ "epoch": 0.6070511323838431,
468
+ "grad_norm": 0.03823630791937631,
469
+ "learning_rate": 0.00019437921551104933,
470
+ "loss": 2.0293,
471
+ "step": 650
472
+ },
473
+ {
474
+ "epoch": 0.6163903805743638,
475
+ "grad_norm": 0.03200103149471209,
476
+ "learning_rate": 0.00019412100973700038,
477
+ "loss": 2.017,
478
+ "step": 660
479
+ },
480
+ {
481
+ "epoch": 0.6257296287648845,
482
+ "grad_norm": 0.03841804153577787,
483
+ "learning_rate": 0.00019385718508739262,
484
+ "loss": 2.0135,
485
+ "step": 670
486
+ },
487
+ {
488
+ "epoch": 0.635068876955405,
489
+ "grad_norm": 0.03052396655271533,
490
+ "learning_rate": 0.0001935877573121407,
491
+ "loss": 2.0237,
492
+ "step": 680
493
+ },
494
+ {
495
+ "epoch": 0.6444081251459257,
496
+ "grad_norm": 0.033817837533771815,
497
+ "learning_rate": 0.00019331274249565717,
498
+ "loss": 2.0069,
499
+ "step": 690
500
+ },
501
+ {
502
+ "epoch": 0.6537473733364464,
503
+ "grad_norm": 0.028286999650643876,
504
+ "learning_rate": 0.00019303215705589194,
505
+ "loss": 2.0112,
506
+ "step": 700
507
+ },
508
+ {
509
+ "epoch": 0.6630866215269671,
510
+ "grad_norm": 0.030693948626257357,
511
+ "learning_rate": 0.00019274601774335243,
512
+ "loss": 2.0,
513
+ "step": 710
514
+ },
515
+ {
516
+ "epoch": 0.6724258697174877,
517
+ "grad_norm": 0.029984615635953022,
518
+ "learning_rate": 0.0001924543416401035,
519
+ "loss": 2.0028,
520
+ "step": 720
521
+ },
522
+ {
523
+ "epoch": 0.6817651179080084,
524
+ "grad_norm": 0.02915985673921391,
525
+ "learning_rate": 0.00019215714615874755,
526
+ "loss": 2.0031,
527
+ "step": 730
528
+ },
529
+ {
530
+ "epoch": 0.6911043660985291,
531
+ "grad_norm": 0.028305399777245336,
532
+ "learning_rate": 0.00019185444904138528,
533
+ "loss": 1.9924,
534
+ "step": 740
535
+ },
536
+ {
537
+ "epoch": 0.7004436142890498,
538
+ "grad_norm": 0.036720505429756495,
539
+ "learning_rate": 0.00019154626835855628,
540
+ "loss": 1.9981,
541
+ "step": 750
542
+ },
543
+ {
544
+ "epoch": 0.7097828624795703,
545
+ "grad_norm": 0.0287124048917296,
546
+ "learning_rate": 0.00019123262250816034,
547
+ "loss": 1.9868,
548
+ "step": 760
549
+ },
550
+ {
551
+ "epoch": 0.719122110670091,
552
+ "grad_norm": 0.03318092492837997,
553
+ "learning_rate": 0.00019091353021435915,
554
+ "loss": 1.9943,
555
+ "step": 770
556
+ },
557
+ {
558
+ "epoch": 0.7284613588606117,
559
+ "grad_norm": 0.054035272137015325,
560
+ "learning_rate": 0.00019058901052645844,
561
+ "loss": 1.9838,
562
+ "step": 780
563
+ },
564
+ {
565
+ "epoch": 0.7378006070511324,
566
+ "grad_norm": 0.03184392761983255,
567
+ "learning_rate": 0.00019025908281777078,
568
+ "loss": 1.982,
569
+ "step": 790
570
+ },
571
+ {
572
+ "epoch": 0.747139855241653,
573
+ "grad_norm": 0.029409948164434735,
574
+ "learning_rate": 0.00018992376678445908,
575
+ "loss": 1.9693,
576
+ "step": 800
577
+ },
578
+ {
579
+ "epoch": 0.7564791034321737,
580
+ "grad_norm": 0.029656963043919016,
581
+ "learning_rate": 0.00018958308244436064,
582
+ "loss": 1.9914,
583
+ "step": 810
584
+ },
585
+ {
586
+ "epoch": 0.7658183516226944,
587
+ "grad_norm": 0.030843610865326686,
588
+ "learning_rate": 0.00018923705013579233,
589
+ "loss": 1.9749,
590
+ "step": 820
591
+ },
592
+ {
593
+ "epoch": 0.7751575998132151,
594
+ "grad_norm": 0.0377584286045999,
595
+ "learning_rate": 0.00018888569051633613,
596
+ "loss": 1.9606,
597
+ "step": 830
598
+ },
599
+ {
600
+ "epoch": 0.7844968480037356,
601
+ "grad_norm": 0.03147699916274391,
602
+ "learning_rate": 0.00018852902456160616,
603
+ "loss": 1.9696,
604
+ "step": 840
605
+ },
606
+ {
607
+ "epoch": 0.7938360961942563,
608
+ "grad_norm": 0.029193153251471263,
609
+ "learning_rate": 0.0001881670735639963,
610
+ "loss": 1.9687,
611
+ "step": 850
612
+ },
613
+ {
614
+ "epoch": 0.803175344384777,
615
+ "grad_norm": 0.030201895228156087,
616
+ "learning_rate": 0.00018779985913140924,
617
+ "loss": 1.9678,
618
+ "step": 860
619
+ },
620
+ {
621
+ "epoch": 0.8125145925752977,
622
+ "grad_norm": 0.029272319485493213,
623
+ "learning_rate": 0.00018742740318596632,
624
+ "loss": 1.9697,
625
+ "step": 870
626
+ },
627
+ {
628
+ "epoch": 0.8218538407658184,
629
+ "grad_norm": 0.033740176465285654,
630
+ "learning_rate": 0.000187049727962699,
631
+ "loss": 1.9647,
632
+ "step": 880
633
+ },
634
+ {
635
+ "epoch": 0.831193088956339,
636
+ "grad_norm": 0.029539399251208593,
637
+ "learning_rate": 0.0001866668560082213,
638
+ "loss": 1.9627,
639
+ "step": 890
640
+ },
641
+ {
642
+ "epoch": 0.8405323371468597,
643
+ "grad_norm": 0.028666077337951026,
644
+ "learning_rate": 0.0001862788101793839,
645
+ "loss": 1.9529,
646
+ "step": 900
647
+ },
648
+ {
649
+ "epoch": 0.8498715853373804,
650
+ "grad_norm": 0.030280792492665805,
651
+ "learning_rate": 0.0001858856136419097,
652
+ "loss": 1.9536,
653
+ "step": 910
654
+ },
655
+ {
656
+ "epoch": 0.859210833527901,
657
+ "grad_norm": 0.03921536105057096,
658
+ "learning_rate": 0.0001854872898690106,
659
+ "loss": 1.9474,
660
+ "step": 920
661
+ },
662
+ {
663
+ "epoch": 0.8685500817184216,
664
+ "grad_norm": 0.030632523637038354,
665
+ "learning_rate": 0.0001850838626399865,
666
+ "loss": 1.9423,
667
+ "step": 930
668
+ },
669
+ {
670
+ "epoch": 0.8778893299089423,
671
+ "grad_norm": 0.04615147601979514,
672
+ "learning_rate": 0.00018467535603880548,
673
+ "loss": 1.946,
674
+ "step": 940
675
+ },
676
+ {
677
+ "epoch": 0.887228578099463,
678
+ "grad_norm": 0.028216236017006333,
679
+ "learning_rate": 0.00018426179445266616,
680
+ "loss": 1.9408,
681
+ "step": 950
682
+ },
683
+ {
684
+ "epoch": 0.8965678262899837,
685
+ "grad_norm": 0.0282407563402959,
686
+ "learning_rate": 0.00018384320257054177,
687
+ "loss": 1.9447,
688
+ "step": 960
689
+ },
690
+ {
691
+ "epoch": 0.9059070744805043,
692
+ "grad_norm": 0.029365880854687894,
693
+ "learning_rate": 0.0001834196053817062,
694
+ "loss": 1.9389,
695
+ "step": 970
696
+ },
697
+ {
698
+ "epoch": 0.915246322671025,
699
+ "grad_norm": 0.02855404439130719,
700
+ "learning_rate": 0.00018299102817424234,
701
+ "loss": 1.9425,
702
+ "step": 980
703
+ },
704
+ {
705
+ "epoch": 0.9245855708615457,
706
+ "grad_norm": 0.03238310984070135,
707
+ "learning_rate": 0.00018255749653353225,
708
+ "loss": 1.9392,
709
+ "step": 990
710
+ },
711
+ {
712
+ "epoch": 0.9339248190520663,
713
+ "grad_norm": 0.030115350805430388,
714
+ "learning_rate": 0.00018211903634072983,
715
+ "loss": 1.956,
716
+ "step": 1000
717
+ },
718
+ {
719
+ "epoch": 0.9432640672425869,
720
+ "grad_norm": 0.039090564032501135,
721
+ "learning_rate": 0.0001816756737712158,
722
+ "loss": 1.9358,
723
+ "step": 1010
724
+ },
725
+ {
726
+ "epoch": 0.9526033154331076,
727
+ "grad_norm": 0.028567954476327023,
728
+ "learning_rate": 0.000181227435293035,
729
+ "loss": 1.9342,
730
+ "step": 1020
731
+ },
732
+ {
733
+ "epoch": 0.9619425636236283,
734
+ "grad_norm": 0.028158653241284505,
735
+ "learning_rate": 0.00018077434766531624,
736
+ "loss": 1.9287,
737
+ "step": 1030
738
+ },
739
+ {
740
+ "epoch": 0.971281811814149,
741
+ "grad_norm": 0.02927795717651538,
742
+ "learning_rate": 0.00018031643793667504,
743
+ "loss": 1.9298,
744
+ "step": 1040
745
+ },
746
+ {
747
+ "epoch": 0.9806210600046696,
748
+ "grad_norm": 0.06298340584032344,
749
+ "learning_rate": 0.0001798537334435986,
750
+ "loss": 1.9303,
751
+ "step": 1050
752
+ },
753
+ {
754
+ "epoch": 0.9899603081951903,
755
+ "grad_norm": 0.03627278406983255,
756
+ "learning_rate": 0.00017938626180881407,
757
+ "loss": 1.9285,
758
+ "step": 1060
759
+ },
760
+ {
761
+ "epoch": 0.999299556385711,
762
+ "grad_norm": 0.03916823421329747,
763
+ "learning_rate": 0.00017891405093963938,
764
+ "loss": 1.9239,
765
+ "step": 1070
766
+ },
767
+ {
768
+ "epoch": 1.0087555451786132,
769
+ "grad_norm": 0.03383539251115568,
770
+ "learning_rate": 0.00017843712902631723,
771
+ "loss": 1.8855,
772
+ "step": 1080
773
+ },
774
+ {
775
+ "epoch": 1.0180947933691338,
776
+ "grad_norm": 0.02931021936560147,
777
+ "learning_rate": 0.00017795552454033224,
778
+ "loss": 1.8004,
779
+ "step": 1090
780
+ },
781
+ {
782
+ "epoch": 1.0274340415596543,
783
+ "grad_norm": 0.029173295095350292,
784
+ "learning_rate": 0.0001774692662327113,
785
+ "loss": 1.7912,
786
+ "step": 1100
787
+ },
788
+ {
789
+ "epoch": 1.0367732897501751,
790
+ "grad_norm": 0.035210065642974735,
791
+ "learning_rate": 0.000176978383132307,
792
+ "loss": 1.7902,
793
+ "step": 1110
794
+ },
795
+ {
796
+ "epoch": 1.0461125379406957,
797
+ "grad_norm": 0.029794447659573477,
798
+ "learning_rate": 0.00017648290454406475,
799
+ "loss": 1.8072,
800
+ "step": 1120
801
+ },
802
+ {
803
+ "epoch": 1.0554517861312165,
804
+ "grad_norm": 0.03194584938279939,
805
+ "learning_rate": 0.0001759828600472734,
806
+ "loss": 1.803,
807
+ "step": 1130
808
+ },
809
+ {
810
+ "epoch": 1.064791034321737,
811
+ "grad_norm": 0.031028415312581603,
812
+ "learning_rate": 0.00017547827949379924,
813
+ "loss": 1.7945,
814
+ "step": 1140
815
+ },
816
+ {
817
+ "epoch": 1.0741302825122578,
818
+ "grad_norm": 0.03313245828751237,
819
+ "learning_rate": 0.00017496919300630403,
820
+ "loss": 1.8139,
821
+ "step": 1150
822
+ },
823
+ {
824
+ "epoch": 1.0834695307027784,
825
+ "grad_norm": 0.03049431724979126,
826
+ "learning_rate": 0.00017445563097644664,
827
+ "loss": 1.8031,
828
+ "step": 1160
829
+ },
830
+ {
831
+ "epoch": 1.0928087788932992,
832
+ "grad_norm": 0.02880548705343715,
833
+ "learning_rate": 0.00017393762406306878,
834
+ "loss": 1.7974,
835
+ "step": 1170
836
+ },
837
+ {
838
+ "epoch": 1.1021480270838198,
839
+ "grad_norm": 0.03200427895977668,
840
+ "learning_rate": 0.00017341520319036469,
841
+ "loss": 1.7994,
842
+ "step": 1180
843
+ },
844
+ {
845
+ "epoch": 1.1114872752743403,
846
+ "grad_norm": 0.031293532815600045,
847
+ "learning_rate": 0.00017288839954603496,
848
+ "loss": 1.8073,
849
+ "step": 1190
850
+ },
851
+ {
852
+ "epoch": 1.1208265234648611,
853
+ "grad_norm": 0.032367211109345505,
854
+ "learning_rate": 0.00017235724457942468,
855
+ "loss": 1.7944,
856
+ "step": 1200
857
+ },
858
+ {
859
+ "epoch": 1.1301657716553817,
860
+ "grad_norm": 0.037783793923191374,
861
+ "learning_rate": 0.0001718217699996462,
862
+ "loss": 1.7948,
863
+ "step": 1210
864
+ },
865
+ {
866
+ "epoch": 1.1395050198459025,
867
+ "grad_norm": 0.02881083117349317,
868
+ "learning_rate": 0.00017128200777368567,
869
+ "loss": 1.8029,
870
+ "step": 1220
871
+ },
872
+ {
873
+ "epoch": 1.148844268036423,
874
+ "grad_norm": 0.032997408408175985,
875
+ "learning_rate": 0.00017073799012449524,
876
+ "loss": 1.7914,
877
+ "step": 1230
878
+ },
879
+ {
880
+ "epoch": 1.1581835162269438,
881
+ "grad_norm": 0.030263615801190885,
882
+ "learning_rate": 0.00017018974952906884,
883
+ "loss": 1.792,
884
+ "step": 1240
885
+ },
886
+ {
887
+ "epoch": 1.1675227644174644,
888
+ "grad_norm": 0.03286310429098484,
889
+ "learning_rate": 0.00016963731871650378,
890
+ "loss": 1.8149,
891
+ "step": 1250
892
+ },
893
+ {
894
+ "epoch": 1.1768620126079852,
895
+ "grad_norm": 0.031111621587597126,
896
+ "learning_rate": 0.00016908073066604663,
897
+ "loss": 1.8092,
898
+ "step": 1260
899
+ },
900
+ {
901
+ "epoch": 1.1862012607985057,
902
+ "grad_norm": 0.03372950172075241,
903
+ "learning_rate": 0.0001685200186051246,
904
+ "loss": 1.818,
905
+ "step": 1270
906
+ },
907
+ {
908
+ "epoch": 1.1955405089890263,
909
+ "grad_norm": 0.040782040436567434,
910
+ "learning_rate": 0.00016795521600736164,
911
+ "loss": 1.7999,
912
+ "step": 1280
913
+ },
914
+ {
915
+ "epoch": 1.204879757179547,
916
+ "grad_norm": 0.03451605168178924,
917
+ "learning_rate": 0.00016738635659058044,
918
+ "loss": 1.7945,
919
+ "step": 1290
920
+ },
921
+ {
922
+ "epoch": 1.2142190053700677,
923
+ "grad_norm": 0.03235681588882673,
924
+ "learning_rate": 0.00016681347431478933,
925
+ "loss": 1.8087,
926
+ "step": 1300
927
+ },
928
+ {
929
+ "epoch": 1.2235582535605884,
930
+ "grad_norm": 0.030750745605971932,
931
+ "learning_rate": 0.00016623660338015487,
932
+ "loss": 1.7995,
933
+ "step": 1310
934
+ },
935
+ {
936
+ "epoch": 1.232897501751109,
937
+ "grad_norm": 0.029444668665577274,
938
+ "learning_rate": 0.00016565577822496042,
939
+ "loss": 1.8025,
940
+ "step": 1320
941
+ },
942
+ {
943
+ "epoch": 1.2422367499416298,
944
+ "grad_norm": 0.038528856709584745,
945
+ "learning_rate": 0.00016507103352354996,
946
+ "loss": 1.7954,
947
+ "step": 1330
948
+ },
949
+ {
950
+ "epoch": 1.2515759981321504,
951
+ "grad_norm": 0.034217088004383035,
952
+ "learning_rate": 0.00016448240418425814,
953
+ "loss": 1.7962,
954
+ "step": 1340
955
+ },
956
+ {
957
+ "epoch": 1.260915246322671,
958
+ "grad_norm": 0.030205405393195585,
959
+ "learning_rate": 0.00016388992534732645,
960
+ "loss": 1.7973,
961
+ "step": 1350
962
+ },
963
+ {
964
+ "epoch": 1.2702544945131917,
965
+ "grad_norm": 0.029082218516562994,
966
+ "learning_rate": 0.00016329363238280528,
967
+ "loss": 1.796,
968
+ "step": 1360
969
+ },
970
+ {
971
+ "epoch": 1.2795937427037123,
972
+ "grad_norm": 0.029003887688766505,
973
+ "learning_rate": 0.00016269356088844238,
974
+ "loss": 1.7946,
975
+ "step": 1370
976
+ },
977
+ {
978
+ "epoch": 1.288932990894233,
979
+ "grad_norm": 0.03341157363649238,
980
+ "learning_rate": 0.00016208974668755779,
981
+ "loss": 1.7972,
982
+ "step": 1380
983
+ },
984
+ {
985
+ "epoch": 1.2982722390847536,
986
+ "grad_norm": 0.030614480844663026,
987
+ "learning_rate": 0.00016148222582690517,
988
+ "loss": 1.7973,
989
+ "step": 1390
990
+ },
991
+ {
992
+ "epoch": 1.3076114872752744,
993
+ "grad_norm": 0.029741346740467405,
994
+ "learning_rate": 0.00016087103457452,
995
+ "loss": 1.8076,
996
+ "step": 1400
997
+ },
998
+ {
999
+ "epoch": 1.316950735465795,
1000
+ "grad_norm": 0.029569313554185597,
1001
+ "learning_rate": 0.00016025620941755424,
1002
+ "loss": 1.8043,
1003
+ "step": 1410
1004
+ },
1005
+ {
1006
+ "epoch": 1.3262899836563156,
1007
+ "grad_norm": 0.02947637404374054,
1008
+ "learning_rate": 0.0001596377870600983,
1009
+ "loss": 1.797,
1010
+ "step": 1420
1011
+ },
1012
+ {
1013
+ "epoch": 1.3356292318468364,
1014
+ "grad_norm": 0.031005062093959545,
1015
+ "learning_rate": 0.00015901580442098968,
1016
+ "loss": 1.8086,
1017
+ "step": 1430
1018
+ },
1019
+ {
1020
+ "epoch": 1.344968480037357,
1021
+ "grad_norm": 0.029493792984873927,
1022
+ "learning_rate": 0.00015839029863160922,
1023
+ "loss": 1.8026,
1024
+ "step": 1440
1025
+ },
1026
+ {
1027
+ "epoch": 1.3543077282278777,
1028
+ "grad_norm": 0.0288068155951218,
1029
+ "learning_rate": 0.0001577613070336641,
1030
+ "loss": 1.7951,
1031
+ "step": 1450
1032
+ },
1033
+ {
1034
+ "epoch": 1.3636469764183983,
1035
+ "grad_norm": 0.03380404824627639,
1036
+ "learning_rate": 0.00015712886717695885,
1037
+ "loss": 1.7938,
1038
+ "step": 1460
1039
+ },
1040
+ {
1041
+ "epoch": 1.372986224608919,
1042
+ "grad_norm": 0.039744706189693335,
1043
+ "learning_rate": 0.0001564930168171536,
1044
+ "loss": 1.8016,
1045
+ "step": 1470
1046
+ },
1047
+ {
1048
+ "epoch": 1.3823254727994396,
1049
+ "grad_norm": 0.030565530594285437,
1050
+ "learning_rate": 0.00015585379391351012,
1051
+ "loss": 1.7984,
1052
+ "step": 1480
1053
+ },
1054
+ {
1055
+ "epoch": 1.3916647209899602,
1056
+ "grad_norm": 0.04009392805554255,
1057
+ "learning_rate": 0.00015521123662662567,
1058
+ "loss": 1.7999,
1059
+ "step": 1490
1060
+ },
1061
+ {
1062
+ "epoch": 1.401003969180481,
1063
+ "grad_norm": 0.03516196009586836,
1064
+ "learning_rate": 0.000154565383316155,
1065
+ "loss": 1.7979,
1066
+ "step": 1500
1067
+ },
1068
+ {
1069
+ "epoch": 1.4103432173710018,
1070
+ "grad_norm": 0.03534161399054556,
1071
+ "learning_rate": 0.0001539162725385202,
1072
+ "loss": 1.8057,
1073
+ "step": 1510
1074
+ },
1075
+ {
1076
+ "epoch": 1.4196824655615223,
1077
+ "grad_norm": 0.028488879438601067,
1078
+ "learning_rate": 0.000153263943044609,
1079
+ "loss": 1.792,
1080
+ "step": 1520
1081
+ },
1082
+ {
1083
+ "epoch": 1.429021713752043,
1084
+ "grad_norm": 0.03125154490954804,
1085
+ "learning_rate": 0.00015260843377746147,
1086
+ "loss": 1.8008,
1087
+ "step": 1530
1088
+ },
1089
+ {
1090
+ "epoch": 1.4383609619425637,
1091
+ "grad_norm": 0.030194357488801882,
1092
+ "learning_rate": 0.00015194978386994507,
1093
+ "loss": 1.7948,
1094
+ "step": 1540
1095
+ },
1096
+ {
1097
+ "epoch": 1.4477002101330843,
1098
+ "grad_norm": 0.03049246845786265,
1099
+ "learning_rate": 0.00015128803264241852,
1100
+ "loss": 1.7967,
1101
+ "step": 1550
1102
+ },
1103
+ {
1104
+ "epoch": 1.4570394583236048,
1105
+ "grad_norm": 0.030497211097258083,
1106
+ "learning_rate": 0.0001506232196003844,
1107
+ "loss": 1.7894,
1108
+ "step": 1560
1109
+ },
1110
+ {
1111
+ "epoch": 1.4663787065141256,
1112
+ "grad_norm": 0.028748806119737205,
1113
+ "learning_rate": 0.00014995538443213094,
1114
+ "loss": 1.806,
1115
+ "step": 1570
1116
+ },
1117
+ {
1118
+ "epoch": 1.4757179547046464,
1119
+ "grad_norm": 0.036423750322912396,
1120
+ "learning_rate": 0.00014928456700636237,
1121
+ "loss": 1.7995,
1122
+ "step": 1580
1123
+ },
1124
+ {
1125
+ "epoch": 1.485057202895167,
1126
+ "grad_norm": 0.039101516109204065,
1127
+ "learning_rate": 0.00014861080736981906,
1128
+ "loss": 1.8028,
1129
+ "step": 1590
1130
+ },
1131
+ {
1132
+ "epoch": 1.4943964510856875,
1133
+ "grad_norm": 0.031368399541673815,
1134
+ "learning_rate": 0.00014793414574488663,
1135
+ "loss": 1.8005,
1136
+ "step": 1600
1137
+ },
1138
+ {
1139
+ "epoch": 1.5037356992762083,
1140
+ "grad_norm": 0.029788484702512056,
1141
+ "learning_rate": 0.00014725462252719495,
1142
+ "loss": 1.7963,
1143
+ "step": 1610
1144
+ },
1145
+ {
1146
+ "epoch": 1.5130749474667289,
1147
+ "grad_norm": 0.029719041811636312,
1148
+ "learning_rate": 0.00014657227828320635,
1149
+ "loss": 1.7957,
1150
+ "step": 1620
1151
+ },
1152
+ {
1153
+ "epoch": 1.5224141956572494,
1154
+ "grad_norm": 0.02820041575417432,
1155
+ "learning_rate": 0.00014588715374779407,
1156
+ "loss": 1.7986,
1157
+ "step": 1630
1158
+ },
1159
+ {
1160
+ "epoch": 1.5317534438477702,
1161
+ "grad_norm": 1.8322544897261024,
1162
+ "learning_rate": 0.0001451992898218102,
1163
+ "loss": 2.016,
1164
+ "step": 1640
1165
+ },
1166
+ {
1167
+ "epoch": 1.541092692038291,
1168
+ "grad_norm": 0.8676995793107466,
1169
+ "learning_rate": 0.0001445087275696443,
1170
+ "loss": 2.1095,
1171
+ "step": 1650
1172
+ },
1173
+ {
1174
+ "epoch": 1.5504319402288116,
1175
+ "grad_norm": 0.08688193434631736,
1176
+ "learning_rate": 0.00014381550821677155,
1177
+ "loss": 2.0497,
1178
+ "step": 1660
1179
+ },
1180
+ {
1181
+ "epoch": 1.5597711884193322,
1182
+ "grad_norm": 0.18321381224589608,
1183
+ "learning_rate": 0.0001431196731472921,
1184
+ "loss": 1.9023,
1185
+ "step": 1670
1186
+ },
1187
+ {
1188
+ "epoch": 1.569110436609853,
1189
+ "grad_norm": 0.058214343698110564,
1190
+ "learning_rate": 0.00014242126390145998,
1191
+ "loss": 1.8566,
1192
+ "step": 1680
1193
+ },
1194
+ {
1195
+ "epoch": 1.5784496848003737,
1196
+ "grad_norm": 0.03965578147557666,
1197
+ "learning_rate": 0.0001417203221732036,
1198
+ "loss": 1.8206,
1199
+ "step": 1690
1200
+ },
1201
+ {
1202
+ "epoch": 1.587788932990894,
1203
+ "grad_norm": 0.03131802880017099,
1204
+ "learning_rate": 0.00014101688980763658,
1205
+ "loss": 1.8272,
1206
+ "step": 1700
1207
+ },
1208
+ {
1209
+ "epoch": 1.5971281811814149,
1210
+ "grad_norm": 0.02788722706683908,
1211
+ "learning_rate": 0.00014031100879855968,
1212
+ "loss": 1.8145,
1213
+ "step": 1710
1214
+ },
1215
+ {
1216
+ "epoch": 1.6064674293719357,
1217
+ "grad_norm": 0.02781057130092059,
1218
+ "learning_rate": 0.00013960272128595372,
1219
+ "loss": 1.8122,
1220
+ "step": 1720
1221
+ },
1222
+ {
1223
+ "epoch": 1.6158066775624562,
1224
+ "grad_norm": 0.032067383734154756,
1225
+ "learning_rate": 0.00013889206955346403,
1226
+ "loss": 1.8064,
1227
+ "step": 1730
1228
+ },
1229
+ {
1230
+ "epoch": 1.6251459257529768,
1231
+ "grad_norm": 0.03448807133884858,
1232
+ "learning_rate": 0.00013817909602587613,
1233
+ "loss": 1.8128,
1234
+ "step": 1740
1235
+ },
1236
+ {
1237
+ "epoch": 1.6344851739434976,
1238
+ "grad_norm": 0.04127395288271696,
1239
+ "learning_rate": 0.00013746384326658305,
1240
+ "loss": 1.8041,
1241
+ "step": 1750
1242
+ },
1243
+ {
1244
+ "epoch": 1.6438244221340184,
1245
+ "grad_norm": 0.030243192787820814,
1246
+ "learning_rate": 0.00013674635397504427,
1247
+ "loss": 1.803,
1248
+ "step": 1760
1249
+ },
1250
+ {
1251
+ "epoch": 1.653163670324539,
1252
+ "grad_norm": 0.032183525625428915,
1253
+ "learning_rate": 0.00013602667098423687,
1254
+ "loss": 1.8092,
1255
+ "step": 1770
1256
+ },
1257
+ {
1258
+ "epoch": 1.6625029185150595,
1259
+ "grad_norm": 0.030391044676815377,
1260
+ "learning_rate": 0.00013530483725809818,
1261
+ "loss": 1.8039,
1262
+ "step": 1780
1263
+ },
1264
+ {
1265
+ "epoch": 1.6718421667055803,
1266
+ "grad_norm": 0.03204756818238517,
1267
+ "learning_rate": 0.000134580895888961,
1268
+ "loss": 1.8017,
1269
+ "step": 1790
1270
+ },
1271
+ {
1272
+ "epoch": 1.6811814148961008,
1273
+ "grad_norm": 0.031117112662107062,
1274
+ "learning_rate": 0.00013385489009498124,
1275
+ "loss": 1.8017,
1276
+ "step": 1800
1277
+ },
1278
+ {
1279
+ "epoch": 1.6905206630866214,
1280
+ "grad_norm": 0.028389293445401805,
1281
+ "learning_rate": 0.00013312686321755761,
1282
+ "loss": 1.811,
1283
+ "step": 1810
1284
+ },
1285
+ {
1286
+ "epoch": 1.6998599112771422,
1287
+ "grad_norm": 4.908185097372493,
1288
+ "learning_rate": 0.0001323968587187443,
1289
+ "loss": 2.194,
1290
+ "step": 1820
1291
+ },
1292
+ {
1293
+ "epoch": 1.709199159467663,
1294
+ "grad_norm": 0.2849452041194025,
1295
+ "learning_rate": 0.00013166492017865637,
1296
+ "loss": 2.0785,
1297
+ "step": 1830
1298
+ },
1299
+ {
1300
+ "epoch": 1.7185384076581836,
1301
+ "grad_norm": 0.10989252058989733,
1302
+ "learning_rate": 0.0001309310912928682,
1303
+ "loss": 1.986,
1304
+ "step": 1840
1305
+ },
1306
+ {
1307
+ "epoch": 1.7278776558487041,
1308
+ "grad_norm": 0.057475612656740484,
1309
+ "learning_rate": 0.00013019541586980463,
1310
+ "loss": 1.8614,
1311
+ "step": 1850
1312
+ },
1313
+ {
1314
+ "epoch": 1.737216904039225,
1315
+ "grad_norm": 0.034908181734207726,
1316
+ "learning_rate": 0.000129457937828126,
1317
+ "loss": 1.8326,
1318
+ "step": 1860
1319
+ },
1320
+ {
1321
+ "epoch": 1.7465561522297455,
1322
+ "grad_norm": 0.02892836681897248,
1323
+ "learning_rate": 0.00012871870119410614,
1324
+ "loss": 1.8243,
1325
+ "step": 1870
1326
+ },
1327
+ {
1328
+ "epoch": 1.755895400420266,
1329
+ "grad_norm": 0.03311636981729384,
1330
+ "learning_rate": 0.00012797775009900397,
1331
+ "loss": 1.8183,
1332
+ "step": 1880
1333
+ },
1334
+ {
1335
+ "epoch": 1.7652346486107868,
1336
+ "grad_norm": 0.03151917952358458,
1337
+ "learning_rate": 0.00012723512877642904,
1338
+ "loss": 1.8034,
1339
+ "step": 1890
1340
+ },
1341
+ {
1342
+ "epoch": 1.7745738968013076,
1343
+ "grad_norm": 0.028109921832296925,
1344
+ "learning_rate": 0.000126490881559701,
1345
+ "loss": 1.8129,
1346
+ "step": 1900
1347
+ },
1348
+ {
1349
+ "epoch": 1.7839131449918282,
1350
+ "grad_norm": 0.030350462454962698,
1351
+ "learning_rate": 0.00012574505287920259,
1352
+ "loss": 1.8003,
1353
+ "step": 1910
1354
+ },
1355
+ {
1356
+ "epoch": 1.7932523931823487,
1357
+ "grad_norm": 0.03131380630103849,
1358
+ "learning_rate": 0.00012499768725972754,
1359
+ "loss": 1.814,
1360
+ "step": 1920
1361
+ },
1362
+ {
1363
+ "epoch": 1.8025916413728695,
1364
+ "grad_norm": 0.029450198273050322,
1365
+ "learning_rate": 0.00012424882931782243,
1366
+ "loss": 1.7998,
1367
+ "step": 1930
1368
+ },
1369
+ {
1370
+ "epoch": 1.81193088956339,
1371
+ "grad_norm": 0.0310524261453681,
1372
+ "learning_rate": 0.0001234985237591231,
1373
+ "loss": 1.8078,
1374
+ "step": 1940
1375
+ },
1376
+ {
1377
+ "epoch": 1.8212701377539107,
1378
+ "grad_norm": 0.029362038478982822,
1379
+ "learning_rate": 0.00012274681537568585,
1380
+ "loss": 1.8014,
1381
+ "step": 1950
1382
+ },
1383
+ {
1384
+ "epoch": 1.8306093859444315,
1385
+ "grad_norm": 0.027166816460226118,
1386
+ "learning_rate": 0.00012199374904331337,
1387
+ "loss": 1.8021,
1388
+ "step": 1960
1389
+ },
1390
+ {
1391
+ "epoch": 1.8399486341349522,
1392
+ "grad_norm": 0.03680509283276228,
1393
+ "learning_rate": 0.00012123936971887578,
1394
+ "loss": 1.7973,
1395
+ "step": 1970
1396
+ },
1397
+ {
1398
+ "epoch": 1.8492878823254728,
1399
+ "grad_norm": 0.03135174840346185,
1400
+ "learning_rate": 0.0001204837224376267,
1401
+ "loss": 1.7874,
1402
+ "step": 1980
1403
+ },
1404
+ {
1405
+ "epoch": 1.8586271305159934,
1406
+ "grad_norm": 0.02644533256389969,
1407
+ "learning_rate": 0.0001197268523105148,
1408
+ "loss": 1.798,
1409
+ "step": 1990
1410
+ },
1411
+ {
1412
+ "epoch": 1.8679663787065142,
1413
+ "grad_norm": 0.02999453651649614,
1414
+ "learning_rate": 0.00011896880452149077,
1415
+ "loss": 1.7957,
1416
+ "step": 2000
1417
+ },
1418
+ {
1419
+ "epoch": 1.877305626897035,
1420
+ "grad_norm": 0.026905209700322272,
1421
+ "learning_rate": 0.00011820962432480985,
1422
+ "loss": 1.793,
1423
+ "step": 2010
1424
+ },
1425
+ {
1426
+ "epoch": 1.8866448750875553,
1427
+ "grad_norm": 0.027263640323285022,
1428
+ "learning_rate": 0.00011744935704233005,
1429
+ "loss": 1.7974,
1430
+ "step": 2020
1431
+ },
1432
+ {
1433
+ "epoch": 1.895984123278076,
1434
+ "grad_norm": 0.030479226063932337,
1435
+ "learning_rate": 0.00011668804806080693,
1436
+ "loss": 1.7898,
1437
+ "step": 2030
1438
+ },
1439
+ {
1440
+ "epoch": 1.9053233714685969,
1441
+ "grad_norm": 0.030129902025534238,
1442
+ "learning_rate": 0.00011592574282918369,
1443
+ "loss": 1.7856,
1444
+ "step": 2040
1445
+ },
1446
+ {
1447
+ "epoch": 1.9146626196591174,
1448
+ "grad_norm": 0.027884976674153635,
1449
+ "learning_rate": 0.00011516248685587814,
1450
+ "loss": 1.7858,
1451
+ "step": 2050
1452
+ },
1453
+ {
1454
+ "epoch": 1.924001867849638,
1455
+ "grad_norm": 0.02925266011156687,
1456
+ "learning_rate": 0.00011439832570606586,
1457
+ "loss": 1.7876,
1458
+ "step": 2060
1459
+ },
1460
+ {
1461
+ "epoch": 1.9333411160401588,
1462
+ "grad_norm": 0.028472914828616754,
1463
+ "learning_rate": 0.00011363330499895997,
1464
+ "loss": 1.7834,
1465
+ "step": 2070
1466
+ },
1467
+ {
1468
+ "epoch": 1.9426803642306796,
1469
+ "grad_norm": 0.025877740032137875,
1470
+ "learning_rate": 0.00011286747040508789,
1471
+ "loss": 1.7955,
1472
+ "step": 2080
1473
+ },
1474
+ {
1475
+ "epoch": 1.9520196124212001,
1476
+ "grad_norm": 0.02605295620697312,
1477
+ "learning_rate": 0.0001121008676435648,
1478
+ "loss": 1.7877,
1479
+ "step": 2090
1480
+ },
1481
+ {
1482
+ "epoch": 1.9613588606117207,
1483
+ "grad_norm": 0.026887649929567867,
1484
+ "learning_rate": 0.00011133354247936423,
1485
+ "loss": 1.773,
1486
+ "step": 2100
1487
+ },
1488
+ {
1489
+ "epoch": 1.9706981088022415,
1490
+ "grad_norm": 0.027982045915154026,
1491
+ "learning_rate": 0.00011056554072058596,
1492
+ "loss": 1.7762,
1493
+ "step": 2110
1494
+ },
1495
+ {
1496
+ "epoch": 1.980037356992762,
1497
+ "grad_norm": 0.028077027059053006,
1498
+ "learning_rate": 0.0001097969082157215,
1499
+ "loss": 1.7963,
1500
+ "step": 2120
1501
+ },
1502
+ {
1503
+ "epoch": 1.9893766051832826,
1504
+ "grad_norm": 0.027877078975954036,
1505
+ "learning_rate": 0.00010902769085091686,
1506
+ "loss": 1.7787,
1507
+ "step": 2130
1508
+ },
1509
+ {
1510
+ "epoch": 1.9987158533738034,
1511
+ "grad_norm": 0.026120077388738373,
1512
+ "learning_rate": 0.00010825793454723325,
1513
+ "loss": 1.7842,
1514
+ "step": 2140
1515
+ },
1516
+ {
1517
+ "epoch": 2.0081718421667056,
1518
+ "grad_norm": 0.044810283079268924,
1519
+ "learning_rate": 0.00010748768525790569,
1520
+ "loss": 1.6591,
1521
+ "step": 2150
1522
+ },
1523
+ {
1524
+ "epoch": 2.0175110903572264,
1525
+ "grad_norm": 0.03431848280739808,
1526
+ "learning_rate": 0.00010671698896559968,
1527
+ "loss": 1.5599,
1528
+ "step": 2160
1529
+ },
1530
+ {
1531
+ "epoch": 2.0268503385477468,
1532
+ "grad_norm": 0.04234332973849956,
1533
+ "learning_rate": 0.00010594589167966606,
1534
+ "loss": 1.5494,
1535
+ "step": 2170
1536
+ },
1537
+ {
1538
+ "epoch": 2.0361895867382676,
1539
+ "grad_norm": 0.03260321438171042,
1540
+ "learning_rate": 0.00010517443943339438,
1541
+ "loss": 1.5473,
1542
+ "step": 2180
1543
+ },
1544
+ {
1545
+ "epoch": 2.0455288349287883,
1546
+ "grad_norm": 0.034116901745609114,
1547
+ "learning_rate": 0.00010440267828126478,
1548
+ "loss": 1.5464,
1549
+ "step": 2190
1550
+ },
1551
+ {
1552
+ "epoch": 2.0548680831193087,
1553
+ "grad_norm": 0.030992757239375807,
1554
+ "learning_rate": 0.00010363065429619858,
1555
+ "loss": 1.5514,
1556
+ "step": 2200
1557
+ },
1558
+ {
1559
+ "epoch": 2.0642073313098295,
1560
+ "grad_norm": 0.03365516197786113,
1561
+ "learning_rate": 0.0001028584135668077,
1562
+ "loss": 1.5493,
1563
+ "step": 2210
1564
+ },
1565
+ {
1566
+ "epoch": 2.0735465795003503,
1567
+ "grad_norm": 0.033293307482261586,
1568
+ "learning_rate": 0.00010208600219464355,
1569
+ "loss": 1.5426,
1570
+ "step": 2220
1571
+ },
1572
+ {
1573
+ "epoch": 2.082885827690871,
1574
+ "grad_norm": 0.03653097737467338,
1575
+ "learning_rate": 0.00010131346629144451,
1576
+ "loss": 1.5471,
1577
+ "step": 2230
1578
+ },
1579
+ {
1580
+ "epoch": 2.0922250758813914,
1581
+ "grad_norm": 0.03390291511697895,
1582
+ "learning_rate": 0.0001005408519763833,
1583
+ "loss": 1.5568,
1584
+ "step": 2240
1585
+ },
1586
+ {
1587
+ "epoch": 2.101564324071912,
1588
+ "grad_norm": 0.03192694661852283,
1589
+ "learning_rate": 9.976820537331374e-05,
1590
+ "loss": 1.5452,
1591
+ "step": 2250
1592
+ },
1593
+ {
1594
+ "epoch": 2.110903572262433,
1595
+ "grad_norm": 0.03561740193515691,
1596
+ "learning_rate": 9.899557260801707e-05,
1597
+ "loss": 1.546,
1598
+ "step": 2260
1599
+ },
1600
+ {
1601
+ "epoch": 2.1202428204529538,
1602
+ "grad_norm": 0.029803732953068658,
1603
+ "learning_rate": 9.822299980544862e-05,
1604
+ "loss": 1.5533,
1605
+ "step": 2270
1606
+ },
1607
+ {
1608
+ "epoch": 2.129582068643474,
1609
+ "grad_norm": 0.031232417271289125,
1610
+ "learning_rate": 9.745053308698392e-05,
1611
+ "loss": 1.5469,
1612
+ "step": 2280
1613
+ },
1614
+ {
1615
+ "epoch": 2.138921316833995,
1616
+ "grad_norm": 0.032434793780181034,
1617
+ "learning_rate": 9.667821856766548e-05,
1618
+ "loss": 1.5514,
1619
+ "step": 2290
1620
+ },
1621
+ {
1622
+ "epoch": 2.1482605650245157,
1623
+ "grad_norm": 0.03579370906405582,
1624
+ "learning_rate": 9.590610235344972e-05,
1625
+ "loss": 1.5577,
1626
+ "step": 2300
1627
+ },
1628
+ {
1629
+ "epoch": 2.157599813215036,
1630
+ "grad_norm": 0.029662202478648328,
1631
+ "learning_rate": 9.51342305384546e-05,
1632
+ "loss": 1.5543,
1633
+ "step": 2310
1634
+ },
1635
+ {
1636
+ "epoch": 2.166939061405557,
1637
+ "grad_norm": 0.03178715913934592,
1638
+ "learning_rate": 9.436264920220781e-05,
1639
+ "loss": 1.5579,
1640
+ "step": 2320
1641
+ },
1642
+ {
1643
+ "epoch": 2.1762783095960776,
1644
+ "grad_norm": 0.03384008887051677,
1645
+ "learning_rate": 9.359140440689601e-05,
1646
+ "loss": 1.5595,
1647
+ "step": 2330
1648
+ },
1649
+ {
1650
+ "epoch": 2.1856175577865984,
1651
+ "grad_norm": 0.03316450664408166,
1652
+ "learning_rate": 9.282054219461475e-05,
1653
+ "loss": 1.5556,
1654
+ "step": 2340
1655
+ },
1656
+ {
1657
+ "epoch": 2.1949568059771187,
1658
+ "grad_norm": 0.032176305552558876,
1659
+ "learning_rate": 9.205010858462007e-05,
1660
+ "loss": 1.5638,
1661
+ "step": 2350
1662
+ },
1663
+ {
1664
+ "epoch": 2.2042960541676395,
1665
+ "grad_norm": 0.031134335256756362,
1666
+ "learning_rate": 9.128014957058109e-05,
1667
+ "loss": 1.5629,
1668
+ "step": 2360
1669
+ },
1670
+ {
1671
+ "epoch": 2.2136353023581603,
1672
+ "grad_norm": 0.032205851810441756,
1673
+ "learning_rate": 9.051071111783436e-05,
1674
+ "loss": 1.5613,
1675
+ "step": 2370
1676
+ },
1677
+ {
1678
+ "epoch": 2.2229745505486807,
1679
+ "grad_norm": 0.029048245476020442,
1680
+ "learning_rate": 8.974183916063968e-05,
1681
+ "loss": 1.5594,
1682
+ "step": 2380
1683
+ },
1684
+ {
1685
+ "epoch": 2.2323137987392014,
1686
+ "grad_norm": 0.03183166054573621,
1687
+ "learning_rate": 8.897357959943795e-05,
1688
+ "loss": 1.5606,
1689
+ "step": 2390
1690
+ },
1691
+ {
1692
+ "epoch": 2.2416530469297222,
1693
+ "grad_norm": 0.032309922117136916,
1694
+ "learning_rate": 8.820597829811109e-05,
1695
+ "loss": 1.5524,
1696
+ "step": 2400
1697
+ },
1698
+ {
1699
+ "epoch": 2.250992295120243,
1700
+ "grad_norm": 0.03598922231958808,
1701
+ "learning_rate": 8.743908108124388e-05,
1702
+ "loss": 1.5604,
1703
+ "step": 2410
1704
+ },
1705
+ {
1706
+ "epoch": 2.2603315433107634,
1707
+ "grad_norm": 0.03046424735786346,
1708
+ "learning_rate": 8.667293373138835e-05,
1709
+ "loss": 1.5598,
1710
+ "step": 2420
1711
+ },
1712
+ {
1713
+ "epoch": 2.269670791501284,
1714
+ "grad_norm": 0.030995453538377543,
1715
+ "learning_rate": 8.59075819863307e-05,
1716
+ "loss": 1.5652,
1717
+ "step": 2430
1718
+ },
1719
+ {
1720
+ "epoch": 2.279010039691805,
1721
+ "grad_norm": 0.029309020623010097,
1722
+ "learning_rate": 8.514307153636077e-05,
1723
+ "loss": 1.5651,
1724
+ "step": 2440
1725
+ },
1726
+ {
1727
+ "epoch": 2.2883492878823253,
1728
+ "grad_norm": 0.03158721106736763,
1729
+ "learning_rate": 8.437944802154434e-05,
1730
+ "loss": 1.5581,
1731
+ "step": 2450
1732
+ },
1733
+ {
1734
+ "epoch": 2.297688536072846,
1735
+ "grad_norm": 0.03168229084049938,
1736
+ "learning_rate": 8.361675702899871e-05,
1737
+ "loss": 1.5671,
1738
+ "step": 2460
1739
+ },
1740
+ {
1741
+ "epoch": 2.307027784263367,
1742
+ "grad_norm": 0.031335222148495136,
1743
+ "learning_rate": 8.2855044090171e-05,
1744
+ "loss": 1.5675,
1745
+ "step": 2470
1746
+ },
1747
+ {
1748
+ "epoch": 2.3163670324538876,
1749
+ "grad_norm": 0.031073847325941303,
1750
+ "learning_rate": 8.209435467811998e-05,
1751
+ "loss": 1.5624,
1752
+ "step": 2480
1753
+ },
1754
+ {
1755
+ "epoch": 2.325706280644408,
1756
+ "grad_norm": 0.030099100631045844,
1757
+ "learning_rate": 8.133473420480161e-05,
1758
+ "loss": 1.5606,
1759
+ "step": 2490
1760
+ },
1761
+ {
1762
+ "epoch": 2.3350455288349288,
1763
+ "grad_norm": 0.034147632950361176,
1764
+ "learning_rate": 8.057622801835788e-05,
1765
+ "loss": 1.5703,
1766
+ "step": 2500
1767
+ },
1768
+ {
1769
+ "epoch": 2.3443847770254496,
1770
+ "grad_norm": 0.03051580784550685,
1771
+ "learning_rate": 7.981888140040955e-05,
1772
+ "loss": 1.5731,
1773
+ "step": 2510
1774
+ },
1775
+ {
1776
+ "epoch": 2.3537240252159704,
1777
+ "grad_norm": 0.03068917065832597,
1778
+ "learning_rate": 7.9062739563353e-05,
1779
+ "loss": 1.5723,
1780
+ "step": 2520
1781
+ },
1782
+ {
1783
+ "epoch": 2.3630632734064907,
1784
+ "grad_norm": 0.02899547641705554,
1785
+ "learning_rate": 7.830784764766118e-05,
1786
+ "loss": 1.5691,
1787
+ "step": 2530
1788
+ },
1789
+ {
1790
+ "epoch": 2.3724025215970115,
1791
+ "grad_norm": 0.030965383166701443,
1792
+ "learning_rate": 7.755425071918858e-05,
1793
+ "loss": 1.5627,
1794
+ "step": 2540
1795
+ },
1796
+ {
1797
+ "epoch": 2.3817417697875323,
1798
+ "grad_norm": 0.03252440018336625,
1799
+ "learning_rate": 7.680199376648108e-05,
1800
+ "loss": 1.5536,
1801
+ "step": 2550
1802
+ },
1803
+ {
1804
+ "epoch": 2.3910810179780526,
1805
+ "grad_norm": 0.031720485449340044,
1806
+ "learning_rate": 7.605112169809008e-05,
1807
+ "loss": 1.5617,
1808
+ "step": 2560
1809
+ },
1810
+ {
1811
+ "epoch": 2.4004202661685734,
1812
+ "grad_norm": 0.031796658969132544,
1813
+ "learning_rate": 7.530167933989161e-05,
1814
+ "loss": 1.5595,
1815
+ "step": 2570
1816
+ },
1817
+ {
1818
+ "epoch": 2.409759514359094,
1819
+ "grad_norm": 0.03218288097429844,
1820
+ "learning_rate": 7.45537114324102e-05,
1821
+ "loss": 1.5628,
1822
+ "step": 2580
1823
+ },
1824
+ {
1825
+ "epoch": 2.4190987625496145,
1826
+ "grad_norm": 0.0305713183075559,
1827
+ "learning_rate": 7.380726262814814e-05,
1828
+ "loss": 1.5717,
1829
+ "step": 2590
1830
+ },
1831
+ {
1832
+ "epoch": 2.4284380107401353,
1833
+ "grad_norm": 0.06879342166341705,
1834
+ "learning_rate": 7.30623774889195e-05,
1835
+ "loss": 1.5726,
1836
+ "step": 2600
1837
+ },
1838
+ {
1839
+ "epoch": 2.437777258930656,
1840
+ "grad_norm": 0.04101428600237338,
1841
+ "learning_rate": 7.231910048319011e-05,
1842
+ "loss": 1.5679,
1843
+ "step": 2610
1844
+ },
1845
+ {
1846
+ "epoch": 2.447116507121177,
1847
+ "grad_norm": 0.031060002638443395,
1848
+ "learning_rate": 7.157747598342274e-05,
1849
+ "loss": 1.562,
1850
+ "step": 2620
1851
+ },
1852
+ {
1853
+ "epoch": 2.4564557553116972,
1854
+ "grad_norm": 0.032302829437386466,
1855
+ "learning_rate": 7.083754826342816e-05,
1856
+ "loss": 1.5767,
1857
+ "step": 2630
1858
+ },
1859
+ {
1860
+ "epoch": 2.465795003502218,
1861
+ "grad_norm": 0.03111462744196413,
1862
+ "learning_rate": 7.009936149572205e-05,
1863
+ "loss": 1.5672,
1864
+ "step": 2640
1865
+ },
1866
+ {
1867
+ "epoch": 2.475134251692739,
1868
+ "grad_norm": 0.031134083521743777,
1869
+ "learning_rate": 6.936295974888807e-05,
1870
+ "loss": 1.5665,
1871
+ "step": 2650
1872
+ },
1873
+ {
1874
+ "epoch": 2.4844734998832596,
1875
+ "grad_norm": 0.030961556373721985,
1876
+ "learning_rate": 6.862838698494693e-05,
1877
+ "loss": 1.5608,
1878
+ "step": 2660
1879
+ },
1880
+ {
1881
+ "epoch": 2.49381274807378,
1882
+ "grad_norm": 0.03168121700432082,
1883
+ "learning_rate": 6.789568705673183e-05,
1884
+ "loss": 1.566,
1885
+ "step": 2670
1886
+ },
1887
+ {
1888
+ "epoch": 2.5031519962643007,
1889
+ "grad_norm": 0.030850372541726772,
1890
+ "learning_rate": 6.716490370527081e-05,
1891
+ "loss": 1.5651,
1892
+ "step": 2680
1893
+ },
1894
+ {
1895
+ "epoch": 2.5124912444548215,
1896
+ "grad_norm": 0.03076635908430861,
1897
+ "learning_rate": 6.643608055717519e-05,
1898
+ "loss": 1.5596,
1899
+ "step": 2690
1900
+ },
1901
+ {
1902
+ "epoch": 2.521830492645342,
1903
+ "grad_norm": 0.031897253741779714,
1904
+ "learning_rate": 6.570926112203528e-05,
1905
+ "loss": 1.5716,
1906
+ "step": 2700
1907
+ },
1908
+ {
1909
+ "epoch": 2.5311697408358627,
1910
+ "grad_norm": 0.03085546721246857,
1911
+ "learning_rate": 6.498448878982291e-05,
1912
+ "loss": 1.5647,
1913
+ "step": 2710
1914
+ },
1915
+ {
1916
+ "epoch": 2.5405089890263834,
1917
+ "grad_norm": 0.03127518794548787,
1918
+ "learning_rate": 6.426180682830107e-05,
1919
+ "loss": 1.5573,
1920
+ "step": 2720
1921
+ },
1922
+ {
1923
+ "epoch": 2.549848237216904,
1924
+ "grad_norm": 0.03196649247686066,
1925
+ "learning_rate": 6.354125838044098e-05,
1926
+ "loss": 1.5597,
1927
+ "step": 2730
1928
+ },
1929
+ {
1930
+ "epoch": 2.5591874854074246,
1931
+ "grad_norm": 0.030359755432035333,
1932
+ "learning_rate": 6.282288646184638e-05,
1933
+ "loss": 1.5625,
1934
+ "step": 2740
1935
+ },
1936
+ {
1937
+ "epoch": 2.5685267335979454,
1938
+ "grad_norm": 0.03030640438940187,
1939
+ "learning_rate": 6.210673395818571e-05,
1940
+ "loss": 1.5717,
1941
+ "step": 2750
1942
+ },
1943
+ {
1944
+ "epoch": 2.577865981788466,
1945
+ "grad_norm": 0.032197470232298186,
1946
+ "learning_rate": 6.139284362263185e-05,
1947
+ "loss": 1.5663,
1948
+ "step": 2760
1949
+ },
1950
+ {
1951
+ "epoch": 2.587205229978987,
1952
+ "grad_norm": 0.030983733397891462,
1953
+ "learning_rate": 6.0681258073309756e-05,
1954
+ "loss": 1.5657,
1955
+ "step": 2770
1956
+ },
1957
+ {
1958
+ "epoch": 2.5965444781695073,
1959
+ "grad_norm": 0.030427577702286164,
1960
+ "learning_rate": 5.9972019790752385e-05,
1961
+ "loss": 1.5708,
1962
+ "step": 2780
1963
+ },
1964
+ {
1965
+ "epoch": 2.605883726360028,
1966
+ "grad_norm": 0.032761226318855745,
1967
+ "learning_rate": 5.9265171115364495e-05,
1968
+ "loss": 1.5641,
1969
+ "step": 2790
1970
+ },
1971
+ {
1972
+ "epoch": 2.615222974550549,
1973
+ "grad_norm": 0.0317533648622182,
1974
+ "learning_rate": 5.856075424489511e-05,
1975
+ "loss": 1.5613,
1976
+ "step": 2800
1977
+ },
1978
+ {
1979
+ "epoch": 2.624562222741069,
1980
+ "grad_norm": 0.03251887796623927,
1981
+ "learning_rate": 5.785881123191834e-05,
1982
+ "loss": 1.5644,
1983
+ "step": 2810
1984
+ },
1985
+ {
1986
+ "epoch": 2.63390147093159,
1987
+ "grad_norm": 0.033109556138937665,
1988
+ "learning_rate": 5.7159383981322866e-05,
1989
+ "loss": 1.5613,
1990
+ "step": 2820
1991
+ },
1992
+ {
1993
+ "epoch": 2.643240719122111,
1994
+ "grad_norm": 0.03190494841434546,
1995
+ "learning_rate": 5.646251424781044e-05,
1996
+ "loss": 1.5597,
1997
+ "step": 2830
1998
+ },
1999
+ {
2000
+ "epoch": 2.652579967312631,
2001
+ "grad_norm": 0.03131425467271855,
2002
+ "learning_rate": 5.576824363340293e-05,
2003
+ "loss": 1.5644,
2004
+ "step": 2840
2005
+ },
2006
+ {
2007
+ "epoch": 2.661919215503152,
2008
+ "grad_norm": 0.032580122114687284,
2009
+ "learning_rate": 5.507661358495904e-05,
2010
+ "loss": 1.5651,
2011
+ "step": 2850
2012
+ },
2013
+ {
2014
+ "epoch": 2.6712584636936727,
2015
+ "grad_norm": 0.031118294785578867,
2016
+ "learning_rate": 5.4387665391699814e-05,
2017
+ "loss": 1.5595,
2018
+ "step": 2860
2019
+ },
2020
+ {
2021
+ "epoch": 2.680597711884193,
2022
+ "grad_norm": 0.030454480461742643,
2023
+ "learning_rate": 5.370144018274371e-05,
2024
+ "loss": 1.5607,
2025
+ "step": 2870
2026
+ },
2027
+ {
2028
+ "epoch": 2.689936960074714,
2029
+ "grad_norm": 0.030828671799046907,
2030
+ "learning_rate": 5.301797892465148e-05,
2031
+ "loss": 1.5587,
2032
+ "step": 2880
2033
+ },
2034
+ {
2035
+ "epoch": 2.6992762082652346,
2036
+ "grad_norm": 0.030541588338347705,
2037
+ "learning_rate": 5.2337322418980204e-05,
2038
+ "loss": 1.5698,
2039
+ "step": 2890
2040
+ },
2041
+ {
2042
+ "epoch": 2.7086154564557554,
2043
+ "grad_norm": 0.030634684731728472,
2044
+ "learning_rate": 5.16595112998477e-05,
2045
+ "loss": 1.5628,
2046
+ "step": 2900
2047
+ },
2048
+ {
2049
+ "epoch": 2.717954704646276,
2050
+ "grad_norm": 0.03045168911848818,
2051
+ "learning_rate": 5.098458603150691e-05,
2052
+ "loss": 1.5544,
2053
+ "step": 2910
2054
+ },
2055
+ {
2056
+ "epoch": 2.7272939528367965,
2057
+ "grad_norm": 0.029966073421542574,
2058
+ "learning_rate": 5.0312586905929816e-05,
2059
+ "loss": 1.557,
2060
+ "step": 2920
2061
+ },
2062
+ {
2063
+ "epoch": 2.7366332010273173,
2064
+ "grad_norm": 0.031203173596988765,
2065
+ "learning_rate": 4.964355404040232e-05,
2066
+ "loss": 1.5571,
2067
+ "step": 2930
2068
+ },
2069
+ {
2070
+ "epoch": 2.745972449217838,
2071
+ "grad_norm": 0.02933060802902336,
2072
+ "learning_rate": 4.897752737512944e-05,
2073
+ "loss": 1.5518,
2074
+ "step": 2940
2075
+ },
2076
+ {
2077
+ "epoch": 2.7553116974083585,
2078
+ "grad_norm": 0.03039237943996916,
2079
+ "learning_rate": 4.8314546670850594e-05,
2080
+ "loss": 1.5682,
2081
+ "step": 2950
2082
+ },
2083
+ {
2084
+ "epoch": 2.7646509455988793,
2085
+ "grad_norm": 0.03077504425768828,
2086
+ "learning_rate": 4.765465150646633e-05,
2087
+ "loss": 1.5618,
2088
+ "step": 2960
2089
+ },
2090
+ {
2091
+ "epoch": 2.7739901937894,
2092
+ "grad_norm": 0.02987361489256037,
2093
+ "learning_rate": 4.699788127667517e-05,
2094
+ "loss": 1.5657,
2095
+ "step": 2970
2096
+ },
2097
+ {
2098
+ "epoch": 2.7833294419799204,
2099
+ "grad_norm": 0.030823634404763923,
2100
+ "learning_rate": 4.634427518962209e-05,
2101
+ "loss": 1.5611,
2102
+ "step": 2980
2103
+ },
2104
+ {
2105
+ "epoch": 2.792668690170441,
2106
+ "grad_norm": 0.031136974955910973,
2107
+ "learning_rate": 4.569387226455776e-05,
2108
+ "loss": 1.558,
2109
+ "step": 2990
2110
+ },
2111
+ {
2112
+ "epoch": 2.802007938360962,
2113
+ "grad_norm": 0.032345263568839946,
2114
+ "learning_rate": 4.5046711329508997e-05,
2115
+ "loss": 1.5567,
2116
+ "step": 3000
2117
+ },
2118
+ {
2119
+ "epoch": 2.8113471865514827,
2120
+ "grad_norm": 0.03075590840408306,
2121
+ "learning_rate": 4.440283101896112e-05,
2122
+ "loss": 1.5509,
2123
+ "step": 3010
2124
+ },
2125
+ {
2126
+ "epoch": 2.8206864347420035,
2127
+ "grad_norm": 0.03212380955577142,
2128
+ "learning_rate": 4.376226977155118e-05,
2129
+ "loss": 1.5549,
2130
+ "step": 3020
2131
+ },
2132
+ {
2133
+ "epoch": 2.830025682932524,
2134
+ "grad_norm": 0.030448994102361984,
2135
+ "learning_rate": 4.3125065827773535e-05,
2136
+ "loss": 1.5582,
2137
+ "step": 3030
2138
+ },
2139
+ {
2140
+ "epoch": 2.8393649311230447,
2141
+ "grad_norm": 0.02952309346631166,
2142
+ "learning_rate": 4.249125722769679e-05,
2143
+ "loss": 1.5621,
2144
+ "step": 3040
2145
+ },
2146
+ {
2147
+ "epoch": 2.8487041793135655,
2148
+ "grad_norm": 0.029801760584304334,
2149
+ "learning_rate": 4.18608818086928e-05,
2150
+ "loss": 1.5566,
2151
+ "step": 3050
2152
+ },
2153
+ {
2154
+ "epoch": 2.858043427504086,
2155
+ "grad_norm": 0.029682850572275397,
2156
+ "learning_rate": 4.12339772031781e-05,
2157
+ "loss": 1.563,
2158
+ "step": 3060
2159
+ },
2160
+ {
2161
+ "epoch": 2.8673826756946066,
2162
+ "grad_norm": 0.0295800536252474,
2163
+ "learning_rate": 4.061058083636702e-05,
2164
+ "loss": 1.5478,
2165
+ "step": 3070
2166
+ },
2167
+ {
2168
+ "epoch": 2.8767219238851274,
2169
+ "grad_norm": 0.029683305961870896,
2170
+ "learning_rate": 3.999072992403756e-05,
2171
+ "loss": 1.5628,
2172
+ "step": 3080
2173
+ },
2174
+ {
2175
+ "epoch": 2.8860611720756477,
2176
+ "grad_norm": 0.029644699672258072,
2177
+ "learning_rate": 3.93744614703098e-05,
2178
+ "loss": 1.5541,
2179
+ "step": 3090
2180
+ },
2181
+ {
2182
+ "epoch": 2.8954004202661685,
2183
+ "grad_norm": 0.030518095362273494,
2184
+ "learning_rate": 3.876181226543668e-05,
2185
+ "loss": 1.5702,
2186
+ "step": 3100
2187
+ }
2188
+ ],
2189
+ "logging_steps": 10,
2190
+ "max_steps": 4280,
2191
+ "num_input_tokens_seen": 0,
2192
+ "num_train_epochs": 4,
2193
+ "save_steps": 100,
2194
+ "stateful_callbacks": {
2195
+ "TrainerControl": {
2196
+ "args": {
2197
+ "should_epoch_stop": false,
2198
+ "should_evaluate": false,
2199
+ "should_log": false,
2200
+ "should_save": true,
2201
+ "should_training_stop": false
2202
+ },
2203
+ "attributes": {}
2204
+ }
2205
+ },
2206
+ "total_flos": 2.5100743120772923e+20,
2207
+ "train_batch_size": 2,
2208
+ "trial_name": null,
2209
+ "trial_params": null
2210
+ }
l2-13b-ga/checkpoint-3100/zero_to_fp32.py ADDED
@@ -0,0 +1,592 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: python zero_to_fp32.py . pytorch_model.bin
14
+
15
+ import argparse
16
+ import torch
17
+ import glob
18
+ import math
19
+ import os
20
+ import re
21
+ from collections import OrderedDict
22
+ from dataclasses import dataclass
23
+
24
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
25
+ # DeepSpeed data structures it has to be available in the current python environment.
26
+ from deepspeed.utils import logger
27
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
28
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
29
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
30
+
31
+
32
+ @dataclass
33
+ class zero_model_state:
34
+ buffers: dict()
35
+ param_shapes: dict()
36
+ shared_params: list
37
+ ds_version: int
38
+ frozen_param_shapes: dict()
39
+ frozen_param_fragments: dict()
40
+
41
+
42
+ debug = 0
43
+
44
+ # load to cpu
45
+ device = torch.device('cpu')
46
+
47
+
48
+ def atoi(text):
49
+ return int(text) if text.isdigit() else text
50
+
51
+
52
+ def natural_keys(text):
53
+ '''
54
+ alist.sort(key=natural_keys) sorts in human order
55
+ http://nedbatchelder.com/blog/200712/human_sorting.html
56
+ (See Toothy's implementation in the comments)
57
+ '''
58
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
59
+
60
+
61
+ def get_model_state_file(checkpoint_dir, zero_stage):
62
+ if not os.path.isdir(checkpoint_dir):
63
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
64
+
65
+ # there should be only one file
66
+ if zero_stage <= 2:
67
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
68
+ elif zero_stage == 3:
69
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
70
+
71
+ if not os.path.exists(file):
72
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
73
+
74
+ return file
75
+
76
+
77
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
78
+ # XXX: need to test that this simple glob rule works for multi-node setup too
79
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
80
+
81
+ if len(ckpt_files) == 0:
82
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
83
+
84
+ return ckpt_files
85
+
86
+
87
+ def get_optim_files(checkpoint_dir):
88
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
89
+
90
+
91
+ def get_model_state_files(checkpoint_dir):
92
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
93
+
94
+
95
+ def parse_model_states(files):
96
+ zero_model_states = []
97
+ for file in files:
98
+ state_dict = torch.load(file, map_location=device)
99
+
100
+ if BUFFER_NAMES not in state_dict:
101
+ raise ValueError(f"{file} is not a model state checkpoint")
102
+ buffer_names = state_dict[BUFFER_NAMES]
103
+ if debug:
104
+ print("Found buffers:", buffer_names)
105
+
106
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
107
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
108
+ param_shapes = state_dict[PARAM_SHAPES]
109
+
110
+ # collect parameters that are included in param_shapes
111
+ param_names = []
112
+ for s in param_shapes:
113
+ for name in s.keys():
114
+ param_names.append(name)
115
+
116
+ # update with frozen parameters
117
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
118
+ if frozen_param_shapes is not None:
119
+ if debug:
120
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
121
+ param_names += list(frozen_param_shapes.keys())
122
+
123
+ # handle shared params
124
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
125
+
126
+ ds_version = state_dict.get(DS_VERSION, None)
127
+
128
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
129
+
130
+ z_model_state = zero_model_state(buffers=buffers,
131
+ param_shapes=param_shapes,
132
+ shared_params=shared_params,
133
+ ds_version=ds_version,
134
+ frozen_param_shapes=frozen_param_shapes,
135
+ frozen_param_fragments=frozen_param_fragments)
136
+ zero_model_states.append(z_model_state)
137
+
138
+ return zero_model_states
139
+
140
+
141
+ def parse_optim_states(files, ds_checkpoint_dir):
142
+
143
+ total_files = len(files)
144
+ state_dicts = []
145
+ for f in files:
146
+ state_dict = torch.load(f, map_location=device)
147
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
148
+ # and also handle the case where it was already removed by another helper script
149
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
150
+ state_dicts.append(state_dict)
151
+
152
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
153
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
154
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
155
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
156
+
157
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
158
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
159
+ # use the max of the partition_count to get the dp world_size.
160
+
161
+ if type(world_size) is list:
162
+ world_size = max(world_size)
163
+
164
+ if world_size != total_files:
165
+ raise ValueError(
166
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
167
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
168
+ )
169
+
170
+ # the groups are named differently in each stage
171
+ if zero_stage <= 2:
172
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
173
+ elif zero_stage == 3:
174
+ fp32_groups_key = FP32_FLAT_GROUPS
175
+ else:
176
+ raise ValueError(f"unknown zero stage {zero_stage}")
177
+
178
+ if zero_stage <= 2:
179
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
180
+ elif zero_stage == 3:
181
+ # if there is more than one param group, there will be multiple flattened tensors - one
182
+ # flattened tensor per group - for simplicity merge them into a single tensor
183
+ #
184
+ # XXX: could make the script more memory efficient for when there are multiple groups - it
185
+ # will require matching the sub-lists of param_shapes for each param group flattened tensor
186
+
187
+ fp32_flat_groups = [
188
+ torch.cat(state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key], 0) for i in range(len(state_dicts))
189
+ ]
190
+
191
+ return zero_stage, world_size, fp32_flat_groups
192
+
193
+
194
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir):
195
+ """
196
+ Returns fp32 state_dict reconstructed from ds checkpoint
197
+
198
+ Args:
199
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
200
+
201
+ """
202
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
203
+
204
+ optim_files = get_optim_files(ds_checkpoint_dir)
205
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
206
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
207
+
208
+ model_files = get_model_state_files(ds_checkpoint_dir)
209
+
210
+ zero_model_states = parse_model_states(model_files)
211
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
212
+
213
+ if zero_stage <= 2:
214
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states)
215
+ elif zero_stage == 3:
216
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states)
217
+
218
+
219
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
220
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
221
+ return
222
+
223
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
224
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
225
+
226
+ if debug:
227
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
228
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
229
+
230
+ wanted_params = len(frozen_param_shapes)
231
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
232
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
233
+ print(f'Frozen params: Have {avail_numel} numels to process.')
234
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
235
+
236
+ total_params = 0
237
+ total_numel = 0
238
+ for name, shape in frozen_param_shapes.items():
239
+ total_params += 1
240
+ unpartitioned_numel = shape.numel()
241
+ total_numel += unpartitioned_numel
242
+
243
+ state_dict[name] = frozen_param_fragments[name]
244
+
245
+ if debug:
246
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
247
+
248
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
249
+
250
+
251
+ def _has_callable(obj, fn):
252
+ attr = getattr(obj, fn, None)
253
+ return callable(attr)
254
+
255
+
256
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
257
+ param_shapes = zero_model_states[0].param_shapes
258
+
259
+ # Reconstruction protocol:
260
+ #
261
+ # XXX: document this
262
+
263
+ if debug:
264
+ for i in range(world_size):
265
+ for j in range(len(fp32_flat_groups[0])):
266
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
267
+
268
+ # XXX: memory usage doubles here (zero2)
269
+ num_param_groups = len(fp32_flat_groups[0])
270
+ merged_single_partition_of_fp32_groups = []
271
+ for i in range(num_param_groups):
272
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
273
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
274
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
275
+ avail_numel = sum(
276
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
277
+
278
+ if debug:
279
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
280
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
281
+ # not asserting if there is a mismatch due to possible padding
282
+ print(f"Have {avail_numel} numels to process.")
283
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
284
+
285
+ # params
286
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
287
+ # out-of-core computing solution
288
+ total_numel = 0
289
+ total_params = 0
290
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
291
+ offset = 0
292
+ avail_numel = full_single_fp32_vector.numel()
293
+ for name, shape in shapes.items():
294
+
295
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
296
+ total_numel += unpartitioned_numel
297
+ total_params += 1
298
+
299
+ if debug:
300
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
301
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
302
+ offset += unpartitioned_numel
303
+
304
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
305
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
306
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
307
+ # live optimizer object, so we are checking that the numbers are within the right range
308
+ align_to = 2 * world_size
309
+
310
+ def zero2_align(x):
311
+ return align_to * math.ceil(x / align_to)
312
+
313
+ if debug:
314
+ print(f"original offset={offset}, avail_numel={avail_numel}")
315
+
316
+ offset = zero2_align(offset)
317
+ avail_numel = zero2_align(avail_numel)
318
+
319
+ if debug:
320
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
321
+
322
+ # Sanity check
323
+ if offset != avail_numel:
324
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
325
+
326
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
327
+
328
+
329
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states):
330
+ state_dict = OrderedDict()
331
+
332
+ # buffers
333
+ buffers = zero_model_states[0].buffers
334
+ state_dict.update(buffers)
335
+ if debug:
336
+ print(f"added {len(buffers)} buffers")
337
+
338
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
339
+
340
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
341
+
342
+ # recover shared parameters
343
+ for pair in zero_model_states[0].shared_params:
344
+ if pair[1] in state_dict:
345
+ state_dict[pair[0]] = state_dict[pair[1]]
346
+
347
+ return state_dict
348
+
349
+
350
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
351
+ remainder = unpartitioned_numel % world_size
352
+ padding_numel = (world_size - remainder) if remainder else 0
353
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
354
+ return partitioned_numel, padding_numel
355
+
356
+
357
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
358
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
359
+ return
360
+
361
+ if debug:
362
+ for i in range(world_size):
363
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
364
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
365
+
366
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
367
+ wanted_params = len(frozen_param_shapes)
368
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
369
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
370
+ print(f'Frozen params: Have {avail_numel} numels to process.')
371
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
372
+
373
+ total_params = 0
374
+ total_numel = 0
375
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
376
+ total_params += 1
377
+ unpartitioned_numel = shape.numel()
378
+ total_numel += unpartitioned_numel
379
+
380
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
381
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
382
+
383
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
384
+
385
+ if debug:
386
+ print(
387
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
388
+ )
389
+
390
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
391
+
392
+
393
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
394
+ param_shapes = zero_model_states[0].param_shapes
395
+ avail_numel = fp32_flat_groups[0].numel() * world_size
396
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
397
+ # param, re-consolidating each param, while dealing with padding if any
398
+
399
+ # merge list of dicts, preserving order
400
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
401
+
402
+ if debug:
403
+ for i in range(world_size):
404
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
405
+
406
+ wanted_params = len(param_shapes)
407
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
408
+ # not asserting if there is a mismatch due to possible padding
409
+ avail_numel = fp32_flat_groups[0].numel() * world_size
410
+ print(f"Trainable params: Have {avail_numel} numels to process.")
411
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
412
+
413
+ # params
414
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
415
+ # out-of-core computing solution
416
+ offset = 0
417
+ total_numel = 0
418
+ total_params = 0
419
+ for name, shape in param_shapes.items():
420
+
421
+ unpartitioned_numel = shape.numel()
422
+ total_numel += unpartitioned_numel
423
+ total_params += 1
424
+
425
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
426
+
427
+ if debug:
428
+ print(
429
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
430
+ )
431
+
432
+ # XXX: memory usage doubles here
433
+ state_dict[name] = torch.cat(
434
+ tuple(fp32_flat_groups[i].narrow(0, offset, partitioned_numel) for i in range(world_size)),
435
+ 0).narrow(0, 0, unpartitioned_numel).view(shape)
436
+ offset += partitioned_numel
437
+
438
+ offset *= world_size
439
+
440
+ # Sanity check
441
+ if offset != avail_numel:
442
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
443
+
444
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
445
+
446
+
447
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states):
448
+ state_dict = OrderedDict()
449
+
450
+ # buffers
451
+ buffers = zero_model_states[0].buffers
452
+ state_dict.update(buffers)
453
+ if debug:
454
+ print(f"added {len(buffers)} buffers")
455
+
456
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
457
+
458
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
459
+
460
+ # recover shared parameters
461
+ for pair in zero_model_states[0].shared_params:
462
+ if pair[1] in state_dict:
463
+ state_dict[pair[0]] = state_dict[pair[1]]
464
+
465
+ return state_dict
466
+
467
+
468
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag=None):
469
+ """
470
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
471
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
472
+ via a model hub.
473
+
474
+ Args:
475
+ - ``checkpoint_dir``: path to the desired checkpoint folder
476
+ - ``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``
477
+
478
+ Returns:
479
+ - pytorch ``state_dict``
480
+
481
+ Note: this approach may not work if your application doesn't have sufficient free CPU memory and
482
+ you may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
483
+ the checkpoint.
484
+
485
+ A typical usage might be ::
486
+
487
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
488
+ # do the training and checkpoint saving
489
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
490
+ model = model.cpu() # move to cpu
491
+ model.load_state_dict(state_dict)
492
+ # submit to model hub or save the model to share with others
493
+
494
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
495
+ application. i.e. you will need to re-initialize the deepspeed engine, since
496
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
497
+
498
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
499
+
500
+ """
501
+ if tag is None:
502
+ latest_path = os.path.join(checkpoint_dir, 'latest')
503
+ if os.path.isfile(latest_path):
504
+ with open(latest_path, 'r') as fd:
505
+ tag = fd.read().strip()
506
+ else:
507
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
508
+
509
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
510
+
511
+ if not os.path.isdir(ds_checkpoint_dir):
512
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
513
+
514
+ return _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir)
515
+
516
+
517
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir, output_file, tag=None):
518
+ """
519
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
520
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
521
+
522
+ Args:
523
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
524
+ - ``output_file``: path to the pytorch fp32 state_dict output file (e.g. path/pytorch_model.bin)
525
+ - ``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``
526
+ """
527
+
528
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
529
+ print(f"Saving fp32 state dict to {output_file}")
530
+ torch.save(state_dict, output_file)
531
+
532
+
533
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
534
+ """
535
+ 1. Put the provided model to cpu
536
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
537
+ 3. Load it into the provided model
538
+
539
+ Args:
540
+ - ``model``: the model object to update
541
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
542
+ - ``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``
543
+
544
+ Returns:
545
+ - ``model`: modified model
546
+
547
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
548
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
549
+ conveniently placed for you in the checkpoint folder.
550
+
551
+ A typical usage might be ::
552
+
553
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
554
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
555
+ # submit to model hub or save the model to share with others
556
+
557
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
558
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
559
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
560
+
561
+ """
562
+ logger.info(f"Extracting fp32 weights")
563
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
564
+
565
+ logger.info(f"Overwriting model with fp32 weights")
566
+ model = model.cpu()
567
+ model.load_state_dict(state_dict, strict=False)
568
+
569
+ return model
570
+
571
+
572
+ if __name__ == "__main__":
573
+
574
+ parser = argparse.ArgumentParser()
575
+ parser.add_argument("checkpoint_dir",
576
+ type=str,
577
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
578
+ parser.add_argument(
579
+ "output_file",
580
+ type=str,
581
+ help="path to the pytorch fp32 state_dict output file (e.g. path/checkpoint-12/pytorch_model.bin)")
582
+ parser.add_argument("-t",
583
+ "--tag",
584
+ type=str,
585
+ default=None,
586
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
587
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
588
+ args = parser.parse_args()
589
+
590
+ debug = args.debug
591
+
592
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir, args.output_file, tag=args.tag)
q2.5-eu-en/checkpoint-1800/trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-2400/added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
q2.5-eu-en/checkpoint-2400/chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
q2.5-eu-en/checkpoint-2400/config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "eos_token_id": 151643,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 896,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 4864,
12
+ "max_position_embeddings": 32768,
13
+ "max_window_layers": 24,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 14,
16
+ "num_hidden_layers": 24,
17
+ "num_key_value_heads": 2,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_scaling": null,
20
+ "rope_theta": 1000000.0,
21
+ "sliding_window": 32768,
22
+ "tie_word_embeddings": true,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.52.4",
25
+ "use_cache": true,
26
+ "use_mrope": false,
27
+ "use_sliding_window": false,
28
+ "vocab_size": 151665
29
+ }
q2.5-eu-en/checkpoint-2400/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": 151643,
5
+ "transformers_version": "4.52.4"
6
+ }
q2.5-eu-en/checkpoint-2400/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step2400
q2.5-eu-en/checkpoint-2400/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-2400/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
q2.5-eu-en/checkpoint-2400/tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|endoftext|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
q2.5-eu-en/checkpoint-2400/trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-2400/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-2400/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)
q2.5-eu-en/checkpoint-2700/added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
q2.5-eu-en/checkpoint-2700/chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
q2.5-eu-en/checkpoint-2700/config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "eos_token_id": 151643,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 896,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 4864,
12
+ "max_position_embeddings": 32768,
13
+ "max_window_layers": 24,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 14,
16
+ "num_hidden_layers": 24,
17
+ "num_key_value_heads": 2,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_scaling": null,
20
+ "rope_theta": 1000000.0,
21
+ "sliding_window": 32768,
22
+ "tie_word_embeddings": true,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.52.4",
25
+ "use_cache": true,
26
+ "use_mrope": false,
27
+ "use_sliding_window": false,
28
+ "vocab_size": 151665
29
+ }
q2.5-eu-en/checkpoint-2700/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": 151643,
5
+ "transformers_version": "4.52.4"
6
+ }
q2.5-eu-en/checkpoint-2700/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step2700
q2.5-eu-en/checkpoint-2700/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-2700/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
q2.5-eu-en/checkpoint-2700/tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|endoftext|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
q2.5-eu-en/checkpoint-2700/trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-2700/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-2700/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)
q2.5-eu-en/checkpoint-300/added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
q2.5-eu-en/checkpoint-300/chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
q2.5-eu-en/checkpoint-300/config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "eos_token_id": 151643,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 896,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 4864,
12
+ "max_position_embeddings": 32768,
13
+ "max_window_layers": 24,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 14,
16
+ "num_hidden_layers": 24,
17
+ "num_key_value_heads": 2,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_scaling": null,
20
+ "rope_theta": 1000000.0,
21
+ "sliding_window": 32768,
22
+ "tie_word_embeddings": true,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.52.4",
25
+ "use_cache": true,
26
+ "use_mrope": false,
27
+ "use_sliding_window": false,
28
+ "vocab_size": 151665
29
+ }
q2.5-eu-en/checkpoint-300/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": 151643,
5
+ "transformers_version": "4.52.4"
6
+ }
q2.5-eu-en/checkpoint-300/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step300
q2.5-eu-en/checkpoint-300/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-300/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
q2.5-eu-en/checkpoint-300/tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|endoftext|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
q2.5-eu-en/checkpoint-300/trainer_state.json ADDED
@@ -0,0 +1,1091 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.1009633587143999,
6
+ "eval_steps": 500,
7
+ "global_step": 300,
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.00033654452904799967,
14
+ "grad_norm": 4.331892967224121,
15
+ "learning_rate": 0.0,
16
+ "loss": 5.5158,
17
+ "step": 1
18
+ },
19
+ {
20
+ "epoch": 0.0006730890580959993,
21
+ "grad_norm": 4.539519786834717,
22
+ "learning_rate": 6.711409395973154e-07,
23
+ "loss": 5.5718,
24
+ "step": 2
25
+ },
26
+ {
27
+ "epoch": 0.0013461781161919987,
28
+ "grad_norm": 4.208465576171875,
29
+ "learning_rate": 2.013422818791946e-06,
30
+ "loss": 5.4905,
31
+ "step": 4
32
+ },
33
+ {
34
+ "epoch": 0.002019267174287998,
35
+ "grad_norm": 3.891338586807251,
36
+ "learning_rate": 3.3557046979865773e-06,
37
+ "loss": 5.4511,
38
+ "step": 6
39
+ },
40
+ {
41
+ "epoch": 0.0026923562323839974,
42
+ "grad_norm": 2.979590654373169,
43
+ "learning_rate": 4.697986577181209e-06,
44
+ "loss": 5.3311,
45
+ "step": 8
46
+ },
47
+ {
48
+ "epoch": 0.0033654452904799967,
49
+ "grad_norm": 3.1792373657226562,
50
+ "learning_rate": 6.04026845637584e-06,
51
+ "loss": 5.3782,
52
+ "step": 10
53
+ },
54
+ {
55
+ "epoch": 0.004038534348575996,
56
+ "grad_norm": 3.9909653663635254,
57
+ "learning_rate": 7.382550335570471e-06,
58
+ "loss": 5.2583,
59
+ "step": 12
60
+ },
61
+ {
62
+ "epoch": 0.004711623406671995,
63
+ "grad_norm": 3.31044340133667,
64
+ "learning_rate": 8.724832214765101e-06,
65
+ "loss": 5.3198,
66
+ "step": 14
67
+ },
68
+ {
69
+ "epoch": 0.005384712464767995,
70
+ "grad_norm": 3.3201687335968018,
71
+ "learning_rate": 1.006711409395973e-05,
72
+ "loss": 5.1138,
73
+ "step": 16
74
+ },
75
+ {
76
+ "epoch": 0.006057801522863994,
77
+ "grad_norm": 2.8034451007843018,
78
+ "learning_rate": 1.1409395973154363e-05,
79
+ "loss": 5.0022,
80
+ "step": 18
81
+ },
82
+ {
83
+ "epoch": 0.0067308905809599934,
84
+ "grad_norm": 2.044506072998047,
85
+ "learning_rate": 1.2751677852348994e-05,
86
+ "loss": 4.8879,
87
+ "step": 20
88
+ },
89
+ {
90
+ "epoch": 0.007403979639055993,
91
+ "grad_norm": 1.6194826364517212,
92
+ "learning_rate": 1.4093959731543624e-05,
93
+ "loss": 4.7436,
94
+ "step": 22
95
+ },
96
+ {
97
+ "epoch": 0.008077068697151992,
98
+ "grad_norm": 1.4383995532989502,
99
+ "learning_rate": 1.5436241610738255e-05,
100
+ "loss": 4.5798,
101
+ "step": 24
102
+ },
103
+ {
104
+ "epoch": 0.00875015775524799,
105
+ "grad_norm": 1.174633264541626,
106
+ "learning_rate": 1.6778523489932888e-05,
107
+ "loss": 4.4188,
108
+ "step": 26
109
+ },
110
+ {
111
+ "epoch": 0.00942324681334399,
112
+ "grad_norm": 1.1277130842208862,
113
+ "learning_rate": 1.8120805369127517e-05,
114
+ "loss": 4.4374,
115
+ "step": 28
116
+ },
117
+ {
118
+ "epoch": 0.01009633587143999,
119
+ "grad_norm": 1.0426617860794067,
120
+ "learning_rate": 1.946308724832215e-05,
121
+ "loss": 4.2195,
122
+ "step": 30
123
+ },
124
+ {
125
+ "epoch": 0.01076942492953599,
126
+ "grad_norm": 0.9180749654769897,
127
+ "learning_rate": 2.080536912751678e-05,
128
+ "loss": 4.1755,
129
+ "step": 32
130
+ },
131
+ {
132
+ "epoch": 0.011442513987631988,
133
+ "grad_norm": 1.0104376077651978,
134
+ "learning_rate": 2.2147651006711412e-05,
135
+ "loss": 4.0892,
136
+ "step": 34
137
+ },
138
+ {
139
+ "epoch": 0.012115603045727988,
140
+ "grad_norm": 0.9427777528762817,
141
+ "learning_rate": 2.348993288590604e-05,
142
+ "loss": 4.0498,
143
+ "step": 36
144
+ },
145
+ {
146
+ "epoch": 0.012788692103823987,
147
+ "grad_norm": 1.0120079517364502,
148
+ "learning_rate": 2.4832214765100674e-05,
149
+ "loss": 3.9471,
150
+ "step": 38
151
+ },
152
+ {
153
+ "epoch": 0.013461781161919987,
154
+ "grad_norm": 1.0842680931091309,
155
+ "learning_rate": 2.6174496644295304e-05,
156
+ "loss": 3.8882,
157
+ "step": 40
158
+ },
159
+ {
160
+ "epoch": 0.014134870220015985,
161
+ "grad_norm": 1.3515102863311768,
162
+ "learning_rate": 2.7516778523489933e-05,
163
+ "loss": 3.8274,
164
+ "step": 42
165
+ },
166
+ {
167
+ "epoch": 0.014807959278111986,
168
+ "grad_norm": 1.1003209352493286,
169
+ "learning_rate": 2.885906040268457e-05,
170
+ "loss": 3.7735,
171
+ "step": 44
172
+ },
173
+ {
174
+ "epoch": 0.015481048336207984,
175
+ "grad_norm": 0.9302487373352051,
176
+ "learning_rate": 3.02013422818792e-05,
177
+ "loss": 3.731,
178
+ "step": 46
179
+ },
180
+ {
181
+ "epoch": 0.016154137394303984,
182
+ "grad_norm": 1.0311543941497803,
183
+ "learning_rate": 3.1543624161073825e-05,
184
+ "loss": 3.6608,
185
+ "step": 48
186
+ },
187
+ {
188
+ "epoch": 0.016827226452399983,
189
+ "grad_norm": 1.0927435159683228,
190
+ "learning_rate": 3.288590604026846e-05,
191
+ "loss": 3.5962,
192
+ "step": 50
193
+ },
194
+ {
195
+ "epoch": 0.01750031551049598,
196
+ "grad_norm": 1.3255321979522705,
197
+ "learning_rate": 3.422818791946309e-05,
198
+ "loss": 3.5669,
199
+ "step": 52
200
+ },
201
+ {
202
+ "epoch": 0.018173404568591983,
203
+ "grad_norm": 0.9304305911064148,
204
+ "learning_rate": 3.557046979865772e-05,
205
+ "loss": 3.5456,
206
+ "step": 54
207
+ },
208
+ {
209
+ "epoch": 0.01884649362668798,
210
+ "grad_norm": 1.159280776977539,
211
+ "learning_rate": 3.6912751677852356e-05,
212
+ "loss": 3.5189,
213
+ "step": 56
214
+ },
215
+ {
216
+ "epoch": 0.01951958268478398,
217
+ "grad_norm": 0.9376134276390076,
218
+ "learning_rate": 3.8255033557046985e-05,
219
+ "loss": 3.432,
220
+ "step": 58
221
+ },
222
+ {
223
+ "epoch": 0.02019267174287998,
224
+ "grad_norm": 1.292802095413208,
225
+ "learning_rate": 3.959731543624161e-05,
226
+ "loss": 3.4564,
227
+ "step": 60
228
+ },
229
+ {
230
+ "epoch": 0.02086576080097598,
231
+ "grad_norm": 1.2383852005004883,
232
+ "learning_rate": 4.0939597315436244e-05,
233
+ "loss": 3.4194,
234
+ "step": 62
235
+ },
236
+ {
237
+ "epoch": 0.02153884985907198,
238
+ "grad_norm": 0.8546445369720459,
239
+ "learning_rate": 4.228187919463087e-05,
240
+ "loss": 3.3873,
241
+ "step": 64
242
+ },
243
+ {
244
+ "epoch": 0.022211938917167977,
245
+ "grad_norm": 1.4104743003845215,
246
+ "learning_rate": 4.36241610738255e-05,
247
+ "loss": 3.3647,
248
+ "step": 66
249
+ },
250
+ {
251
+ "epoch": 0.022885027975263976,
252
+ "grad_norm": 1.3548426628112793,
253
+ "learning_rate": 4.496644295302014e-05,
254
+ "loss": 3.3213,
255
+ "step": 68
256
+ },
257
+ {
258
+ "epoch": 0.023558117033359978,
259
+ "grad_norm": 1.1530455350875854,
260
+ "learning_rate": 4.630872483221477e-05,
261
+ "loss": 3.2789,
262
+ "step": 70
263
+ },
264
+ {
265
+ "epoch": 0.024231206091455976,
266
+ "grad_norm": 1.3092457056045532,
267
+ "learning_rate": 4.76510067114094e-05,
268
+ "loss": 3.2922,
269
+ "step": 72
270
+ },
271
+ {
272
+ "epoch": 0.024904295149551975,
273
+ "grad_norm": 1.577699065208435,
274
+ "learning_rate": 4.8993288590604034e-05,
275
+ "loss": 3.2308,
276
+ "step": 74
277
+ },
278
+ {
279
+ "epoch": 0.025577384207647973,
280
+ "grad_norm": 1.3348486423492432,
281
+ "learning_rate": 5.033557046979866e-05,
282
+ "loss": 3.2656,
283
+ "step": 76
284
+ },
285
+ {
286
+ "epoch": 0.026250473265743975,
287
+ "grad_norm": 1.1966625452041626,
288
+ "learning_rate": 5.167785234899329e-05,
289
+ "loss": 3.2703,
290
+ "step": 78
291
+ },
292
+ {
293
+ "epoch": 0.026923562323839974,
294
+ "grad_norm": 1.3125278949737549,
295
+ "learning_rate": 5.302013422818792e-05,
296
+ "loss": 3.2034,
297
+ "step": 80
298
+ },
299
+ {
300
+ "epoch": 0.027596651381935972,
301
+ "grad_norm": 1.1957862377166748,
302
+ "learning_rate": 5.436241610738255e-05,
303
+ "loss": 3.2476,
304
+ "step": 82
305
+ },
306
+ {
307
+ "epoch": 0.02826974044003197,
308
+ "grad_norm": 1.2177337408065796,
309
+ "learning_rate": 5.570469798657718e-05,
310
+ "loss": 3.2166,
311
+ "step": 84
312
+ },
313
+ {
314
+ "epoch": 0.028942829498127973,
315
+ "grad_norm": 0.8806389570236206,
316
+ "learning_rate": 5.704697986577181e-05,
317
+ "loss": 3.1722,
318
+ "step": 86
319
+ },
320
+ {
321
+ "epoch": 0.02961591855622397,
322
+ "grad_norm": 1.8180561065673828,
323
+ "learning_rate": 5.838926174496645e-05,
324
+ "loss": 3.1597,
325
+ "step": 88
326
+ },
327
+ {
328
+ "epoch": 0.03028900761431997,
329
+ "grad_norm": 1.1676297187805176,
330
+ "learning_rate": 5.973154362416108e-05,
331
+ "loss": 3.1829,
332
+ "step": 90
333
+ },
334
+ {
335
+ "epoch": 0.030962096672415968,
336
+ "grad_norm": 1.0163198709487915,
337
+ "learning_rate": 6.107382550335571e-05,
338
+ "loss": 3.1643,
339
+ "step": 92
340
+ },
341
+ {
342
+ "epoch": 0.03163518573051197,
343
+ "grad_norm": 1.0734015703201294,
344
+ "learning_rate": 6.241610738255034e-05,
345
+ "loss": 3.1692,
346
+ "step": 94
347
+ },
348
+ {
349
+ "epoch": 0.03230827478860797,
350
+ "grad_norm": 1.4144916534423828,
351
+ "learning_rate": 6.375838926174497e-05,
352
+ "loss": 3.1217,
353
+ "step": 96
354
+ },
355
+ {
356
+ "epoch": 0.03298136384670397,
357
+ "grad_norm": 1.5647915601730347,
358
+ "learning_rate": 6.51006711409396e-05,
359
+ "loss": 3.1324,
360
+ "step": 98
361
+ },
362
+ {
363
+ "epoch": 0.033654452904799965,
364
+ "grad_norm": 1.1999105215072632,
365
+ "learning_rate": 6.644295302013423e-05,
366
+ "loss": 3.1103,
367
+ "step": 100
368
+ },
369
+ {
370
+ "epoch": 0.03432754196289597,
371
+ "grad_norm": 1.512838363647461,
372
+ "learning_rate": 6.778523489932886e-05,
373
+ "loss": 3.1036,
374
+ "step": 102
375
+ },
376
+ {
377
+ "epoch": 0.03500063102099196,
378
+ "grad_norm": 1.1092990636825562,
379
+ "learning_rate": 6.912751677852349e-05,
380
+ "loss": 3.1244,
381
+ "step": 104
382
+ },
383
+ {
384
+ "epoch": 0.035673720079087964,
385
+ "grad_norm": 1.2763620615005493,
386
+ "learning_rate": 7.046979865771812e-05,
387
+ "loss": 3.0989,
388
+ "step": 106
389
+ },
390
+ {
391
+ "epoch": 0.036346809137183966,
392
+ "grad_norm": 1.2328648567199707,
393
+ "learning_rate": 7.181208053691275e-05,
394
+ "loss": 3.0506,
395
+ "step": 108
396
+ },
397
+ {
398
+ "epoch": 0.03701989819527996,
399
+ "grad_norm": 1.6039047241210938,
400
+ "learning_rate": 7.315436241610739e-05,
401
+ "loss": 3.0589,
402
+ "step": 110
403
+ },
404
+ {
405
+ "epoch": 0.03769298725337596,
406
+ "grad_norm": 1.7161307334899902,
407
+ "learning_rate": 7.449664429530202e-05,
408
+ "loss": 3.0296,
409
+ "step": 112
410
+ },
411
+ {
412
+ "epoch": 0.03836607631147196,
413
+ "grad_norm": 1.2628991603851318,
414
+ "learning_rate": 7.583892617449665e-05,
415
+ "loss": 3.063,
416
+ "step": 114
417
+ },
418
+ {
419
+ "epoch": 0.03903916536956796,
420
+ "grad_norm": 1.1414180994033813,
421
+ "learning_rate": 7.718120805369128e-05,
422
+ "loss": 3.0366,
423
+ "step": 116
424
+ },
425
+ {
426
+ "epoch": 0.03971225442766396,
427
+ "grad_norm": 1.5152932405471802,
428
+ "learning_rate": 7.852348993288591e-05,
429
+ "loss": 3.0241,
430
+ "step": 118
431
+ },
432
+ {
433
+ "epoch": 0.04038534348575996,
434
+ "grad_norm": 1.6119567155838013,
435
+ "learning_rate": 7.986577181208054e-05,
436
+ "loss": 3.0139,
437
+ "step": 120
438
+ },
439
+ {
440
+ "epoch": 0.04105843254385596,
441
+ "grad_norm": 1.6078091859817505,
442
+ "learning_rate": 8.120805369127518e-05,
443
+ "loss": 3.0288,
444
+ "step": 122
445
+ },
446
+ {
447
+ "epoch": 0.04173152160195196,
448
+ "grad_norm": 1.1092705726623535,
449
+ "learning_rate": 8.255033557046981e-05,
450
+ "loss": 2.9996,
451
+ "step": 124
452
+ },
453
+ {
454
+ "epoch": 0.042404610660047956,
455
+ "grad_norm": 1.2352242469787598,
456
+ "learning_rate": 8.389261744966444e-05,
457
+ "loss": 2.9872,
458
+ "step": 126
459
+ },
460
+ {
461
+ "epoch": 0.04307769971814396,
462
+ "grad_norm": 1.636400580406189,
463
+ "learning_rate": 8.523489932885907e-05,
464
+ "loss": 2.9814,
465
+ "step": 128
466
+ },
467
+ {
468
+ "epoch": 0.04375078877623995,
469
+ "grad_norm": 1.4877128601074219,
470
+ "learning_rate": 8.65771812080537e-05,
471
+ "loss": 2.9756,
472
+ "step": 130
473
+ },
474
+ {
475
+ "epoch": 0.044423877834335955,
476
+ "grad_norm": 1.2983709573745728,
477
+ "learning_rate": 8.791946308724833e-05,
478
+ "loss": 2.9756,
479
+ "step": 132
480
+ },
481
+ {
482
+ "epoch": 0.04509696689243196,
483
+ "grad_norm": 1.7350983619689941,
484
+ "learning_rate": 8.926174496644296e-05,
485
+ "loss": 2.9579,
486
+ "step": 134
487
+ },
488
+ {
489
+ "epoch": 0.04577005595052795,
490
+ "grad_norm": 0.978854775428772,
491
+ "learning_rate": 9.060402684563759e-05,
492
+ "loss": 2.9269,
493
+ "step": 136
494
+ },
495
+ {
496
+ "epoch": 0.046443145008623954,
497
+ "grad_norm": 1.362163782119751,
498
+ "learning_rate": 9.194630872483221e-05,
499
+ "loss": 2.99,
500
+ "step": 138
501
+ },
502
+ {
503
+ "epoch": 0.047116234066719956,
504
+ "grad_norm": 1.328202247619629,
505
+ "learning_rate": 9.328859060402684e-05,
506
+ "loss": 2.966,
507
+ "step": 140
508
+ },
509
+ {
510
+ "epoch": 0.04778932312481595,
511
+ "grad_norm": 1.2497445344924927,
512
+ "learning_rate": 9.463087248322147e-05,
513
+ "loss": 2.9254,
514
+ "step": 142
515
+ },
516
+ {
517
+ "epoch": 0.04846241218291195,
518
+ "grad_norm": 1.071092128753662,
519
+ "learning_rate": 9.59731543624161e-05,
520
+ "loss": 2.9597,
521
+ "step": 144
522
+ },
523
+ {
524
+ "epoch": 0.04913550124100795,
525
+ "grad_norm": 1.451729416847229,
526
+ "learning_rate": 9.731543624161075e-05,
527
+ "loss": 2.9605,
528
+ "step": 146
529
+ },
530
+ {
531
+ "epoch": 0.04980859029910395,
532
+ "grad_norm": 1.328731656074524,
533
+ "learning_rate": 9.865771812080538e-05,
534
+ "loss": 2.9493,
535
+ "step": 148
536
+ },
537
+ {
538
+ "epoch": 0.05048167935719995,
539
+ "grad_norm": 1.4675222635269165,
540
+ "learning_rate": 0.0001,
541
+ "loss": 2.9298,
542
+ "step": 150
543
+ },
544
+ {
545
+ "epoch": 0.05115476841529595,
546
+ "grad_norm": 1.208961009979248,
547
+ "learning_rate": 9.99998761551904e-05,
548
+ "loss": 2.9382,
549
+ "step": 152
550
+ },
551
+ {
552
+ "epoch": 0.05182785747339195,
553
+ "grad_norm": 1.0392056703567505,
554
+ "learning_rate": 9.999950462137508e-05,
555
+ "loss": 2.8829,
556
+ "step": 154
557
+ },
558
+ {
559
+ "epoch": 0.05250094653148795,
560
+ "grad_norm": 1.378711462020874,
561
+ "learning_rate": 9.999888540039458e-05,
562
+ "loss": 2.9041,
563
+ "step": 156
564
+ },
565
+ {
566
+ "epoch": 0.053174035589583946,
567
+ "grad_norm": 1.2687252759933472,
568
+ "learning_rate": 9.999801849531635e-05,
569
+ "loss": 2.9148,
570
+ "step": 158
571
+ },
572
+ {
573
+ "epoch": 0.05384712464767995,
574
+ "grad_norm": 1.2382102012634277,
575
+ "learning_rate": 9.999690391043487e-05,
576
+ "loss": 2.9107,
577
+ "step": 160
578
+ },
579
+ {
580
+ "epoch": 0.05452021370577594,
581
+ "grad_norm": 1.0215928554534912,
582
+ "learning_rate": 9.999554165127159e-05,
583
+ "loss": 2.9187,
584
+ "step": 162
585
+ },
586
+ {
587
+ "epoch": 0.055193302763871945,
588
+ "grad_norm": 1.2638540267944336,
589
+ "learning_rate": 9.99939317245748e-05,
590
+ "loss": 2.9261,
591
+ "step": 164
592
+ },
593
+ {
594
+ "epoch": 0.055866391821967946,
595
+ "grad_norm": 1.3826959133148193,
596
+ "learning_rate": 9.999207413831982e-05,
597
+ "loss": 2.8944,
598
+ "step": 166
599
+ },
600
+ {
601
+ "epoch": 0.05653948088006394,
602
+ "grad_norm": 1.0764875411987305,
603
+ "learning_rate": 9.998996890170867e-05,
604
+ "loss": 2.9031,
605
+ "step": 168
606
+ },
607
+ {
608
+ "epoch": 0.05721256993815994,
609
+ "grad_norm": 1.5163936614990234,
610
+ "learning_rate": 9.99876160251703e-05,
611
+ "loss": 2.8687,
612
+ "step": 170
613
+ },
614
+ {
615
+ "epoch": 0.057885658996255945,
616
+ "grad_norm": 1.5821291208267212,
617
+ "learning_rate": 9.998501552036037e-05,
618
+ "loss": 2.8828,
619
+ "step": 172
620
+ },
621
+ {
622
+ "epoch": 0.05855874805435194,
623
+ "grad_norm": 1.4572120904922485,
624
+ "learning_rate": 9.998216740016124e-05,
625
+ "loss": 2.8898,
626
+ "step": 174
627
+ },
628
+ {
629
+ "epoch": 0.05923183711244794,
630
+ "grad_norm": 1.2185218334197998,
631
+ "learning_rate": 9.99790716786819e-05,
632
+ "loss": 2.8456,
633
+ "step": 176
634
+ },
635
+ {
636
+ "epoch": 0.05990492617054394,
637
+ "grad_norm": 1.106446385383606,
638
+ "learning_rate": 9.99757283712579e-05,
639
+ "loss": 2.8793,
640
+ "step": 178
641
+ },
642
+ {
643
+ "epoch": 0.06057801522863994,
644
+ "grad_norm": 1.1448893547058105,
645
+ "learning_rate": 9.997213749445129e-05,
646
+ "loss": 2.8579,
647
+ "step": 180
648
+ },
649
+ {
650
+ "epoch": 0.06125110428673594,
651
+ "grad_norm": 1.1587834358215332,
652
+ "learning_rate": 9.996829906605056e-05,
653
+ "loss": 2.8839,
654
+ "step": 182
655
+ },
656
+ {
657
+ "epoch": 0.061924193344831936,
658
+ "grad_norm": 1.0969592332839966,
659
+ "learning_rate": 9.996421310507046e-05,
660
+ "loss": 2.8638,
661
+ "step": 184
662
+ },
663
+ {
664
+ "epoch": 0.06259728240292793,
665
+ "grad_norm": 0.9740116000175476,
666
+ "learning_rate": 9.9959879631752e-05,
667
+ "loss": 2.8455,
668
+ "step": 186
669
+ },
670
+ {
671
+ "epoch": 0.06327037146102393,
672
+ "grad_norm": 1.2307910919189453,
673
+ "learning_rate": 9.995529866756231e-05,
674
+ "loss": 2.8534,
675
+ "step": 188
676
+ },
677
+ {
678
+ "epoch": 0.06394346051911994,
679
+ "grad_norm": 1.5021939277648926,
680
+ "learning_rate": 9.995047023519452e-05,
681
+ "loss": 2.8469,
682
+ "step": 190
683
+ },
684
+ {
685
+ "epoch": 0.06461654957721594,
686
+ "grad_norm": 1.1044224500656128,
687
+ "learning_rate": 9.994539435856771e-05,
688
+ "loss": 2.8429,
689
+ "step": 192
690
+ },
691
+ {
692
+ "epoch": 0.06528963863531194,
693
+ "grad_norm": 1.4586883783340454,
694
+ "learning_rate": 9.99400710628267e-05,
695
+ "loss": 2.836,
696
+ "step": 194
697
+ },
698
+ {
699
+ "epoch": 0.06596272769340794,
700
+ "grad_norm": 1.2613426446914673,
701
+ "learning_rate": 9.993450037434199e-05,
702
+ "loss": 2.8243,
703
+ "step": 196
704
+ },
705
+ {
706
+ "epoch": 0.06663581675150393,
707
+ "grad_norm": 1.0347422361373901,
708
+ "learning_rate": 9.992868232070963e-05,
709
+ "loss": 2.7965,
710
+ "step": 198
711
+ },
712
+ {
713
+ "epoch": 0.06730890580959993,
714
+ "grad_norm": 2.1357574462890625,
715
+ "learning_rate": 9.992261693075103e-05,
716
+ "loss": 2.8486,
717
+ "step": 200
718
+ },
719
+ {
720
+ "epoch": 0.06798199486769593,
721
+ "grad_norm": 1.0357908010482788,
722
+ "learning_rate": 9.991630423451286e-05,
723
+ "loss": 2.8386,
724
+ "step": 202
725
+ },
726
+ {
727
+ "epoch": 0.06865508392579193,
728
+ "grad_norm": 1.1383159160614014,
729
+ "learning_rate": 9.990974426326696e-05,
730
+ "loss": 2.7874,
731
+ "step": 204
732
+ },
733
+ {
734
+ "epoch": 0.06932817298388794,
735
+ "grad_norm": 0.8452678322792053,
736
+ "learning_rate": 9.990293704951001e-05,
737
+ "loss": 2.786,
738
+ "step": 206
739
+ },
740
+ {
741
+ "epoch": 0.07000126204198392,
742
+ "grad_norm": 0.9482727646827698,
743
+ "learning_rate": 9.989588262696357e-05,
744
+ "loss": 2.8156,
745
+ "step": 208
746
+ },
747
+ {
748
+ "epoch": 0.07067435110007993,
749
+ "grad_norm": 0.8251766562461853,
750
+ "learning_rate": 9.988858103057378e-05,
751
+ "loss": 2.7588,
752
+ "step": 210
753
+ },
754
+ {
755
+ "epoch": 0.07134744015817593,
756
+ "grad_norm": 1.211065649986267,
757
+ "learning_rate": 9.988103229651121e-05,
758
+ "loss": 2.7623,
759
+ "step": 212
760
+ },
761
+ {
762
+ "epoch": 0.07202052921627193,
763
+ "grad_norm": 0.8990377187728882,
764
+ "learning_rate": 9.987323646217075e-05,
765
+ "loss": 2.8164,
766
+ "step": 214
767
+ },
768
+ {
769
+ "epoch": 0.07269361827436793,
770
+ "grad_norm": 0.9878025054931641,
771
+ "learning_rate": 9.986519356617132e-05,
772
+ "loss": 2.7847,
773
+ "step": 216
774
+ },
775
+ {
776
+ "epoch": 0.07336670733246392,
777
+ "grad_norm": 0.7551445364952087,
778
+ "learning_rate": 9.985690364835576e-05,
779
+ "loss": 2.8111,
780
+ "step": 218
781
+ },
782
+ {
783
+ "epoch": 0.07403979639055992,
784
+ "grad_norm": 0.9582260251045227,
785
+ "learning_rate": 9.984836674979062e-05,
786
+ "loss": 2.793,
787
+ "step": 220
788
+ },
789
+ {
790
+ "epoch": 0.07471288544865592,
791
+ "grad_norm": 0.8087739944458008,
792
+ "learning_rate": 9.983958291276591e-05,
793
+ "loss": 2.7464,
794
+ "step": 222
795
+ },
796
+ {
797
+ "epoch": 0.07538597450675193,
798
+ "grad_norm": 1.2373522520065308,
799
+ "learning_rate": 9.983055218079493e-05,
800
+ "loss": 2.7656,
801
+ "step": 224
802
+ },
803
+ {
804
+ "epoch": 0.07605906356484793,
805
+ "grad_norm": 0.9746289849281311,
806
+ "learning_rate": 9.982127459861408e-05,
807
+ "loss": 2.7765,
808
+ "step": 226
809
+ },
810
+ {
811
+ "epoch": 0.07673215262294392,
812
+ "grad_norm": 0.6946307420730591,
813
+ "learning_rate": 9.981175021218255e-05,
814
+ "loss": 2.7491,
815
+ "step": 228
816
+ },
817
+ {
818
+ "epoch": 0.07740524168103992,
819
+ "grad_norm": 0.8959107398986816,
820
+ "learning_rate": 9.980197906868215e-05,
821
+ "loss": 2.7565,
822
+ "step": 230
823
+ },
824
+ {
825
+ "epoch": 0.07807833073913592,
826
+ "grad_norm": 0.9889335036277771,
827
+ "learning_rate": 9.979196121651716e-05,
828
+ "loss": 2.7974,
829
+ "step": 232
830
+ },
831
+ {
832
+ "epoch": 0.07875141979723192,
833
+ "grad_norm": 0.9802746176719666,
834
+ "learning_rate": 9.978169670531388e-05,
835
+ "loss": 2.7772,
836
+ "step": 234
837
+ },
838
+ {
839
+ "epoch": 0.07942450885532792,
840
+ "grad_norm": 0.6934760808944702,
841
+ "learning_rate": 9.977118558592059e-05,
842
+ "loss": 2.7602,
843
+ "step": 236
844
+ },
845
+ {
846
+ "epoch": 0.08009759791342393,
847
+ "grad_norm": 0.8996357917785645,
848
+ "learning_rate": 9.97604279104072e-05,
849
+ "loss": 2.7669,
850
+ "step": 238
851
+ },
852
+ {
853
+ "epoch": 0.08077068697151991,
854
+ "grad_norm": 0.8844061493873596,
855
+ "learning_rate": 9.974942373206499e-05,
856
+ "loss": 2.7458,
857
+ "step": 240
858
+ },
859
+ {
860
+ "epoch": 0.08144377602961592,
861
+ "grad_norm": 1.023626685142517,
862
+ "learning_rate": 9.973817310540638e-05,
863
+ "loss": 2.7639,
864
+ "step": 242
865
+ },
866
+ {
867
+ "epoch": 0.08211686508771192,
868
+ "grad_norm": 0.8241132497787476,
869
+ "learning_rate": 9.972667608616466e-05,
870
+ "loss": 2.7457,
871
+ "step": 244
872
+ },
873
+ {
874
+ "epoch": 0.08278995414580792,
875
+ "grad_norm": 0.7864794135093689,
876
+ "learning_rate": 9.971493273129364e-05,
877
+ "loss": 2.763,
878
+ "step": 246
879
+ },
880
+ {
881
+ "epoch": 0.08346304320390392,
882
+ "grad_norm": 1.071751356124878,
883
+ "learning_rate": 9.970294309896747e-05,
884
+ "loss": 2.7347,
885
+ "step": 248
886
+ },
887
+ {
888
+ "epoch": 0.08413613226199991,
889
+ "grad_norm": 0.8978875279426575,
890
+ "learning_rate": 9.969070724858031e-05,
891
+ "loss": 2.7807,
892
+ "step": 250
893
+ },
894
+ {
895
+ "epoch": 0.08480922132009591,
896
+ "grad_norm": 0.9984204769134521,
897
+ "learning_rate": 9.967822524074602e-05,
898
+ "loss": 2.7399,
899
+ "step": 252
900
+ },
901
+ {
902
+ "epoch": 0.08548231037819191,
903
+ "grad_norm": 0.8611739873886108,
904
+ "learning_rate": 9.966549713729787e-05,
905
+ "loss": 2.753,
906
+ "step": 254
907
+ },
908
+ {
909
+ "epoch": 0.08615539943628792,
910
+ "grad_norm": 0.8647720217704773,
911
+ "learning_rate": 9.965252300128826e-05,
912
+ "loss": 2.7224,
913
+ "step": 256
914
+ },
915
+ {
916
+ "epoch": 0.08682848849438392,
917
+ "grad_norm": 0.8688477873802185,
918
+ "learning_rate": 9.963930289698833e-05,
919
+ "loss": 2.6879,
920
+ "step": 258
921
+ },
922
+ {
923
+ "epoch": 0.0875015775524799,
924
+ "grad_norm": 1.1445469856262207,
925
+ "learning_rate": 9.962583688988778e-05,
926
+ "loss": 2.739,
927
+ "step": 260
928
+ },
929
+ {
930
+ "epoch": 0.08817466661057591,
931
+ "grad_norm": 0.8668599128723145,
932
+ "learning_rate": 9.961212504669437e-05,
933
+ "loss": 2.6962,
934
+ "step": 262
935
+ },
936
+ {
937
+ "epoch": 0.08884775566867191,
938
+ "grad_norm": 0.905125617980957,
939
+ "learning_rate": 9.959816743533375e-05,
940
+ "loss": 2.7239,
941
+ "step": 264
942
+ },
943
+ {
944
+ "epoch": 0.08952084472676791,
945
+ "grad_norm": 0.8252028822898865,
946
+ "learning_rate": 9.958396412494901e-05,
947
+ "loss": 2.7381,
948
+ "step": 266
949
+ },
950
+ {
951
+ "epoch": 0.09019393378486391,
952
+ "grad_norm": 0.7380514740943909,
953
+ "learning_rate": 9.956951518590043e-05,
954
+ "loss": 2.7135,
955
+ "step": 268
956
+ },
957
+ {
958
+ "epoch": 0.09086702284295992,
959
+ "grad_norm": 0.7395239472389221,
960
+ "learning_rate": 9.955482068976502e-05,
961
+ "loss": 2.6954,
962
+ "step": 270
963
+ },
964
+ {
965
+ "epoch": 0.0915401119010559,
966
+ "grad_norm": 0.6564229726791382,
967
+ "learning_rate": 9.953988070933628e-05,
968
+ "loss": 2.7145,
969
+ "step": 272
970
+ },
971
+ {
972
+ "epoch": 0.0922132009591519,
973
+ "grad_norm": 0.7306910157203674,
974
+ "learning_rate": 9.952469531862378e-05,
975
+ "loss": 2.6951,
976
+ "step": 274
977
+ },
978
+ {
979
+ "epoch": 0.09288629001724791,
980
+ "grad_norm": 0.6810031533241272,
981
+ "learning_rate": 9.950926459285277e-05,
982
+ "loss": 2.7201,
983
+ "step": 276
984
+ },
985
+ {
986
+ "epoch": 0.09355937907534391,
987
+ "grad_norm": 0.6724168658256531,
988
+ "learning_rate": 9.949358860846388e-05,
989
+ "loss": 2.7112,
990
+ "step": 278
991
+ },
992
+ {
993
+ "epoch": 0.09423246813343991,
994
+ "grad_norm": 0.7065703272819519,
995
+ "learning_rate": 9.947766744311268e-05,
996
+ "loss": 2.6884,
997
+ "step": 280
998
+ },
999
+ {
1000
+ "epoch": 0.0949055571915359,
1001
+ "grad_norm": 0.8231908679008484,
1002
+ "learning_rate": 9.946150117566931e-05,
1003
+ "loss": 2.7286,
1004
+ "step": 282
1005
+ },
1006
+ {
1007
+ "epoch": 0.0955786462496319,
1008
+ "grad_norm": 0.9570270776748657,
1009
+ "learning_rate": 9.944508988621812e-05,
1010
+ "loss": 2.7166,
1011
+ "step": 284
1012
+ },
1013
+ {
1014
+ "epoch": 0.0962517353077279,
1015
+ "grad_norm": 0.9357023239135742,
1016
+ "learning_rate": 9.94284336560572e-05,
1017
+ "loss": 2.6768,
1018
+ "step": 286
1019
+ },
1020
+ {
1021
+ "epoch": 0.0969248243658239,
1022
+ "grad_norm": 0.6350796222686768,
1023
+ "learning_rate": 9.941153256769809e-05,
1024
+ "loss": 2.6921,
1025
+ "step": 288
1026
+ },
1027
+ {
1028
+ "epoch": 0.09759791342391991,
1029
+ "grad_norm": 0.6700872778892517,
1030
+ "learning_rate": 9.939438670486525e-05,
1031
+ "loss": 2.6847,
1032
+ "step": 290
1033
+ },
1034
+ {
1035
+ "epoch": 0.0982710024820159,
1036
+ "grad_norm": 0.6851752400398254,
1037
+ "learning_rate": 9.937699615249572e-05,
1038
+ "loss": 2.6586,
1039
+ "step": 292
1040
+ },
1041
+ {
1042
+ "epoch": 0.0989440915401119,
1043
+ "grad_norm": 0.7098946571350098,
1044
+ "learning_rate": 9.935936099673871e-05,
1045
+ "loss": 2.6793,
1046
+ "step": 294
1047
+ },
1048
+ {
1049
+ "epoch": 0.0996171805982079,
1050
+ "grad_norm": 0.680543839931488,
1051
+ "learning_rate": 9.934148132495511e-05,
1052
+ "loss": 2.6763,
1053
+ "step": 296
1054
+ },
1055
+ {
1056
+ "epoch": 0.1002902696563039,
1057
+ "grad_norm": 0.6832155585289001,
1058
+ "learning_rate": 9.932335722571709e-05,
1059
+ "loss": 2.6768,
1060
+ "step": 298
1061
+ },
1062
+ {
1063
+ "epoch": 0.1009633587143999,
1064
+ "grad_norm": 0.8236553072929382,
1065
+ "learning_rate": 9.930498878880768e-05,
1066
+ "loss": 2.6738,
1067
+ "step": 300
1068
+ }
1069
+ ],
1070
+ "logging_steps": 2,
1071
+ "max_steps": 2972,
1072
+ "num_input_tokens_seen": 0,
1073
+ "num_train_epochs": 1,
1074
+ "save_steps": 300,
1075
+ "stateful_callbacks": {
1076
+ "TrainerControl": {
1077
+ "args": {
1078
+ "should_epoch_stop": false,
1079
+ "should_evaluate": false,
1080
+ "should_log": false,
1081
+ "should_save": true,
1082
+ "should_training_stop": false
1083
+ },
1084
+ "attributes": {}
1085
+ }
1086
+ },
1087
+ "total_flos": 3.377550336196608e+17,
1088
+ "train_batch_size": 16,
1089
+ "trial_name": null,
1090
+ "trial_params": null
1091
+ }
q2.5-eu-en/checkpoint-300/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
q2.5-eu-en/checkpoint-300/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)
q2.5/checkpoint-12000/added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
q2.5/checkpoint-12000/chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
q2.5/checkpoint-12000/config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "eos_token_id": 151643,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 896,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 4864,
12
+ "max_position_embeddings": 32768,
13
+ "max_window_layers": 24,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 14,
16
+ "num_hidden_layers": 24,
17
+ "num_key_value_heads": 2,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_scaling": null,
20
+ "rope_theta": 1000000.0,
21
+ "sliding_window": 32768,
22
+ "tie_word_embeddings": true,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.52.4",
25
+ "use_cache": true,
26
+ "use_mrope": false,
27
+ "use_sliding_window": false,
28
+ "vocab_size": 151665
29
+ }
q2.5/checkpoint-12000/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": 151643,
5
+ "transformers_version": "4.52.4"
6
+ }
q2.5/checkpoint-12000/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step12000