AlexCuadron commited on
Commit
75bfa20
·
verified ·
1 Parent(s): 0cd8861

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "mistralai/Mistral-Nemo-Instruct-2407",
3
+ "architectures": [
4
+ "MistralForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "head_dim": 128,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 5120,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 14336,
14
+ "max_position_embeddings": 131072,
15
+ "model_type": "mistral",
16
+ "num_attention_heads": 32,
17
+ "num_hidden_layers": 40,
18
+ "num_key_value_heads": 8,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_theta": 1000000.0,
21
+ "sliding_window": null,
22
+ "tie_word_embeddings": false,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.49.0",
25
+ "use_cache": false,
26
+ "vocab_size": 131072
27
+ }
eval_results.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 2.994994994994995,
3
+ "eval_loss": 1.367593765258789,
4
+ "eval_runtime": 17.9519,
5
+ "eval_samples_per_second": 6.183,
6
+ "eval_steps_per_second": 6.183
7
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.49.0"
6
+ }
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step1496
model-00001-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b196524cbc421adf565c9cf6958ede2f61d43192e740f49526994bab4712443
3
+ size 4865522496
model-00002-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:579a10a0d0a8660834f6afd2e52efe5b7cf5df85e65ba2695228f71528497eab
3
+ size 4907529424
model-00003-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53ddf55ff614abb6401b8fb2eb14ac9c081b9ac26ce19ff239570965a9ccee81
3
+ size 4907529456
model-00004-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d904e73f3277ae743f97ccd7af2998c657c42529620dbebf4f5b148e8a5c6f6f
3
+ size 4907529456
model-00005-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6210a06a7c9787f01312bbaf0f6a0bcdbbf08266ef05675d40b9f0c726a12857
3
+ size 4907496272
model.safetensors.index.json ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 24495564800
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00005-of-00005.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00005.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00005.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
13
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
14
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
15
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
16
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
17
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00005.safetensors",
18
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
19
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
20
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
21
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
22
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
23
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
24
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
25
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
26
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00005.safetensors",
27
+ "model.layers.10.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
28
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
29
+ "model.layers.10.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
30
+ "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
31
+ "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
32
+ "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
33
+ "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
34
+ "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
35
+ "model.layers.11.input_layernorm.weight": "model-00002-of-00005.safetensors",
36
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
37
+ "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
38
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
39
+ "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
40
+ "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
41
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
42
+ "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
43
+ "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
44
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00005.safetensors",
45
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
46
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
47
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
48
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
49
+ "model.layers.12.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
50
+ "model.layers.12.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
51
+ "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
52
+ "model.layers.12.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
53
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00005.safetensors",
54
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
55
+ "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
56
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
57
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
58
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
59
+ "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
60
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
61
+ "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
62
+ "model.layers.14.input_layernorm.weight": "model-00002-of-00005.safetensors",
63
+ "model.layers.14.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
64
+ "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
65
+ "model.layers.14.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
66
+ "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
67
+ "model.layers.14.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
68
+ "model.layers.14.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
69
+ "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
70
+ "model.layers.14.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
71
+ "model.layers.15.input_layernorm.weight": "model-00003-of-00005.safetensors",
72
+ "model.layers.15.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
73
+ "model.layers.15.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
74
+ "model.layers.15.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
75
+ "model.layers.15.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
76
+ "model.layers.15.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
77
+ "model.layers.15.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
78
+ "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
79
+ "model.layers.15.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
80
+ "model.layers.16.input_layernorm.weight": "model-00003-of-00005.safetensors",
81
+ "model.layers.16.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
82
+ "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
83
+ "model.layers.16.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
84
+ "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
85
+ "model.layers.16.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
86
+ "model.layers.16.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
87
+ "model.layers.16.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
88
+ "model.layers.16.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
89
+ "model.layers.17.input_layernorm.weight": "model-00003-of-00005.safetensors",
90
+ "model.layers.17.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
91
+ "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
92
+ "model.layers.17.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
93
+ "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
94
+ "model.layers.17.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
95
+ "model.layers.17.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
96
+ "model.layers.17.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
97
+ "model.layers.17.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
98
+ "model.layers.18.input_layernorm.weight": "model-00003-of-00005.safetensors",
99
+ "model.layers.18.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
100
+ "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
101
+ "model.layers.18.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
102
+ "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
103
+ "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
104
+ "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
105
+ "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
106
+ "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
107
+ "model.layers.19.input_layernorm.weight": "model-00003-of-00005.safetensors",
108
+ "model.layers.19.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
109
+ "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
110
+ "model.layers.19.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
111
+ "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
112
+ "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
113
+ "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
114
+ "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
115
+ "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
116
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00005.safetensors",
117
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
118
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
119
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
120
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
121
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
122
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
123
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
124
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
125
+ "model.layers.20.input_layernorm.weight": "model-00003-of-00005.safetensors",
126
+ "model.layers.20.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
127
+ "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
128
+ "model.layers.20.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
129
+ "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
130
+ "model.layers.20.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
131
+ "model.layers.20.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
132
+ "model.layers.20.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
133
+ "model.layers.20.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
134
+ "model.layers.21.input_layernorm.weight": "model-00003-of-00005.safetensors",
135
+ "model.layers.21.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
136
+ "model.layers.21.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
137
+ "model.layers.21.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
138
+ "model.layers.21.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
139
+ "model.layers.21.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
140
+ "model.layers.21.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
141
+ "model.layers.21.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
142
+ "model.layers.21.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
143
+ "model.layers.22.input_layernorm.weight": "model-00003-of-00005.safetensors",
144
+ "model.layers.22.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
145
+ "model.layers.22.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
146
+ "model.layers.22.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
147
+ "model.layers.22.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
148
+ "model.layers.22.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
149
+ "model.layers.22.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
150
+ "model.layers.22.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
151
+ "model.layers.22.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
152
+ "model.layers.23.input_layernorm.weight": "model-00003-of-00005.safetensors",
153
+ "model.layers.23.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
154
+ "model.layers.23.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
155
+ "model.layers.23.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
156
+ "model.layers.23.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
157
+ "model.layers.23.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
158
+ "model.layers.23.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
159
+ "model.layers.23.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
160
+ "model.layers.23.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
161
+ "model.layers.24.input_layernorm.weight": "model-00004-of-00005.safetensors",
162
+ "model.layers.24.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
163
+ "model.layers.24.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
164
+ "model.layers.24.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
165
+ "model.layers.24.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
166
+ "model.layers.24.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
167
+ "model.layers.24.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
168
+ "model.layers.24.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
169
+ "model.layers.24.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
170
+ "model.layers.25.input_layernorm.weight": "model-00004-of-00005.safetensors",
171
+ "model.layers.25.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
172
+ "model.layers.25.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
173
+ "model.layers.25.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
174
+ "model.layers.25.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
175
+ "model.layers.25.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
176
+ "model.layers.25.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
177
+ "model.layers.25.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
178
+ "model.layers.25.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
179
+ "model.layers.26.input_layernorm.weight": "model-00004-of-00005.safetensors",
180
+ "model.layers.26.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
181
+ "model.layers.26.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
182
+ "model.layers.26.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
183
+ "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
184
+ "model.layers.26.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
185
+ "model.layers.26.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
186
+ "model.layers.26.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
187
+ "model.layers.26.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
188
+ "model.layers.27.input_layernorm.weight": "model-00004-of-00005.safetensors",
189
+ "model.layers.27.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
190
+ "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
191
+ "model.layers.27.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
192
+ "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
193
+ "model.layers.27.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
194
+ "model.layers.27.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
195
+ "model.layers.27.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
196
+ "model.layers.27.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
197
+ "model.layers.28.input_layernorm.weight": "model-00004-of-00005.safetensors",
198
+ "model.layers.28.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
199
+ "model.layers.28.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
200
+ "model.layers.28.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
201
+ "model.layers.28.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
202
+ "model.layers.28.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
203
+ "model.layers.28.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
204
+ "model.layers.28.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
205
+ "model.layers.28.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
206
+ "model.layers.29.input_layernorm.weight": "model-00004-of-00005.safetensors",
207
+ "model.layers.29.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
208
+ "model.layers.29.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
209
+ "model.layers.29.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
210
+ "model.layers.29.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
211
+ "model.layers.29.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
212
+ "model.layers.29.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
213
+ "model.layers.29.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
214
+ "model.layers.29.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
215
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00005.safetensors",
216
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
217
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
218
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
219
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
220
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
221
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
222
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
223
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
224
+ "model.layers.30.input_layernorm.weight": "model-00004-of-00005.safetensors",
225
+ "model.layers.30.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
226
+ "model.layers.30.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
227
+ "model.layers.30.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
228
+ "model.layers.30.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
229
+ "model.layers.30.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
230
+ "model.layers.30.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
231
+ "model.layers.30.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
232
+ "model.layers.30.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
233
+ "model.layers.31.input_layernorm.weight": "model-00004-of-00005.safetensors",
234
+ "model.layers.31.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
235
+ "model.layers.31.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
236
+ "model.layers.31.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
237
+ "model.layers.31.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
238
+ "model.layers.31.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
239
+ "model.layers.31.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
240
+ "model.layers.31.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
241
+ "model.layers.31.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
242
+ "model.layers.32.input_layernorm.weight": "model-00004-of-00005.safetensors",
243
+ "model.layers.32.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
244
+ "model.layers.32.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
245
+ "model.layers.32.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
246
+ "model.layers.32.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
247
+ "model.layers.32.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
248
+ "model.layers.32.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
249
+ "model.layers.32.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
250
+ "model.layers.32.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
251
+ "model.layers.33.input_layernorm.weight": "model-00005-of-00005.safetensors",
252
+ "model.layers.33.mlp.down_proj.weight": "model-00005-of-00005.safetensors",
253
+ "model.layers.33.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
254
+ "model.layers.33.mlp.up_proj.weight": "model-00005-of-00005.safetensors",
255
+ "model.layers.33.post_attention_layernorm.weight": "model-00005-of-00005.safetensors",
256
+ "model.layers.33.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
257
+ "model.layers.33.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
258
+ "model.layers.33.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
259
+ "model.layers.33.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
260
+ "model.layers.34.input_layernorm.weight": "model-00005-of-00005.safetensors",
261
+ "model.layers.34.mlp.down_proj.weight": "model-00005-of-00005.safetensors",
262
+ "model.layers.34.mlp.gate_proj.weight": "model-00005-of-00005.safetensors",
263
+ "model.layers.34.mlp.up_proj.weight": "model-00005-of-00005.safetensors",
264
+ "model.layers.34.post_attention_layernorm.weight": "model-00005-of-00005.safetensors",
265
+ "model.layers.34.self_attn.k_proj.weight": "model-00005-of-00005.safetensors",
266
+ "model.layers.34.self_attn.o_proj.weight": "model-00005-of-00005.safetensors",
267
+ "model.layers.34.self_attn.q_proj.weight": "model-00005-of-00005.safetensors",
268
+ "model.layers.34.self_attn.v_proj.weight": "model-00005-of-00005.safetensors",
269
+ "model.layers.35.input_layernorm.weight": "model-00005-of-00005.safetensors",
270
+ "model.layers.35.mlp.down_proj.weight": "model-00005-of-00005.safetensors",
271
+ "model.layers.35.mlp.gate_proj.weight": "model-00005-of-00005.safetensors",
272
+ "model.layers.35.mlp.up_proj.weight": "model-00005-of-00005.safetensors",
273
+ "model.layers.35.post_attention_layernorm.weight": "model-00005-of-00005.safetensors",
274
+ "model.layers.35.self_attn.k_proj.weight": "model-00005-of-00005.safetensors",
275
+ "model.layers.35.self_attn.o_proj.weight": "model-00005-of-00005.safetensors",
276
+ "model.layers.35.self_attn.q_proj.weight": "model-00005-of-00005.safetensors",
277
+ "model.layers.35.self_attn.v_proj.weight": "model-00005-of-00005.safetensors",
278
+ "model.layers.36.input_layernorm.weight": "model-00005-of-00005.safetensors",
279
+ "model.layers.36.mlp.down_proj.weight": "model-00005-of-00005.safetensors",
280
+ "model.layers.36.mlp.gate_proj.weight": "model-00005-of-00005.safetensors",
281
+ "model.layers.36.mlp.up_proj.weight": "model-00005-of-00005.safetensors",
282
+ "model.layers.36.post_attention_layernorm.weight": "model-00005-of-00005.safetensors",
283
+ "model.layers.36.self_attn.k_proj.weight": "model-00005-of-00005.safetensors",
284
+ "model.layers.36.self_attn.o_proj.weight": "model-00005-of-00005.safetensors",
285
+ "model.layers.36.self_attn.q_proj.weight": "model-00005-of-00005.safetensors",
286
+ "model.layers.36.self_attn.v_proj.weight": "model-00005-of-00005.safetensors",
287
+ "model.layers.37.input_layernorm.weight": "model-00005-of-00005.safetensors",
288
+ "model.layers.37.mlp.down_proj.weight": "model-00005-of-00005.safetensors",
289
+ "model.layers.37.mlp.gate_proj.weight": "model-00005-of-00005.safetensors",
290
+ "model.layers.37.mlp.up_proj.weight": "model-00005-of-00005.safetensors",
291
+ "model.layers.37.post_attention_layernorm.weight": "model-00005-of-00005.safetensors",
292
+ "model.layers.37.self_attn.k_proj.weight": "model-00005-of-00005.safetensors",
293
+ "model.layers.37.self_attn.o_proj.weight": "model-00005-of-00005.safetensors",
294
+ "model.layers.37.self_attn.q_proj.weight": "model-00005-of-00005.safetensors",
295
+ "model.layers.37.self_attn.v_proj.weight": "model-00005-of-00005.safetensors",
296
+ "model.layers.38.input_layernorm.weight": "model-00005-of-00005.safetensors",
297
+ "model.layers.38.mlp.down_proj.weight": "model-00005-of-00005.safetensors",
298
+ "model.layers.38.mlp.gate_proj.weight": "model-00005-of-00005.safetensors",
299
+ "model.layers.38.mlp.up_proj.weight": "model-00005-of-00005.safetensors",
300
+ "model.layers.38.post_attention_layernorm.weight": "model-00005-of-00005.safetensors",
301
+ "model.layers.38.self_attn.k_proj.weight": "model-00005-of-00005.safetensors",
302
+ "model.layers.38.self_attn.o_proj.weight": "model-00005-of-00005.safetensors",
303
+ "model.layers.38.self_attn.q_proj.weight": "model-00005-of-00005.safetensors",
304
+ "model.layers.38.self_attn.v_proj.weight": "model-00005-of-00005.safetensors",
305
+ "model.layers.39.input_layernorm.weight": "model-00005-of-00005.safetensors",
306
+ "model.layers.39.mlp.down_proj.weight": "model-00005-of-00005.safetensors",
307
+ "model.layers.39.mlp.gate_proj.weight": "model-00005-of-00005.safetensors",
308
+ "model.layers.39.mlp.up_proj.weight": "model-00005-of-00005.safetensors",
309
+ "model.layers.39.post_attention_layernorm.weight": "model-00005-of-00005.safetensors",
310
+ "model.layers.39.self_attn.k_proj.weight": "model-00005-of-00005.safetensors",
311
+ "model.layers.39.self_attn.o_proj.weight": "model-00005-of-00005.safetensors",
312
+ "model.layers.39.self_attn.q_proj.weight": "model-00005-of-00005.safetensors",
313
+ "model.layers.39.self_attn.v_proj.weight": "model-00005-of-00005.safetensors",
314
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00005.safetensors",
315
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
316
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
317
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
318
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
319
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
320
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
321
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
322
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
323
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00005.safetensors",
324
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
325
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
326
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
327
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
328
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
329
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
330
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
331
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
332
+ "model.layers.6.input_layernorm.weight": "model-00002-of-00005.safetensors",
333
+ "model.layers.6.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
334
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
335
+ "model.layers.6.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
336
+ "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
337
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
338
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
339
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
340
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
341
+ "model.layers.7.input_layernorm.weight": "model-00002-of-00005.safetensors",
342
+ "model.layers.7.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
343
+ "model.layers.7.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
344
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
345
+ "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
346
+ "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
347
+ "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
348
+ "model.layers.7.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
349
+ "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
350
+ "model.layers.8.input_layernorm.weight": "model-00002-of-00005.safetensors",
351
+ "model.layers.8.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
352
+ "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
353
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
354
+ "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
355
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
356
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
357
+ "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
358
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
359
+ "model.layers.9.input_layernorm.weight": "model-00002-of-00005.safetensors",
360
+ "model.layers.9.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
361
+ "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
362
+ "model.layers.9.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
363
+ "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
364
+ "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
365
+ "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
366
+ "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
367
+ "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
368
+ "model.norm.weight": "model-00005-of-00005.safetensors"
369
+ }
370
+ }
rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18c25e1b2d8ad42b7c8bd21cb9144fd371f9c347f00894a109bb865dcd893c82
3
+ size 14645
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:04fea7973d7269014fc457c2867d702a68b514f4362225b1a7efeba4a0a3d197
3
+ size 1465
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "pad_token": "</s>",
17
+ "unk_token": {
18
+ "content": "<unk>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0240ce510f08e6c2041724e9043e33be9d251d1e4a4d94eb68cd47b954b61d2
3
+ size 17078292
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff
 
trainer_state.json ADDED
@@ -0,0 +1,1092 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 2.994994994994995,
5
+ "eval_steps": 500,
6
+ "global_step": 1497,
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.02002002002002002,
13
+ "grad_norm": 85.3724365234375,
14
+ "learning_rate": 6.666666666666667e-07,
15
+ "loss": 1.0542,
16
+ "step": 10
17
+ },
18
+ {
19
+ "epoch": 0.04004004004004004,
20
+ "grad_norm": 19.482826232910156,
21
+ "learning_rate": 1.3333333333333334e-06,
22
+ "loss": 0.9033,
23
+ "step": 20
24
+ },
25
+ {
26
+ "epoch": 0.06006006006006006,
27
+ "grad_norm": 14.044015884399414,
28
+ "learning_rate": 2.0000000000000003e-06,
29
+ "loss": 0.889,
30
+ "step": 30
31
+ },
32
+ {
33
+ "epoch": 0.08008008008008008,
34
+ "grad_norm": 16.23746681213379,
35
+ "learning_rate": 2.666666666666667e-06,
36
+ "loss": 0.8984,
37
+ "step": 40
38
+ },
39
+ {
40
+ "epoch": 0.1001001001001001,
41
+ "grad_norm": 19.264328002929688,
42
+ "learning_rate": 3.3333333333333333e-06,
43
+ "loss": 1.076,
44
+ "step": 50
45
+ },
46
+ {
47
+ "epoch": 0.12012012012012012,
48
+ "grad_norm": 28.011310577392578,
49
+ "learning_rate": 4.000000000000001e-06,
50
+ "loss": 0.8041,
51
+ "step": 60
52
+ },
53
+ {
54
+ "epoch": 0.14014014014014015,
55
+ "grad_norm": 17.133804321289062,
56
+ "learning_rate": 4.666666666666667e-06,
57
+ "loss": 0.9156,
58
+ "step": 70
59
+ },
60
+ {
61
+ "epoch": 0.16016016016016016,
62
+ "grad_norm": 38.36112976074219,
63
+ "learning_rate": 5.333333333333334e-06,
64
+ "loss": 0.8373,
65
+ "step": 80
66
+ },
67
+ {
68
+ "epoch": 0.18018018018018017,
69
+ "grad_norm": 25.803749084472656,
70
+ "learning_rate": 6e-06,
71
+ "loss": 0.8105,
72
+ "step": 90
73
+ },
74
+ {
75
+ "epoch": 0.2002002002002002,
76
+ "grad_norm": 11.236152648925781,
77
+ "learning_rate": 6.666666666666667e-06,
78
+ "loss": 0.9213,
79
+ "step": 100
80
+ },
81
+ {
82
+ "epoch": 0.22022022022022023,
83
+ "grad_norm": 11.80700397491455,
84
+ "learning_rate": 7.333333333333333e-06,
85
+ "loss": 0.8716,
86
+ "step": 110
87
+ },
88
+ {
89
+ "epoch": 0.24024024024024024,
90
+ "grad_norm": 46.683860778808594,
91
+ "learning_rate": 8.000000000000001e-06,
92
+ "loss": 0.9531,
93
+ "step": 120
94
+ },
95
+ {
96
+ "epoch": 0.2602602602602603,
97
+ "grad_norm": 34.97478103637695,
98
+ "learning_rate": 8.666666666666668e-06,
99
+ "loss": 0.9266,
100
+ "step": 130
101
+ },
102
+ {
103
+ "epoch": 0.2802802802802803,
104
+ "grad_norm": 15.305174827575684,
105
+ "learning_rate": 9.333333333333334e-06,
106
+ "loss": 1.0951,
107
+ "step": 140
108
+ },
109
+ {
110
+ "epoch": 0.3003003003003003,
111
+ "grad_norm": 15.696242332458496,
112
+ "learning_rate": 1e-05,
113
+ "loss": 1.0434,
114
+ "step": 150
115
+ },
116
+ {
117
+ "epoch": 0.3203203203203203,
118
+ "grad_norm": 12.64402961730957,
119
+ "learning_rate": 9.998640169192487e-06,
120
+ "loss": 0.9082,
121
+ "step": 160
122
+ },
123
+ {
124
+ "epoch": 0.34034034034034033,
125
+ "grad_norm": 20.176891326904297,
126
+ "learning_rate": 9.994561416425877e-06,
127
+ "loss": 0.9433,
128
+ "step": 170
129
+ },
130
+ {
131
+ "epoch": 0.36036036036036034,
132
+ "grad_norm": 18.762786865234375,
133
+ "learning_rate": 9.987765960265639e-06,
134
+ "loss": 1.0805,
135
+ "step": 180
136
+ },
137
+ {
138
+ "epoch": 0.38038038038038036,
139
+ "grad_norm": 15.463565826416016,
140
+ "learning_rate": 9.978257496980025e-06,
141
+ "loss": 1.1743,
142
+ "step": 190
143
+ },
144
+ {
145
+ "epoch": 0.4004004004004004,
146
+ "grad_norm": 18.117294311523438,
147
+ "learning_rate": 9.966041198529562e-06,
148
+ "loss": 1.1714,
149
+ "step": 200
150
+ },
151
+ {
152
+ "epoch": 0.42042042042042044,
153
+ "grad_norm": 17.657556533813477,
154
+ "learning_rate": 9.95112370975384e-06,
155
+ "loss": 1.0502,
156
+ "step": 210
157
+ },
158
+ {
159
+ "epoch": 0.44044044044044045,
160
+ "grad_norm": 12.93178653717041,
161
+ "learning_rate": 9.933513144757187e-06,
162
+ "loss": 1.0316,
163
+ "step": 220
164
+ },
165
+ {
166
+ "epoch": 0.46046046046046046,
167
+ "grad_norm": 59.494056701660156,
168
+ "learning_rate": 9.913219082495128e-06,
169
+ "loss": 1.2795,
170
+ "step": 230
171
+ },
172
+ {
173
+ "epoch": 0.4804804804804805,
174
+ "grad_norm": 48.5118522644043,
175
+ "learning_rate": 9.890252561564094e-06,
176
+ "loss": 1.15,
177
+ "step": 240
178
+ },
179
+ {
180
+ "epoch": 0.5005005005005005,
181
+ "grad_norm": 11.185559272766113,
182
+ "learning_rate": 9.864626074197164e-06,
183
+ "loss": 1.3438,
184
+ "step": 250
185
+ },
186
+ {
187
+ "epoch": 0.5205205205205206,
188
+ "grad_norm": 15.397900581359863,
189
+ "learning_rate": 9.836353559469145e-06,
190
+ "loss": 1.1612,
191
+ "step": 260
192
+ },
193
+ {
194
+ "epoch": 0.5405405405405406,
195
+ "grad_norm": 15.821572303771973,
196
+ "learning_rate": 9.80545039571465e-06,
197
+ "loss": 1.5568,
198
+ "step": 270
199
+ },
200
+ {
201
+ "epoch": 0.5605605605605606,
202
+ "grad_norm": 15.897789001464844,
203
+ "learning_rate": 9.771933392163324e-06,
204
+ "loss": 1.0575,
205
+ "step": 280
206
+ },
207
+ {
208
+ "epoch": 0.5805805805805806,
209
+ "grad_norm": 9.421996116638184,
210
+ "learning_rate": 9.735820779796775e-06,
211
+ "loss": 1.1343,
212
+ "step": 290
213
+ },
214
+ {
215
+ "epoch": 0.6006006006006006,
216
+ "grad_norm": 16.344079971313477,
217
+ "learning_rate": 9.697132201432133e-06,
218
+ "loss": 1.1245,
219
+ "step": 300
220
+ },
221
+ {
222
+ "epoch": 0.6206206206206206,
223
+ "grad_norm": 18.52800178527832,
224
+ "learning_rate": 9.655888701037704e-06,
225
+ "loss": 1.2379,
226
+ "step": 310
227
+ },
228
+ {
229
+ "epoch": 0.6406406406406406,
230
+ "grad_norm": 18.442955017089844,
231
+ "learning_rate": 9.612112712286463e-06,
232
+ "loss": 0.9832,
233
+ "step": 320
234
+ },
235
+ {
236
+ "epoch": 0.6606606606606606,
237
+ "grad_norm": 15.195363998413086,
238
+ "learning_rate": 9.565828046353669e-06,
239
+ "loss": 1.115,
240
+ "step": 330
241
+ },
242
+ {
243
+ "epoch": 0.6806806806806807,
244
+ "grad_norm": 19.73291778564453,
245
+ "learning_rate": 9.517059878965177e-06,
246
+ "loss": 1.0119,
247
+ "step": 340
248
+ },
249
+ {
250
+ "epoch": 0.7007007007007007,
251
+ "grad_norm": 165.94976806640625,
252
+ "learning_rate": 9.465834736703565e-06,
253
+ "loss": 0.8088,
254
+ "step": 350
255
+ },
256
+ {
257
+ "epoch": 0.7207207207207207,
258
+ "grad_norm": 9.471101760864258,
259
+ "learning_rate": 9.41218048257946e-06,
260
+ "loss": 0.9265,
261
+ "step": 360
262
+ },
263
+ {
264
+ "epoch": 0.7407407407407407,
265
+ "grad_norm": 25.840486526489258,
266
+ "learning_rate": 9.356126300875947e-06,
267
+ "loss": 1.0758,
268
+ "step": 370
269
+ },
270
+ {
271
+ "epoch": 0.7607607607607607,
272
+ "grad_norm": 14.781391143798828,
273
+ "learning_rate": 9.297702681274294e-06,
274
+ "loss": 1.0414,
275
+ "step": 380
276
+ },
277
+ {
278
+ "epoch": 0.7807807807807807,
279
+ "grad_norm": 24.92754364013672,
280
+ "learning_rate": 9.23694140226963e-06,
281
+ "loss": 1.1561,
282
+ "step": 390
283
+ },
284
+ {
285
+ "epoch": 0.8008008008008008,
286
+ "grad_norm": 8.37315559387207,
287
+ "learning_rate": 9.173875513885592e-06,
288
+ "loss": 0.9872,
289
+ "step": 400
290
+ },
291
+ {
292
+ "epoch": 0.8208208208208209,
293
+ "grad_norm": 15.049481391906738,
294
+ "learning_rate": 9.10853931969735e-06,
295
+ "loss": 1.1482,
296
+ "step": 410
297
+ },
298
+ {
299
+ "epoch": 0.8408408408408409,
300
+ "grad_norm": 23.98802375793457,
301
+ "learning_rate": 9.040968358172787e-06,
302
+ "loss": 0.8824,
303
+ "step": 420
304
+ },
305
+ {
306
+ "epoch": 0.8608608608608609,
307
+ "grad_norm": 19.458723068237305,
308
+ "learning_rate": 8.971199383341972e-06,
309
+ "loss": 1.1417,
310
+ "step": 430
311
+ },
312
+ {
313
+ "epoch": 0.8808808808808809,
314
+ "grad_norm": 17.3590145111084,
315
+ "learning_rate": 8.89927034480546e-06,
316
+ "loss": 1.0421,
317
+ "step": 440
318
+ },
319
+ {
320
+ "epoch": 0.9009009009009009,
321
+ "grad_norm": 69.77664184570312,
322
+ "learning_rate": 8.82522036709227e-06,
323
+ "loss": 1.2733,
324
+ "step": 450
325
+ },
326
+ {
327
+ "epoch": 0.9209209209209209,
328
+ "grad_norm": 28.997215270996094,
329
+ "learning_rate": 8.7490897283788e-06,
330
+ "loss": 1.121,
331
+ "step": 460
332
+ },
333
+ {
334
+ "epoch": 0.9409409409409409,
335
+ "grad_norm": 10.64609146118164,
336
+ "learning_rate": 8.67091983858022e-06,
337
+ "loss": 1.2421,
338
+ "step": 470
339
+ },
340
+ {
341
+ "epoch": 0.960960960960961,
342
+ "grad_norm": 24.771728515625,
343
+ "learning_rate": 8.590753216826273e-06,
344
+ "loss": 1.1545,
345
+ "step": 480
346
+ },
347
+ {
348
+ "epoch": 0.980980980980981,
349
+ "grad_norm": 19.748878479003906,
350
+ "learning_rate": 8.50863346833376e-06,
351
+ "loss": 0.9979,
352
+ "step": 490
353
+ },
354
+ {
355
+ "epoch": 1.0,
356
+ "grad_norm": 21.032365798950195,
357
+ "learning_rate": 8.42460526068824e-06,
358
+ "loss": 1.2302,
359
+ "step": 500
360
+ },
361
+ {
362
+ "epoch": 1.0,
363
+ "eval_loss": 1.2434757947921753,
364
+ "eval_runtime": 17.9994,
365
+ "eval_samples_per_second": 6.167,
366
+ "eval_steps_per_second": 6.167,
367
+ "step": 500
368
+ },
369
+ {
370
+ "epoch": 1.02002002002002,
371
+ "grad_norm": 8.104686737060547,
372
+ "learning_rate": 8.338714299547898e-06,
373
+ "loss": 0.5829,
374
+ "step": 510
375
+ },
376
+ {
377
+ "epoch": 1.04004004004004,
378
+ "grad_norm": 26.031190872192383,
379
+ "learning_rate": 8.251007303782754e-06,
380
+ "loss": 0.5962,
381
+ "step": 520
382
+ },
383
+ {
384
+ "epoch": 1.06006006006006,
385
+ "grad_norm": 10.554441452026367,
386
+ "learning_rate": 8.161531980062754e-06,
387
+ "loss": 0.5562,
388
+ "step": 530
389
+ },
390
+ {
391
+ "epoch": 1.08008008008008,
392
+ "grad_norm": 14.080601692199707,
393
+ "learning_rate": 8.070336996908585e-06,
394
+ "loss": 0.3213,
395
+ "step": 540
396
+ },
397
+ {
398
+ "epoch": 1.1001001001001,
399
+ "grad_norm": 8.222271919250488,
400
+ "learning_rate": 7.977471958219276e-06,
401
+ "loss": 0.4989,
402
+ "step": 550
403
+ },
404
+ {
405
+ "epoch": 1.12012012012012,
406
+ "grad_norm": 12.388670921325684,
407
+ "learning_rate": 7.882987376291051e-06,
408
+ "loss": 0.4506,
409
+ "step": 560
410
+ },
411
+ {
412
+ "epoch": 1.14014014014014,
413
+ "grad_norm": 13.545977592468262,
414
+ "learning_rate": 7.786934644342044e-06,
415
+ "loss": 0.3504,
416
+ "step": 570
417
+ },
418
+ {
419
+ "epoch": 1.16016016016016,
420
+ "grad_norm": 14.527294158935547,
421
+ "learning_rate": 7.689366008557879e-06,
422
+ "loss": 0.449,
423
+ "step": 580
424
+ },
425
+ {
426
+ "epoch": 1.1801801801801801,
427
+ "grad_norm": 15.87846851348877,
428
+ "learning_rate": 7.590334539673263e-06,
429
+ "loss": 0.6237,
430
+ "step": 590
431
+ },
432
+ {
433
+ "epoch": 1.2002002002002001,
434
+ "grad_norm": 34.297176361083984,
435
+ "learning_rate": 7.489894104105124e-06,
436
+ "loss": 0.4128,
437
+ "step": 600
438
+ },
439
+ {
440
+ "epoch": 1.2202202202202201,
441
+ "grad_norm": 27.035425186157227,
442
+ "learning_rate": 7.388099334652901e-06,
443
+ "loss": 0.5148,
444
+ "step": 610
445
+ },
446
+ {
447
+ "epoch": 1.2402402402402402,
448
+ "grad_norm": 28.68889045715332,
449
+ "learning_rate": 7.285005600782014e-06,
450
+ "loss": 0.499,
451
+ "step": 620
452
+ },
453
+ {
454
+ "epoch": 1.2602602602602602,
455
+ "grad_norm": 15.210294723510742,
456
+ "learning_rate": 7.180668978506613e-06,
457
+ "loss": 0.334,
458
+ "step": 630
459
+ },
460
+ {
461
+ "epoch": 1.2802802802802802,
462
+ "grad_norm": 10.216584205627441,
463
+ "learning_rate": 7.075146219888027e-06,
464
+ "loss": 0.5616,
465
+ "step": 640
466
+ },
467
+ {
468
+ "epoch": 1.3003003003003002,
469
+ "grad_norm": 5.705782413482666,
470
+ "learning_rate": 6.968494722165483e-06,
471
+ "loss": 0.5176,
472
+ "step": 650
473
+ },
474
+ {
475
+ "epoch": 1.3203203203203202,
476
+ "grad_norm": 14.276741027832031,
477
+ "learning_rate": 6.860772496535887e-06,
478
+ "loss": 0.3602,
479
+ "step": 660
480
+ },
481
+ {
482
+ "epoch": 1.3403403403403402,
483
+ "grad_norm": 33.196533203125,
484
+ "learning_rate": 6.752038136599663e-06,
485
+ "loss": 0.6254,
486
+ "step": 670
487
+ },
488
+ {
489
+ "epoch": 1.3603603603603602,
490
+ "grad_norm": 40.43268585205078,
491
+ "learning_rate": 6.642350786489809e-06,
492
+ "loss": 0.3451,
493
+ "step": 680
494
+ },
495
+ {
496
+ "epoch": 1.3803803803803802,
497
+ "grad_norm": 10.993099212646484,
498
+ "learning_rate": 6.531770108701467e-06,
499
+ "loss": 0.4373,
500
+ "step": 690
501
+ },
502
+ {
503
+ "epoch": 1.4004004004004005,
504
+ "grad_norm": 6.688507080078125,
505
+ "learning_rate": 6.42035625163959e-06,
506
+ "loss": 0.5468,
507
+ "step": 700
508
+ },
509
+ {
510
+ "epoch": 1.4204204204204205,
511
+ "grad_norm": 6.958929061889648,
512
+ "learning_rate": 6.3081698169022635e-06,
513
+ "loss": 0.4452,
514
+ "step": 710
515
+ },
516
+ {
517
+ "epoch": 1.4404404404404405,
518
+ "grad_norm": 5.645272731781006,
519
+ "learning_rate": 6.195271826317544e-06,
520
+ "loss": 0.4576,
521
+ "step": 720
522
+ },
523
+ {
524
+ "epoch": 1.4604604604604605,
525
+ "grad_norm": 7.839102268218994,
526
+ "learning_rate": 6.081723688751711e-06,
527
+ "loss": 0.5665,
528
+ "step": 730
529
+ },
530
+ {
531
+ "epoch": 1.4804804804804805,
532
+ "grad_norm": 13.920954704284668,
533
+ "learning_rate": 5.967587166707007e-06,
534
+ "loss": 0.3914,
535
+ "step": 740
536
+ },
537
+ {
538
+ "epoch": 1.5005005005005005,
539
+ "grad_norm": 5.867576599121094,
540
+ "learning_rate": 5.852924342727006e-06,
541
+ "loss": 0.651,
542
+ "step": 750
543
+ },
544
+ {
545
+ "epoch": 1.5205205205205206,
546
+ "grad_norm": 8.858614921569824,
547
+ "learning_rate": 5.737797585627918e-06,
548
+ "loss": 0.7602,
549
+ "step": 760
550
+ },
551
+ {
552
+ "epoch": 1.5405405405405406,
553
+ "grad_norm": 13.370222091674805,
554
+ "learning_rate": 5.62226951657417e-06,
555
+ "loss": 0.4655,
556
+ "step": 770
557
+ },
558
+ {
559
+ "epoch": 1.5605605605605606,
560
+ "grad_norm": 31.85508918762207,
561
+ "learning_rate": 5.506402975016738e-06,
562
+ "loss": 0.4276,
563
+ "step": 780
564
+ },
565
+ {
566
+ "epoch": 1.5805805805805806,
567
+ "grad_norm": 19.144956588745117,
568
+ "learning_rate": 5.390260984512728e-06,
569
+ "loss": 0.5327,
570
+ "step": 790
571
+ },
572
+ {
573
+ "epoch": 1.6006006006006006,
574
+ "grad_norm": 5.009524345397949,
575
+ "learning_rate": 5.273906718444834e-06,
576
+ "loss": 0.3488,
577
+ "step": 800
578
+ },
579
+ {
580
+ "epoch": 1.6206206206206206,
581
+ "grad_norm": 8.031986236572266,
582
+ "learning_rate": 5.15740346565929e-06,
583
+ "loss": 0.3583,
584
+ "step": 810
585
+ },
586
+ {
587
+ "epoch": 1.6406406406406406,
588
+ "grad_norm": 12.562287330627441,
589
+ "learning_rate": 5.0408145960410185e-06,
590
+ "loss": 0.3778,
591
+ "step": 820
592
+ },
593
+ {
594
+ "epoch": 1.6606606606606606,
595
+ "grad_norm": 15.383856773376465,
596
+ "learning_rate": 4.924203526044712e-06,
597
+ "loss": 0.4205,
598
+ "step": 830
599
+ },
600
+ {
601
+ "epoch": 1.6806806806806807,
602
+ "grad_norm": 37.331111907958984,
603
+ "learning_rate": 4.807633684200559e-06,
604
+ "loss": 0.4592,
605
+ "step": 840
606
+ },
607
+ {
608
+ "epoch": 1.7007007007007007,
609
+ "grad_norm": 3.9080111980438232,
610
+ "learning_rate": 4.691168476613426e-06,
611
+ "loss": 0.4791,
612
+ "step": 850
613
+ },
614
+ {
615
+ "epoch": 1.7207207207207207,
616
+ "grad_norm": 20.06818962097168,
617
+ "learning_rate": 4.574871252474227e-06,
618
+ "loss": 0.3267,
619
+ "step": 860
620
+ },
621
+ {
622
+ "epoch": 1.7407407407407407,
623
+ "grad_norm": 14.15330696105957,
624
+ "learning_rate": 4.458805269602245e-06,
625
+ "loss": 0.4908,
626
+ "step": 870
627
+ },
628
+ {
629
+ "epoch": 1.7607607607607607,
630
+ "grad_norm": 25.060203552246094,
631
+ "learning_rate": 4.34303366003717e-06,
632
+ "loss": 0.5989,
633
+ "step": 880
634
+ },
635
+ {
636
+ "epoch": 1.7807807807807807,
637
+ "grad_norm": 16.91396713256836,
638
+ "learning_rate": 4.227619395699523e-06,
639
+ "loss": 0.3807,
640
+ "step": 890
641
+ },
642
+ {
643
+ "epoch": 1.800800800800801,
644
+ "grad_norm": 9.745075225830078,
645
+ "learning_rate": 4.112625254138219e-06,
646
+ "loss": 0.4,
647
+ "step": 900
648
+ },
649
+ {
650
+ "epoch": 1.820820820820821,
651
+ "grad_norm": 26.580297470092773,
652
+ "learning_rate": 3.998113784383808e-06,
653
+ "loss": 0.3955,
654
+ "step": 910
655
+ },
656
+ {
657
+ "epoch": 1.840840840840841,
658
+ "grad_norm": 33.1876335144043,
659
+ "learning_rate": 3.8841472729260435e-06,
660
+ "loss": 0.6142,
661
+ "step": 920
662
+ },
663
+ {
664
+ "epoch": 1.860860860860861,
665
+ "grad_norm": 19.648466110229492,
666
+ "learning_rate": 3.7707877098342484e-06,
667
+ "loss": 0.4582,
668
+ "step": 930
669
+ },
670
+ {
671
+ "epoch": 1.880880880880881,
672
+ "grad_norm": 15.191150665283203,
673
+ "learning_rate": 3.65809675503891e-06,
674
+ "loss": 0.3308,
675
+ "step": 940
676
+ },
677
+ {
678
+ "epoch": 1.900900900900901,
679
+ "grad_norm": 23.23360252380371,
680
+ "learning_rate": 3.5461357047928522e-06,
681
+ "loss": 0.4302,
682
+ "step": 950
683
+ },
684
+ {
685
+ "epoch": 1.920920920920921,
686
+ "grad_norm": 4.980640888214111,
687
+ "learning_rate": 3.43496545833022e-06,
688
+ "loss": 0.4197,
689
+ "step": 960
690
+ },
691
+ {
692
+ "epoch": 1.940940940940941,
693
+ "grad_norm": 13.961352348327637,
694
+ "learning_rate": 3.3246464847414223e-06,
695
+ "loss": 0.3797,
696
+ "step": 970
697
+ },
698
+ {
699
+ "epoch": 1.960960960960961,
700
+ "grad_norm": 7.734709739685059,
701
+ "learning_rate": 3.2152387900820343e-06,
702
+ "loss": 0.3735,
703
+ "step": 980
704
+ },
705
+ {
706
+ "epoch": 1.980980980980981,
707
+ "grad_norm": 4.623331546783447,
708
+ "learning_rate": 3.106801884733566e-06,
709
+ "loss": 0.3805,
710
+ "step": 990
711
+ },
712
+ {
713
+ "epoch": 2.0,
714
+ "grad_norm": 25.117450714111328,
715
+ "learning_rate": 2.9993947510338438e-06,
716
+ "loss": 0.3607,
717
+ "step": 1000
718
+ },
719
+ {
720
+ "epoch": 2.0,
721
+ "eval_loss": 1.321751594543457,
722
+ "eval_runtime": 18.4065,
723
+ "eval_samples_per_second": 6.03,
724
+ "eval_steps_per_second": 6.03,
725
+ "step": 1000
726
+ },
727
+ {
728
+ "epoch": 2.02002002002002,
729
+ "grad_norm": 5.904636383056641,
730
+ "learning_rate": 2.8930758111946117e-06,
731
+ "loss": 0.2806,
732
+ "step": 1010
733
+ },
734
+ {
735
+ "epoch": 2.04004004004004,
736
+ "grad_norm": 32.370277404785156,
737
+ "learning_rate": 2.7879028955237887e-06,
738
+ "loss": 0.2025,
739
+ "step": 1020
740
+ },
741
+ {
742
+ "epoch": 2.06006006006006,
743
+ "grad_norm": 24.176109313964844,
744
+ "learning_rate": 2.683933210969718e-06,
745
+ "loss": 0.3624,
746
+ "step": 1030
747
+ },
748
+ {
749
+ "epoch": 2.08008008008008,
750
+ "grad_norm": 3.880007266998291,
751
+ "learning_rate": 2.58122331000444e-06,
752
+ "loss": 0.1176,
753
+ "step": 1040
754
+ },
755
+ {
756
+ "epoch": 2.1001001001001,
757
+ "grad_norm": 7.256086826324463,
758
+ "learning_rate": 2.4798290598629826e-06,
759
+ "loss": 0.121,
760
+ "step": 1050
761
+ },
762
+ {
763
+ "epoch": 2.12012012012012,
764
+ "grad_norm": 3.795654535293579,
765
+ "learning_rate": 2.3798056121553646e-06,
766
+ "loss": 0.1519,
767
+ "step": 1060
768
+ },
769
+ {
770
+ "epoch": 2.14014014014014,
771
+ "grad_norm": 16.733631134033203,
772
+ "learning_rate": 2.2812073728678525e-06,
773
+ "loss": 0.1601,
774
+ "step": 1070
775
+ },
776
+ {
777
+ "epoch": 2.16016016016016,
778
+ "grad_norm": 4.601969242095947,
779
+ "learning_rate": 2.184087972769786e-06,
780
+ "loss": 0.1254,
781
+ "step": 1080
782
+ },
783
+ {
784
+ "epoch": 2.18018018018018,
785
+ "grad_norm": 16.99506378173828,
786
+ "learning_rate": 2.0885002382420695e-06,
787
+ "loss": 0.2021,
788
+ "step": 1090
789
+ },
790
+ {
791
+ "epoch": 2.2002002002002,
792
+ "grad_norm": 3.1727092266082764,
793
+ "learning_rate": 1.9944961625431954e-06,
794
+ "loss": 0.1348,
795
+ "step": 1100
796
+ },
797
+ {
798
+ "epoch": 2.22022022022022,
799
+ "grad_norm": 4.597020626068115,
800
+ "learning_rate": 1.9021268775284301e-06,
801
+ "loss": 0.148,
802
+ "step": 1110
803
+ },
804
+ {
805
+ "epoch": 2.24024024024024,
806
+ "grad_norm": 25.738351821899414,
807
+ "learning_rate": 1.8114426258375473e-06,
808
+ "loss": 0.4416,
809
+ "step": 1120
810
+ },
811
+ {
812
+ "epoch": 2.26026026026026,
813
+ "grad_norm": 10.155012130737305,
814
+ "learning_rate": 1.722492733566226e-06,
815
+ "loss": 0.1879,
816
+ "step": 1130
817
+ },
818
+ {
819
+ "epoch": 2.28028028028028,
820
+ "grad_norm": 6.9975409507751465,
821
+ "learning_rate": 1.635325583436005e-06,
822
+ "loss": 0.1471,
823
+ "step": 1140
824
+ },
825
+ {
826
+ "epoch": 2.3003003003003,
827
+ "grad_norm": 7.446280002593994,
828
+ "learning_rate": 1.5499885884773436e-06,
829
+ "loss": 0.1164,
830
+ "step": 1150
831
+ },
832
+ {
833
+ "epoch": 2.32032032032032,
834
+ "grad_norm": 5.518588066101074,
835
+ "learning_rate": 1.4665281662401454e-06,
836
+ "loss": 0.1355,
837
+ "step": 1160
838
+ },
839
+ {
840
+ "epoch": 2.34034034034034,
841
+ "grad_norm": 6.030386924743652,
842
+ "learning_rate": 1.3849897135457574e-06,
843
+ "loss": 0.1302,
844
+ "step": 1170
845
+ },
846
+ {
847
+ "epoch": 2.3603603603603602,
848
+ "grad_norm": 4.593402862548828,
849
+ "learning_rate": 1.3054175817941677e-06,
850
+ "loss": 0.1307,
851
+ "step": 1180
852
+ },
853
+ {
854
+ "epoch": 2.3803803803803802,
855
+ "grad_norm": 10.065942764282227,
856
+ "learning_rate": 1.2278550528398486e-06,
857
+ "loss": 0.119,
858
+ "step": 1190
859
+ },
860
+ {
861
+ "epoch": 2.4004004004004003,
862
+ "grad_norm": 5.5326619148254395,
863
+ "learning_rate": 1.1523443154493509e-06,
864
+ "loss": 0.1194,
865
+ "step": 1200
866
+ },
867
+ {
868
+ "epoch": 2.4204204204204203,
869
+ "grad_norm": 13.280714988708496,
870
+ "learning_rate": 1.0789264423534757e-06,
871
+ "loss": 0.2006,
872
+ "step": 1210
873
+ },
874
+ {
875
+ "epoch": 2.4404404404404403,
876
+ "grad_norm": 2.77651309967041,
877
+ "learning_rate": 1.0076413679064857e-06,
878
+ "loss": 0.1594,
879
+ "step": 1220
880
+ },
881
+ {
882
+ "epoch": 2.4604604604604603,
883
+ "grad_norm": 5.999819278717041,
884
+ "learning_rate": 9.385278663645209e-07,
885
+ "loss": 0.3126,
886
+ "step": 1230
887
+ },
888
+ {
889
+ "epoch": 2.4804804804804803,
890
+ "grad_norm": 8.069478034973145,
891
+ "learning_rate": 8.716235307950255e-07,
892
+ "loss": 0.2226,
893
+ "step": 1240
894
+ },
895
+ {
896
+ "epoch": 2.5005005005005003,
897
+ "grad_norm": 12.986360549926758,
898
+ "learning_rate": 8.069647526286656e-07,
899
+ "loss": 0.1229,
900
+ "step": 1250
901
+ },
902
+ {
903
+ "epoch": 2.5205205205205203,
904
+ "grad_norm": 8.093034744262695,
905
+ "learning_rate": 7.445867018648517e-07,
906
+ "loss": 0.1374,
907
+ "step": 1260
908
+ },
909
+ {
910
+ "epoch": 2.5405405405405403,
911
+ "grad_norm": 3.4107353687286377,
912
+ "learning_rate": 6.845233079416397e-07,
913
+ "loss": 0.117,
914
+ "step": 1270
915
+ },
916
+ {
917
+ "epoch": 2.5605605605605604,
918
+ "grad_norm": 4.261966705322266,
919
+ "learning_rate": 6.268072412804138e-07,
920
+ "loss": 0.1725,
921
+ "step": 1280
922
+ },
923
+ {
924
+ "epoch": 2.5805805805805804,
925
+ "grad_norm": 5.60800838470459,
926
+ "learning_rate": 5.714698955153897e-07,
927
+ "loss": 0.1813,
928
+ "step": 1290
929
+ },
930
+ {
931
+ "epoch": 2.6006006006006004,
932
+ "grad_norm": 8.807952880859375,
933
+ "learning_rate": 5.185413704175963e-07,
934
+ "loss": 0.1745,
935
+ "step": 1300
936
+ },
937
+ {
938
+ "epoch": 2.6206206206206204,
939
+ "grad_norm": 5.851156234741211,
940
+ "learning_rate": 4.6805045552264397e-07,
941
+ "loss": 0.1793,
942
+ "step": 1310
943
+ },
944
+ {
945
+ "epoch": 2.6406406406406404,
946
+ "grad_norm": 22.0322322845459,
947
+ "learning_rate": 4.2002461447116174e-07,
948
+ "loss": 0.2279,
949
+ "step": 1320
950
+ },
951
+ {
952
+ "epoch": 2.6606606606606604,
953
+ "grad_norm": 6.453255653381348,
954
+ "learning_rate": 3.7448997007043684e-07,
955
+ "loss": 0.132,
956
+ "step": 1330
957
+ },
958
+ {
959
+ "epoch": 2.6806806806806804,
960
+ "grad_norm": 12.178539276123047,
961
+ "learning_rate": 3.314712900853767e-07,
962
+ "loss": 0.1058,
963
+ "step": 1340
964
+ },
965
+ {
966
+ "epoch": 2.7007007007007005,
967
+ "grad_norm": 10.403335571289062,
968
+ "learning_rate": 2.909919737665179e-07,
969
+ "loss": 0.1642,
970
+ "step": 1350
971
+ },
972
+ {
973
+ "epoch": 2.7207207207207205,
974
+ "grad_norm": 3.435100793838501,
975
+ "learning_rate": 2.53074039122419e-07,
976
+ "loss": 0.1115,
977
+ "step": 1360
978
+ },
979
+ {
980
+ "epoch": 2.7407407407407405,
981
+ "grad_norm": 12.800907135009766,
982
+ "learning_rate": 2.177381109433535e-07,
983
+ "loss": 0.1716,
984
+ "step": 1370
985
+ },
986
+ {
987
+ "epoch": 2.7607607607607605,
988
+ "grad_norm": 9.72323226928711,
989
+ "learning_rate": 1.8500340958282292e-07,
990
+ "loss": 0.1695,
991
+ "step": 1380
992
+ },
993
+ {
994
+ "epoch": 2.7807807807807805,
995
+ "grad_norm": 17.054372787475586,
996
+ "learning_rate": 1.5488774050298083e-07,
997
+ "loss": 0.2744,
998
+ "step": 1390
999
+ },
1000
+ {
1001
+ "epoch": 2.800800800800801,
1002
+ "grad_norm": 8.085247993469238,
1003
+ "learning_rate": 1.2740748458966834e-07,
1004
+ "loss": 0.1364,
1005
+ "step": 1400
1006
+ },
1007
+ {
1008
+ "epoch": 2.820820820820821,
1009
+ "grad_norm": 4.367096424102783,
1010
+ "learning_rate": 1.0257758924232142e-07,
1011
+ "loss": 0.2643,
1012
+ "step": 1410
1013
+ },
1014
+ {
1015
+ "epoch": 2.840840840840841,
1016
+ "grad_norm": 3.3376331329345703,
1017
+ "learning_rate": 8.04115602435962e-08,
1018
+ "loss": 0.1234,
1019
+ "step": 1420
1020
+ },
1021
+ {
1022
+ "epoch": 2.860860860860861,
1023
+ "grad_norm": 215.3577423095703,
1024
+ "learning_rate": 6.092145441313757e-08,
1025
+ "loss": 1.156,
1026
+ "step": 1430
1027
+ },
1028
+ {
1029
+ "epoch": 2.880880880880881,
1030
+ "grad_norm": 2.81681489944458,
1031
+ "learning_rate": 4.411787304948567e-08,
1032
+ "loss": 0.1531,
1033
+ "step": 1440
1034
+ },
1035
+ {
1036
+ "epoch": 2.900900900900901,
1037
+ "grad_norm": 15.65246295928955,
1038
+ "learning_rate": 3.000995616368685e-08,
1039
+ "loss": 0.1828,
1040
+ "step": 1450
1041
+ },
1042
+ {
1043
+ "epoch": 2.920920920920921,
1044
+ "grad_norm": 8.164206504821777,
1045
+ "learning_rate": 1.860537750774549e-08,
1046
+ "loss": 0.1498,
1047
+ "step": 1460
1048
+ },
1049
+ {
1050
+ "epoch": 2.940940940940941,
1051
+ "grad_norm": 3.0739083290100098,
1052
+ "learning_rate": 9.910340400621777e-09,
1053
+ "loss": 0.1659,
1054
+ "step": 1470
1055
+ },
1056
+ {
1057
+ "epoch": 2.960960960960961,
1058
+ "grad_norm": 6.969380855560303,
1059
+ "learning_rate": 3.929574354049614e-09,
1060
+ "loss": 0.0964,
1061
+ "step": 1480
1062
+ },
1063
+ {
1064
+ "epoch": 2.980980980980981,
1065
+ "grad_norm": 11.09949779510498,
1066
+ "learning_rate": 6.663324999967024e-10,
1067
+ "loss": 0.1811,
1068
+ "step": 1490
1069
+ }
1070
+ ],
1071
+ "logging_steps": 10,
1072
+ "max_steps": 1497,
1073
+ "num_input_tokens_seen": 0,
1074
+ "num_train_epochs": 3,
1075
+ "save_steps": 500,
1076
+ "stateful_callbacks": {
1077
+ "TrainerControl": {
1078
+ "args": {
1079
+ "should_epoch_stop": false,
1080
+ "should_evaluate": false,
1081
+ "should_log": false,
1082
+ "should_save": true,
1083
+ "should_training_stop": true
1084
+ },
1085
+ "attributes": {}
1086
+ }
1087
+ },
1088
+ "total_flos": 4689647124480.0,
1089
+ "train_batch_size": 1,
1090
+ "trial_name": null,
1091
+ "trial_params": null
1092
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5ebdb802368b97aab5fa24a166376243f20077914e0e68821ec7b56f2c26d84
3
+ size 8017
upload.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import HfApi
2
+ import os
3
+
4
+ # Set the correct repository name
5
+ repo_id = "AlexCuadron/chai-sft-12b" # Using the correct case
6
+ model_path = "./"
7
+
8
+ # Create API client
9
+ api = HfApi()
10
+
11
+ # First, create the repository if it doesn't exist
12
+ print(f"Creating repository {repo_id}...")
13
+ try:
14
+ api.create_repo(
15
+ repo_id=repo_id,
16
+ repo_type="model",
17
+ private=False # Set to True if you want a private repository
18
+ )
19
+ print(f"Repository {repo_id} created successfully!")
20
+ except Exception as e:
21
+ print(f"Note: {e}")
22
+ print("Continuing with upload as the repo might already exist...")
23
+
24
+ # Then upload the model
25
+ print(f"Starting upload to {repo_id}...")
26
+ api.upload_folder(
27
+ folder_path=model_path,
28
+ repo_id=repo_id,
29
+ repo_type="model"
30
+ )
31
+ print("Upload completed successfully!")
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)