rpeddu commited on
Commit
73918ce
·
verified ·
1 Parent(s): d9b96bf

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
added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "eos_token_id": 151645,
7
+ "hidden_act": "silu",
8
+ "hidden_size": 896,
9
+ "initializer_range": 0.02,
10
+ "intermediate_size": 4864,
11
+ "max_position_embeddings": 32768,
12
+ "max_window_layers": 21,
13
+ "model_type": "qwen2",
14
+ "num_attention_heads": 14,
15
+ "num_hidden_layers": 24,
16
+ "num_key_value_heads": 2,
17
+ "pad_token_id": 151654,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_scaling": null,
20
+ "rope_theta": 1000000.0,
21
+ "sliding_window": null,
22
+ "tie_word_embeddings": true,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.51.3",
25
+ "unsloth_fixed": true,
26
+ "use_cache": false,
27
+ "use_sliding_window": false,
28
+ "vocab_size": 151936
29
+ }
generation_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "max_length": 32768,
9
+ "pad_token_id": 151654,
10
+ "repetition_penalty": 1.1,
11
+ "temperature": 0.7,
12
+ "top_k": 20,
13
+ "top_p": 0.8,
14
+ "transformers_version": "4.51.3"
15
+ }
global_step7000/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0852d1fbff16422886263593984c42479de79563c30e9657704a99170ba0aad
3
+ size 1482103621
global_step7000/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:903383d27744021bfe73816fc4e9492dc00d25ea9cf56adcf0344478976e2559
3
+ size 1482103621
global_step7000/bf16_zero_pp_rank_2_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f8ed521b5f01a15a4d97666f4041bc32c498777bce82b9b12b3ebdff8379a3b
3
+ size 1482103621
global_step7000/bf16_zero_pp_rank_3_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:458060de5e82f671d2d76485c86ed2a2e63cd1c72b2d51d7d2c96c166b948231
3
+ size 1482103621
global_step7000/zero_pp_rank_0_mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:754e68fc6e83a53cfbe61e3f715249a22778fd051166234714eed25a932631d4
3
+ size 143059
global_step7000/zero_pp_rank_1_mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a31b45f44056f70d8be3b7c623112b13c96bf967dc215e8d91db97717afc262a
3
+ size 142995
global_step7000/zero_pp_rank_2_mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbd19837ad97e20a7ed9f7b640a347732c417b977e9c85b9702288a8ae175626
3
+ size 142995
global_step7000/zero_pp_rank_3_mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:feb1eab726fdfda9f2cd5f9dffaae579f5b8ce6eabd287421d00e6e2c01d1805
3
+ size 142995
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step7000
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da75b70e7761305896f20ed419b1ce89f132e4dc41c9dbfff095105888bf3488
3
+ size 988097824
rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fac59f8685f9987cb2f2c0813fb063d93985dae8ca7b3e3348bbd3b9962e8e8e
3
+ size 15429
rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2c41082d86bdc69b01102c0ecce9462330f04cdaa135203d57af14ff58941c3
3
+ size 15365
rng_state_2.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:845609fc37929e5a312464583328e4fd9732b30e9807636ea1f368cfe52393e2
3
+ size 15429
rng_state_3.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c5052e84f057d012da47071b672bc71bcf008104c8d05356cd8037609551ecd
3
+ size 15429
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:412035590d0899313ef5cc734e77cc09a9b1b46dab5e47596b0bbf94ebdd86e4
3
+ size 1465
special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|vision_pad|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64e71213db910f5cafa86d35091f37393dcc344b1bbc34091d1b3eed4cca01d5
3
+ size 11422064
tokenizer_config.json ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
199
+ "clean_up_tokenization_spaces": false,
200
+ "eos_token": "<|im_end|>",
201
+ "errors": "replace",
202
+ "extra_special_tokens": {},
203
+ "max_length": null,
204
+ "model_max_length": 32768,
205
+ "pad_to_multiple_of": null,
206
+ "pad_token": "<|vision_pad|>",
207
+ "pad_token_type_id": 0,
208
+ "padding_side": "right",
209
+ "split_special_tokens": false,
210
+ "tokenizer_class": "Qwen2Tokenizer",
211
+ "unk_token": null
212
+ }
trainer_state.json ADDED
@@ -0,0 +1,1994 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 1.1678065054211844,
6
+ "eval_steps": 500,
7
+ "global_step": 7000,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "clip_ratio": 0.00699951171875,
14
+ "completion_length": 1024.0,
15
+ "epoch": 0.008340283569641367,
16
+ "grad_norm": 14.120885699967895,
17
+ "kl": 2.8944024658203125,
18
+ "learning_rate": 1.9945510147345007e-06,
19
+ "loss": 0.0458,
20
+ "num_tokens": 608832.0,
21
+ "reward": -3.234580533504486,
22
+ "reward_std": 3.1962914752960203,
23
+ "rewards/generate_all_rewards": -3.234580533504486,
24
+ "step": 50
25
+ },
26
+ {
27
+ "clip_ratio": 0.005478515625,
28
+ "completion_length": 1024.0,
29
+ "epoch": 0.016680567139282735,
30
+ "grad_norm": 5.506146217443755,
31
+ "kl": 4.24171875,
32
+ "learning_rate": 1.9889908256880732e-06,
33
+ "loss": 0.0764,
34
+ "num_tokens": 1207352.0,
35
+ "reward": -1.5938849544525147,
36
+ "reward_std": 3.6290176486968995,
37
+ "rewards/generate_all_rewards": -1.5938849544525147,
38
+ "step": 100
39
+ },
40
+ {
41
+ "clip_ratio": 0.006314697265625,
42
+ "completion_length": 1024.0,
43
+ "epoch": 0.025020850708924104,
44
+ "grad_norm": 14.06130768102936,
45
+ "kl": 6.4025,
46
+ "learning_rate": 1.9834306366416458e-06,
47
+ "loss": 0.121,
48
+ "num_tokens": 1817552.0,
49
+ "reward": -0.14887901425361633,
50
+ "reward_std": 3.041101009249687,
51
+ "rewards/generate_all_rewards": -0.14887901425361633,
52
+ "step": 150
53
+ },
54
+ {
55
+ "clip_ratio": 0.008756103515625,
56
+ "completion_length": 1024.0,
57
+ "epoch": 0.03336113427856547,
58
+ "grad_norm": 3.8576112038400194,
59
+ "kl": 6.95140625,
60
+ "learning_rate": 1.9778704475952183e-06,
61
+ "loss": 0.1366,
62
+ "num_tokens": 2408832.0,
63
+ "reward": 0.1574733567237854,
64
+ "reward_std": 3.0124819111824035,
65
+ "rewards/generate_all_rewards": 0.1574733567237854,
66
+ "step": 200
67
+ },
68
+ {
69
+ "clip_ratio": 0.00777587890625,
70
+ "completion_length": 1024.0,
71
+ "epoch": 0.041701417848206836,
72
+ "grad_norm": 8.583233886890447,
73
+ "kl": 4.32921875,
74
+ "learning_rate": 1.9723102585487904e-06,
75
+ "loss": 0.0816,
76
+ "num_tokens": 3012520.0,
77
+ "reward": 1.650909082889557,
78
+ "reward_std": 2.1874516403675077,
79
+ "rewards/generate_all_rewards": 1.650909082889557,
80
+ "step": 250
81
+ },
82
+ {
83
+ "clip_ratio": 0.0061767578125,
84
+ "completion_length": 1024.0,
85
+ "epoch": 0.05004170141784821,
86
+ "grad_norm": 9.521656811246332,
87
+ "kl": 2.9395703125,
88
+ "learning_rate": 1.966750069502363e-06,
89
+ "loss": 0.0528,
90
+ "num_tokens": 3635196.0,
91
+ "reward": 2.0889700829982756,
92
+ "reward_std": 1.676103963404894,
93
+ "rewards/generate_all_rewards": 2.0889700829982756,
94
+ "step": 300
95
+ },
96
+ {
97
+ "clip_ratio": 0.00710205078125,
98
+ "completion_length": 1024.0,
99
+ "epoch": 0.058381984987489574,
100
+ "grad_norm": 3.2056926065848876,
101
+ "kl": 3.523515625,
102
+ "learning_rate": 1.9611898804559355e-06,
103
+ "loss": 0.0655,
104
+ "num_tokens": 4244948.0,
105
+ "reward": 2.5839235186576843,
106
+ "reward_std": 1.675377692580223,
107
+ "rewards/generate_all_rewards": 2.5839235186576843,
108
+ "step": 350
109
+ },
110
+ {
111
+ "clip_ratio": 0.0070361328125,
112
+ "completion_length": 1024.0,
113
+ "epoch": 0.06672226855713094,
114
+ "grad_norm": 5.870128860699156,
115
+ "kl": 3.76171875,
116
+ "learning_rate": 1.955629691409508e-06,
117
+ "loss": 0.07,
118
+ "num_tokens": 4843180.0,
119
+ "reward": 1.3626538455486297,
120
+ "reward_std": 1.5572759065032005,
121
+ "rewards/generate_all_rewards": 1.3626538455486297,
122
+ "step": 400
123
+ },
124
+ {
125
+ "clip_ratio": 0.007911376953125,
126
+ "completion_length": 1024.0,
127
+ "epoch": 0.0750625521267723,
128
+ "grad_norm": 3.5520731952805487,
129
+ "kl": 3.944765625,
130
+ "learning_rate": 1.95006950236308e-06,
131
+ "loss": 0.0754,
132
+ "num_tokens": 5447660.0,
133
+ "reward": 2.8184473848342897,
134
+ "reward_std": 1.537802910655737,
135
+ "rewards/generate_all_rewards": 2.8184473848342897,
136
+ "step": 450
137
+ },
138
+ {
139
+ "clip_ratio": 0.013525390625,
140
+ "completion_length": 1024.0,
141
+ "epoch": 0.08340283569641367,
142
+ "grad_norm": 7.328124794124316,
143
+ "kl": 3.373125,
144
+ "learning_rate": 1.9445093133166527e-06,
145
+ "loss": 0.0614,
146
+ "num_tokens": 6051428.0,
147
+ "reward": 2.4807280468940736,
148
+ "reward_std": 0.9742915752530098,
149
+ "rewards/generate_all_rewards": 2.4807280468940736,
150
+ "step": 500
151
+ },
152
+ {
153
+ "clip_ratio": 0.010689697265625,
154
+ "completion_length": 1024.0,
155
+ "epoch": 0.09174311926605505,
156
+ "grad_norm": 8.879346331019656,
157
+ "kl": 3.567578125,
158
+ "learning_rate": 1.938949124270225e-06,
159
+ "loss": 0.0664,
160
+ "num_tokens": 6652180.0,
161
+ "reward": 2.4438777142763137,
162
+ "reward_std": 1.1059524276852608,
163
+ "rewards/generate_all_rewards": 2.4438777142763137,
164
+ "step": 550
165
+ },
166
+ {
167
+ "clip_ratio": 0.006470947265625,
168
+ "completion_length": 1024.0,
169
+ "epoch": 0.10008340283569642,
170
+ "grad_norm": 15.87593845075513,
171
+ "kl": 1.68625,
172
+ "learning_rate": 1.9333889352237977e-06,
173
+ "loss": 0.0261,
174
+ "num_tokens": 7262336.0,
175
+ "reward": 3.7379005312919618,
176
+ "reward_std": 0.9547000896930694,
177
+ "rewards/generate_all_rewards": 3.7379005312919618,
178
+ "step": 600
179
+ },
180
+ {
181
+ "clip_ratio": 0.008651123046875,
182
+ "completion_length": 1024.0,
183
+ "epoch": 0.10842368640533778,
184
+ "grad_norm": 16.184176794809037,
185
+ "kl": 1.2030859375,
186
+ "learning_rate": 1.92782874617737e-06,
187
+ "loss": 0.0164,
188
+ "num_tokens": 7853484.0,
189
+ "reward": 3.1192458760738373,
190
+ "reward_std": 0.7382513232529163,
191
+ "rewards/generate_all_rewards": 3.1192458760738373,
192
+ "step": 650
193
+ },
194
+ {
195
+ "clip_ratio": 0.007640380859375,
196
+ "completion_length": 1024.0,
197
+ "epoch": 0.11676396997497915,
198
+ "grad_norm": 12.281047071498108,
199
+ "kl": 3.4060546875,
200
+ "learning_rate": 1.9222685571309424e-06,
201
+ "loss": 0.0604,
202
+ "num_tokens": 8459596.0,
203
+ "reward": 3.791183285713196,
204
+ "reward_std": 1.1176388543844222,
205
+ "rewards/generate_all_rewards": 3.791183285713196,
206
+ "step": 700
207
+ },
208
+ {
209
+ "clip_ratio": 0.00601806640625,
210
+ "completion_length": 1024.0,
211
+ "epoch": 0.12510425354462051,
212
+ "grad_norm": 10.59835515773422,
213
+ "kl": 1.3465234375,
214
+ "learning_rate": 1.916708368084515e-06,
215
+ "loss": 0.0197,
216
+ "num_tokens": 9062924.0,
217
+ "reward": 3.9991130876541137,
218
+ "reward_std": 0.933748829215765,
219
+ "rewards/generate_all_rewards": 3.9991130876541137,
220
+ "step": 750
221
+ },
222
+ {
223
+ "clip_ratio": 0.008304443359375,
224
+ "completion_length": 1024.0,
225
+ "epoch": 0.13344453711426188,
226
+ "grad_norm": 4.399868599163885,
227
+ "kl": 2.779375,
228
+ "learning_rate": 1.911148179038087e-06,
229
+ "loss": 0.0503,
230
+ "num_tokens": 9676376.0,
231
+ "reward": 3.1121265506744384,
232
+ "reward_std": 0.8076464046537876,
233
+ "rewards/generate_all_rewards": 3.1121265506744384,
234
+ "step": 800
235
+ },
236
+ {
237
+ "clip_ratio": 0.00646484375,
238
+ "completion_length": 1024.0,
239
+ "epoch": 0.14178482068390325,
240
+ "grad_norm": 12.33402253801181,
241
+ "kl": 2.50671875,
242
+ "learning_rate": 1.9055879899916596e-06,
243
+ "loss": 0.0423,
244
+ "num_tokens": 10291400.0,
245
+ "reward": 2.333748939037323,
246
+ "reward_std": 0.9894427044689655,
247
+ "rewards/generate_all_rewards": 2.333748939037323,
248
+ "step": 850
249
+ },
250
+ {
251
+ "clip_ratio": 0.01214111328125,
252
+ "completion_length": 1024.0,
253
+ "epoch": 0.1501251042535446,
254
+ "grad_norm": 14.289114263028262,
255
+ "kl": 1.8778515625,
256
+ "learning_rate": 1.9000278009452319e-06,
257
+ "loss": 0.0295,
258
+ "num_tokens": 10887736.0,
259
+ "reward": 2.980680326223373,
260
+ "reward_std": 0.6083575973659754,
261
+ "rewards/generate_all_rewards": 2.980680326223373,
262
+ "step": 900
263
+ },
264
+ {
265
+ "clip_ratio": 0.009613037109375,
266
+ "completion_length": 1024.0,
267
+ "epoch": 0.15846538782318598,
268
+ "grad_norm": 10.14315612638421,
269
+ "kl": 2.92171875,
270
+ "learning_rate": 1.8944676118988046e-06,
271
+ "loss": 0.0497,
272
+ "num_tokens": 11494176.0,
273
+ "reward": 2.402811622619629,
274
+ "reward_std": 1.0233210255205631,
275
+ "rewards/generate_all_rewards": 2.402811622619629,
276
+ "step": 950
277
+ },
278
+ {
279
+ "clip_ratio": 0.00775146484375,
280
+ "completion_length": 1024.0,
281
+ "epoch": 0.16680567139282734,
282
+ "grad_norm": 3.95911283332978,
283
+ "kl": 1.9640625,
284
+ "learning_rate": 1.888907422852377e-06,
285
+ "loss": 0.0329,
286
+ "num_tokens": 12103840.0,
287
+ "reward": 3.709632108211517,
288
+ "reward_std": 0.8795299279689789,
289
+ "rewards/generate_all_rewards": 3.709632108211517,
290
+ "step": 1000
291
+ },
292
+ {
293
+ "clip_ratio": 0.009173583984375,
294
+ "completion_length": 1024.0,
295
+ "epoch": 0.17514595496246874,
296
+ "grad_norm": 2.404205261708653,
297
+ "kl": 2.656328125,
298
+ "learning_rate": 1.8833472338059493e-06,
299
+ "loss": 0.0456,
300
+ "num_tokens": 12706496.0,
301
+ "reward": 3.0651380997896194,
302
+ "reward_std": 0.8471601485460997,
303
+ "rewards/generate_all_rewards": 3.0651380997896194,
304
+ "step": 1050
305
+ },
306
+ {
307
+ "clip_ratio": 0.00503662109375,
308
+ "completion_length": 1024.0,
309
+ "epoch": 0.1834862385321101,
310
+ "grad_norm": 16.0574388547409,
311
+ "kl": 2.2871875,
312
+ "learning_rate": 1.8777870447595216e-06,
313
+ "loss": 0.0421,
314
+ "num_tokens": 13320876.0,
315
+ "reward": 3.456456989645958,
316
+ "reward_std": 0.8847015166282653,
317
+ "rewards/generate_all_rewards": 3.456456989645958,
318
+ "step": 1100
319
+ },
320
+ {
321
+ "clip_ratio": 0.004837646484375,
322
+ "completion_length": 1024.0,
323
+ "epoch": 0.19182652210175147,
324
+ "grad_norm": 7.653139462749305,
325
+ "kl": 2.241796875,
326
+ "learning_rate": 1.8722268557130943e-06,
327
+ "loss": 0.0392,
328
+ "num_tokens": 13915940.0,
329
+ "reward": 2.1091002190113066,
330
+ "reward_std": 0.8859185457229615,
331
+ "rewards/generate_all_rewards": 2.1091002190113066,
332
+ "step": 1150
333
+ },
334
+ {
335
+ "clip_ratio": 0.0070654296875,
336
+ "completion_length": 1024.0,
337
+ "epoch": 0.20016680567139283,
338
+ "grad_norm": 7.678037556240038,
339
+ "kl": 2.1728125,
340
+ "learning_rate": 1.8666666666666667e-06,
341
+ "loss": 0.0371,
342
+ "num_tokens": 14512636.0,
343
+ "reward": 1.9523184645175933,
344
+ "reward_std": 1.1099144089221955,
345
+ "rewards/generate_all_rewards": 1.9523184645175933,
346
+ "step": 1200
347
+ },
348
+ {
349
+ "clip_ratio": 0.0082373046875,
350
+ "completion_length": 1024.0,
351
+ "epoch": 0.2085070892410342,
352
+ "grad_norm": 20.776332057103467,
353
+ "kl": 2.02796875,
354
+ "learning_rate": 1.861106477620239e-06,
355
+ "loss": 0.0341,
356
+ "num_tokens": 15119036.0,
357
+ "reward": 3.578354719877243,
358
+ "reward_std": 0.9086613065004349,
359
+ "rewards/generate_all_rewards": 3.578354719877243,
360
+ "step": 1250
361
+ },
362
+ {
363
+ "clip_ratio": 0.00704345703125,
364
+ "completion_length": 1024.0,
365
+ "epoch": 0.21684737281067556,
366
+ "grad_norm": 2.912945916637192,
367
+ "kl": 2.1746875,
368
+ "learning_rate": 1.8555462885738113e-06,
369
+ "loss": 0.0361,
370
+ "num_tokens": 15734840.0,
371
+ "reward": 3.4535324451327325,
372
+ "reward_std": 1.1092214401811362,
373
+ "rewards/generate_all_rewards": 3.4535324451327325,
374
+ "step": 1300
375
+ },
376
+ {
377
+ "clip_ratio": 0.005543212890625,
378
+ "completion_length": 1024.0,
379
+ "epoch": 0.22518765638031693,
380
+ "grad_norm": 4.363074357591489,
381
+ "kl": 1.61734375,
382
+ "learning_rate": 1.849986099527384e-06,
383
+ "loss": 0.0271,
384
+ "num_tokens": 16342192.0,
385
+ "reward": 3.3417653107643126,
386
+ "reward_std": 0.829094213321805,
387
+ "rewards/generate_all_rewards": 3.3417653107643126,
388
+ "step": 1350
389
+ },
390
+ {
391
+ "clip_ratio": 0.007327880859375,
392
+ "completion_length": 1024.0,
393
+ "epoch": 0.2335279399499583,
394
+ "grad_norm": 51.189874692363496,
395
+ "kl": 3.0484375,
396
+ "learning_rate": 1.8444259104809564e-06,
397
+ "loss": 0.053,
398
+ "num_tokens": 16957324.0,
399
+ "reward": 3.9473286485671997,
400
+ "reward_std": 0.7120842409878969,
401
+ "rewards/generate_all_rewards": 3.9473286485671997,
402
+ "step": 1400
403
+ },
404
+ {
405
+ "clip_ratio": 0.006270751953125,
406
+ "completion_length": 1024.0,
407
+ "epoch": 0.24186822351959966,
408
+ "grad_norm": 7.8429753301262695,
409
+ "kl": 2.339921875,
410
+ "learning_rate": 1.8388657214345287e-06,
411
+ "loss": 0.0396,
412
+ "num_tokens": 17558900.0,
413
+ "reward": 2.530026806592941,
414
+ "reward_std": 0.9393242979049683,
415
+ "rewards/generate_all_rewards": 2.530026806592941,
416
+ "step": 1450
417
+ },
418
+ {
419
+ "clip_ratio": 0.0064697265625,
420
+ "completion_length": 1024.0,
421
+ "epoch": 0.25020850708924103,
422
+ "grad_norm": 5.769136809903878,
423
+ "kl": 2.0521875,
424
+ "learning_rate": 1.833305532388101e-06,
425
+ "loss": 0.0349,
426
+ "num_tokens": 18161068.0,
427
+ "reward": 3.6563946413993835,
428
+ "reward_std": 0.5981371226906776,
429
+ "rewards/generate_all_rewards": 3.6563946413993835,
430
+ "step": 1500
431
+ },
432
+ {
433
+ "clip_ratio": 0.0059423828125,
434
+ "completion_length": 1024.0,
435
+ "epoch": 0.2585487906588824,
436
+ "grad_norm": 4.37800770904507,
437
+ "kl": 2.79046875,
438
+ "learning_rate": 1.8277453433416735e-06,
439
+ "loss": 0.0483,
440
+ "num_tokens": 18776456.0,
441
+ "reward": 2.3797482299804686,
442
+ "reward_std": 1.1877363938093186,
443
+ "rewards/generate_all_rewards": 2.3797482299804686,
444
+ "step": 1550
445
+ },
446
+ {
447
+ "clip_ratio": 0.009705810546875,
448
+ "completion_length": 1024.0,
449
+ "epoch": 0.26688907422852376,
450
+ "grad_norm": 5.849705216576927,
451
+ "kl": 2.444140625,
452
+ "learning_rate": 1.822185154295246e-06,
453
+ "loss": 0.0422,
454
+ "num_tokens": 19375140.0,
455
+ "reward": 3.1630379295349123,
456
+ "reward_std": 0.7082004471123219,
457
+ "rewards/generate_all_rewards": 3.1630379295349123,
458
+ "step": 1600
459
+ },
460
+ {
461
+ "clip_ratio": 0.006885986328125,
462
+ "completion_length": 1024.0,
463
+ "epoch": 0.27522935779816515,
464
+ "grad_norm": 11.341122516574023,
465
+ "kl": 1.932421875,
466
+ "learning_rate": 1.8166249652488184e-06,
467
+ "loss": 0.0311,
468
+ "num_tokens": 19975452.0,
469
+ "reward": 2.987669861316681,
470
+ "reward_std": 0.7325755050033331,
471
+ "rewards/generate_all_rewards": 2.987669861316681,
472
+ "step": 1650
473
+ },
474
+ {
475
+ "clip_ratio": 0.0052978515625,
476
+ "completion_length": 1024.0,
477
+ "epoch": 0.2835696413678065,
478
+ "grad_norm": 16.88086046670062,
479
+ "kl": 2.680234375,
480
+ "learning_rate": 1.8110647762023907e-06,
481
+ "loss": 0.0472,
482
+ "num_tokens": 20587572.0,
483
+ "reward": 3.527438926696777,
484
+ "reward_std": 1.062203018963337,
485
+ "rewards/generate_all_rewards": 3.527438926696777,
486
+ "step": 1700
487
+ },
488
+ {
489
+ "clip_ratio": 0.007686767578125,
490
+ "completion_length": 1024.0,
491
+ "epoch": 0.2919099249374479,
492
+ "grad_norm": 3.020717228432076,
493
+ "kl": 2.73734375,
494
+ "learning_rate": 1.8055045871559633e-06,
495
+ "loss": 0.0487,
496
+ "num_tokens": 21194080.0,
497
+ "reward": 3.477699854373932,
498
+ "reward_std": 0.9699093826115132,
499
+ "rewards/generate_all_rewards": 3.477699854373932,
500
+ "step": 1750
501
+ },
502
+ {
503
+ "clip_ratio": 0.005350341796875,
504
+ "completion_length": 1024.0,
505
+ "epoch": 0.3002502085070892,
506
+ "grad_norm": 10.250138946853658,
507
+ "kl": 1.2153125,
508
+ "learning_rate": 1.7999443981095358e-06,
509
+ "loss": 0.0179,
510
+ "num_tokens": 21802912.0,
511
+ "reward": 4.211458885669709,
512
+ "reward_std": 0.5974260994791984,
513
+ "rewards/generate_all_rewards": 4.211458885669709,
514
+ "step": 1800
515
+ },
516
+ {
517
+ "clip_ratio": 0.00499755859375,
518
+ "completion_length": 1024.0,
519
+ "epoch": 0.3085904920767306,
520
+ "grad_norm": 2.728898524811883,
521
+ "kl": 2.489296875,
522
+ "learning_rate": 1.7943842090631081e-06,
523
+ "loss": 0.0422,
524
+ "num_tokens": 22416820.0,
525
+ "reward": 3.9941040158271788,
526
+ "reward_std": 0.9688579052686691,
527
+ "rewards/generate_all_rewards": 3.9941040158271788,
528
+ "step": 1850
529
+ },
530
+ {
531
+ "clip_ratio": 0.004656982421875,
532
+ "completion_length": 1024.0,
533
+ "epoch": 0.31693077564637195,
534
+ "grad_norm": 3.263929854853948,
535
+ "kl": 1.40859375,
536
+ "learning_rate": 1.7888240200166804e-06,
537
+ "loss": 0.0225,
538
+ "num_tokens": 23012076.0,
539
+ "reward": 3.5541777658462523,
540
+ "reward_std": 0.6293248501420021,
541
+ "rewards/generate_all_rewards": 3.5541777658462523,
542
+ "step": 1900
543
+ },
544
+ {
545
+ "clip_ratio": 0.00759521484375,
546
+ "completion_length": 1024.0,
547
+ "epoch": 0.32527105921601335,
548
+ "grad_norm": 43.80415642034278,
549
+ "kl": 2.095546875,
550
+ "learning_rate": 1.783263830970253e-06,
551
+ "loss": 0.0352,
552
+ "num_tokens": 23611824.0,
553
+ "reward": 3.3262206852436065,
554
+ "reward_std": 0.669879068210721,
555
+ "rewards/generate_all_rewards": 3.3262206852436065,
556
+ "step": 1950
557
+ },
558
+ {
559
+ "clip_ratio": 0.00798095703125,
560
+ "completion_length": 1024.0,
561
+ "epoch": 0.3336113427856547,
562
+ "grad_norm": 19.175386958975828,
563
+ "kl": 2.42546875,
564
+ "learning_rate": 1.7777036419238253e-06,
565
+ "loss": 0.0422,
566
+ "num_tokens": 24227908.0,
567
+ "reward": 3.655040820837021,
568
+ "reward_std": 0.8108076846599579,
569
+ "rewards/generate_all_rewards": 3.655040820837021,
570
+ "step": 2000
571
+ },
572
+ {
573
+ "clip_ratio": 0.00546875,
574
+ "completion_length": 1024.0,
575
+ "epoch": 0.3419516263552961,
576
+ "grad_norm": 3.351550298003648,
577
+ "kl": 2.765546875,
578
+ "learning_rate": 1.7721434528773978e-06,
579
+ "loss": 0.0498,
580
+ "num_tokens": 24836204.0,
581
+ "reward": 3.816224058866501,
582
+ "reward_std": 0.7453654401004315,
583
+ "rewards/generate_all_rewards": 3.816224058866501,
584
+ "step": 2050
585
+ },
586
+ {
587
+ "clip_ratio": 0.008900146484375,
588
+ "completion_length": 1024.0,
589
+ "epoch": 0.3502919099249375,
590
+ "grad_norm": 3.2293957852618385,
591
+ "kl": 2.447734375,
592
+ "learning_rate": 1.7665832638309701e-06,
593
+ "loss": 0.045,
594
+ "num_tokens": 25456812.0,
595
+ "reward": 4.989015902280808,
596
+ "reward_std": 0.7733614352345467,
597
+ "rewards/generate_all_rewards": 4.989015902280808,
598
+ "step": 2100
599
+ },
600
+ {
601
+ "clip_ratio": 0.007430419921875,
602
+ "completion_length": 1024.0,
603
+ "epoch": 0.3586321934945788,
604
+ "grad_norm": 8.737056342531416,
605
+ "kl": 5.238203125,
606
+ "learning_rate": 1.7610230747845425e-06,
607
+ "loss": 0.1001,
608
+ "num_tokens": 26071304.0,
609
+ "reward": 2.9227333569526674,
610
+ "reward_std": 1.5148471367359162,
611
+ "rewards/generate_all_rewards": 2.9227333569526674,
612
+ "step": 2150
613
+ },
614
+ {
615
+ "clip_ratio": 0.007855224609375,
616
+ "completion_length": 1024.0,
617
+ "epoch": 0.3669724770642202,
618
+ "grad_norm": 2719.9654735665067,
619
+ "kl": 2.415546875,
620
+ "learning_rate": 1.755462885738115e-06,
621
+ "loss": 0.0428,
622
+ "num_tokens": 26679488.0,
623
+ "reward": 3.643260437250137,
624
+ "reward_std": 0.8649014130234718,
625
+ "rewards/generate_all_rewards": 3.643260437250137,
626
+ "step": 2200
627
+ },
628
+ {
629
+ "clip_ratio": 0.006314697265625,
630
+ "completion_length": 1024.0,
631
+ "epoch": 0.37531276063386154,
632
+ "grad_norm": 5.853101521377133,
633
+ "kl": 3.21375,
634
+ "learning_rate": 1.7499026966916875e-06,
635
+ "loss": 0.0575,
636
+ "num_tokens": 27294504.0,
637
+ "reward": 2.968059607744217,
638
+ "reward_std": 1.0330314177647233,
639
+ "rewards/generate_all_rewards": 2.968059607744217,
640
+ "step": 2250
641
+ },
642
+ {
643
+ "clip_ratio": 0.005992431640625,
644
+ "completion_length": 1024.0,
645
+ "epoch": 0.38365304420350294,
646
+ "grad_norm": 8.224103504347667,
647
+ "kl": 5.151015625,
648
+ "learning_rate": 1.7443425076452599e-06,
649
+ "loss": 0.0975,
650
+ "num_tokens": 27914656.0,
651
+ "reward": 2.8436513328552246,
652
+ "reward_std": 2.013354176878929,
653
+ "rewards/generate_all_rewards": 2.8436513328552246,
654
+ "step": 2300
655
+ },
656
+ {
657
+ "clip_ratio": 0.0057470703125,
658
+ "completion_length": 1024.0,
659
+ "epoch": 0.3919933277731443,
660
+ "grad_norm": 7.8051782744106415,
661
+ "kl": 4.03734375,
662
+ "learning_rate": 1.7387823185988322e-06,
663
+ "loss": 0.0742,
664
+ "num_tokens": 28516504.0,
665
+ "reward": 2.9896522617340087,
666
+ "reward_std": 1.8563957458920777,
667
+ "rewards/generate_all_rewards": 2.9896522617340087,
668
+ "step": 2350
669
+ },
670
+ {
671
+ "clip_ratio": 0.004320068359375,
672
+ "completion_length": 1024.0,
673
+ "epoch": 0.40033361134278567,
674
+ "grad_norm": 3.3006539122678276,
675
+ "kl": 2.824375,
676
+ "learning_rate": 1.7332221295524047e-06,
677
+ "loss": 0.0525,
678
+ "num_tokens": 29117264.0,
679
+ "reward": 3.0978617167472837,
680
+ "reward_std": 1.175471960231662,
681
+ "rewards/generate_all_rewards": 3.0978617167472837,
682
+ "step": 2400
683
+ },
684
+ {
685
+ "clip_ratio": 0.0046337890625,
686
+ "completion_length": 1024.0,
687
+ "epoch": 0.408673894912427,
688
+ "grad_norm": 12.460451063363156,
689
+ "kl": 2.73203125,
690
+ "learning_rate": 1.727661940505977e-06,
691
+ "loss": 0.0495,
692
+ "num_tokens": 29726312.0,
693
+ "reward": 3.126603194475174,
694
+ "reward_std": 1.1947118404507637,
695
+ "rewards/generate_all_rewards": 3.126603194475174,
696
+ "step": 2450
697
+ },
698
+ {
699
+ "clip_ratio": 0.007073974609375,
700
+ "completion_length": 1024.0,
701
+ "epoch": 0.4170141784820684,
702
+ "grad_norm": 6.23861285525636,
703
+ "kl": 3.635703125,
704
+ "learning_rate": 1.7221017514595496e-06,
705
+ "loss": 0.0665,
706
+ "num_tokens": 30314692.0,
707
+ "reward": 2.6027573454380035,
708
+ "reward_std": 0.7329472535848618,
709
+ "rewards/generate_all_rewards": 2.6027573454380035,
710
+ "step": 2500
711
+ },
712
+ {
713
+ "clip_ratio": 0.005120849609375,
714
+ "completion_length": 1024.0,
715
+ "epoch": 0.42535446205170974,
716
+ "grad_norm": 12.279697999562723,
717
+ "kl": 2.185078125,
718
+ "learning_rate": 1.7165415624131219e-06,
719
+ "loss": 0.0379,
720
+ "num_tokens": 30929740.0,
721
+ "reward": 4.00673865199089,
722
+ "reward_std": 0.6778046156093478,
723
+ "rewards/generate_all_rewards": 4.00673865199089,
724
+ "step": 2550
725
+ },
726
+ {
727
+ "clip_ratio": 0.00871337890625,
728
+ "completion_length": 1024.0,
729
+ "epoch": 0.43369474562135113,
730
+ "grad_norm": 12.736320988063575,
731
+ "kl": 2.5959375,
732
+ "learning_rate": 1.7109813733666944e-06,
733
+ "loss": 0.0452,
734
+ "num_tokens": 31523968.0,
735
+ "reward": 3.6301355397701265,
736
+ "reward_std": 0.6656330497562886,
737
+ "rewards/generate_all_rewards": 3.6301355397701265,
738
+ "step": 2600
739
+ },
740
+ {
741
+ "clip_ratio": 0.0074755859375,
742
+ "completion_length": 1024.0,
743
+ "epoch": 0.44203502919099247,
744
+ "grad_norm": 2.6222378119323952,
745
+ "kl": 3.994296875,
746
+ "learning_rate": 1.7054211843202667e-06,
747
+ "loss": 0.0724,
748
+ "num_tokens": 32128080.0,
749
+ "reward": 2.5648028159141543,
750
+ "reward_std": 1.231038143262267,
751
+ "rewards/generate_all_rewards": 2.5648028159141543,
752
+ "step": 2650
753
+ },
754
+ {
755
+ "clip_ratio": 0.005047607421875,
756
+ "completion_length": 1024.0,
757
+ "epoch": 0.45037531276063386,
758
+ "grad_norm": 9.275686783269586,
759
+ "kl": 2.709140625,
760
+ "learning_rate": 1.6998609952738393e-06,
761
+ "loss": 0.0454,
762
+ "num_tokens": 32720372.0,
763
+ "reward": 3.4994620156288145,
764
+ "reward_std": 0.4822941809147596,
765
+ "rewards/generate_all_rewards": 3.4994620156288145,
766
+ "step": 2700
767
+ },
768
+ {
769
+ "clip_ratio": 0.0049267578125,
770
+ "completion_length": 1024.0,
771
+ "epoch": 0.45871559633027525,
772
+ "grad_norm": 8.541221675792642,
773
+ "kl": 2.709296875,
774
+ "learning_rate": 1.6943008062274116e-06,
775
+ "loss": 0.0486,
776
+ "num_tokens": 33336552.0,
777
+ "reward": 3.0300825768709183,
778
+ "reward_std": 0.5665881184674799,
779
+ "rewards/generate_all_rewards": 3.0300825768709183,
780
+ "step": 2750
781
+ },
782
+ {
783
+ "clip_ratio": 0.0037109375,
784
+ "completion_length": 1024.0,
785
+ "epoch": 0.4670558798999166,
786
+ "grad_norm": 5.125419890585354,
787
+ "kl": 1.825859375,
788
+ "learning_rate": 1.6887406171809841e-06,
789
+ "loss": 0.0302,
790
+ "num_tokens": 33945248.0,
791
+ "reward": 3.4999762004613877,
792
+ "reward_std": 0.5717377527058125,
793
+ "rewards/generate_all_rewards": 3.4999762004613877,
794
+ "step": 2800
795
+ },
796
+ {
797
+ "clip_ratio": 0.0053125,
798
+ "completion_length": 1024.0,
799
+ "epoch": 0.475396163469558,
800
+ "grad_norm": 10.202348905573427,
801
+ "kl": 2.3403125,
802
+ "learning_rate": 1.6831804281345565e-06,
803
+ "loss": 0.0395,
804
+ "num_tokens": 34550132.0,
805
+ "reward": 2.1186443191766737,
806
+ "reward_std": 0.3818393291532993,
807
+ "rewards/generate_all_rewards": 2.1186443191766737,
808
+ "step": 2850
809
+ },
810
+ {
811
+ "clip_ratio": 0.00617431640625,
812
+ "completion_length": 1024.0,
813
+ "epoch": 0.4837364470391993,
814
+ "grad_norm": 2.246128805290571,
815
+ "kl": 2.578515625,
816
+ "learning_rate": 1.677620239088129e-06,
817
+ "loss": 0.0449,
818
+ "num_tokens": 35151512.0,
819
+ "reward": 2.3393343752622604,
820
+ "reward_std": 0.6313513360917569,
821
+ "rewards/generate_all_rewards": 2.3393343752622604,
822
+ "step": 2900
823
+ },
824
+ {
825
+ "clip_ratio": 0.004263916015625,
826
+ "completion_length": 1024.0,
827
+ "epoch": 0.4920767306088407,
828
+ "grad_norm": 9.691052501917392,
829
+ "kl": 1.461484375,
830
+ "learning_rate": 1.6720600500417013e-06,
831
+ "loss": 0.0248,
832
+ "num_tokens": 35754108.0,
833
+ "reward": 3.9832346379756927,
834
+ "reward_std": 0.4096560184657574,
835
+ "rewards/generate_all_rewards": 3.9832346379756927,
836
+ "step": 2950
837
+ },
838
+ {
839
+ "clip_ratio": 0.0049609375,
840
+ "completion_length": 1024.0,
841
+ "epoch": 0.5004170141784821,
842
+ "grad_norm": 2.452304665586332,
843
+ "kl": 2.235390625,
844
+ "learning_rate": 1.6664998609952738e-06,
845
+ "loss": 0.0385,
846
+ "num_tokens": 36368004.0,
847
+ "reward": 4.140755372047424,
848
+ "reward_std": 0.432945069745183,
849
+ "rewards/generate_all_rewards": 4.140755372047424,
850
+ "step": 3000
851
+ },
852
+ {
853
+ "clip_ratio": 0.006944580078125,
854
+ "completion_length": 1024.0,
855
+ "epoch": 0.5087572977481234,
856
+ "grad_norm": 4.598716528073911,
857
+ "kl": 2.54578125,
858
+ "learning_rate": 1.6609396719488462e-06,
859
+ "loss": 0.0442,
860
+ "num_tokens": 36977484.0,
861
+ "reward": 3.9808691453933718,
862
+ "reward_std": 0.4201528353989124,
863
+ "rewards/generate_all_rewards": 3.9808691453933718,
864
+ "step": 3050
865
+ },
866
+ {
867
+ "clip_ratio": 0.00439697265625,
868
+ "completion_length": 1024.0,
869
+ "epoch": 0.5170975813177648,
870
+ "grad_norm": 9.080608114471648,
871
+ "kl": 2.86203125,
872
+ "learning_rate": 1.6553794829024185e-06,
873
+ "loss": 0.0512,
874
+ "num_tokens": 37583980.0,
875
+ "reward": 2.9114849293231964,
876
+ "reward_std": 0.6796937258541584,
877
+ "rewards/generate_all_rewards": 2.9114849293231964,
878
+ "step": 3100
879
+ },
880
+ {
881
+ "clip_ratio": 0.00376708984375,
882
+ "completion_length": 1024.0,
883
+ "epoch": 0.5254378648874062,
884
+ "grad_norm": 8.167703275815628,
885
+ "kl": 3.2890625,
886
+ "learning_rate": 1.649819293855991e-06,
887
+ "loss": 0.0587,
888
+ "num_tokens": 38185184.0,
889
+ "reward": 3.087721600532532,
890
+ "reward_std": 0.8554429135844112,
891
+ "rewards/generate_all_rewards": 3.087721600532532,
892
+ "step": 3150
893
+ },
894
+ {
895
+ "clip_ratio": 0.00428466796875,
896
+ "completion_length": 1024.0,
897
+ "epoch": 0.5337781484570475,
898
+ "grad_norm": 9.265129726935722,
899
+ "kl": 3.20609375,
900
+ "learning_rate": 1.6442591048095636e-06,
901
+ "loss": 0.0587,
902
+ "num_tokens": 38794784.0,
903
+ "reward": 3.553533103466034,
904
+ "reward_std": 0.7431424564123154,
905
+ "rewards/generate_all_rewards": 3.553533103466034,
906
+ "step": 3200
907
+ },
908
+ {
909
+ "clip_ratio": 0.006676025390625,
910
+ "completion_length": 1024.0,
911
+ "epoch": 0.5421184320266889,
912
+ "grad_norm": 5.64854377106438,
913
+ "kl": 2.15875,
914
+ "learning_rate": 1.6386989157631359e-06,
915
+ "loss": 0.0361,
916
+ "num_tokens": 39402240.0,
917
+ "reward": 2.871965115070343,
918
+ "reward_std": 0.42509609084576366,
919
+ "rewards/generate_all_rewards": 2.871965115070343,
920
+ "step": 3250
921
+ },
922
+ {
923
+ "clip_ratio": 0.002960205078125,
924
+ "completion_length": 1024.0,
925
+ "epoch": 0.5504587155963303,
926
+ "grad_norm": 4.95636107786261,
927
+ "kl": 2.88828125,
928
+ "learning_rate": 1.6331387267167082e-06,
929
+ "loss": 0.0513,
930
+ "num_tokens": 40009924.0,
931
+ "reward": 3.8079018712043764,
932
+ "reward_std": 0.7513183067925274,
933
+ "rewards/generate_all_rewards": 3.8079018712043764,
934
+ "step": 3300
935
+ },
936
+ {
937
+ "clip_ratio": 0.004202880859375,
938
+ "completion_length": 1024.0,
939
+ "epoch": 0.5587989991659716,
940
+ "grad_norm": 6.97217793872751,
941
+ "kl": 3.969921875,
942
+ "learning_rate": 1.6275785376702807e-06,
943
+ "loss": 0.0709,
944
+ "num_tokens": 40625152.0,
945
+ "reward": 2.3424331378936767,
946
+ "reward_std": 1.1434777556359768,
947
+ "rewards/generate_all_rewards": 2.3424331378936767,
948
+ "step": 3350
949
+ },
950
+ {
951
+ "clip_ratio": 0.005111083984375,
952
+ "completion_length": 1024.0,
953
+ "epoch": 0.567139282735613,
954
+ "grad_norm": 15.565181340971451,
955
+ "kl": 3.036171875,
956
+ "learning_rate": 1.6220183486238533e-06,
957
+ "loss": 0.0562,
958
+ "num_tokens": 41229704.0,
959
+ "reward": 3.3502265119552614,
960
+ "reward_std": 1.13145647123456,
961
+ "rewards/generate_all_rewards": 3.3502265119552614,
962
+ "step": 3400
963
+ },
964
+ {
965
+ "clip_ratio": 0.00511962890625,
966
+ "completion_length": 1024.0,
967
+ "epoch": 0.5754795663052544,
968
+ "grad_norm": 7.176359529921464,
969
+ "kl": 2.051875,
970
+ "learning_rate": 1.6164581595774256e-06,
971
+ "loss": 0.0347,
972
+ "num_tokens": 41825184.0,
973
+ "reward": 3.6443237620592117,
974
+ "reward_std": 0.7032080652937293,
975
+ "rewards/generate_all_rewards": 3.6443237620592117,
976
+ "step": 3450
977
+ },
978
+ {
979
+ "clip_ratio": 0.011055908203125,
980
+ "completion_length": 1024.0,
981
+ "epoch": 0.5838198498748958,
982
+ "grad_norm": 4.526966823196885,
983
+ "kl": 2.79703125,
984
+ "learning_rate": 1.610897970530998e-06,
985
+ "loss": 0.0513,
986
+ "num_tokens": 42442268.0,
987
+ "reward": 4.048895968794823,
988
+ "reward_std": 0.958944509550929,
989
+ "rewards/generate_all_rewards": 4.048895968794823,
990
+ "step": 3500
991
+ },
992
+ {
993
+ "clip_ratio": 0.00597412109375,
994
+ "completion_length": 1024.0,
995
+ "epoch": 0.5921601334445371,
996
+ "grad_norm": 16.586877688863396,
997
+ "kl": 2.502890625,
998
+ "learning_rate": 1.6053377814845702e-06,
999
+ "loss": 0.0449,
1000
+ "num_tokens": 43049748.0,
1001
+ "reward": 3.0637675487995146,
1002
+ "reward_std": 0.749227255731821,
1003
+ "rewards/generate_all_rewards": 3.0637675487995146,
1004
+ "step": 3550
1005
+ },
1006
+ {
1007
+ "clip_ratio": 0.004638671875,
1008
+ "completion_length": 1024.0,
1009
+ "epoch": 0.6005004170141784,
1010
+ "grad_norm": 10.447493313935354,
1011
+ "kl": 3.10890625,
1012
+ "learning_rate": 1.599777592438143e-06,
1013
+ "loss": 0.0547,
1014
+ "num_tokens": 43651800.0,
1015
+ "reward": 2.9153013825416565,
1016
+ "reward_std": 0.824127499461174,
1017
+ "rewards/generate_all_rewards": 2.9153013825416565,
1018
+ "step": 3600
1019
+ },
1020
+ {
1021
+ "clip_ratio": 0.005782470703125,
1022
+ "completion_length": 1024.0,
1023
+ "epoch": 0.6088407005838199,
1024
+ "grad_norm": 32.10338980603829,
1025
+ "kl": 2.6153125,
1026
+ "learning_rate": 1.5942174033917153e-06,
1027
+ "loss": 0.0471,
1028
+ "num_tokens": 44241760.0,
1029
+ "reward": 3.5675123274326324,
1030
+ "reward_std": 0.6166292682575295,
1031
+ "rewards/generate_all_rewards": 3.5675123274326324,
1032
+ "step": 3650
1033
+ },
1034
+ {
1035
+ "clip_ratio": 0.005928955078125,
1036
+ "completion_length": 1024.0,
1037
+ "epoch": 0.6171809841534612,
1038
+ "grad_norm": 6.685408071704869,
1039
+ "kl": 3.515390625,
1040
+ "learning_rate": 1.5886572143452876e-06,
1041
+ "loss": 0.0666,
1042
+ "num_tokens": 44852096.0,
1043
+ "reward": 3.9864674687385557,
1044
+ "reward_std": 0.8102425380796194,
1045
+ "rewards/generate_all_rewards": 3.9864674687385557,
1046
+ "step": 3700
1047
+ },
1048
+ {
1049
+ "clip_ratio": 0.00569580078125,
1050
+ "completion_length": 1024.0,
1051
+ "epoch": 0.6255212677231026,
1052
+ "grad_norm": 3.368030262404586,
1053
+ "kl": 2.3678125,
1054
+ "learning_rate": 1.58309702529886e-06,
1055
+ "loss": 0.0432,
1056
+ "num_tokens": 45460220.0,
1057
+ "reward": 3.25111713051796,
1058
+ "reward_std": 0.9311061368137598,
1059
+ "rewards/generate_all_rewards": 3.25111713051796,
1060
+ "step": 3750
1061
+ },
1062
+ {
1063
+ "clip_ratio": 0.006986083984375,
1064
+ "completion_length": 1024.0,
1065
+ "epoch": 0.6338615512927439,
1066
+ "grad_norm": 7.551706236295235,
1067
+ "kl": 2.4209375,
1068
+ "learning_rate": 1.5775368362524327e-06,
1069
+ "loss": 0.041,
1070
+ "num_tokens": 46072700.0,
1071
+ "reward": 2.695195918381214,
1072
+ "reward_std": 0.8751908247172833,
1073
+ "rewards/generate_all_rewards": 2.695195918381214,
1074
+ "step": 3800
1075
+ },
1076
+ {
1077
+ "clip_ratio": 0.003411865234375,
1078
+ "completion_length": 1024.0,
1079
+ "epoch": 0.6422018348623854,
1080
+ "grad_norm": 18.6347155666052,
1081
+ "kl": 3.246953125,
1082
+ "learning_rate": 1.571976647206005e-06,
1083
+ "loss": 0.0602,
1084
+ "num_tokens": 46667728.0,
1085
+ "reward": 2.4113513553142547,
1086
+ "reward_std": 1.3523825246095658,
1087
+ "rewards/generate_all_rewards": 2.4113513553142547,
1088
+ "step": 3850
1089
+ },
1090
+ {
1091
+ "clip_ratio": 0.004542236328125,
1092
+ "completion_length": 1024.0,
1093
+ "epoch": 0.6505421184320267,
1094
+ "grad_norm": 21.13739448151968,
1095
+ "kl": 2.31109375,
1096
+ "learning_rate": 1.5664164581595773e-06,
1097
+ "loss": 0.0404,
1098
+ "num_tokens": 47270204.0,
1099
+ "reward": 3.915536617040634,
1100
+ "reward_std": 0.6984670387580991,
1101
+ "rewards/generate_all_rewards": 3.915536617040634,
1102
+ "step": 3900
1103
+ },
1104
+ {
1105
+ "clip_ratio": 0.005711669921875,
1106
+ "completion_length": 1024.0,
1107
+ "epoch": 0.658882402001668,
1108
+ "grad_norm": 3.7694883514173156,
1109
+ "kl": 2.70125,
1110
+ "learning_rate": 1.5608562691131497e-06,
1111
+ "loss": 0.047,
1112
+ "num_tokens": 47877444.0,
1113
+ "reward": 4.0312881523370745,
1114
+ "reward_std": 0.6717341633141041,
1115
+ "rewards/generate_all_rewards": 4.0312881523370745,
1116
+ "step": 3950
1117
+ },
1118
+ {
1119
+ "clip_ratio": 0.002728271484375,
1120
+ "completion_length": 1024.0,
1121
+ "epoch": 0.6672226855713094,
1122
+ "grad_norm": 28.629124425382763,
1123
+ "kl": 4.227265625,
1124
+ "learning_rate": 1.5552960800667224e-06,
1125
+ "loss": 0.0783,
1126
+ "num_tokens": 48487624.0,
1127
+ "reward": 3.6814190673828127,
1128
+ "reward_std": 0.98351726539433,
1129
+ "rewards/generate_all_rewards": 3.6814190673828127,
1130
+ "step": 4000
1131
+ },
1132
+ {
1133
+ "clip_ratio": 0.003985595703125,
1134
+ "completion_length": 1024.0,
1135
+ "epoch": 0.6755629691409508,
1136
+ "grad_norm": 2.066191936598565,
1137
+ "kl": 2.4734375,
1138
+ "learning_rate": 1.5497358910202947e-06,
1139
+ "loss": 0.0416,
1140
+ "num_tokens": 49084624.0,
1141
+ "reward": 3.4913946342468263,
1142
+ "reward_std": 0.5357848100364209,
1143
+ "rewards/generate_all_rewards": 3.4913946342468263,
1144
+ "step": 4050
1145
+ },
1146
+ {
1147
+ "clip_ratio": 0.0029345703125,
1148
+ "completion_length": 1024.0,
1149
+ "epoch": 0.6839032527105922,
1150
+ "grad_norm": 2.29887054280825,
1151
+ "kl": 1.980625,
1152
+ "learning_rate": 1.544175701973867e-06,
1153
+ "loss": 0.0351,
1154
+ "num_tokens": 49697284.0,
1155
+ "reward": 3.8557702827453615,
1156
+ "reward_std": 0.6670322266966104,
1157
+ "rewards/generate_all_rewards": 3.8557702827453615,
1158
+ "step": 4100
1159
+ },
1160
+ {
1161
+ "clip_ratio": 0.0025244278740137816,
1162
+ "completion_length": 1023.4825,
1163
+ "epoch": 0.6922435362802335,
1164
+ "grad_norm": 2.273554199254762,
1165
+ "kl": 2.0675,
1166
+ "learning_rate": 1.5386155129274394e-06,
1167
+ "loss": 0.0349,
1168
+ "num_tokens": 50298965.0,
1169
+ "reward": 3.7827609944343568,
1170
+ "reward_std": 0.6611206940561533,
1171
+ "rewards/generate_all_rewards": 3.7827609944343568,
1172
+ "step": 4150
1173
+ },
1174
+ {
1175
+ "clip_ratio": 0.003787841796875,
1176
+ "completion_length": 1024.0,
1177
+ "epoch": 0.700583819849875,
1178
+ "grad_norm": 2.729061403557998,
1179
+ "kl": 2.938828125,
1180
+ "learning_rate": 1.5330553238810117e-06,
1181
+ "loss": 0.0527,
1182
+ "num_tokens": 50900509.0,
1183
+ "reward": 3.8453090608119966,
1184
+ "reward_std": 0.6590460070222616,
1185
+ "rewards/generate_all_rewards": 3.8453090608119966,
1186
+ "step": 4200
1187
+ },
1188
+ {
1189
+ "clip_ratio": 0.003973388671875,
1190
+ "completion_length": 1024.0,
1191
+ "epoch": 0.7089241034195163,
1192
+ "grad_norm": 2.6324042043612716,
1193
+ "kl": 2.7425,
1194
+ "learning_rate": 1.5274951348345844e-06,
1195
+ "loss": 0.0492,
1196
+ "num_tokens": 51503393.0,
1197
+ "reward": 3.854447617530823,
1198
+ "reward_std": 0.7062110313773156,
1199
+ "rewards/generate_all_rewards": 3.854447617530823,
1200
+ "step": 4250
1201
+ },
1202
+ {
1203
+ "clip_ratio": 0.005185546875,
1204
+ "completion_length": 1024.0,
1205
+ "epoch": 0.7172643869891576,
1206
+ "grad_norm": 10.054096567071998,
1207
+ "kl": 2.940234375,
1208
+ "learning_rate": 1.5219349457881568e-06,
1209
+ "loss": 0.0519,
1210
+ "num_tokens": 52114009.0,
1211
+ "reward": 3.3904974472522738,
1212
+ "reward_std": 0.5645231993496418,
1213
+ "rewards/generate_all_rewards": 3.3904974472522738,
1214
+ "step": 4300
1215
+ },
1216
+ {
1217
+ "clip_ratio": 0.0033544921875,
1218
+ "completion_length": 1024.0,
1219
+ "epoch": 0.725604670558799,
1220
+ "grad_norm": 2.216377326696927,
1221
+ "kl": 2.188515625,
1222
+ "learning_rate": 1.516374756741729e-06,
1223
+ "loss": 0.038,
1224
+ "num_tokens": 52716977.0,
1225
+ "reward": 3.649118809700012,
1226
+ "reward_std": 0.7559943076968193,
1227
+ "rewards/generate_all_rewards": 3.649118809700012,
1228
+ "step": 4350
1229
+ },
1230
+ {
1231
+ "clip_ratio": 0.008282470703125,
1232
+ "completion_length": 1024.0,
1233
+ "epoch": 0.7339449541284404,
1234
+ "grad_norm": 19.31919089805816,
1235
+ "kl": 3.878515625,
1236
+ "learning_rate": 1.5108145676953014e-06,
1237
+ "loss": 0.0728,
1238
+ "num_tokens": 53315957.0,
1239
+ "reward": 3.508232383728027,
1240
+ "reward_std": 0.46971126724034545,
1241
+ "rewards/generate_all_rewards": 3.508232383728027,
1242
+ "step": 4400
1243
+ },
1244
+ {
1245
+ "clip_ratio": 0.004521484375,
1246
+ "completion_length": 1024.0,
1247
+ "epoch": 0.7422852376980817,
1248
+ "grad_norm": 4.5243235708567155,
1249
+ "kl": 2.6675,
1250
+ "learning_rate": 1.5052543786488742e-06,
1251
+ "loss": 0.0474,
1252
+ "num_tokens": 53921229.0,
1253
+ "reward": 3.100267617702484,
1254
+ "reward_std": 0.3896624885499477,
1255
+ "rewards/generate_all_rewards": 3.100267617702484,
1256
+ "step": 4450
1257
+ },
1258
+ {
1259
+ "clip_ratio": 0.003692626953125,
1260
+ "completion_length": 1024.0,
1261
+ "epoch": 0.7506255212677231,
1262
+ "grad_norm": 2.355784905819362,
1263
+ "kl": 4.606171875,
1264
+ "learning_rate": 1.4996941896024465e-06,
1265
+ "loss": 0.0863,
1266
+ "num_tokens": 54520793.0,
1267
+ "reward": 2.8280148708820345,
1268
+ "reward_std": 1.2710373802483081,
1269
+ "rewards/generate_all_rewards": 2.8280148708820345,
1270
+ "step": 4500
1271
+ },
1272
+ {
1273
+ "clip_ratio": 0.002569580078125,
1274
+ "completion_length": 1024.0,
1275
+ "epoch": 0.7589658048373644,
1276
+ "grad_norm": 12.17255970472075,
1277
+ "kl": 72.12828125,
1278
+ "learning_rate": 1.4941340005560188e-06,
1279
+ "loss": 1.435,
1280
+ "num_tokens": 55124933.0,
1281
+ "reward": 3.7596522867679596,
1282
+ "reward_std": 0.4142132857814431,
1283
+ "rewards/generate_all_rewards": 3.7596522867679596,
1284
+ "step": 4550
1285
+ },
1286
+ {
1287
+ "clip_ratio": 0.002452392578125,
1288
+ "completion_length": 1024.0,
1289
+ "epoch": 0.7673060884070059,
1290
+ "grad_norm": 34.23055432567639,
1291
+ "kl": 1.603515625,
1292
+ "learning_rate": 1.4885738115095911e-06,
1293
+ "loss": 0.0263,
1294
+ "num_tokens": 55732813.0,
1295
+ "reward": 3.4148662626743316,
1296
+ "reward_std": 0.41280762093607337,
1297
+ "rewards/generate_all_rewards": 3.4148662626743316,
1298
+ "step": 4600
1299
+ },
1300
+ {
1301
+ "clip_ratio": 0.00472900390625,
1302
+ "completion_length": 1024.0,
1303
+ "epoch": 0.7756463719766472,
1304
+ "grad_norm": 7.328812046406036,
1305
+ "kl": 2.65265625,
1306
+ "learning_rate": 1.4830136224631637e-06,
1307
+ "loss": 0.0485,
1308
+ "num_tokens": 56338861.0,
1309
+ "reward": 4.01952663898468,
1310
+ "reward_std": 0.638951450586319,
1311
+ "rewards/generate_all_rewards": 4.01952663898468,
1312
+ "step": 4650
1313
+ },
1314
+ {
1315
+ "clip_ratio": 0.003695068359375,
1316
+ "completion_length": 1024.0,
1317
+ "epoch": 0.7839866555462885,
1318
+ "grad_norm": 11.307922352650342,
1319
+ "kl": 2.89109375,
1320
+ "learning_rate": 1.4774534334167362e-06,
1321
+ "loss": 0.0528,
1322
+ "num_tokens": 56942965.0,
1323
+ "reward": 3.3853393924236297,
1324
+ "reward_std": 0.7829919610917568,
1325
+ "rewards/generate_all_rewards": 3.3853393924236297,
1326
+ "step": 4700
1327
+ },
1328
+ {
1329
+ "clip_ratio": 0.003349609375,
1330
+ "completion_length": 1024.0,
1331
+ "epoch": 0.79232693911593,
1332
+ "grad_norm": 5.0280708015540645,
1333
+ "kl": 2.42765625,
1334
+ "learning_rate": 1.4718932443703085e-06,
1335
+ "loss": 0.043,
1336
+ "num_tokens": 57542753.0,
1337
+ "reward": 3.185204845368862,
1338
+ "reward_std": 0.6598466786742211,
1339
+ "rewards/generate_all_rewards": 3.185204845368862,
1340
+ "step": 4750
1341
+ },
1342
+ {
1343
+ "clip_ratio": 0.00411865234375,
1344
+ "completion_length": 1024.0,
1345
+ "epoch": 0.8006672226855713,
1346
+ "grad_norm": 3.835529281144975,
1347
+ "kl": 2.94375,
1348
+ "learning_rate": 1.4663330553238808e-06,
1349
+ "loss": 0.0548,
1350
+ "num_tokens": 58163693.0,
1351
+ "reward": 4.450564415454864,
1352
+ "reward_std": 1.0702211380563675,
1353
+ "rewards/generate_all_rewards": 4.450564415454864,
1354
+ "step": 4800
1355
+ },
1356
+ {
1357
+ "clip_ratio": 0.002451171875,
1358
+ "completion_length": 1024.0,
1359
+ "epoch": 0.8090075062552127,
1360
+ "grad_norm": 19.94946459088367,
1361
+ "kl": 2.078359375,
1362
+ "learning_rate": 1.4607728662774534e-06,
1363
+ "loss": 0.0365,
1364
+ "num_tokens": 58750017.0,
1365
+ "reward": 2.8765233075618744,
1366
+ "reward_std": 0.7672751601785421,
1367
+ "rewards/generate_all_rewards": 2.8765233075618744,
1368
+ "step": 4850
1369
+ },
1370
+ {
1371
+ "clip_ratio": 0.00357421875,
1372
+ "completion_length": 1024.0,
1373
+ "epoch": 0.817347789824854,
1374
+ "grad_norm": 17.047237053916263,
1375
+ "kl": 3.17078125,
1376
+ "learning_rate": 1.455212677231026e-06,
1377
+ "loss": 0.056,
1378
+ "num_tokens": 59348589.0,
1379
+ "reward": 4.052628271579742,
1380
+ "reward_std": 0.6698121561482548,
1381
+ "rewards/generate_all_rewards": 4.052628271579742,
1382
+ "step": 4900
1383
+ },
1384
+ {
1385
+ "clip_ratio": 0.004931640625,
1386
+ "completion_length": 1024.0,
1387
+ "epoch": 0.8256880733944955,
1388
+ "grad_norm": 4.826417211060371,
1389
+ "kl": 2.607734375,
1390
+ "learning_rate": 1.4496524881845982e-06,
1391
+ "loss": 0.0451,
1392
+ "num_tokens": 59954733.0,
1393
+ "reward": 2.8341499626636506,
1394
+ "reward_std": 0.46431461662054063,
1395
+ "rewards/generate_all_rewards": 2.8341499626636506,
1396
+ "step": 4950
1397
+ },
1398
+ {
1399
+ "clip_ratio": 0.005946044921875,
1400
+ "completion_length": 1024.0,
1401
+ "epoch": 0.8340283569641368,
1402
+ "grad_norm": 10.291202916786846,
1403
+ "kl": 3.267421875,
1404
+ "learning_rate": 1.4440922991381705e-06,
1405
+ "loss": 0.06,
1406
+ "num_tokens": 60574085.0,
1407
+ "reward": 3.4563196295499803,
1408
+ "reward_std": 0.794042921513319,
1409
+ "rewards/generate_all_rewards": 3.4563196295499803,
1410
+ "step": 5000
1411
+ },
1412
+ {
1413
+ "clip_ratio": 0.005137939453125,
1414
+ "completion_length": 1024.0,
1415
+ "epoch": 0.8423686405337781,
1416
+ "grad_norm": 31.864028882209055,
1417
+ "kl": 2.831640625,
1418
+ "learning_rate": 1.438532110091743e-06,
1419
+ "loss": 0.0516,
1420
+ "num_tokens": 61172865.0,
1421
+ "reward": 2.721455451250076,
1422
+ "reward_std": 0.5221429407224059,
1423
+ "rewards/generate_all_rewards": 2.721455451250076,
1424
+ "step": 5050
1425
+ },
1426
+ {
1427
+ "clip_ratio": 0.00337646484375,
1428
+ "completion_length": 1024.0,
1429
+ "epoch": 0.8507089241034195,
1430
+ "grad_norm": 14.39794633355936,
1431
+ "kl": 1.65421875,
1432
+ "learning_rate": 1.4329719210453156e-06,
1433
+ "loss": 0.028,
1434
+ "num_tokens": 61761873.0,
1435
+ "reward": 4.077827769517898,
1436
+ "reward_std": 0.6053008568286896,
1437
+ "rewards/generate_all_rewards": 4.077827769517898,
1438
+ "step": 5100
1439
+ },
1440
+ {
1441
+ "clip_ratio": 0.003028564453125,
1442
+ "completion_length": 1024.0,
1443
+ "epoch": 0.8590492076730609,
1444
+ "grad_norm": 6.864401695816703,
1445
+ "kl": 2.664453125,
1446
+ "learning_rate": 1.427411731998888e-06,
1447
+ "loss": 0.0474,
1448
+ "num_tokens": 62374005.0,
1449
+ "reward": 3.6210562777519226,
1450
+ "reward_std": 0.3803251222521067,
1451
+ "rewards/generate_all_rewards": 3.6210562777519226,
1452
+ "step": 5150
1453
+ },
1454
+ {
1455
+ "clip_ratio": 0.00245361328125,
1456
+ "completion_length": 1024.0,
1457
+ "epoch": 0.8673894912427023,
1458
+ "grad_norm": 3.555441991695044,
1459
+ "kl": 2.218125,
1460
+ "learning_rate": 1.4218515429524603e-06,
1461
+ "loss": 0.0374,
1462
+ "num_tokens": 62985201.0,
1463
+ "reward": 3.7183710026741026,
1464
+ "reward_std": 0.6048373529314994,
1465
+ "rewards/generate_all_rewards": 3.7183710026741026,
1466
+ "step": 5200
1467
+ },
1468
+ {
1469
+ "clip_ratio": 0.00371826171875,
1470
+ "completion_length": 1024.0,
1471
+ "epoch": 0.8757297748123436,
1472
+ "grad_norm": 6.813815164137024,
1473
+ "kl": 3.165859375,
1474
+ "learning_rate": 1.4162913539060328e-06,
1475
+ "loss": 0.0591,
1476
+ "num_tokens": 63587933.0,
1477
+ "reward": 3.470691123008728,
1478
+ "reward_std": 0.8655337832123041,
1479
+ "rewards/generate_all_rewards": 3.470691123008728,
1480
+ "step": 5250
1481
+ },
1482
+ {
1483
+ "clip_ratio": 0.00478271484375,
1484
+ "completion_length": 1024.0,
1485
+ "epoch": 0.8840700583819849,
1486
+ "grad_norm": 3.837611227178622,
1487
+ "kl": 2.496484375,
1488
+ "learning_rate": 1.4107311648596051e-06,
1489
+ "loss": 0.0445,
1490
+ "num_tokens": 64193125.0,
1491
+ "reward": 2.8873752689361574,
1492
+ "reward_std": 0.6322074158862233,
1493
+ "rewards/generate_all_rewards": 2.8873752689361574,
1494
+ "step": 5300
1495
+ },
1496
+ {
1497
+ "clip_ratio": 0.00561767578125,
1498
+ "completion_length": 1024.0,
1499
+ "epoch": 0.8924103419516264,
1500
+ "grad_norm": 10.223757483016007,
1501
+ "kl": 5.140546875,
1502
+ "learning_rate": 1.4051709758131776e-06,
1503
+ "loss": 0.0962,
1504
+ "num_tokens": 64791869.0,
1505
+ "reward": 2.5429132187366488,
1506
+ "reward_std": 0.906138878762722,
1507
+ "rewards/generate_all_rewards": 2.5429132187366488,
1508
+ "step": 5350
1509
+ },
1510
+ {
1511
+ "clip_ratio": 0.00482421875,
1512
+ "completion_length": 1024.0,
1513
+ "epoch": 0.9007506255212677,
1514
+ "grad_norm": 14.701033479824986,
1515
+ "kl": 4.24796875,
1516
+ "learning_rate": 1.39961078676675e-06,
1517
+ "loss": 0.0798,
1518
+ "num_tokens": 65400309.0,
1519
+ "reward": 2.5115936332941056,
1520
+ "reward_std": 0.8834956586360931,
1521
+ "rewards/generate_all_rewards": 2.5115936332941056,
1522
+ "step": 5400
1523
+ },
1524
+ {
1525
+ "clip_ratio": 0.00357421875,
1526
+ "completion_length": 1024.0,
1527
+ "epoch": 0.9090909090909091,
1528
+ "grad_norm": 9.892821812806087,
1529
+ "kl": 5.386484375,
1530
+ "learning_rate": 1.3940505977203225e-06,
1531
+ "loss": 0.1015,
1532
+ "num_tokens": 65993385.0,
1533
+ "reward": 1.6406327021121978,
1534
+ "reward_std": 1.3033610412478447,
1535
+ "rewards/generate_all_rewards": 1.6406327021121978,
1536
+ "step": 5450
1537
+ },
1538
+ {
1539
+ "clip_ratio": 0.003983154296875,
1540
+ "completion_length": 1024.0,
1541
+ "epoch": 0.9174311926605505,
1542
+ "grad_norm": 3.900132285131672,
1543
+ "kl": 2.206015625,
1544
+ "learning_rate": 1.3884904086738948e-06,
1545
+ "loss": 0.0387,
1546
+ "num_tokens": 66600541.0,
1547
+ "reward": 3.18016503572464,
1548
+ "reward_std": 0.8799462950974702,
1549
+ "rewards/generate_all_rewards": 3.18016503572464,
1550
+ "step": 5500
1551
+ },
1552
+ {
1553
+ "clip_ratio": 0.00421142578125,
1554
+ "completion_length": 1024.0,
1555
+ "epoch": 0.9257714762301918,
1556
+ "grad_norm": 2.87190664608335,
1557
+ "kl": 2.29390625,
1558
+ "learning_rate": 1.3829302196274674e-06,
1559
+ "loss": 0.0432,
1560
+ "num_tokens": 67211765.0,
1561
+ "reward": 3.1571250998973848,
1562
+ "reward_std": 0.6987396457791328,
1563
+ "rewards/generate_all_rewards": 3.1571250998973848,
1564
+ "step": 5550
1565
+ },
1566
+ {
1567
+ "clip_ratio": 0.00346923828125,
1568
+ "completion_length": 1024.0,
1569
+ "epoch": 0.9341117597998332,
1570
+ "grad_norm": 4.817047536540244,
1571
+ "kl": 2.0128125,
1572
+ "learning_rate": 1.3773700305810397e-06,
1573
+ "loss": 0.0367,
1574
+ "num_tokens": 67836585.0,
1575
+ "reward": 4.290312564373016,
1576
+ "reward_std": 0.7204281195998192,
1577
+ "rewards/generate_all_rewards": 4.290312564373016,
1578
+ "step": 5600
1579
+ },
1580
+ {
1581
+ "clip_ratio": 0.00431640625,
1582
+ "completion_length": 1024.0,
1583
+ "epoch": 0.9424520433694745,
1584
+ "grad_norm": 14.566705655714621,
1585
+ "kl": 2.095234375,
1586
+ "learning_rate": 1.3718098415346122e-06,
1587
+ "loss": 0.0362,
1588
+ "num_tokens": 68447877.0,
1589
+ "reward": 4.023037674427033,
1590
+ "reward_std": 0.45142842307686804,
1591
+ "rewards/generate_all_rewards": 4.023037674427033,
1592
+ "step": 5650
1593
+ },
1594
+ {
1595
+ "clip_ratio": 0.006263427734375,
1596
+ "completion_length": 1024.0,
1597
+ "epoch": 0.950792326939116,
1598
+ "grad_norm": 7.824949124358837,
1599
+ "kl": 3.860703125,
1600
+ "learning_rate": 1.3662496524881845e-06,
1601
+ "loss": 0.0707,
1602
+ "num_tokens": 69049573.0,
1603
+ "reward": 3.0012189817428587,
1604
+ "reward_std": 0.3978773768246174,
1605
+ "rewards/generate_all_rewards": 3.0012189817428587,
1606
+ "step": 5700
1607
+ },
1608
+ {
1609
+ "clip_ratio": 0.002972412109375,
1610
+ "completion_length": 1024.0,
1611
+ "epoch": 0.9591326105087573,
1612
+ "grad_norm": 3.1286184419710303,
1613
+ "kl": 3.4021875,
1614
+ "learning_rate": 1.3606894634417569e-06,
1615
+ "loss": 0.0635,
1616
+ "num_tokens": 69639193.0,
1617
+ "reward": 3.187228103876114,
1618
+ "reward_std": 0.8414063957333565,
1619
+ "rewards/generate_all_rewards": 3.187228103876114,
1620
+ "step": 5750
1621
+ },
1622
+ {
1623
+ "clip_ratio": 0.004266357421875,
1624
+ "completion_length": 1024.0,
1625
+ "epoch": 0.9674728940783986,
1626
+ "grad_norm": 19.314033277311875,
1627
+ "kl": 2.820625,
1628
+ "learning_rate": 1.3551292743953294e-06,
1629
+ "loss": 0.0517,
1630
+ "num_tokens": 70247585.0,
1631
+ "reward": 3.7847342348098754,
1632
+ "reward_std": 0.6664008083939552,
1633
+ "rewards/generate_all_rewards": 3.7847342348098754,
1634
+ "step": 5800
1635
+ },
1636
+ {
1637
+ "clip_ratio": 0.00450439453125,
1638
+ "completion_length": 1024.0,
1639
+ "epoch": 0.97581317764804,
1640
+ "grad_norm": 7.481107247218354,
1641
+ "kl": 2.52328125,
1642
+ "learning_rate": 1.349569085348902e-06,
1643
+ "loss": 0.0467,
1644
+ "num_tokens": 70850869.0,
1645
+ "reward": 3.71783961057663,
1646
+ "reward_std": 0.6372227993607521,
1647
+ "rewards/generate_all_rewards": 3.71783961057663,
1648
+ "step": 5850
1649
+ },
1650
+ {
1651
+ "clip_ratio": 0.003583984375,
1652
+ "completion_length": 1024.0,
1653
+ "epoch": 0.9841534612176814,
1654
+ "grad_norm": 13.485541281738868,
1655
+ "kl": 2.18,
1656
+ "learning_rate": 1.3440088963024742e-06,
1657
+ "loss": 0.0388,
1658
+ "num_tokens": 71456689.0,
1659
+ "reward": 3.874968693852425,
1660
+ "reward_std": 0.7574485129117966,
1661
+ "rewards/generate_all_rewards": 3.874968693852425,
1662
+ "step": 5900
1663
+ },
1664
+ {
1665
+ "clip_ratio": 0.003751220703125,
1666
+ "completion_length": 1024.0,
1667
+ "epoch": 0.9924937447873228,
1668
+ "grad_norm": 4.232392646106402,
1669
+ "kl": 2.265625,
1670
+ "learning_rate": 1.3384487072560466e-06,
1671
+ "loss": 0.0411,
1672
+ "num_tokens": 72057601.0,
1673
+ "reward": 3.2541480442881583,
1674
+ "reward_std": 0.5004438938200474,
1675
+ "rewards/generate_all_rewards": 3.2541480442881583,
1676
+ "step": 5950
1677
+ },
1678
+ {
1679
+ "clip_ratio": 0.004661865234375,
1680
+ "completion_length": 1024.0,
1681
+ "epoch": 1.001000834028357,
1682
+ "grad_norm": 4.190575159866155,
1683
+ "kl": 2.268203125,
1684
+ "learning_rate": 1.332888518209619e-06,
1685
+ "loss": 0.041,
1686
+ "num_tokens": 72657241.0,
1687
+ "reward": 4.536292546391487,
1688
+ "reward_std": 0.7764492811262608,
1689
+ "rewards/generate_all_rewards": 4.536292546391487,
1690
+ "step": 6000
1691
+ },
1692
+ {
1693
+ "clip_ratio": 0.003243408203125,
1694
+ "completion_length": 1024.0,
1695
+ "epoch": 1.0093411175979983,
1696
+ "grad_norm": 2.73669917409696,
1697
+ "kl": 2.99953125,
1698
+ "learning_rate": 1.3273283291631916e-06,
1699
+ "loss": 0.0554,
1700
+ "num_tokens": 73258405.0,
1701
+ "reward": 3.7951004153490064,
1702
+ "reward_std": 0.5186809635162354,
1703
+ "rewards/generate_all_rewards": 3.7951004153490064,
1704
+ "step": 6050
1705
+ },
1706
+ {
1707
+ "clip_ratio": 0.004434814453125,
1708
+ "completion_length": 1024.0,
1709
+ "epoch": 1.0176814011676396,
1710
+ "grad_norm": 3.2206800159419102,
1711
+ "kl": 3.396875,
1712
+ "learning_rate": 1.321768140116764e-06,
1713
+ "loss": 0.0631,
1714
+ "num_tokens": 73852137.0,
1715
+ "reward": 2.9864656680822375,
1716
+ "reward_std": 0.6515207149833441,
1717
+ "rewards/generate_all_rewards": 2.9864656680822375,
1718
+ "step": 6100
1719
+ },
1720
+ {
1721
+ "clip_ratio": 0.0039599609375,
1722
+ "completion_length": 1024.0,
1723
+ "epoch": 1.0260216847372812,
1724
+ "grad_norm": 5.2073505200985615,
1725
+ "kl": 3.2271875,
1726
+ "learning_rate": 1.3162079510703363e-06,
1727
+ "loss": 0.0602,
1728
+ "num_tokens": 74469161.0,
1729
+ "reward": 3.73267055273056,
1730
+ "reward_std": 0.5677018699049949,
1731
+ "rewards/generate_all_rewards": 3.73267055273056,
1732
+ "step": 6150
1733
+ },
1734
+ {
1735
+ "clip_ratio": 0.002672119140625,
1736
+ "completion_length": 1024.0,
1737
+ "epoch": 1.0343619683069225,
1738
+ "grad_norm": 5.539030446663812,
1739
+ "kl": 3.00671875,
1740
+ "learning_rate": 1.3106477620239086e-06,
1741
+ "loss": 0.0557,
1742
+ "num_tokens": 75077049.0,
1743
+ "reward": 3.6774249446392058,
1744
+ "reward_std": 0.8043338760733605,
1745
+ "rewards/generate_all_rewards": 3.6774249446392058,
1746
+ "step": 6200
1747
+ },
1748
+ {
1749
+ "clip_ratio": 0.004927978515625,
1750
+ "completion_length": 1024.0,
1751
+ "epoch": 1.0427022518765638,
1752
+ "grad_norm": 2.7534484045841787,
1753
+ "kl": 3.223828125,
1754
+ "learning_rate": 1.3050875729774811e-06,
1755
+ "loss": 0.0604,
1756
+ "num_tokens": 75687349.0,
1757
+ "reward": 3.7158334070444106,
1758
+ "reward_std": 0.658657222688198,
1759
+ "rewards/generate_all_rewards": 3.7158334070444106,
1760
+ "step": 6250
1761
+ },
1762
+ {
1763
+ "clip_ratio": 0.005045166015625,
1764
+ "completion_length": 1024.0,
1765
+ "epoch": 1.0510425354462052,
1766
+ "grad_norm": 4.953550380847901,
1767
+ "kl": 2.543203125,
1768
+ "learning_rate": 1.2995273839310537e-06,
1769
+ "loss": 0.0472,
1770
+ "num_tokens": 76300569.0,
1771
+ "reward": 4.2147672295570375,
1772
+ "reward_std": 0.8778787985444069,
1773
+ "rewards/generate_all_rewards": 4.2147672295570375,
1774
+ "step": 6300
1775
+ },
1776
+ {
1777
+ "clip_ratio": 0.003118896484375,
1778
+ "completion_length": 1024.0,
1779
+ "epoch": 1.0593828190158465,
1780
+ "grad_norm": 12.367784692060768,
1781
+ "kl": 2.41859375,
1782
+ "learning_rate": 1.293967194884626e-06,
1783
+ "loss": 0.043,
1784
+ "num_tokens": 76904045.0,
1785
+ "reward": 3.5026879012584686,
1786
+ "reward_std": 0.6680633321404457,
1787
+ "rewards/generate_all_rewards": 3.5026879012584686,
1788
+ "step": 6350
1789
+ },
1790
+ {
1791
+ "clip_ratio": 0.00299072265625,
1792
+ "completion_length": 1024.0,
1793
+ "epoch": 1.0677231025854879,
1794
+ "grad_norm": 58.121185792290575,
1795
+ "kl": 2.092421875,
1796
+ "learning_rate": 1.2884070058381983e-06,
1797
+ "loss": 0.0389,
1798
+ "num_tokens": 77527197.0,
1799
+ "reward": 4.4785698533058165,
1800
+ "reward_std": 0.33464464247226716,
1801
+ "rewards/generate_all_rewards": 4.4785698533058165,
1802
+ "step": 6400
1803
+ },
1804
+ {
1805
+ "clip_ratio": 0.005118408203125,
1806
+ "completion_length": 1024.0,
1807
+ "epoch": 1.0760633861551292,
1808
+ "grad_norm": 24.287293596006418,
1809
+ "kl": 3.210234375,
1810
+ "learning_rate": 1.2828468167917708e-06,
1811
+ "loss": 0.0578,
1812
+ "num_tokens": 78134137.0,
1813
+ "reward": 3.7603088819980623,
1814
+ "reward_std": 0.4170807982981205,
1815
+ "rewards/generate_all_rewards": 3.7603088819980623,
1816
+ "step": 6450
1817
+ },
1818
+ {
1819
+ "clip_ratio": 0.003282470703125,
1820
+ "completion_length": 1024.0,
1821
+ "epoch": 1.0844036697247708,
1822
+ "grad_norm": 15.397400516678681,
1823
+ "kl": 2.402890625,
1824
+ "learning_rate": 1.2772866277453434e-06,
1825
+ "loss": 0.0428,
1826
+ "num_tokens": 78750593.0,
1827
+ "reward": 4.395290724039078,
1828
+ "reward_std": 0.5200403224676847,
1829
+ "rewards/generate_all_rewards": 4.395290724039078,
1830
+ "step": 6500
1831
+ },
1832
+ {
1833
+ "clip_ratio": 0.0048388671875,
1834
+ "completion_length": 1024.0,
1835
+ "epoch": 1.092743953294412,
1836
+ "grad_norm": 4.963221819052845,
1837
+ "kl": 5.079765625,
1838
+ "learning_rate": 1.2717264386989157e-06,
1839
+ "loss": 0.0951,
1840
+ "num_tokens": 79360801.0,
1841
+ "reward": 3.146202702522278,
1842
+ "reward_std": 0.6797874164581299,
1843
+ "rewards/generate_all_rewards": 3.146202702522278,
1844
+ "step": 6550
1845
+ },
1846
+ {
1847
+ "clip_ratio": 0.003487548828125,
1848
+ "completion_length": 1024.0,
1849
+ "epoch": 1.1010842368640534,
1850
+ "grad_norm": 15.023192969035028,
1851
+ "kl": 3.15125,
1852
+ "learning_rate": 1.266166249652488e-06,
1853
+ "loss": 0.0587,
1854
+ "num_tokens": 79952117.0,
1855
+ "reward": 3.741974139213562,
1856
+ "reward_std": 0.4647814616560936,
1857
+ "rewards/generate_all_rewards": 3.741974139213562,
1858
+ "step": 6600
1859
+ },
1860
+ {
1861
+ "clip_ratio": 0.004453125,
1862
+ "completion_length": 1024.0,
1863
+ "epoch": 1.1094245204336948,
1864
+ "grad_norm": 9.103985085349178,
1865
+ "kl": 2.305625,
1866
+ "learning_rate": 1.2606060606060606e-06,
1867
+ "loss": 0.0413,
1868
+ "num_tokens": 80552069.0,
1869
+ "reward": 4.223839626312256,
1870
+ "reward_std": 0.5068751226365567,
1871
+ "rewards/generate_all_rewards": 4.223839626312256,
1872
+ "step": 6650
1873
+ },
1874
+ {
1875
+ "clip_ratio": 0.003953857421875,
1876
+ "completion_length": 1024.0,
1877
+ "epoch": 1.117764804003336,
1878
+ "grad_norm": 3.2493747477518973,
1879
+ "kl": 2.931640625,
1880
+ "learning_rate": 1.255045871559633e-06,
1881
+ "loss": 0.0535,
1882
+ "num_tokens": 81155465.0,
1883
+ "reward": 3.6686401844024656,
1884
+ "reward_std": 0.7149755907058716,
1885
+ "rewards/generate_all_rewards": 3.6686401844024656,
1886
+ "step": 6700
1887
+ },
1888
+ {
1889
+ "clip_ratio": 0.00394287109375,
1890
+ "completion_length": 1024.0,
1891
+ "epoch": 1.1261050875729774,
1892
+ "grad_norm": 3.186846652783417,
1893
+ "kl": 3.184296875,
1894
+ "learning_rate": 1.2494856825132054e-06,
1895
+ "loss": 0.0584,
1896
+ "num_tokens": 81751105.0,
1897
+ "reward": 4.3162576973438265,
1898
+ "reward_std": 0.45037852857261895,
1899
+ "rewards/generate_all_rewards": 4.3162576973438265,
1900
+ "step": 6750
1901
+ },
1902
+ {
1903
+ "clip_ratio": 0.003707275390625,
1904
+ "completion_length": 1024.0,
1905
+ "epoch": 1.1344453711426188,
1906
+ "grad_norm": 3.04261280846647,
1907
+ "kl": 2.888828125,
1908
+ "learning_rate": 1.2439254934667777e-06,
1909
+ "loss": 0.0521,
1910
+ "num_tokens": 82351093.0,
1911
+ "reward": 3.8912365996837615,
1912
+ "reward_std": 0.35723258018493653,
1913
+ "rewards/generate_all_rewards": 3.8912365996837615,
1914
+ "step": 6800
1915
+ },
1916
+ {
1917
+ "clip_ratio": 0.00365478515625,
1918
+ "completion_length": 1024.0,
1919
+ "epoch": 1.1427856547122601,
1920
+ "grad_norm": 4.310881136848889,
1921
+ "kl": 2.07828125,
1922
+ "learning_rate": 1.23836530442035e-06,
1923
+ "loss": 0.0358,
1924
+ "num_tokens": 82958733.0,
1925
+ "reward": 4.600189430117607,
1926
+ "reward_std": 0.4825837394595146,
1927
+ "rewards/generate_all_rewards": 4.600189430117607,
1928
+ "step": 6850
1929
+ },
1930
+ {
1931
+ "clip_ratio": 0.005318603515625,
1932
+ "completion_length": 1024.0,
1933
+ "epoch": 1.1511259382819015,
1934
+ "grad_norm": 5.6721210845224075,
1935
+ "kl": 3.6896875,
1936
+ "learning_rate": 1.2328051153739228e-06,
1937
+ "loss": 0.067,
1938
+ "num_tokens": 83556809.0,
1939
+ "reward": 3.0905766177177427,
1940
+ "reward_std": 0.7636496469378471,
1941
+ "rewards/generate_all_rewards": 3.0905766177177427,
1942
+ "step": 6900
1943
+ },
1944
+ {
1945
+ "clip_ratio": 0.003841552734375,
1946
+ "completion_length": 1024.0,
1947
+ "epoch": 1.159466221851543,
1948
+ "grad_norm": 35.64711800695698,
1949
+ "kl": 2.9359375,
1950
+ "learning_rate": 1.2272449263274951e-06,
1951
+ "loss": 0.0535,
1952
+ "num_tokens": 84165225.0,
1953
+ "reward": 3.255465921163559,
1954
+ "reward_std": 1.003816493228078,
1955
+ "rewards/generate_all_rewards": 3.255465921163559,
1956
+ "step": 6950
1957
+ },
1958
+ {
1959
+ "clip_ratio": 0.00360595703125,
1960
+ "completion_length": 1024.0,
1961
+ "epoch": 1.1678065054211844,
1962
+ "grad_norm": 5.510807439460425,
1963
+ "kl": 2.919296875,
1964
+ "learning_rate": 1.2216847372810674e-06,
1965
+ "loss": 0.0537,
1966
+ "num_tokens": 84781149.0,
1967
+ "reward": 3.9430871558189393,
1968
+ "reward_std": 0.46672826692461966,
1969
+ "rewards/generate_all_rewards": 3.9430871558189393,
1970
+ "step": 7000
1971
+ }
1972
+ ],
1973
+ "logging_steps": 50,
1974
+ "max_steps": 17985,
1975
+ "num_input_tokens_seen": 0,
1976
+ "num_train_epochs": 3,
1977
+ "save_steps": 1000,
1978
+ "stateful_callbacks": {
1979
+ "TrainerControl": {
1980
+ "args": {
1981
+ "should_epoch_stop": false,
1982
+ "should_evaluate": false,
1983
+ "should_log": false,
1984
+ "should_save": true,
1985
+ "should_training_stop": false
1986
+ },
1987
+ "attributes": {}
1988
+ }
1989
+ },
1990
+ "total_flos": 0.0,
1991
+ "train_batch_size": 4,
1992
+ "trial_name": null,
1993
+ "trial_params": null
1994
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ced00c0dc42390164944b48c1567a5cf07bbb0603e64c349f2106e674c6d7365
3
+ size 7825
vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)